Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
Hardcode colour of states with zero cases to white (#71)
Browse files Browse the repository at this point in the history
* Hardcode 0 cases to white color

* Remove overlap from legend
  • Loading branch information
shuklaayush committed Mar 25, 2020
1 parent d298e3b commit b8f63de
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/choropleth.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function ChoroplethMap(props) {
const n = Math.floor(generatedLabels[i]);
return `${n}+`;
} else {
const n1 = Math.floor(generatedLabels[i]);
const n1 = 1 + Math.floor(generatedLabels[i]);
const n2 = Math.floor(generatedLabels[i+1]);
return `${n1} - ${n2}`;
}
Expand Down Expand Up @@ -119,7 +119,8 @@ function ChoroplethMap(props) {
.enter().append('path')
.attr('fill', function(d) {
const n = unemployment.get(d.properties.ST_NM.toLowerCase());
return d3.interpolateReds(d.confirmed = (n>0)*0.05 + n/statistic.maxConfirmed*maxInterpolation);
const color = (n == 0) ? '#ffffff' : d3.interpolateReds(maxInterpolation * n/statistic.maxConfirmed);
return color
})
.attr('d', path)
.attr('pointer-events', 'all')
Expand All @@ -131,7 +132,8 @@ function ChoroplethMap(props) {
.on('mouseleave', (d) => {
const n = unemployment.get(d.properties.ST_NM.toLowerCase());
const target = d3.event.target;
d3.select(target).attr('fill', d3.interpolateReds(d.confirmed = (n>0)*0.05 + n/statistic.maxConfirmed*maxInterpolation)).attr('stroke', 'None');
const color = (n == 0) ? '#ffffff' : d3.interpolateReds(maxInterpolation * n/statistic.maxConfirmed);
d3.select(target).attr('fill', color).attr('stroke', 'None');
})
.style('cursor', 'pointer')
.append('title')
Expand Down

1 comment on commit b8f63de

@vercel
Copy link

@vercel vercel bot commented on b8f63de Mar 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.