Skip to content

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

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from

Conversation

Atash3000
Copy link
Collaborator

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 :
Screenshot 2025-04-21 at 09 42 58

Optional

Storybook Links

Screenshots

@Atash3000 Atash3000 added this to the 4.25.4 milestone Apr 21, 2025
@Atash3000 Atash3000 requested review from adamdoe and joshlacey April 21, 2025 13:47
Copy link
Collaborator

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'
Copy link
Collaborator

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) => {
Copy link
Collaborator

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?

@adamdoe adamdoe requested a review from Copilot April 22, 2025 19:47
Copy link

@Copilot Copilot AI left a 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) && (

Atash3000 and others added 2 commits April 24, 2025 11:41
…nd.Group.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Atash3000 Atash3000 requested a review from adamdoe April 25, 2025 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants