Skip to content

Commit

Permalink
update classification groups for sequential chart
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthvik129 committed Sep 24, 2024
1 parent 732e85c commit 96e9c92
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 12 deletions.
76 changes: 69 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.36",
"version": "0.3.37",
"private": false,
"license": "MIT",
"author": "CivicDataLab <tech@civicdatalab.in>",
Expand Down
7 changes: 3 additions & 4 deletions packages/opub-ui/src/components/MapChart/MapChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,16 @@ const Map = ({
if (isSequentialLegend) {
const min = Math.min(...values);
const max = Math.max(...values);
const step = (max - min) / 5; // Calculate step size
const grades = Array.from({ length: 5 + 1 }, (_, i) => min + step * i); // Create ranges
const step = (max - min) / 3;
const grades = Array.from({ length: 3 + 1 }, (_, i) => min + step * i);

// Loop through intervals and generate a label with a color square for each
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)}` : '+'}`,
label: `${Math.round(from)} - ${to ? `${Math.round(to)}` : '+'}`,
});
}
}
Expand Down

0 comments on commit 96e9c92

Please sign in to comment.