Skip to content

Commit

Permalink
remove category creation for sequential data
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthvik129 committed Sep 24, 2024
1 parent f2472f2 commit 7b16bce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/opub-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "opub-ui",
"description": "OPub UI Library",
"version": "0.3.38",
"version": "0.3.39",
"private": false,
"license": "MIT",
"author": "CivicDataLab <tech@civicdatalab.in>",
Expand Down
25 changes: 3 additions & 22 deletions packages/opub-ui/src/components/MapChart/MapChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,38 +184,18 @@ const Map = ({
values.push(features[i].properties[mapProperty]);
}

// console.log('values', values);

// Set the sequential scale properties
const colorScale = d3
.scaleSequential()
.domain([Math.min(...values), Math.max(...values)])
.interpolator(interpolateBlues);

if (isSequentialLegend) {
const min = Math.min(...values);
const max = Math.max(...values);
const step = (max - min) / 3;
const grades = Array.from({ length: 3 + 1 }, (_, i) => min + step * i);

for (let i = 0; i < grades.length; i++) {
const from = grades[i];
const to = grades[i + 1] || Math.max(...values);

labels.push({
color: colorScale(from),
label: `${Math.round(from)} - ${to ? `${Math.round(to)}` : '+'}`,
});
}
}

React.useEffect(() => {
if (mapRef && resetZoom) {
const controlElm = mapRef._container?.querySelector('.leaflet-control');
const button = mapRef._container.querySelector(
'[data-type="reset-zoom"]'
);
console.log(button, controlElm);

controlElm?.appendChild(button);
button.classList.remove('hidden');
Expand Down Expand Up @@ -252,6 +232,7 @@ const Map = ({
const handleMouseOut = React.useCallback((e: { target: any }) => {
var layer = e.target;

console.log('mouseout', layer.feature.properties[mapProperty]);
// layer.setStyle(style(layer.feature));
layer.setStyle({
fillColor: isSequentialLegend
Expand Down Expand Up @@ -337,9 +318,9 @@ const Map = ({
/>
</>
)}
{(legendData || isSequentialLegend) && (
{legendData && (
<Legend
legendData={legendData || labels}
legendData={legendData}
legendHeading={legendHeading}
horizontalLegend={horizontalLegend}
/>
Expand Down

0 comments on commit 7b16bce

Please sign in to comment.