-
Notifications
You must be signed in to change notification settings - Fork 27
Feature : [DEV-50357] - Add Grouped Legend to the Maps #2076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[fix]: rename and fix import to the lowercase version based on new convention of having styles start lowercased.
legend.group.css
@@ -0,0 +1,130 @@ | |||
import { useContext, useMemo } from 'react' | |||
import './Legend.Group.css' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[fix]: this will need to be updated to the new name.
const LegendGroup = ({ legendItems }) => { | ||
const { runtimeLegend, setAccessibleStatus, setRuntimeLegend, state, currentViewport } = useContext(ConfigContext) | ||
|
||
const getGridColClass = (viewport: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using the viewport can you use bootstraps helpers?
col-number, col-md-number, col-lg-number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds the grouped legend feature to the Maps component, allowing legends to be grouped by various criteria through a new dropdown in the legend panel.
- Introduces a new state property (groupBy) in the initial state and Legend types.
- Adds a new LegendGroup component that groups legend items based on a selected key.
- Updates the Legend, EditorPanel, Storybook stories, and sample HTML to integrate and test the new grouped legend functionality.
Reviewed Changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
packages/map/src/data/initial-state.js | Added groupBy property to the map state. |
packages/map/src/components/Legend/components/LegendGroup/Legend.Group.tsx | New component implementing legend grouping logic. |
packages/map/src/components/Legend/components/Legend.tsx | Integrated LegendGroup into legend rendering with conditional fallback. |
packages/map/src/components/EditorPanel/components/EditorPanel.tsx | Added editor control for handling legendGroupBy state updates. |
packages/map/src/_stories/CdcMap.Legend.stories.tsx | Added Storybook story for grouped legend configuration. |
packages/map/src/CdcMap.tsx | Updated to include new legend grouping behavior. |
packages/map/index.html | Updated example containers for map configuration. |
packages/core/types/Legend.ts | Updated Legend type to include groupBy field. |
Files not reviewed (2)
- packages/map/examples/default-hex.json: Language not supported
- packages/map/src/components/Legend/components/LegendGroup/Legend.Group.css: Language not supported
Comments suppressed due to low confidence (1)
packages/map/src/components/Legend/components/Legend.tsx:297
- [nitpick] Consider extracting the condition ['Select Option', ''].includes(state.legend.groupBy) into a clearly named boolean variable to improve readability.
!!legendListItems.length && ['Select Option', ''].includes(state.legend.groupBy) && (
packages/map/src/components/Legend/components/LegendGroup/Legend.Group.tsx
Outdated
Show resolved
Hide resolved
…nd.Group.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… into feature/DEV-50357a
Summary
Testing Steps
Open Maps

On the legend panel there is new dropdown "Legend Group By"
Select any value which groups legend by year, week, value etc
Note : Legend grouping works only if it is Categorical Maps
Also created a story, see attcahed image :
Optional
Storybook Links
Screenshots