diff --git a/static/js/modules/maps.js b/static/js/modules/maps.js index 6b3f75f03..f57e973d9 100644 --- a/static/js/modules/maps.js +++ b/static/js/modules/maps.js @@ -70,8 +70,8 @@ function stateMap($elm, data, width, height, max, addLegend, addTooltips) { ); var quantiles = 4; max = max || _.max(_.pluck(data.results, 'total')); - var scale = chroma.scale(['#fff', '#2678BA']).domain([0, max]); - var quantize = chroma.scale(['#fff', '#2678BA']).domain([0, max], quantiles); + var scale = chroma.scale(['#fff', '#36BDBB']).domain([0, max]); + var quantize = chroma.scale(['#fff', '#36BDBB']).domain([0, max], quantiles); var map = svg.append('g') .selectAll('path') .data(stateFeatures) @@ -85,11 +85,15 @@ function stateMap($elm, data, width, height, max, addLegend, addTooltips) { .attr('class', 'shape') .attr('d', path) .on('mouseover', function(d) { - this.parentNode.appendChild(this); + if (results.hasOwnProperty(d.properties.name)) { + this.parentNode.appendChild(this); + this.classList.add('state--hover') + } }); if (addLegend || typeof addLegend === 'undefined') { - stateLegend(svg, scale, quantize, quantiles); + var legendSVG = d3.select('.legend-container svg'); + stateLegend(legendSVG, scale, quantize, quantiles); } if (addTooltips) { @@ -110,7 +114,7 @@ function stateLegend(svg, scale, quantize, quantiles) { .attr('x', function(d, i) { return i * legendWidth + (legendWidth - legendBar) / 2; }) - .attr('y', 20) + .attr('y', 0) .attr('width', legendBar) .attr('height', 20) .style('fill', function(d) { @@ -123,7 +127,7 @@ function stateLegend(svg, scale, quantize, quantiles) { .attr('x', function(d, i) { return (i + 0.5) * legendWidth; }) - .attr('y', 50) + .attr('y', 30) .attr('width', legendWidth) .attr('height', 20) .attr('font-size', '10px') diff --git a/static/js/pages/committee-single.js b/static/js/pages/committee-single.js index 9a2d70e3c..610969fce 100644 --- a/static/js/pages/committee-single.js +++ b/static/js/pages/committee-single.js @@ -176,6 +176,23 @@ function buildStateUrl($elm) { ); } +function highlightRowAndState($map, $table, state, scroll) { + var $scrollBody = $table.closest('.dataTables_scrollBody'); + var $row = $scrollBody.find('span[data-state="' + state + '"]'); + + if ($row.length > 0) { + maps.highlightState($('.state-map'), state); + $scrollBody.find('.row-active').removeClass('row-active'); + $row.parents('tr').addClass('row-active'); + if (scroll) { + $scrollBody.animate({ + scrollTop: $row.closest('tr').height() * parseInt($row.attr('data-row')) + }, 500); + } + } + +} + var aggregateCallbacks = _.extend( {afterRender: tables.barsAfterRender.bind(undefined, undefined)}, tables.offsetCallbacks @@ -229,13 +246,8 @@ $(document).ready(function() { ) ); events.on('state.map', function(params) { - var $scrollBody = $table.closest('.dataTables_scrollBody'); - var $row = $scrollBody.find('span[data-state="' + params.state + '"]'); - $scrollBody.find('.active').removeClass('active'); - $row.parents('tr').addClass('active'); - $scrollBody.animate({ - scrollTop: $row.closest('tr').height() * parseInt($row.attr('data-row')) - }, 500); + var $map = $('.state-map'); + highlightRowAndState($map, $table, params.state, true) }); $table.on('click', 'tr', function(e) { events.emit('state.table', {state: $(this).find('span[data-state]').attr('data-state')}); @@ -294,14 +306,13 @@ $(document).ready(function() { var $map = $('.state-map'); var url = buildStateUrl($map); $.getJSON(url).done(function(data) { - maps.stateMap($map, data, 400, 400, null, true, false); + maps.stateMap($map, data, 400, 300, null, true, false); }); events.on('state.table', function(params) { - maps.highlightState($map, params.state); + highlightRowAndState($map, $('.data-table'), params.state, false); }); $map.on('click', 'path[data-state]', function(e) { var state = $(this).attr('data-state'); - maps.highlightState($map, state); events.emit('state.map', {state: state}); }); }); diff --git a/static/js/pages/elections.js b/static/js/pages/elections.js index 98802eaf6..cd799a0bd 100644 --- a/static/js/pages/elections.js +++ b/static/js/pages/elections.js @@ -384,8 +384,8 @@ function updateColorScale($container, cached) { } }); var max = mapMax(cached); - var scale = chroma.scale(['#fff', '#2678BA']).domain([0, max]); - var quantize = chroma.scale(['#fff', '#2678BA']).domain([0, max], 4); + var scale = chroma.scale(['#fff', '#36BDBB']).domain([0, max]); + var quantize = chroma.scale(['#fff', '#36BDBB']).domain([0, max], 4); $container.closest('#state-maps').find('.state-map').each(function(_, elm) { var $elm = $(elm); var results = cached[$elm.find('select').val()]; @@ -396,7 +396,7 @@ function updateColorScale($container, cached) { }); }); $container.find('.legend svg g').remove(); - var svg = d3.select($container.get(0)).select('.legend svg'); + var svg = d3.select($container.get(0)).select('.legend-container svg'); if (isFinite(max)) { maps.stateLegend(svg, scale, quantize, 4); } diff --git a/static/js/pages/receipts.js b/static/js/pages/receipts.js index 0f4765d8b..f99d8ea0e 100644 --- a/static/js/pages/receipts.js +++ b/static/js/pages/receipts.js @@ -13,7 +13,7 @@ var columns = [ data: 'contributor', orderable: false, className: 'all', - width: '280px', + width: '20%', render: function(data, type, row, meta) { if (data) { return tables.buildEntityLink(data.name, '/committee/' + data.committee_id, 'committee'); diff --git a/templates/partials/elections/candidate-comparison-tab.html b/templates/partials/elections/candidate-comparison-tab.html index a1b1627eb..246ba1e73 100644 --- a/templates/partials/elections/candidate-comparison-tab.html +++ b/templates/partials/elections/candidate-comparison-tab.html @@ -95,9 +95,11 @@

Contributions by location

-
- Total amount received from state: - +
+
+ Total amount received from state: + +
diff --git a/templates/partials/filings-table.html b/templates/partials/filings-table.html index 8f9ad502a..cea4f89a5 100644 --- a/templates/partials/filings-table.html +++ b/templates/partials/filings-table.html @@ -1,4 +1,4 @@ - +
diff --git a/templates/partials/receipts-tab.html b/templates/partials/receipts-tab.html index 8b1c5c34e..565d85b8d 100644 --- a/templates/partials/receipts-tab.html +++ b/templates/partials/receipts-tab.html @@ -39,7 +39,7 @@

Receipts by State

-
+

Document
Receipts by State
-
-
+
+
+
+ Total amount received from state: + +
+