@neo4j-ndl/react-charts 1.0.114 → 1.0.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"chart-test-utils.js","sourceRoot":"","sources":["../../../../src/charts/tests/chart-test-utils.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,0CAAyC;AACzC,0DAAgD;AAChD,6EAA2D;AAI3D,yFAAsF;AAEtF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,EAAE;IACtC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAE5B,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAE/C,OAAO,OAAO,GAAG,KAAK,KAAK,KAAK,IAAI,GAAG,CAAC;AAC1C,CAAC,CAAC;AAEW,QAAA,4BAA4B,GAA2B;IAClE,CAAC,EAAE,iBAAiB;IACpB,EAAE,EAAE,iBAAiB;IACrB,EAAE,EAAE,iBAAiB;IACrB,EAAE,EAAE,kBAAkB;IACtB,CAAC,EAAE,gBAAgB;IACnB,CAAC,EAAE,iBAAiB;IACpB,CAAC,EAAE,iBAAiB;IACpB,CAAC,EAAE,kBAAkB;IACrB,CAAC,EAAE,kBAAkB;IACrB,CAAC,EAAE,iBAAiB;IACpB,CAAC,EAAE,iBAAiB;IACpB,CAAC,EAAE,iBAAiB;CACrB,CAAC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MAAM,iCAAiC,GAAG,CAC/C,IAAU,EACV,UAAkB,EAClB,KAAa,EACb,cAAsB,EACtB,EAAE;IACF,MAAM,aAAa,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEzD,MAAM,IAAA,8BAAM,EACV,IAAI;SACD,OAAO,CAAC,cAAc,cAAc,IAAI,CAAC;SACzC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,aAAa,IAAI,CAAC,CAAC,CACvD,CAAC,WAAW,EAAE,CAAC;IAChB,MAAM,IAAI;SACP,OAAO,CAAC,cAAc,cAAc,IAAI,CAAC;SACzC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,aAAa,IAAI,CAAC,CAAC;SACnD,KAAK,EAAE,CAAC;IACX,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,UAAU,aAAa,KAAK,EAAE,CAAC,CAAC;IAClE,MAAM,IAAA,8BAAM,EAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AACtC,CAAC,CAAA,CAAC;AAnBW,QAAA,iCAAiC,qCAmB5C","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { tokens } from '@neo4j-ndl/base';\nimport { Chart } from '@neo4j-ndl/react-charts';\nimport { expect } from '@playwright/experimental-ct-react';\nimport { type Page } from '@playwright/test';\nimport { type ComponentProps } from 'react';\n\nimport { ChartWrapperWithTooltipFormatter } from './ChartWrapperWithTooltipFormatter';\n\n/**\n * Convert hex color to rgb format\n *\n * @param hex color in hex code format\n * @returns color in rgb format rgb(_, _, _)\n */\nconst convertHexToRGB = (hex: string) => {\n hex = hex.replace(/^#/, '');\n\n const red = parseInt(hex.substring(0, 2), 16);\n const green = parseInt(hex.substring(2, 4), 16);\n const blue = parseInt(hex.substring(4, 6), 16);\n\n return `rgb(${red}, ${green}, ${blue})`;\n};\n\nexport const chartColorsAfterHighlighting: Record<number, string> = {\n 1: 'rgb(93,207,216)',\n 10: 'rgb(210,126,49)',\n 11: 'rgb(78,151,121)',\n 12: 'rgb(190,255,117)',\n 2: 'rgb(84,80,223)',\n 3: 'rgb(242,152,62)',\n 4: 'rgb(221,75,155)',\n 5: 'rgb(156,154,255)',\n 6: 'rgb(132,244,136)',\n 7: 'rgb(69,140,249)',\n 8: 'rgb(113,69,188)',\n 9: 'rgb(240,210,70)',\n};\n\nexport const pieChartProps = (\n seriesName: string,\n value: number,\n rgbSeriesColor: string,\n) => ({\n legend: {\n show: true,\n },\n series: [\n {\n type: 'pie' as const,\n radius: '90%',\n center: ['50%', '50%'],\n encode: {\n itemName: 'product',\n value: '2012',\n },\n itemStyle: {\n color: rgbSeriesColor,\n },\n },\n ],\n dataset: [\n {\n source: [\n ['product', '2012'],\n [seriesName, value],\n ],\n },\n ],\n});\n\nexport const barChartProps = (\n seriesName: string,\n value: number,\n rgbSeriesColor: string,\n) => ({\n legend: {\n show: true,\n },\n dataset: {\n dimensions: ['Country', 'Sales'],\n source: [['Finland', value]],\n },\n series: [\n {\n encode: {\n x: 'Country',\n y: 'Sales',\n },\n name: seriesName,\n type: 'bar' as const,\n itemStyle: {\n color: rgbSeriesColor,\n },\n },\n ],\n xAxis: {\n type: 'category' as const,\n },\n yAxis: {\n type: 'value' as const,\n },\n});\n\nexport const multiSeriesChartProps = {\n dataset: {\n dimensions: ['day', 'first', 'second', 'third', 'fourth', 'fifth', 'sixth'],\n source: [\n ['Monday', 20, 40, 60, 80, 100, 120],\n ['Tuesday', 30, 50, 70, 90, 110, 130],\n ['Wednesday', 25, 45, 65, 85, 105, 125],\n ['Thursday', 35, 55, 75, 95, 115, 135],\n ['Friday', 40, 60, 80, 100, 120, 140],\n ],\n },\n legend: {\n show: true,\n wrappingType: 'wrapping' as const,\n },\n option: {},\n series: [\n {\n encode: { x: 'day', y: 'first' },\n name: 'First Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'second' },\n name: 'Second Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'third' },\n name: 'Third Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'fourth' },\n name: 'Fourth Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'fifth' },\n name: 'Fifth Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'sixth' },\n name: 'Sixth Series',\n type: 'line' as const,\n },\n ],\n xAxis: {\n type: 'category' as const,\n },\n yAxis: {\n type: 'value' as const,\n },\n};\n\nexport const multiSeriesChart = ({\n chartProps,\n width = '100%',\n height = '400px',\n}: {\n chartProps?: Partial<ComponentProps<typeof Chart>>;\n width?: string;\n height?: string;\n}) => (\n <div style={{ height, width }} className=\"ndl-chart\">\n <Chart {...multiSeriesChartProps} {...chartProps} />\n </div>\n);\n\nexport const pieChartWithTooltipFormatter = ({\n seriesName,\n value,\n rgbSeriesColor,\n chartProps,\n width = '100%',\n height = '400px',\n}: {\n chartProps?: Partial<ComponentProps<typeof Chart>>;\n width?: string;\n height?: string;\n seriesName: string;\n value: number;\n rgbSeriesColor: string;\n}) => (\n <div style={{ height, width }}>\n <ChartWrapperWithTooltipFormatter\n {...pieChartProps(seriesName, value, rgbSeriesColor)}\n {...chartProps}\n />\n </div>\n);\n\nexport const barChartWithTooltipFormatter = ({\n seriesName,\n value,\n rgbSeriesColor,\n chartProps,\n width = '100%',\n height = '400px',\n}: {\n chartProps?: Partial<ComponentProps<typeof Chart>>;\n width?: string;\n height?: string;\n seriesName: string;\n value: number;\n rgbSeriesColor: string;\n}) => (\n <div style={{ height, width }}>\n <ChartWrapperWithTooltipFormatter\n {...barChartProps(seriesName, value, rgbSeriesColor)}\n {...chartProps}\n />\n </div>\n);\n\nexport const expectChartElementVisible = async (page: Page) => {\n await expect(page.locator('svg')).toBeVisible();\n await expect(page.locator('.ndl-chart-legend')).toBeVisible();\n};\n\nconst SELECTORS = {\n CHECKMARK: '.ndl-chart-legend-item-square-checkmark',\n DESELECTED: '.ndl-chart-legend-item-deselected',\n seriesCheckmark: (name: string) =>\n `[data-labelname=\"${name}\"] .ndl-chart-legend-item-square-checkmark`,\n seriesDeselected: (name: string) =>\n `[data-labelname=\"${name}\"].ndl-chart-legend-item-deselected`,\n} as const;\n\nconst getGraphPaletteColorFromSeriesIndex = (index: string): string => {\n const hexColor = tokens.categorical[index as keyof typeof tokens.categorical];\n if (!hexColor) {\n throw new Error(`Categorical palette index ${index} not found`);\n }\n\n return hexColor;\n};\n\n/**\n * Checks so a single series is not blurred.\n */\nexport const expectSingleSeriesNotToBeBlurred = async (\n page: Page,\n seriesName: string,\n) => {\n const allChartSeries = multiSeriesChartProps.series;\n\n const seriesIndex =\n allChartSeries.findIndex((seriesItem) => seriesItem.name === seriesName) +\n 1;\n\n const rgbSeriesColor = chartColorsAfterHighlighting[seriesIndex];\n const hexSeriesColor = getGraphPaletteColorFromSeriesIndex(\n seriesIndex.toString(),\n );\n\n // More flexible color matching - try both with and without spaces\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n const hexRgb = convertHexToRGB(hexSeriesColor);\n const rgbWithoutSpaces = hexRgb.replace(/, /g, ',');\n\n const pathLocator = page\n .locator(`path[stroke=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[stroke=\"${rgbWithSpaces}\"]`))\n .or(page.locator(`path[stroke=\"${hexSeriesColor}\"]`))\n .or(page.locator(`path[stroke=\"${convertHexToRGB(hexSeriesColor)}\"]`))\n .or(page.locator(`path[stroke=\"${rgbWithoutSpaces}\"]`));\n\n // Wait for the element to be attached to the DOM before checking its attributes\n await expect(pathLocator).toBeAttached({ timeout: 10000 });\n await expect(pathLocator).not.toHaveAttribute('stroke-opacity');\n};\n\n/**\n * Checks so that the seriesNamesToBeHighlighted are visible in the chart and that other series are blurred.\n */\nexport const expectLegendSeriesToBeHighlightedInChart = async (\n page: Page,\n seriesNamesToBeHighlighted: string[],\n) => {\n const allChartSeries = multiSeriesChartProps.series;\n\n for (const name of seriesNamesToBeHighlighted) {\n const highlightedSeriesIndex =\n allChartSeries.findIndex((seriesItem) => seriesItem.name === name) + 1;\n\n const rgbSeriesColor = chartColorsAfterHighlighting[highlightedSeriesIndex];\n const hexSeriesColor = getGraphPaletteColorFromSeriesIndex(\n highlightedSeriesIndex.toString(),\n );\n\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n const hexRgb = convertHexToRGB(hexSeriesColor);\n const rgbWithoutSpaces = hexRgb.replace(/, /g, ',');\n\n const pathLocator = page\n .locator(`path[stroke=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[stroke=\"${rgbWithSpaces}\"]`))\n .or(page.locator(`path[stroke=\"${hexSeriesColor}\"]`))\n .or(page.locator(`path[stroke=\"${convertHexToRGB(hexSeriesColor)}\"]`))\n .or(page.locator(`path[stroke=\"${rgbWithoutSpaces}\"]`));\n\n await expect(pathLocator).not.toHaveAttribute('stroke-opacity');\n }\n\n const seriesToBeBlurred = allChartSeries.filter(\n (series) => !seriesNamesToBeHighlighted.includes(series.name),\n );\n\n for (const series of seriesToBeBlurred) {\n const blurredSeriesIndex =\n allChartSeries.findIndex(\n (seriesItem) => seriesItem.name === series.name,\n ) + 1;\n\n const rgbSeriesColor = chartColorsAfterHighlighting[blurredSeriesIndex];\n const hexSeriesColor = getGraphPaletteColorFromSeriesIndex(\n blurredSeriesIndex.toString(),\n );\n\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n const hexRgb = convertHexToRGB(hexSeriesColor);\n const rgbWithoutSpaces = hexRgb.replace(/, /g, ',');\n\n const pathLocator = page\n .locator(`path[stroke=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[stroke=\"${rgbWithSpaces}\"]`))\n .or(page.locator(`path[stroke=\"${hexSeriesColor}\"]`))\n .or(page.locator(`path[stroke=\"${convertHexToRGB(hexSeriesColor)}\"]`))\n .or(page.locator(`path[stroke=\"${rgbWithoutSpaces}\"]`));\n\n await expect(pathLocator).toHaveAttribute('stroke-opacity');\n }\n};\n\n/**\n * Identifies if the series are visible / not visible in the chart by checking for a path with the series color (lacks other unique identifiers)\n * Apache Echarts displays the path color in both hex, rgb and a slightly adjusted rgb when highlighted, therefor we need to check for all three when looking for the series in the chart.\n */\nexport const expectLegendSeriesToBeVisibleInChart = async (\n page: Page,\n seriesNamesToBeVisible: string[],\n) => {\n const allChartSeries = multiSeriesChartProps.series;\n\n // Check so that the series that should be visible are present in the chart\n for (const name of seriesNamesToBeVisible) {\n const visibleSeriesIndex =\n allChartSeries.findIndex((series) => series.name === name) + 1;\n\n const rgbSeriesColor = chartColorsAfterHighlighting[visibleSeriesIndex];\n const hexSeriesColor = getGraphPaletteColorFromSeriesIndex(\n visibleSeriesIndex.toString(),\n );\n\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n const hexRgb = convertHexToRGB(hexSeriesColor);\n const rgbWithoutSpaces = hexRgb.replace(/, /g, ',');\n\n await expect(\n page\n .locator(`path[stroke=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[stroke=\"${rgbWithSpaces}\"]`))\n .or(page.locator(`path[stroke=\"${hexSeriesColor}\"]`))\n .or(page.locator(`path[stroke=\"${convertHexToRGB(hexSeriesColor)}\"]`))\n .or(page.locator(`path[stroke=\"${rgbWithoutSpaces}\"]`)),\n ).toBeVisible({ timeout: 10000 });\n }\n\n // Check so that the other series are not present in the chart\n const hiddenSeries = multiSeriesChartProps.series.filter(\n (series) => !seriesNamesToBeVisible.includes(series.name),\n );\n\n for (const hiddenSeriesItem of hiddenSeries) {\n const hiddenSeriesIndex =\n allChartSeries.findIndex(\n (allChartSeriesItem) =>\n hiddenSeriesItem.name === allChartSeriesItem.name,\n ) + 1;\n\n const rgbSeriesColor = chartColorsAfterHighlighting[hiddenSeriesIndex];\n const hexSeriesColor = getGraphPaletteColorFromSeriesIndex(\n hiddenSeriesIndex.toString(),\n );\n\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n const hexRgb = convertHexToRGB(hexSeriesColor);\n const rgbWithoutSpaces = hexRgb.replace(/, /g, ',');\n\n await expect(\n page\n .locator(`path[stroke=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[stroke=\"${rgbWithSpaces}\"]`))\n .or(page.locator(`path[stroke=\"${hexSeriesColor}\"]`))\n .or(page.locator(`path[stroke=\"${convertHexToRGB(hexSeriesColor)}\"]`))\n .or(page.locator(`path[stroke=\"${rgbWithoutSpaces}\"]`)),\n ).not.toBeVisible();\n }\n};\n\n// Check so legends are selected -> has checkmark and no strike-through classes\nexport const expectLegendsSelected = async (\n page: Page,\n seriesNames: string[],\n) => {\n for (const name of seriesNames) {\n await expect(page.locator(SELECTORS.seriesCheckmark(name))).toBeVisible();\n await expect(\n page.locator(SELECTORS.seriesDeselected(name)),\n ).not.toBeVisible();\n }\n};\n\n// Check so legends are deselected -> has strike-through and no checkmark classes\nexport const expectLegendsDeselected = async (\n page: Page,\n seriesNames: string[],\n) => {\n for (const name of seriesNames) {\n await expect(page.locator(SELECTORS.seriesDeselected(name))).toBeVisible();\n await expect(\n page.locator(SELECTORS.seriesCheckmark(name)),\n ).not.toBeVisible();\n }\n};\n\n// Check so all legends are neutral -> no checkmark and no strike-through classes\nexport const expectAllLegendsNeutral = async (page: Page) => {\n await expect(page.locator(SELECTORS.CHECKMARK)).not.toBeVisible();\n await expect(page.locator(SELECTORS.DESELECTED)).not.toBeVisible();\n};\n\n/**\n * Clicks the series legend item and hover the chart to make sure no blur effect exists on other series in the chart.\n * This is needed to make sure the series has the correct color when looking for them in the chart in later steps.\n */\nexport const clickSeries = async (page: Page, seriesName: string) => {\n await page.locator(`[data-labelname=\"${seriesName}\"]`).click();\n await page.hover('.ndl-chart');\n};\n\nexport const expectFormattedTooltipToBeVisible = async (\n page: Page,\n seriesName: string,\n value: number,\n rgbSeriesColor: string,\n) => {\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n\n await expect(\n page\n .locator(`path[fill=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`fill[stroke=\"${rgbWithSpaces}\"]`)),\n ).toBeVisible();\n await page\n .locator(`path[fill=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`fill[stroke=\"${rgbWithSpaces}\"]`))\n .hover();\n const tooltip = page.getByText(`${seriesName}formatted ${value}`);\n await expect(tooltip).toBeVisible();\n};\n"]}
1
+ {"version":3,"file":"chart-test-utils.js","sourceRoot":"","sources":["../../../../src/charts/tests/chart-test-utils.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,0CAAyC;AACzC,0DAAgD;AAChD,6EAA2D;AAI3D,yFAAsF;AAEtF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,EAAE;IACtC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAE5B,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAE/C,OAAO,OAAO,GAAG,KAAK,KAA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AAQ,CAAC,CAAC,OAAO,EAAE,EAAE,CACpB,OAAO,CAAC,GAAG,CACT,OAAO,CAAC,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAC/D,CACF,CAAC;AACN,CAAC,CAAC;AARW,QAAA,mBAAmB,uBAQ9B","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { tokens } from '@neo4j-ndl/base';\nimport { Chart } from '@neo4j-ndl/react-charts';\nimport { expect } from '@playwright/experimental-ct-react';\nimport { type Page } from '@playwright/test';\nimport { type ComponentProps } from 'react';\n\nimport { ChartWrapperWithTooltipFormatter } from './ChartWrapperWithTooltipFormatter';\n\n/**\n * Convert hex color to rgb format\n *\n * @param hex color in hex code format\n * @returns color in rgb format rgb(_, _, _)\n */\nconst convertHexToRGB = (hex: string) => {\n hex = hex.replace(/^#/, '');\n\n const red = parseInt(hex.substring(0, 2), 16);\n const green = parseInt(hex.substring(2, 4), 16);\n const blue = parseInt(hex.substring(4, 6), 16);\n\n return `rgb(${red}, ${green}, ${blue})`;\n};\n\nexport const chartColorsAfterHighlighting: Record<number, string> = {\n 1: 'rgb(93,207,216)',\n 10: 'rgb(210,126,49)',\n 11: 'rgb(78,151,121)',\n 12: 'rgb(190,255,117)',\n 2: 'rgb(84,80,223)',\n 3: 'rgb(242,152,62)',\n 4: 'rgb(221,75,155)',\n 5: 'rgb(156,154,255)',\n 6: 'rgb(132,244,136)',\n 7: 'rgb(69,140,249)',\n 8: 'rgb(113,69,188)',\n 9: 'rgb(240,210,70)',\n};\n\nexport const pieChartProps = (\n seriesName: string,\n value: number,\n rgbSeriesColor: string,\n) => ({\n dataset: [\n {\n source: [\n ['product', '2012'],\n [seriesName, value],\n ],\n },\n ],\n legend: {\n show: true,\n },\n series: [\n {\n type: 'pie' as const,\n radius: '90%',\n center: ['50%', '50%'],\n encode: {\n itemName: 'product',\n value: '2012',\n },\n itemStyle: {\n color: rgbSeriesColor,\n },\n },\n ],\n});\n\nexport const barChartProps = (\n seriesName: string,\n value: number,\n rgbSeriesColor: string,\n) => ({\n dataset: {\n dimensions: ['Country', 'Sales'],\n source: [['Finland', value]],\n },\n legend: {\n show: true,\n },\n series: [\n {\n encode: {\n x: 'Country',\n y: 'Sales',\n },\n name: seriesName,\n type: 'bar' as const,\n itemStyle: {\n color: rgbSeriesColor,\n },\n },\n ],\n xAxis: {\n type: 'category' as const,\n },\n yAxis: {\n type: 'value' as const,\n },\n});\n\nexport const multiSeriesChartProps = {\n dataset: {\n dimensions: ['day', 'first', 'second', 'third', 'fourth', 'fifth', 'sixth'],\n source: [\n ['Monday', 20, 40, 60, 80, 100, 120],\n ['Tuesday', 30, 50, 70, 90, 110, 130],\n ['Wednesday', 25, 45, 65, 85, 105, 125],\n ['Thursday', 35, 55, 75, 95, 115, 135],\n ['Friday', 40, 60, 80, 100, 120, 140],\n ],\n },\n legend: {\n show: true,\n wrappingType: 'wrapping' as const,\n },\n option: {},\n series: [\n {\n encode: { x: 'day', y: 'first' },\n name: 'First Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'second' },\n name: 'Second Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'third' },\n name: 'Third Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'fourth' },\n name: 'Fourth Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'fifth' },\n name: 'Fifth Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'sixth' },\n name: 'Sixth Series',\n type: 'line' as const,\n },\n ],\n xAxis: {\n type: 'category' as const,\n },\n yAxis: {\n type: 'value' as const,\n },\n};\n\nexport const multiSeriesChart = ({\n chartProps,\n width = '100%',\n height = '400px',\n}: {\n chartProps?: Partial<ComponentProps<typeof Chart>>;\n width?: string;\n height?: string;\n}) => (\n <div style={{ height, width }} className=\"ndl-chart\">\n <Chart {...multiSeriesChartProps} {...chartProps} />\n </div>\n);\n\nexport const pieChartWithTooltipFormatter = ({\n seriesName,\n value,\n rgbSeriesColor,\n chartProps,\n width = '100%',\n height = '400px',\n}: {\n chartProps?: Partial<ComponentProps<typeof Chart>>;\n width?: string;\n height?: string;\n seriesName: string;\n value: number;\n rgbSeriesColor: string;\n}) => (\n <div style={{ height, width }}>\n <ChartWrapperWithTooltipFormatter\n {...pieChartProps(seriesName, value, rgbSeriesColor)}\n {...chartProps}\n />\n </div>\n);\n\nexport const barChartWithTooltipFormatter = ({\n seriesName,\n value,\n rgbSeriesColor,\n chartProps,\n width = '100%',\n height = '400px',\n}: {\n chartProps?: Partial<ComponentProps<typeof Chart>>;\n width?: string;\n height?: string;\n seriesName: string;\n value: number;\n rgbSeriesColor: string;\n}) => (\n <div style={{ height, width }}>\n <ChartWrapperWithTooltipFormatter\n {...barChartProps(seriesName, value, rgbSeriesColor)}\n {...chartProps}\n />\n </div>\n);\n\nexport const expectChartElementVisible = async (page: Page) => {\n await expect(page.locator('svg')).toBeVisible();\n await expect(page.locator('.ndl-chart-legend')).toBeVisible();\n};\n\nconst SELECTORS = {\n CHECKMARK: '.ndl-chart-legend-item-square-checkmark',\n DESELECTED: '.ndl-chart-legend-item-deselected',\n seriesCheckmark: (name: string) =>\n `[data-labelname=\"${name}\"] .ndl-chart-legend-item-square-checkmark`,\n seriesDeselected: (name: string) =>\n `[data-labelname=\"${name}\"].ndl-chart-legend-item-deselected`,\n} as const;\n\nconst getGraphPaletteColorFromSeriesIndex = (index: string): string => {\n const hexColor = tokens.categorical[index as keyof typeof tokens.categorical];\n if (!hexColor) {\n throw new Error(`Categorical palette index ${index} not found`);\n }\n\n return hexColor;\n};\n\n/**\n * Checks so a single series is not blurred.\n */\nexport const expectSingleSeriesNotToBeBlurred = async (\n page: Page,\n seriesName: string,\n) => {\n const allChartSeries = multiSeriesChartProps.series;\n\n const seriesIndex =\n allChartSeries.findIndex((seriesItem) => seriesItem.name === seriesName) +\n 1;\n\n const rgbSeriesColor = chartColorsAfterHighlighting[seriesIndex];\n const hexSeriesColor = getGraphPaletteColorFromSeriesIndex(\n seriesIndex.toString(),\n );\n\n // More flexible color matching - try both with and without spaces\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n const hexRgb = convertHexToRGB(hexSeriesColor);\n const rgbWithoutSpaces = hexRgb.replace(/, /g, ',');\n\n const pathLocator = page\n .locator(`path[stroke=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[stroke=\"${rgbWithSpaces}\"]`))\n .or(page.locator(`path[stroke=\"${hexSeriesColor}\"]`))\n .or(page.locator(`path[stroke=\"${convertHexToRGB(hexSeriesColor)}\"]`))\n .or(page.locator(`path[stroke=\"${rgbWithoutSpaces}\"]`));\n\n // Wait for the element to be attached to the DOM before checking its attributes\n await expect(pathLocator).toBeAttached({ timeout: 10000 });\n await expect(pathLocator).not.toHaveAttribute('stroke-opacity');\n};\n\n/**\n * Checks so that the seriesNamesToBeHighlighted are visible in the chart and that other series are blurred.\n */\nexport const expectLegendSeriesToBeHighlightedInChart = async (\n page: Page,\n seriesNamesToBeHighlighted: string[],\n) => {\n const allChartSeries = multiSeriesChartProps.series;\n\n for (const name of seriesNamesToBeHighlighted) {\n const highlightedSeriesIndex =\n allChartSeries.findIndex((seriesItem) => seriesItem.name === name) + 1;\n\n const rgbSeriesColor = chartColorsAfterHighlighting[highlightedSeriesIndex];\n const hexSeriesColor = getGraphPaletteColorFromSeriesIndex(\n highlightedSeriesIndex.toString(),\n );\n\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n const hexRgb = convertHexToRGB(hexSeriesColor);\n const rgbWithoutSpaces = hexRgb.replace(/, /g, ',');\n\n const pathLocator = page\n .locator(`path[stroke=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[stroke=\"${rgbWithSpaces}\"]`))\n .or(page.locator(`path[stroke=\"${hexSeriesColor}\"]`))\n .or(page.locator(`path[stroke=\"${convertHexToRGB(hexSeriesColor)}\"]`))\n .or(page.locator(`path[stroke=\"${rgbWithoutSpaces}\"]`));\n\n await expect(pathLocator).not.toHaveAttribute('stroke-opacity');\n }\n\n const seriesToBeBlurred = allChartSeries.filter(\n (series) => !seriesNamesToBeHighlighted.includes(series.name),\n );\n\n for (const series of seriesToBeBlurred) {\n const blurredSeriesIndex =\n allChartSeries.findIndex(\n (seriesItem) => seriesItem.name === series.name,\n ) + 1;\n\n const rgbSeriesColor = chartColorsAfterHighlighting[blurredSeriesIndex];\n const hexSeriesColor = getGraphPaletteColorFromSeriesIndex(\n blurredSeriesIndex.toString(),\n );\n\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n const hexRgb = convertHexToRGB(hexSeriesColor);\n const rgbWithoutSpaces = hexRgb.replace(/, /g, ',');\n\n const pathLocator = page\n .locator(`path[stroke=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[stroke=\"${rgbWithSpaces}\"]`))\n .or(page.locator(`path[stroke=\"${hexSeriesColor}\"]`))\n .or(page.locator(`path[stroke=\"${convertHexToRGB(hexSeriesColor)}\"]`))\n .or(page.locator(`path[stroke=\"${rgbWithoutSpaces}\"]`));\n\n await expect(pathLocator).toHaveAttribute('stroke-opacity');\n }\n};\n\n/**\n * Identifies if the series are visible / not visible in the chart by checking for a path with the series color (lacks other unique identifiers)\n * Apache Echarts displays the path color in both hex, rgb and a slightly adjusted rgb when highlighted, therefor we need to check for all three when looking for the series in the chart.\n */\nexport const expectLegendSeriesToBeVisibleInChart = async (\n page: Page,\n seriesNamesToBeVisible: string[],\n) => {\n const allChartSeries = multiSeriesChartProps.series;\n\n // Check so that the series that should be visible are present in the chart\n for (const name of seriesNamesToBeVisible) {\n const visibleSeriesIndex =\n allChartSeries.findIndex((series) => series.name === name) + 1;\n\n const rgbSeriesColor = chartColorsAfterHighlighting[visibleSeriesIndex];\n const hexSeriesColor = getGraphPaletteColorFromSeriesIndex(\n visibleSeriesIndex.toString(),\n );\n\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n const hexRgb = convertHexToRGB(hexSeriesColor);\n const rgbWithoutSpaces = hexRgb.replace(/, /g, ',');\n\n await expect(\n page\n .locator(`path[stroke=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[stroke=\"${rgbWithSpaces}\"]`))\n .or(page.locator(`path[stroke=\"${hexSeriesColor}\"]`))\n .or(page.locator(`path[stroke=\"${convertHexToRGB(hexSeriesColor)}\"]`))\n .or(page.locator(`path[stroke=\"${rgbWithoutSpaces}\"]`)),\n ).toBeVisible({ timeout: 10000 });\n }\n\n // Check so that the other series are not present in the chart\n const hiddenSeries = multiSeriesChartProps.series.filter(\n (series) => !seriesNamesToBeVisible.includes(series.name),\n );\n\n for (const hiddenSeriesItem of hiddenSeries) {\n const hiddenSeriesIndex =\n allChartSeries.findIndex(\n (allChartSeriesItem) =>\n hiddenSeriesItem.name === allChartSeriesItem.name,\n ) + 1;\n\n const rgbSeriesColor = chartColorsAfterHighlighting[hiddenSeriesIndex];\n const hexSeriesColor = getGraphPaletteColorFromSeriesIndex(\n hiddenSeriesIndex.toString(),\n );\n\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n const hexRgb = convertHexToRGB(hexSeriesColor);\n const rgbWithoutSpaces = hexRgb.replace(/, /g, ',');\n\n await expect(\n page\n .locator(`path[stroke=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[stroke=\"${rgbWithSpaces}\"]`))\n .or(page.locator(`path[stroke=\"${hexSeriesColor}\"]`))\n .or(page.locator(`path[stroke=\"${convertHexToRGB(hexSeriesColor)}\"]`))\n .or(page.locator(`path[stroke=\"${rgbWithoutSpaces}\"]`)),\n ).not.toBeVisible();\n }\n};\n\n// Check so legends are selected -> has checkmark and no strike-through classes\nexport const expectLegendsSelected = async (\n page: Page,\n seriesNames: string[],\n) => {\n for (const name of seriesNames) {\n await expect(page.locator(SELECTORS.seriesCheckmark(name))).toBeVisible();\n await expect(\n page.locator(SELECTORS.seriesDeselected(name)),\n ).not.toBeVisible();\n }\n};\n\n// Check so legends are deselected -> has strike-through and no checkmark classes\nexport const expectLegendsDeselected = async (\n page: Page,\n seriesNames: string[],\n) => {\n for (const name of seriesNames) {\n await expect(page.locator(SELECTORS.seriesDeselected(name))).toBeVisible();\n await expect(\n page.locator(SELECTORS.seriesCheckmark(name)),\n ).not.toBeVisible();\n }\n};\n\n// Check so all legends are neutral -> no checkmark and no strike-through classes\nexport const expectAllLegendsNeutral = async (page: Page) => {\n await expect(page.locator(SELECTORS.CHECKMARK)).not.toBeVisible();\n await expect(page.locator(SELECTORS.DESELECTED)).not.toBeVisible();\n};\n\n/**\n * Clicks the series legend item and hover the chart to make sure no blur effect exists on other series in the chart.\n * This is needed to make sure the series has the correct color when looking for them in the chart in later steps.\n */\nexport const clickSeries = async (page: Page, seriesName: string) => {\n await page.locator(`[data-labelname=\"${seriesName}\"]`).click();\n await page.hover('.ndl-chart');\n};\n\nexport const expectFormattedTooltipToBeVisible = async (\n page: Page,\n seriesName: string,\n value: number,\n rgbSeriesColor: string,\n) => {\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n\n await expect(\n page\n .locator(`path[fill=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`fill[stroke=\"${rgbWithSpaces}\"]`)),\n ).toBeVisible();\n await page\n .locator(`path[fill=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`fill[stroke=\"${rgbWithSpaces}\"]`))\n .hover();\n const tooltip = page.getByText(`${seriesName}formatted ${value}`);\n await expect(tooltip).toBeVisible();\n};\n\nexport const waitForAnimationEnd = (page: Page, selector: string) => {\n return page\n .locator(selector)\n .evaluate((element) =>\n Promise.all(\n element.getAnimations().map((animation) => animation.finished),\n ),\n );\n};\n"]}
@@ -94,6 +94,8 @@ export function Chart({ dataset, option: userOption, xAxis: propXAxis, yAxis: pr
94
94
  const chartRef = useRef(null);
95
95
  const chartEchartRef = useRef(null);
96
96
  const chartLegendRef = useRef(null);
97
+ const legendSelectedRef = useRef({});
98
+ const legendColorCacheRef = useRef(new Map());
97
99
  const [isWaitingForFirstResize, setIsWaitingForFirstResize] = useState(true);
98
100
  const dataZoomOptions = userOption === null || userOption === void 0 ? void 0 : userOption.dataZoom;
99
101
  const toolboxOptions = userOption === null || userOption === void 0 ? void 0 : userOption.toolbox;
@@ -131,6 +133,7 @@ export function Chart({ dataset, option: userOption, xAxis: propXAxis, yAxis: pr
131
133
  if (chartEchartRef.current === null) {
132
134
  return;
133
135
  }
136
+ const chart = getInstanceByDom(chartEchartRef.current);
134
137
  const option = Object.assign(Object.assign({ dataset,
135
138
  xAxis,
136
139
  yAxis }, userOption), { aria: Object.assign({ decal: {
@@ -138,6 +141,11 @@ export function Chart({ dataset, option: userOption, xAxis: propXAxis, yAxis: pr
138
141
  }, enabled: true }, userOption === null || userOption === void 0 ? void 0 : userOption.aria), grid: Object.assign({ left: hasCategoryXAxis ? '15px' : '10px', right: hasCategoryXAxis ? '15px' : '10px', top: '10px', bottom: hasSliderZoom ? '60px' : '10px', type: 'solid', containLabel: true }, userOption === null || userOption === void 0 ? void 0 : userOption.grid), legend: {
139
142
  // Removes in-built echarts legend
140
143
  show: false,
144
+ // Preserve legend filter state across re-renders. legendSelectedRef
145
+ // is the single source of truth, written by the Legend component.
146
+ // ECharts mutates the options object, so pass a shallow copy here
147
+ // to avoid it mutating the React ref object.
148
+ selected: Object.assign({}, (legendSelectedRef.current || {})),
141
149
  }, series, tooltip: {
142
150
  trigger: 'axis',
143
151
  confine: true,
@@ -190,7 +198,6 @@ export function Chart({ dataset, option: userOption, xAxis: propXAxis, yAxis: pr
190
198
  },
191
199
  }, dataZoom, toolbox: mergeToolbox(toolboxOptions) });
192
200
  // Update chart with initial option
193
- const chart = getInstanceByDom(chartEchartRef.current);
194
201
  chart === null || chart === void 0 ? void 0 : chart.setOption(option, settings);
195
202
  // Get option returns the current option of the chart.
196
203
  // This is slightly different than the option we gave as an argument.
@@ -378,7 +385,7 @@ export function Chart({ dataset, option: userOption, xAxis: propXAxis, yAxis: pr
378
385
  const legendSeries = [];
379
386
  if (Array.isArray(optionSeries)) {
380
387
  optionSeries.forEach((currentSeries, index) => {
381
- var _a, _b, _c;
388
+ var _a, _b, _c, _d;
382
389
  if (currentSeries === null) {
383
390
  return;
384
391
  }
@@ -416,13 +423,20 @@ export function Chart({ dataset, option: userOption, xAxis: propXAxis, yAxis: pr
416
423
  return;
417
424
  }
418
425
  const sourceLength = Array.isArray(source) ? source.length : 0;
426
+ const selected = legendSelectedRef.current;
427
+ const isAllVisible = Object.values(selected).every((v) => v);
419
428
  for (let rowIndex = 1; rowIndex < sourceLength; rowIndex++) {
420
429
  const row = source[rowIndex];
421
- const color = chart === null || chart === void 0 ? void 0 : chart.getVisual({ dataIndexInside: rowIndex - 1, seriesIndex: index }, 'color');
422
- legendSeries.push({
423
- color: typeof color === 'string' ? color : '#000000',
424
- name: String(row[firstDatasetRowIndex]),
425
- });
430
+ const name = String(row[firstDatasetRowIndex]);
431
+ const freshColor = chart === null || chart === void 0 ? void 0 : chart.getVisual({ dataIndexInside: rowIndex - 1, seriesIndex: index }, 'color');
432
+ // Only trust getVisual colors when all items are visible.
433
+ // When items are deselected, getVisual returns grayed-out
434
+ // colors, so we use the cached color from when it was visible.
435
+ if (isAllVisible && typeof freshColor === 'string') {
436
+ legendColorCacheRef.current.set(name, freshColor);
437
+ }
438
+ const color = (_c = legendColorCacheRef.current.get(name)) !== null && _c !== void 0 ? _c : (typeof freshColor === 'string' ? freshColor : '#000000');
439
+ legendSeries.push({ color, name });
426
440
  }
427
441
  }
428
442
  else {
@@ -432,7 +446,7 @@ export function Chart({ dataset, option: userOption, xAxis: propXAxis, yAxis: pr
432
446
  }
433
447
  else {
434
448
  const name = Array.isArray(optionSeries)
435
- ? (_c = optionSeries[index]) === null || _c === void 0 ? void 0 : _c.name
449
+ ? (_d = optionSeries[index]) === null || _d === void 0 ? void 0 : _d.name
436
450
  : undefined;
437
451
  if (name === undefined) {
438
452
  return null;
@@ -459,6 +473,6 @@ export function Chart({ dataset, option: userOption, xAxis: propXAxis, yAxis: pr
459
473
  });
460
474
  }
461
475
  }
462
- return (_jsxs("div", { ref: chartRef, className: "ndl-chart", style: style, children: [_jsx("div", { ref: chartEchartRef }), (legend === null || legend === void 0 ? void 0 : legend.show) && !isWaitingForFirstResize && (_jsx(Legend, { ref: chartLegendRef, wrappingType: legend.wrappingType, series: legendSeries !== null && legendSeries !== void 0 ? legendSeries : [], chartRef: chartEchartRef }))] }));
476
+ return (_jsxs("div", { ref: chartRef, className: "ndl-chart", style: style, children: [_jsx("div", { ref: chartEchartRef }), (legend === null || legend === void 0 ? void 0 : legend.show) && !isWaitingForFirstResize && (_jsx(Legend, { ref: chartLegendRef, wrappingType: legend.wrappingType, series: legendSeries !== null && legendSeries !== void 0 ? legendSeries : [], chartRef: chartEchartRef, selectedRef: legendSelectedRef }))] }));
463
477
  }
464
478
  //# sourceMappingURL=Chart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Chart.js","sourceRoot":"","sources":["../../../src/charts/Chart.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAIL,gBAAgB,EAChB,IAAI,EACJ,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,OAAO,EAA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IAAI,KAAK,EAAE,CAAC;YACV,yCAAyC;YACzC,iEAAiE;YACjE,KAAK,CAAC,cAAc,CAAC;gBACnB,oBAAoB,EAAE,IAAI;gBAC1B,GAAG,EAAE,gBAAgB;gBACrB,IAAI,EAAE,kBAAkB;aACzB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,CACL,eAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,WAAW,EAAC,KAAK,EAAE,KAAK,aACpD,cAAK,GAAG,EAAE,cAAc,GAAI,EAC3B,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,KAAI,CAAC,uBAAuB,IAAI,CAC3C,KAAC,MAAM,IACL,GAAG,EAAE,cAAc,EACnB,YAAY,EAAE,MAAM,CAAC,YAAY,EACjC,MAAM,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,EAC1B,QAAQ,EAAE,cAAc,GACxB,CACH,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { tokens } from '@neo4j-ndl/base';\nimport { useNeedleTheme } from '@neo4j-ndl/react';\nimport {\n type DataZoomComponentOption,\n type ECharts,\n type EChartsOption,\n getInstanceByDom,\n init,\n registerTheme,\n} from 'echarts';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { renderToString } from 'react-dom/server';\n\nimport {\n type ChartProps,\n type Condition,\n type NeedleSeries,\n type NotificationType,\n type ThresholdLineSeriesOption,\n} from './chart-types';\nimport { ChartTooltip } from './ChartTooltip';\nimport { defaultThresholdLineSeriesOption } from './defaults';\nimport { Legend } from './Legend';\nimport { ndlEchartsTheme } from './themes/ndl-echarts-theme';\nimport {\n mergeDataZoom,\n mergeSeries,\n mergeToolbox,\n mergeXAxis,\n mergeYAxis,\n} from './user-option-utils';\nimport { capitalizeFirstLetter, extractValueFromTooltipSeries } from './utils';\n\n// This returns a boolean if the condition is met\n// and also what to display in the tooltip.\nfunction checkCondition(\n value: number,\n condition: Condition,\n threshold: number,\n): {\n isConditionMet: boolean;\n conditionText: string | undefined;\n} {\n switch (condition) {\n case 'greater':\n return {\n conditionText: 'Above',\n isConditionMet: value > threshold,\n };\n case 'greaterOrEqual':\n return {\n conditionText:\n value > threshold\n ? 'Above'\n : value === threshold\n ? 'Equal'\n : undefined,\n isConditionMet: value >= threshold,\n };\n case 'less':\n return {\n conditionText: 'Below',\n isConditionMet: value < threshold,\n };\n case 'lessOrEqual':\n return {\n conditionText:\n value < threshold\n ? 'Below'\n : value === threshold\n ? 'Equal'\n : undefined,\n isConditionMet: value <= threshold,\n };\n case 'equal':\n return {\n conditionText: 'Equal',\n isConditionMet: value === threshold,\n };\n case 'notEqual':\n return {\n conditionText: 'Not equal',\n isConditionMet: value !== threshold,\n };\n default:\n return { conditionText: undefined, isConditionMet: false };\n }\n}\n\n/*\nKeep this, if we want more than one type of the same threshold line\nthis will be useful to use.\n\nexport interface NewRegisteredSeriesOption extends RegisteredSeriesOption {\nthresholdLine: ThresholdLineSeriesOption;\n}\nexport type SeriesOption = Values<NewRegisteredSeriesOption>;\nexport type Series = SeriesOption | SeriesOption[];\n*/\n\nexport function Chart({\n dataset,\n option: userOption,\n xAxis: propXAxis,\n yAxis: propYAxis,\n series: propsSeries,\n style,\n settings = {\n lazyUpdate: false,\n notMerge: true,\n silent: false,\n },\n isLoading,\n isChartZoomDisabled = false,\n legend,\n callbacks,\n}: ChartProps): React.JSX.Element {\n const chartRef = useRef<HTMLDivElement>(null);\n const chartEchartRef = useRef<HTMLDivElement>(null);\n const chartLegendRef = useRef<HTMLDivElement>(null);\n const [isWaitingForFirstResize, setIsWaitingForFirstResize] = useState(true);\n\n const dataZoomOptions = (userOption as EChartsOption)?.dataZoom;\n const toolboxOptions = (userOption as EChartsOption)?.toolbox;\n\n const hasSliderZoom = Array.isArray(dataZoomOptions)\n ? dataZoomOptions.some((dataZoomOption: DataZoomComponentOption) => {\n return dataZoomOption?.type === 'slider';\n })\n : dataZoomOptions?.type === 'slider';\n\n const { theme } = useNeedleTheme();\n const thresholdLines = useMemo(() => {\n const seriesArray = Array.isArray(propsSeries)\n ? propsSeries\n : [propsSeries];\n\n const thresholdLineSeries = seriesArray.filter((currentSeries) => {\n return currentSeries.type === 'thresholdLine';\n }) as ThresholdLineSeriesOption<NotificationType>[];\n\n return thresholdLineSeries.map((currentThresholdLineSeriesOption) => {\n return {\n ...currentThresholdLineSeriesOption,\n condition:\n currentThresholdLineSeriesOption.condition ??\n defaultThresholdLineSeriesOption.condition,\n value: currentThresholdLineSeriesOption.yAxis,\n };\n });\n }, [propsSeries]);\n\n const dataZoom = useMemo(() => {\n return mergeDataZoom(dataZoomOptions);\n }, [dataZoomOptions]);\n\n const series = mergeSeries(propsSeries, theme, userOption);\n const xAxis = mergeXAxis(propXAxis, theme);\n const yAxis = mergeYAxis(propYAxis, theme);\n\n const hasCategoryXAxis = Array.isArray(xAxis)\n ? xAxis.some((x) => x.type === 'category')\n : xAxis?.type === 'category';\n\n // The initial option used, the charts option is not necessarily\n // the same as this due to mutation via dispatch and setOption.\n // use getOption to get the current option of the chart.\n const initialOption = useMemo(() => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const option = {\n dataset,\n xAxis,\n yAxis,\n ...userOption,\n aria: {\n decal: {\n show: false,\n },\n enabled: true,\n ...(userOption?.aria as EChartsOption['aria']),\n },\n grid: {\n left: hasCategoryXAxis ? '15px' : '10px',\n right: hasCategoryXAxis ? '15px' : '10px',\n top: '10px',\n bottom: hasSliderZoom ? '60px' : '10px',\n type: 'solid',\n containLabel: true,\n ...(userOption?.grid as EChartsOption['grid']),\n },\n legend: {\n // Removes in-built echarts legend\n show: false,\n },\n series,\n tooltip: {\n trigger: 'axis',\n confine: true,\n // Reset the default tooltip css styling\n padding: 0,\n borderRadius: 0,\n borderWidth: 0,\n extraCssText: 'box-shadow: none; background-color: transparent;',\n formatter: function (params: unknown) {\n const paramsArray = Array.isArray(params) ? params : [params];\n const firstParam = paramsArray[0];\n\n let valueFormatter = (value: unknown) => `${value}`;\n if (\n typeof userOption?.tooltip === 'object' &&\n userOption.tooltip !== null &&\n 'valueFormatter' in userOption.tooltip\n ) {\n valueFormatter = userOption.tooltip.valueFormatter as (\n value: unknown,\n ) => string;\n }\n return `${renderToString(\n <span className=\"ndl-charts-chart-tooltip\">\n <ChartTooltip.Title>\n {firstParam?.axisValueLabel ?? ''}\n </ChartTooltip.Title>\n {paramsArray.map((series) => {\n const { value: seriesValueUnknown } = series;\n\n const seriesValue = Array.isArray(seriesValueUnknown)\n ? seriesValueUnknown[1]\n : seriesValueUnknown;\n\n const isThresholdLine =\n series.seriesName.startsWith('thresholdLine');\n\n const notifications = thresholdLines\n .filter((threshold) => {\n const {\n value: thresholdValue,\n condition,\n customCondition,\n } = threshold;\n\n const isConditionMet = customCondition\n ? customCondition(seriesValue, thresholdValue)\n : checkCondition(seriesValue, condition, thresholdValue)\n .isConditionMet;\n\n return !isThresholdLine && isConditionMet;\n })\n .map((threshold) => {\n const {\n notificationType,\n value: thresholdValue,\n condition,\n customConditionText,\n customCondition,\n } = threshold;\n\n return {\n id: `threshold-${notificationType}`,\n leadingElement: customCondition\n ? customConditionText\n : `${\n checkCondition(\n seriesValue,\n condition,\n thresholdValue,\n ).conditionText\n } threshold`,\n notificationType,\n trailingElement: thresholdValue,\n };\n });\n\n const value = extractValueFromTooltipSeries(\n series.value,\n series.encode,\n series.axisDim,\n );\n\n return (\n <ChartTooltip.Content\n key={series.seriesName}\n leadingElement={\n isThresholdLine\n ? `${capitalizeFirstLetter(\n series.seriesName.replace('thresholdLine-', ''),\n )} threshold`\n : series.seriesName\n }\n trailingElement={valueFormatter(value)}\n indentSquareColor={series.color}\n notifications={notifications}\n />\n );\n })}\n </span>,\n )}`;\n },\n },\n dataZoom,\n toolbox: mergeToolbox(toolboxOptions),\n };\n\n // Update chart with initial option\n const chart = getInstanceByDom(chartEchartRef.current);\n chart?.setOption(option, settings);\n // Get option returns the current option of the chart.\n // This is slightly different than the option we gave as an argument.\n // Because we use useMemo in other areas we want to get this set first,\n // this is why we are setting then getting then returning. If we did this in\n // a useEffect it would run after the other useMemos which is not what we want.\n // This is purely for order of operations.\n const chartOption = chart?.getOption();\n\n return chartOption;\n }, [\n dataset,\n xAxis,\n yAxis,\n userOption,\n hasCategoryXAxis,\n hasSliderZoom,\n series,\n dataZoom,\n toolboxOptions,\n thresholdLines,\n settings,\n ]);\n\n useEffect(() => {\n // Initialize chart\n let chart: ECharts | undefined;\n if (chartEchartRef.current !== null) {\n registerTheme('ndl-light', ndlEchartsTheme('light'));\n registerTheme('ndl-dark', ndlEchartsTheme('dark'));\n\n const currentChart = getInstanceByDom(chartEchartRef.current);\n if (currentChart) {\n chart = currentChart;\n } else {\n const echartsTheme = theme === 'light' ? 'ndl-light' : 'ndl-dark';\n chart = init(chartEchartRef.current, echartsTheme, {\n renderer: 'svg',\n });\n }\n }\n\n if (callbacks?.onZoom) {\n chart?.on('datazoom', () => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const currentChart = getInstanceByDom(chartEchartRef.current);\n if (!currentChart) {\n return;\n }\n\n const option = currentChart.getOption();\n if (!option || !option.dataZoom) {\n return;\n }\n\n const dataZoom = Array.isArray(option.dataZoom)\n ? option.dataZoom[0]\n : option.dataZoom;\n const { startValue, endValue } = dataZoom as {\n startValue: number;\n endValue: number;\n };\n\n callbacks?.onZoom?.({ endValue, startValue });\n });\n }\n\n // Add chart resize listener\n // ResizeObserver is leading to a bit janky UX\n function resizeChart() {\n // TODO: We need to revisit this. Right now using grid containLabel seems to work.\n // We still need to visit this for overflowing of the x-axis labels.\n // const calculateGridLeft = () => {\n // const textElements = chartEchartRef.current?.querySelectorAll('text');\n // const filteredTextElements = Array.from(textElements || []).filter(\n // (element) => element.getAttribute('text-anchor') === 'end',\n // );\n // let maxWidth = 0;\n // filteredTextElements.forEach((element) => {\n // const bbox = element.getBBox();\n // maxWidth = Math.max(maxWidth, bbox.width);\n // });\n // const tickLength = 5;\n // const tickPadding = 3;\n // return maxWidth + tickLength + tickPadding;\n // };\n //\n // // Example of dynamically setting the grid's left\n // const gridLeft = calculateGridLeft();\n // chart?.setOption({\n // grid: {\n // left: gridLeft,\n // },\n // });\n\n // We want to fit the chart to the charts container.\n const chartContainerHeight = chartRef.current?.clientHeight;\n const chartContainerWidth = chartRef.current?.clientWidth;\n // Need to take legends height into consideration, otherwise it will overflow the parent.\n const chartLegendHeight = chartLegendRef?.current?.clientHeight || 0;\n const height = chartContainerHeight\n ? chartContainerHeight - chartLegendHeight\n : undefined;\n chart?.resize({\n height,\n width: chartContainerWidth,\n });\n }\n window.addEventListener('resize', resizeChart);\n requestAnimationFrame(() => {\n resizeChart();\n setIsWaitingForFirstResize(false);\n });\n\n // Add chart zoom listeners\n const handleMouseMove = () => {\n // I do not like this at all: https://github.com/apache/echarts/issues/19819\n // echarts updates the svgs on every mouse movement so we need to do this.\n chart?.getZr().setCursorStyle('default');\n };\n // We cannot use chart.getZr().on('mousemove', handleMouseMove)\n // This is because it doesn't respect our callbacks. It will\n // always run echarts code last instead of our callback.\n const chartChild = chartEchartRef.current?.children[0] as HTMLElement;\n if (!isChartZoomDisabled) {\n chartChild.addEventListener('mousemove', handleMouseMove);\n }\n\n const handleMouseDown = (params: { event: MouseEvent }) => {\n const event = params.event;\n const amountOfMouseClicks = event.detail;\n const isDoubleClick = amountOfMouseClicks === 2;\n if (isDoubleClick) {\n // Reset zooming.\n if (chart === undefined) {\n return;\n }\n chart?.dispatchAction({\n end: 100,\n start: 0,\n type: 'dataZoom',\n });\n if (callbacks?.onZoom) {\n callbacks?.onZoom?.({ endValue: 100, startValue: 0 });\n }\n }\n };\n if (!isChartZoomDisabled) {\n chart?.getZr().on('mousedown', handleMouseDown);\n }\n\n // Return cleanup function\n const chartRefCurrentElement = chartEchartRef.current;\n const element = chartRefCurrentElement?.children[0];\n return () => {\n window.removeEventListener('resize', resizeChart);\n\n element?.removeEventListener('mousemove', handleMouseMove);\n\n // Remove chart zoom handlers\n if (chartRefCurrentElement) {\n const chart = getInstanceByDom(chartRefCurrentElement);\n chart?.getZr().off('mousedown', handleMouseDown);\n }\n };\n });\n\n useEffect(() => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef?.current);\n\n if (isLoading === true || isWaitingForFirstResize) {\n chart?.showLoading({\n color: tokens.theme[theme].color.primary.bg.status,\n fontFamily: tokens.typography['label'].fontFamily,\n fontSize: tokens.typography['label'].fontSize,\n fontWeight: tokens.typography['label'].fontWeight,\n maskColor: `rgb( from ${tokens.theme[theme].color.neutral.text.inverse} r g b / 0.8)`,\n text: 'Loading',\n textColor: tokens.theme[theme].color.neutral.text.default,\n });\n } else {\n chart?.hideLoading();\n }\n }, [isLoading, isWaitingForFirstResize, theme]);\n\n const legendSeries = useMemo(() => {\n if (chartEchartRef.current === null || isWaitingForFirstResize) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef?.current);\n const optionSeries = (initialOption?.series as NeedleSeries) ?? [];\n const optionDataset = initialOption?.dataset;\n\n const legendSeries: {\n name: string;\n color: string;\n }[] = [];\n if (Array.isArray(optionSeries)) {\n optionSeries.forEach((currentSeries, index) => {\n if (currentSeries === null) {\n return;\n } else if (\n currentSeries.type === 'line' &&\n typeof currentSeries.name === 'string' &&\n currentSeries.name?.includes('thresholdLine')\n ) {\n return;\n } else if (currentSeries.type === 'pie') {\n const encodedItemName = currentSeries.encode?.itemName;\n let currentDataset = Array.isArray(optionDataset)\n ? optionDataset[0]\n : optionDataset;\n if (currentSeries.datasetId && Array.isArray(optionDataset)) {\n currentDataset = optionDataset.find(\n (ds) => ds.id === currentSeries.datasetId,\n );\n } else if (currentSeries.datasetIndex !== undefined) {\n currentDataset = Array.isArray(optionDataset)\n ? optionDataset[currentSeries.datasetIndex]\n : optionDataset;\n }\n const firstDatasetRow = Array.isArray(currentDataset?.source)\n ? currentDataset?.source[0]\n : undefined;\n if (!firstDatasetRow) {\n return;\n }\n\n if (Array.isArray(firstDatasetRow)) {\n const firstDatasetRowIndex = firstDatasetRow.findIndex(\n (item) => item === encodedItemName,\n );\n\n if (firstDatasetRowIndex === -1) {\n return;\n }\n\n const source = currentDataset?.source;\n if (!source) {\n return;\n }\n\n const sourceLength = Array.isArray(source) ? source.length : 0;\n for (let rowIndex = 1; rowIndex < sourceLength; rowIndex++) {\n const row = source[rowIndex] as (string | number)[];\n const color = chart?.getVisual(\n { dataIndexInside: rowIndex - 1, seriesIndex: index },\n 'color',\n );\n legendSeries.push({\n color: typeof color === 'string' ? color : '#000000',\n name: String(row[firstDatasetRowIndex]),\n });\n }\n } else {\n // TODO: handle dictionary\n }\n\n return;\n } else {\n const name = Array.isArray(optionSeries)\n ? optionSeries[index]?.name\n : undefined;\n\n if (name === undefined) {\n return null;\n }\n\n const color = chart?.getVisual({ seriesIndex: index }, 'color');\n legendSeries.push({\n color: typeof color === 'string' ? color : '#000000',\n name: String(name),\n });\n }\n });\n }\n return legendSeries.filter((currentSeries) => currentSeries !== null);\n }, [isWaitingForFirstResize, initialOption]);\n\n if (chartEchartRef.current !== null && !isChartZoomDisabled) {\n const chart = getInstanceByDom(chartEchartRef.current);\n if (chart) {\n // Needs to be re-set on every re-render.\n // Sets the selectable zoom area over the chart (not the slider).\n chart.dispatchAction({\n dataZoomSelectActive: true,\n key: 'dataZoomSelect',\n type: 'takeGlobalCursor',\n });\n }\n }\n\n return (\n <div ref={chartRef} className=\"ndl-chart\" style={style}>\n <div ref={chartEchartRef} />\n {legend?.show && !isWaitingForFirstResize && (\n <Legend\n ref={chartLegendRef}\n wrappingType={legend.wrappingType}\n series={legendSeries ?? []}\n chartRef={chartEchartRef}\n />\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"Chart.js","sourceRoot":"","sources":["../../../src/charts/Chart.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAIL,gBAAgB,EAChB,IAAI,EACJ,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AASlD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gCAAgC,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAE/E,iDAAiD;AACjD,2CAA2C;AAC3C,SAAS,cAAc,CACrB,KAAa,EACb,SAAoB,EACpB,SAAiB;IAKjB,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO;gBACL,aAAa,EAAE,OAAO;gBACtB,cAAc,EAAE,KAAK,GAAG,SAAS;aAClC,CAAC;QACJ,KAAK,gBAAgB;YACnB,OAAO;gBACL,aAAa,EACX,KAAK,GAA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Ac,CAAC,OAAO,CAAC,CAAC;QACvD,IAAI,KAAK,EAAE,CAAC;YACV,yCAAyC;YACzC,iEAAiE;YACjE,KAAK,CAAC,cAAc,CAAC;gBACnB,oBAAoB,EAAE,IAAI;gBAC1B,GAAG,EAAE,gBAAgB;gBACrB,IAAI,EAAE,kBAAkB;aACzB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,CACL,eAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,WAAW,EAAC,KAAK,EAAE,KAAK,aACpD,cAAK,GAAG,EAAE,cAAc,GAAI,EAC3B,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,KAAI,CAAC,uBAAuB,IAAI,CAC3C,KAAC,MAAM,IACL,GAAG,EAAE,cAAc,EACnB,YAAY,EAAE,MAAM,CAAC,YAAY,EACjC,MAAM,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,EAC1B,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,iBAAiB,GAC9B,CACH,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { tokens } from '@neo4j-ndl/base';\nimport { useNeedleTheme } from '@neo4j-ndl/react';\nimport {\n type DataZoomComponentOption,\n type ECharts,\n type EChartsOption,\n getInstanceByDom,\n init,\n registerTheme,\n} from 'echarts';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { renderToString } from 'react-dom/server';\n\nimport {\n type ChartProps,\n type Condition,\n type NeedleSeries,\n type NotificationType,\n type ThresholdLineSeriesOption,\n} from './chart-types';\nimport { ChartTooltip } from './ChartTooltip';\nimport { defaultThresholdLineSeriesOption } from './defaults';\nimport { Legend } from './Legend';\nimport { ndlEchartsTheme } from './themes/ndl-echarts-theme';\nimport {\n mergeDataZoom,\n mergeSeries,\n mergeToolbox,\n mergeXAxis,\n mergeYAxis,\n} from './user-option-utils';\nimport { capitalizeFirstLetter, extractValueFromTooltipSeries } from './utils';\n\n// This returns a boolean if the condition is met\n// and also what to display in the tooltip.\nfunction checkCondition(\n value: number,\n condition: Condition,\n threshold: number,\n): {\n isConditionMet: boolean;\n conditionText: string | undefined;\n} {\n switch (condition) {\n case 'greater':\n return {\n conditionText: 'Above',\n isConditionMet: value > threshold,\n };\n case 'greaterOrEqual':\n return {\n conditionText:\n value > threshold\n ? 'Above'\n : value === threshold\n ? 'Equal'\n : undefined,\n isConditionMet: value >= threshold,\n };\n case 'less':\n return {\n conditionText: 'Below',\n isConditionMet: value < threshold,\n };\n case 'lessOrEqual':\n return {\n conditionText:\n value < threshold\n ? 'Below'\n : value === threshold\n ? 'Equal'\n : undefined,\n isConditionMet: value <= threshold,\n };\n case 'equal':\n return {\n conditionText: 'Equal',\n isConditionMet: value === threshold,\n };\n case 'notEqual':\n return {\n conditionText: 'Not equal',\n isConditionMet: value !== threshold,\n };\n default:\n return { conditionText: undefined, isConditionMet: false };\n }\n}\n\n/*\nKeep this, if we want more than one type of the same threshold line\nthis will be useful to use.\n\nexport interface NewRegisteredSeriesOption extends RegisteredSeriesOption {\nthresholdLine: ThresholdLineSeriesOption;\n}\nexport type SeriesOption = Values<NewRegisteredSeriesOption>;\nexport type Series = SeriesOption | SeriesOption[];\n*/\n\nexport function Chart({\n dataset,\n option: userOption,\n xAxis: propXAxis,\n yAxis: propYAxis,\n series: propsSeries,\n style,\n settings = {\n lazyUpdate: false,\n notMerge: true,\n silent: false,\n },\n isLoading,\n isChartZoomDisabled = false,\n legend,\n callbacks,\n}: ChartProps): React.JSX.Element {\n const chartRef = useRef<HTMLDivElement>(null);\n const chartEchartRef = useRef<HTMLDivElement>(null);\n const chartLegendRef = useRef<HTMLDivElement>(null);\n const legendSelectedRef = useRef<Record<string, boolean>>({});\n const legendColorCacheRef = useRef<Map<string, string>>(new Map());\n const [isWaitingForFirstResize, setIsWaitingForFirstResize] = useState(true);\n\n const dataZoomOptions = (userOption as EChartsOption)?.dataZoom;\n const toolboxOptions = (userOption as EChartsOption)?.toolbox;\n\n const hasSliderZoom = Array.isArray(dataZoomOptions)\n ? dataZoomOptions.some((dataZoomOption: DataZoomComponentOption) => {\n return dataZoomOption?.type === 'slider';\n })\n : dataZoomOptions?.type === 'slider';\n\n const { theme } = useNeedleTheme();\n const thresholdLines = useMemo(() => {\n const seriesArray = Array.isArray(propsSeries)\n ? propsSeries\n : [propsSeries];\n\n const thresholdLineSeries = seriesArray.filter((currentSeries) => {\n return currentSeries.type === 'thresholdLine';\n }) as ThresholdLineSeriesOption<NotificationType>[];\n\n return thresholdLineSeries.map((currentThresholdLineSeriesOption) => {\n return {\n ...currentThresholdLineSeriesOption,\n condition:\n currentThresholdLineSeriesOption.condition ??\n defaultThresholdLineSeriesOption.condition,\n value: currentThresholdLineSeriesOption.yAxis,\n };\n });\n }, [propsSeries]);\n\n const dataZoom = useMemo(() => {\n return mergeDataZoom(dataZoomOptions);\n }, [dataZoomOptions]);\n\n const series = mergeSeries(propsSeries, theme, userOption);\n const xAxis = mergeXAxis(propXAxis, theme);\n const yAxis = mergeYAxis(propYAxis, theme);\n\n const hasCategoryXAxis = Array.isArray(xAxis)\n ? xAxis.some((x) => x.type === 'category')\n : xAxis?.type === 'category';\n\n // The initial option used, the charts option is not necessarily\n // the same as this due to mutation via dispatch and setOption.\n // use getOption to get the current option of the chart.\n const initialOption = useMemo(() => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef.current);\n\n const option = {\n dataset,\n xAxis,\n yAxis,\n ...userOption,\n aria: {\n decal: {\n show: false,\n },\n enabled: true,\n ...(userOption?.aria as EChartsOption['aria']),\n },\n grid: {\n left: hasCategoryXAxis ? '15px' : '10px',\n right: hasCategoryXAxis ? '15px' : '10px',\n top: '10px',\n bottom: hasSliderZoom ? '60px' : '10px',\n type: 'solid',\n containLabel: true,\n ...(userOption?.grid as EChartsOption['grid']),\n },\n legend: {\n // Removes in-built echarts legend\n show: false,\n // Preserve legend filter state across re-renders. legendSelectedRef\n // is the single source of truth, written by the Legend component.\n // ECharts mutates the options object, so pass a shallow copy here\n // to avoid it mutating the React ref object.\n selected: { ...(legendSelectedRef.current || {}) },\n },\n series,\n tooltip: {\n trigger: 'axis',\n confine: true,\n // Reset the default tooltip css styling\n padding: 0,\n borderRadius: 0,\n borderWidth: 0,\n extraCssText: 'box-shadow: none; background-color: transparent;',\n formatter: function (params: unknown) {\n const paramsArray = Array.isArray(params) ? params : [params];\n const firstParam = paramsArray[0];\n\n let valueFormatter = (value: unknown) => `${value}`;\n if (\n typeof userOption?.tooltip === 'object' &&\n userOption.tooltip !== null &&\n 'valueFormatter' in userOption.tooltip\n ) {\n valueFormatter = userOption.tooltip.valueFormatter as (\n value: unknown,\n ) => string;\n }\n return `${renderToString(\n <span className=\"ndl-charts-chart-tooltip\">\n <ChartTooltip.Title>\n {firstParam?.axisValueLabel ?? ''}\n </ChartTooltip.Title>\n {paramsArray.map((series) => {\n const { value: seriesValueUnknown } = series;\n\n const seriesValue = Array.isArray(seriesValueUnknown)\n ? seriesValueUnknown[1]\n : seriesValueUnknown;\n\n const isThresholdLine =\n series.seriesName.startsWith('thresholdLine');\n\n const notifications = thresholdLines\n .filter((threshold) => {\n const {\n value: thresholdValue,\n condition,\n customCondition,\n } = threshold;\n\n const isConditionMet = customCondition\n ? customCondition(seriesValue, thresholdValue)\n : checkCondition(seriesValue, condition, thresholdValue)\n .isConditionMet;\n\n return !isThresholdLine && isConditionMet;\n })\n .map((threshold) => {\n const {\n notificationType,\n value: thresholdValue,\n condition,\n customConditionText,\n customCondition,\n } = threshold;\n\n return {\n id: `threshold-${notificationType}`,\n leadingElement: customCondition\n ? customConditionText\n : `${\n checkCondition(\n seriesValue,\n condition,\n thresholdValue,\n ).conditionText\n } threshold`,\n notificationType,\n trailingElement: thresholdValue,\n };\n });\n\n const value = extractValueFromTooltipSeries(\n series.value,\n series.encode,\n series.axisDim,\n );\n\n return (\n <ChartTooltip.Content\n key={series.seriesName}\n leadingElement={\n isThresholdLine\n ? `${capitalizeFirstLetter(\n series.seriesName.replace('thresholdLine-', ''),\n )} threshold`\n : series.seriesName\n }\n trailingElement={valueFormatter(value)}\n indentSquareColor={series.color}\n notifications={notifications}\n />\n );\n })}\n </span>,\n )}`;\n },\n },\n dataZoom,\n toolbox: mergeToolbox(toolboxOptions),\n };\n\n // Update chart with initial option\n chart?.setOption(option, settings);\n // Get option returns the current option of the chart.\n // This is slightly different than the option we gave as an argument.\n // Because we use useMemo in other areas we want to get this set first,\n // this is why we are setting then getting then returning. If we did this in\n // a useEffect it would run after the other useMemos which is not what we want.\n // This is purely for order of operations.\n const chartOption = chart?.getOption();\n\n return chartOption;\n }, [\n dataset,\n xAxis,\n yAxis,\n userOption,\n hasCategoryXAxis,\n hasSliderZoom,\n series,\n dataZoom,\n toolboxOptions,\n thresholdLines,\n settings,\n ]);\n\n useEffect(() => {\n // Initialize chart\n let chart: ECharts | undefined;\n if (chartEchartRef.current !== null) {\n registerTheme('ndl-light', ndlEchartsTheme('light'));\n registerTheme('ndl-dark', ndlEchartsTheme('dark'));\n\n const currentChart = getInstanceByDom(chartEchartRef.current);\n if (currentChart) {\n chart = currentChart;\n } else {\n const echartsTheme = theme === 'light' ? 'ndl-light' : 'ndl-dark';\n chart = init(chartEchartRef.current, echartsTheme, {\n renderer: 'svg',\n });\n }\n }\n\n if (callbacks?.onZoom) {\n chart?.on('datazoom', () => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const currentChart = getInstanceByDom(chartEchartRef.current);\n if (!currentChart) {\n return;\n }\n\n const option = currentChart.getOption();\n if (!option || !option.dataZoom) {\n return;\n }\n\n const dataZoom = Array.isArray(option.dataZoom)\n ? option.dataZoom[0]\n : option.dataZoom;\n const { startValue, endValue } = dataZoom as {\n startValue: number;\n endValue: number;\n };\n\n callbacks?.onZoom?.({ endValue, startValue });\n });\n }\n\n // Add chart resize listener\n // ResizeObserver is leading to a bit janky UX\n function resizeChart() {\n // TODO: We need to revisit this. Right now using grid containLabel seems to work.\n // We still need to visit this for overflowing of the x-axis labels.\n // const calculateGridLeft = () => {\n // const textElements = chartEchartRef.current?.querySelectorAll('text');\n // const filteredTextElements = Array.from(textElements || []).filter(\n // (element) => element.getAttribute('text-anchor') === 'end',\n // );\n // let maxWidth = 0;\n // filteredTextElements.forEach((element) => {\n // const bbox = element.getBBox();\n // maxWidth = Math.max(maxWidth, bbox.width);\n // });\n // const tickLength = 5;\n // const tickPadding = 3;\n // return maxWidth + tickLength + tickPadding;\n // };\n //\n // // Example of dynamically setting the grid's left\n // const gridLeft = calculateGridLeft();\n // chart?.setOption({\n // grid: {\n // left: gridLeft,\n // },\n // });\n\n // We want to fit the chart to the charts container.\n const chartContainerHeight = chartRef.current?.clientHeight;\n const chartContainerWidth = chartRef.current?.clientWidth;\n // Need to take legends height into consideration, otherwise it will overflow the parent.\n const chartLegendHeight = chartLegendRef?.current?.clientHeight || 0;\n const height = chartContainerHeight\n ? chartContainerHeight - chartLegendHeight\n : undefined;\n chart?.resize({\n height,\n width: chartContainerWidth,\n });\n }\n window.addEventListener('resize', resizeChart);\n requestAnimationFrame(() => {\n resizeChart();\n setIsWaitingForFirstResize(false);\n });\n\n // Add chart zoom listeners\n const handleMouseMove = () => {\n // I do not like this at all: https://github.com/apache/echarts/issues/19819\n // echarts updates the svgs on every mouse movement so we need to do this.\n chart?.getZr().setCursorStyle('default');\n };\n // We cannot use chart.getZr().on('mousemove', handleMouseMove)\n // This is because it doesn't respect our callbacks. It will\n // always run echarts code last instead of our callback.\n const chartChild = chartEchartRef.current?.children[0] as HTMLElement;\n if (!isChartZoomDisabled) {\n chartChild.addEventListener('mousemove', handleMouseMove);\n }\n\n const handleMouseDown = (params: { event: MouseEvent }) => {\n const event = params.event;\n const amountOfMouseClicks = event.detail;\n const isDoubleClick = amountOfMouseClicks === 2;\n if (isDoubleClick) {\n // Reset zooming.\n if (chart === undefined) {\n return;\n }\n chart?.dispatchAction({\n end: 100,\n start: 0,\n type: 'dataZoom',\n });\n if (callbacks?.onZoom) {\n callbacks?.onZoom?.({ endValue: 100, startValue: 0 });\n }\n }\n };\n if (!isChartZoomDisabled) {\n chart?.getZr().on('mousedown', handleMouseDown);\n }\n\n // Return cleanup function\n const chartRefCurrentElement = chartEchartRef.current;\n const element = chartRefCurrentElement?.children[0];\n return () => {\n window.removeEventListener('resize', resizeChart);\n\n element?.removeEventListener('mousemove', handleMouseMove);\n\n // Remove chart zoom handlers\n if (chartRefCurrentElement) {\n const chart = getInstanceByDom(chartRefCurrentElement);\n chart?.getZr().off('mousedown', handleMouseDown);\n }\n };\n });\n\n useEffect(() => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef?.current);\n\n if (isLoading === true || isWaitingForFirstResize) {\n chart?.showLoading({\n color: tokens.theme[theme].color.primary.bg.status,\n fontFamily: tokens.typography['label'].fontFamily,\n fontSize: tokens.typography['label'].fontSize,\n fontWeight: tokens.typography['label'].fontWeight,\n maskColor: `rgb( from ${tokens.theme[theme].color.neutral.text.inverse} r g b / 0.8)`,\n text: 'Loading',\n textColor: tokens.theme[theme].color.neutral.text.default,\n });\n } else {\n chart?.hideLoading();\n }\n }, [isLoading, isWaitingForFirstResize, theme]);\n\n const legendSeries = useMemo(() => {\n if (chartEchartRef.current === null || isWaitingForFirstResize) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef?.current);\n const optionSeries = (initialOption?.series as NeedleSeries) ?? [];\n const optionDataset = initialOption?.dataset;\n\n const legendSeries: {\n name: string;\n color: string;\n }[] = [];\n if (Array.isArray(optionSeries)) {\n optionSeries.forEach((currentSeries, index) => {\n if (currentSeries === null) {\n return;\n } else if (\n currentSeries.type === 'line' &&\n typeof currentSeries.name === 'string' &&\n currentSeries.name?.includes('thresholdLine')\n ) {\n return;\n } else if (currentSeries.type === 'pie') {\n const encodedItemName = currentSeries.encode?.itemName;\n let currentDataset = Array.isArray(optionDataset)\n ? optionDataset[0]\n : optionDataset;\n if (currentSeries.datasetId && Array.isArray(optionDataset)) {\n currentDataset = optionDataset.find(\n (ds) => ds.id === currentSeries.datasetId,\n );\n } else if (currentSeries.datasetIndex !== undefined) {\n currentDataset = Array.isArray(optionDataset)\n ? optionDataset[currentSeries.datasetIndex]\n : optionDataset;\n }\n const firstDatasetRow = Array.isArray(currentDataset?.source)\n ? currentDataset?.source[0]\n : undefined;\n if (!firstDatasetRow) {\n return;\n }\n\n if (Array.isArray(firstDatasetRow)) {\n const firstDatasetRowIndex = firstDatasetRow.findIndex(\n (item) => item === encodedItemName,\n );\n\n if (firstDatasetRowIndex === -1) {\n return;\n }\n\n const source = currentDataset?.source;\n if (!source) {\n return;\n }\n\n const sourceLength = Array.isArray(source) ? source.length : 0;\n const selected = legendSelectedRef.current;\n const isAllVisible = Object.values(selected).every((v) => v);\n\n for (let rowIndex = 1; rowIndex < sourceLength; rowIndex++) {\n const row = source[rowIndex] as (string | number)[];\n const name = String(row[firstDatasetRowIndex]);\n const freshColor = chart?.getVisual(\n { dataIndexInside: rowIndex - 1, seriesIndex: index },\n 'color',\n );\n\n // Only trust getVisual colors when all items are visible.\n // When items are deselected, getVisual returns grayed-out\n // colors, so we use the cached color from when it was visible.\n if (isAllVisible && typeof freshColor === 'string') {\n legendColorCacheRef.current.set(name, freshColor);\n }\n\n const color =\n legendColorCacheRef.current.get(name) ??\n (typeof freshColor === 'string' ? freshColor : '#000000');\n\n legendSeries.push({ color, name });\n }\n } else {\n // TODO: handle dictionary\n }\n\n return;\n } else {\n const name = Array.isArray(optionSeries)\n ? optionSeries[index]?.name\n : undefined;\n\n if (name === undefined) {\n return null;\n }\n\n const color = chart?.getVisual({ seriesIndex: index }, 'color');\n legendSeries.push({\n color: typeof color === 'string' ? color : '#000000',\n name: String(name),\n });\n }\n });\n }\n return legendSeries.filter((currentSeries) => currentSeries !== null);\n }, [isWaitingForFirstResize, initialOption]);\n\n if (chartEchartRef.current !== null && !isChartZoomDisabled) {\n const chart = getInstanceByDom(chartEchartRef.current);\n if (chart) {\n // Needs to be re-set on every re-render.\n // Sets the selectable zoom area over the chart (not the slider).\n chart.dispatchAction({\n dataZoomSelectActive: true,\n key: 'dataZoomSelect',\n type: 'takeGlobalCursor',\n });\n }\n }\n\n return (\n <div ref={chartRef} className=\"ndl-chart\" style={style}>\n <div ref={chartEchartRef} />\n {legend?.show && !isWaitingForFirstResize && (\n <Legend\n ref={chartLegendRef}\n wrappingType={legend.wrappingType}\n series={legendSeries ?? []}\n chartRef={chartEchartRef}\n selectedRef={legendSelectedRef}\n />\n )}\n </div>\n );\n}\n"]}
@@ -55,8 +55,16 @@ const LegendItem = function LegendItemComponent(_a) {
55
55
  }, children: selected === true && (_jsx(CheckIconOutline, { className: "ndl-chart-legend-item-square-checkmark" })) }), _jsx(Typography, { variant: "body-medium", className: "ndl-chart-legend-item-text", children: children })] })));
56
56
  };
57
57
  export const Legend = function LegendComponent(_a) {
58
- var { className, wrappingType = 'wrapping', series, chartRef, ref, htmlAttributes } = _a, restProps = __rest(_a, ["className", "wrappingType", "series", "chartRef", "ref", "htmlAttributes"]);
59
- const [selectedSeries, setSelectedSeries] = useState(Object.fromEntries(series.map((s) => { var _a; return [(_a = s.name) !== null && _a !== void 0 ? _a : '', true]; })));
58
+ var { className, wrappingType = 'wrapping', series, chartRef, selectedRef, ref, htmlAttributes } = _a, restProps = __rest(_a, ["className", "wrappingType", "series", "chartRef", "selectedRef", "ref", "htmlAttributes"]);
59
+ const initialSelected = Object.fromEntries(series.map((s) => { var _a; return [(_a = s.name) !== null && _a !== void 0 ? _a : '', true]; }));
60
+ const [selectedSeries, setSelectedSeries] = useState(initialSelected);
61
+ // Keep the shared ref in sync so Chart can read the latest selection state
62
+ // when building setOption. This is the single source of truth for legend filters.
63
+ useEffect(() => {
64
+ if (selectedRef) {
65
+ selectedRef.current = selectedSeries;
66
+ }
67
+ }, [selectedRef, selectedSeries]);
60
68
  const highlightTimeOut = useRef(null);
61
69
  const downplayTimeOut = useRef(null);
62
70
  const hoverTimeOut = 80;
@@ -81,7 +89,16 @@ export const Legend = function LegendComponent(_a) {
81
89
  }, hoverTimeOut);
82
90
  };
83
91
  useEffect(() => {
84
- setSelectedSeries(Object.fromEntries(series.map((s) => { var _a; return [(_a = s.name) !== null && _a !== void 0 ? _a : '', true]; })));
92
+ var _a, _b, _c;
93
+ // Preserve existing legend selection state across re-renders.
94
+ // Only new series default to visible (true); removed series are dropped.
95
+ const prev = (_a = selectedRef === null || selectedRef === void 0 ? void 0 : selectedRef.current) !== null && _a !== void 0 ? _a : {};
96
+ const next = {};
97
+ for (const s of series) {
98
+ const name = (_b = s.name) !== null && _b !== void 0 ? _b : '';
99
+ next[name] = (_c = prev[name]) !== null && _c !== void 0 ? _c : true;
100
+ }
101
+ setSelectedSeries(next);
85
102
  if (chartRef.current === null) {
86
103
  return;
87
104
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Legend.js","sourceRoot":"","sources":["../../../src/charts/Legend.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EACL,eAAe,EACf,OAAO,EACP,UAAU,EACV,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAoB,g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AClD,kBAAkB,CAAC,KAAK,CACtB,CAAC,IAAI,EAAE,EAAE,WAAC,OAAA,cAAc,CAAC,MAAA,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAA,EAAA,CAC1C,CAAC;gCAEJ,IAAI,0BAA0B,EAAE,CAAC;oCAC/B,eAAe,EAAE,CAAC;oCAClB,OAAO;gCACT,CAAC;gCAED,kBAAkB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;oCACzC,MAAM,mBAAmB,GACvB,oBAAoB,KAAK,MAAM,CAAC,MAAM,IAAI,KAAK,KAAK,CAAC,CAAC;oCAExD,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CACtB,IAAI,CAAC,IAAI,EACT,mBAAmB,EACnB,KAAK,EACL,MAAM,CACP,CAAC;gCACJ,CAAC,CAAC,CAAC;4BACL,CAAC,aAEA,kBAAkB,CAAC,MAAM,aACf,GACG,EAClB,KAAC,OAAO,CAAC,OAAO,cACb,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAChC,sBAAoB,IAAI,CAAC,IAAI,IAArB,IAAI,CAAC,IAAI,CAAiB,CACnC,CAAC,GACc,IACV,CACX,IACG,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { tokens } from '@neo4j-ndl/base';\nimport {\n ConditionalWrap,\n Tooltip,\n Typography,\n useResizeObserver,\n} from '@neo4j-ndl/react';\nimport { CheckIconOutline } from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { type EChartsType, getInstanceByDom } from 'echarts';\nimport type React from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport {\n type LegendItemProps,\n type LegendOverflowProps,\n type LegendProps,\n} from './chart-types';\nimport {\n getComputedElementWidth,\n highlightOrDownplaySeries,\n isThresholdLine,\n resetAllSeriesHighlight,\n useLegendVisibility,\n} from './legend-utils';\nimport { type CommonProps } from './types';\n\nconst LegendItem = function LegendItemComponent({\n children,\n as,\n className,\n name,\n selected,\n deSelected,\n onLegendItemClick,\n color,\n hasButtons = true,\n ref,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n ...restProps\n}: LegendItemProps) {\n const Component = as ?? (hasButtons ? 'button' : 'div');\n\n const classes = classNames(\n 'ndl-chart-legend-item',\n {\n 'ndl-chart-legend-item-deselected': deSelected,\n 'ndl-chart-legend-item-selected': selected,\n },\n className,\n );\n\n // We don't want to display threshold lines in the legend\n if (isThresholdLine(name) ?? false) {\n return null;\n }\n\n return (\n <Component\n className={classes}\n ref={ref}\n data-labelname={name}\n title={name}\n onClick={hasButtons ? onLegendItemClick : undefined}\n onMouseEnter={onLegendItemMouseEnter}\n onMouseLeave={onLegendItemMouseLeave}\n {...restProps}\n >\n <span\n className=\"ndl-chart-legend-item-square\"\n style={\n {\n '--ndl-chart-legend-item-color': color,\n backgroundColor: deSelected === true ? 'transparent' : color,\n } as React.CSSProperties\n }\n >\n {selected === true && (\n <CheckIconOutline className=\"ndl-chart-legend-item-square-checkmark\" />\n )}\n </span>\n <Typography variant=\"body-medium\" className=\"ndl-chart-legend-item-text\">\n {children}\n </Typography>\n </Component>\n );\n};\n\nexport const Legend = function LegendComponent({\n className,\n wrappingType = 'wrapping',\n series,\n chartRef,\n ref,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', LegendProps>) {\n const [selectedSeries, setSelectedSeries] = useState<Record<string, boolean>>(\n Object.fromEntries(series.map((s) => [s.name ?? '', true])),\n );\n\n const highlightTimeOut = useRef<ReturnType<typeof setTimeout> | null>(null);\n const downplayTimeOut = useRef<ReturnType<typeof setTimeout> | null>(null);\n const hoverTimeOut = 80;\n\n const highlightSeries = (\n seriesToUpdate: { name: string; color: string }[],\n ) => {\n // Clear the downplay timeout when a new item is hovered\n if (downplayTimeOut.current) {\n clearTimeout(downplayTimeOut.current);\n }\n\n // Delay the highlight to avoid flickering when quickly hovering the legend items\n highlightTimeOut.current = setTimeout(() => {\n highlightOrDownplaySeries(\n chartRef,\n series,\n selectedSeries,\n seriesToUpdate,\n 'highlight',\n );\n }, hoverTimeOut);\n };\n\n const downplaySeries = (\n seriesToUpdate: { name: string; color: string }[],\n ) => {\n // Clear the highlight timeout when the mouse is leaving the legend item\n if (highlightTimeOut.current) {\n clearTimeout(highlightTimeOut.current);\n }\n\n // Delay the downplay to avoid flickering when moving the highlight between legend items (no downplay needed in between)\n downplayTimeOut.current = setTimeout(() => {\n highlightOrDownplaySeries(\n chartRef,\n series,\n selectedSeries,\n seriesToUpdate,\n 'downplay',\n );\n }, hoverTimeOut);\n };\n\n useEffect(() => {\n setSelectedSeries(\n Object.fromEntries(series.map((s) => [s.name ?? '', true])),\n );\n\n if (chartRef.current === null) {\n return;\n }\n const chart = getInstanceByDom(chartRef.current);\n\n const eventTypes = [\n 'legendselectchanged',\n 'legendselectall',\n 'legendselected',\n 'legendunselected',\n ] as const;\n\n eventTypes.forEach((eventType) => {\n chart?.on(eventType, (params) => {\n if (\n typeof params === 'object' &&\n params !== null &&\n 'selected' in params &&\n params.selected !== null\n ) {\n const selected = params.selected ?? {};\n const filteredSelected = Object.fromEntries(\n Object.entries(selected).filter(\n ([key]) => !(isThresholdLine(key) ?? false),\n ),\n );\n\n // Reset the series highlight to avoid series to stay blurred on selection change\n if (eventType === 'legendselectchanged') {\n resetAllSeriesHighlight(chart as EChartsType);\n }\n\n setSelectedSeries(filteredSelected);\n }\n });\n });\n\n return () => {\n eventTypes.forEach((eventType) => {\n chart?.off(eventType);\n });\n };\n }, [chartRef, series]);\n\n const classes = classNames(\n `ndl-chart-legend`,\n {\n 'ndl-chart-legend-truncation': wrappingType === 'truncation',\n 'ndl-chart-legend-wrapping': wrappingType === 'wrapping',\n },\n className,\n );\n\n const { toggleLegendVisibility, setAllVisible } = useLegendVisibility(\n chartRef,\n selectedSeries,\n );\n\n return (\n <div\n ref={ref}\n className=\"ndl-chart-legend-container\"\n {...restProps}\n {...htmlAttributes}\n >\n {wrappingType === 'truncation' || wrappingType === 'wrapping' ? (\n <div className={classes}>\n {series.map((currentSeries, index) => {\n const hasMoreThanOneItem = series.length > 1;\n\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n\n const color = currentSeries.color;\n\n const isDeselected =\n currentSeries.name === undefined\n ? false\n : !selectedSeries[currentSeries.name];\n\n return (\n <ConditionalWrap\n key={index}\n shouldWrap={wrappingType === 'truncation'}\n wrap={(children) => (\n <Tooltip type=\"simple\" key={index}>\n <Tooltip.Trigger hasButtonWrapper>\n {children}\n </Tooltip.Trigger>\n </Tooltip>\n )}\n >\n <LegendItem\n name={currentSeries.name}\n color={color}\n hasButtons={\n hasMoreThanOneItem && currentSeries.name !== undefined\n }\n onLegendItemMouseEnter={() => {\n !isDeselected && highlightSeries([currentSeries]);\n }}\n onLegendItemMouseLeave={() => {\n !isDeselected && downplaySeries([currentSeries]);\n }}\n onLegendItemClick={() => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length;\n\n const isOnlyVisible =\n selectedSeries[currentSeries.name ?? ''] &&\n selectedSeriesLength === 1;\n\n toggleLegendVisibility(\n currentSeries.name,\n isAllSeriesSelected,\n isOnlyVisible,\n );\n }}\n selected={\n !isAllSeriesVisible &&\n selectedSeries[currentSeries.name ?? '']\n }\n deSelected={isDeselected}\n >\n {currentSeries.name ?? `Series ${index}`}\n </LegendItem>\n </ConditionalWrap>\n );\n })}\n </div>\n ) : (\n <LegendOverflowType\n className={classes}\n selectedSeries={selectedSeries}\n wrappingType={wrappingType}\n chartRef={chartRef}\n series={series}\n onSetAllVisible={setAllVisible}\n onLegendItemMouseEnter={(seriesToUpdate) =>\n highlightSeries(seriesToUpdate)\n }\n onLegendItemMouseLeave={(seriesToUpdate) =>\n downplaySeries(seriesToUpdate)\n }\n onToggleLegendVisibility={(\n name,\n isAllSeriesSelected,\n isOnlyVisible,\n ) => {\n toggleLegendVisibility(name, isAllSeriesSelected, isOnlyVisible);\n }}\n />\n )}\n </div>\n );\n};\n\nconst LegendOverflowType = function LegendOverflow({\n className,\n series,\n onSetAllVisible,\n onToggleLegendVisibility,\n selectedSeries,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n}: LegendOverflowProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n const [nonOverflowItemsNames, setNonOverflowItemsNames] = useState<string[]>(\n series.map((s) => s.name),\n );\n\n useEffect(() => {\n setNonOverflowItemsNames(series.map((s) => s.name));\n }, [series]);\n\n const overflowItemsNames = series.filter(\n (item) => !nonOverflowItemsNames.includes(item.name),\n );\n\n const [width, setWidth] = useState(Infinity);\n useResizeObserver({\n // TODO: remove type cast. use-hooks.ts 3.1.1 has a type issue with the ref, it should be HTMLElement | null\n // https://github.com/juliencrn/usehooks-ts/pull/680\n onResize: (entry) => {\n if (entry.width === undefined) {\n return;\n }\n if (width < entry.width) {\n setNonOverflowItemsNames(series.map((s) => s.name));\n }\n setWidth(entry.width);\n },\n ref: containerRef as React.RefObject<HTMLElement>,\n });\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return;\n }\n\n let elements = Array.from(container.children);\n if (elements.length === 0 || series.length === 0) {\n return;\n }\n\n let totalWidth = 0;\n\n if (overflowItemsNames.length > 0) {\n const lastElementItem = elements[elements.length - 1];\n const lastItemWidth = getComputedElementWidth(lastElementItem);\n\n elements = elements.slice(0, elements.length - 1);\n totalWidth += lastItemWidth;\n }\n\n elements.forEach((element) => {\n const elementWidth = getComputedElementWidth(element);\n totalWidth += elementWidth;\n const textContent = element.textContent;\n if (!textContent) {\n return;\n }\n const itemName = element.getAttribute('data-labelname');\n if (itemName === null) {\n return;\n }\n if (totalWidth > width) {\n setNonOverflowItemsNames((oldNames) =>\n oldNames.filter((name) => name !== itemName),\n );\n }\n });\n }, [overflowItemsNames.length, series.length, width]);\n\n const classes = classNames(\n {\n 'ndl-chart-legend-calculating': width === Infinity,\n },\n className,\n );\n\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const hasMoreThanOneItem = nonOverflowItemsNames.length > 1;\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n\n const isOverflowItemsDeselected = overflowItemsNames.every(\n (item) => !selectedSeries[item.name ?? ''],\n );\n\n return (\n <div className={classes} ref={containerRef}>\n {nonOverflowItemsNames.map((name) => {\n const currentSeries = series.find((s) => s.name === name);\n if (currentSeries === undefined) {\n return null;\n }\n\n const isDeselected =\n currentSeries.name === undefined\n ? false\n : !selectedSeries[currentSeries.name];\n\n return (\n <LegendItem\n key={name}\n name={name}\n color={currentSeries.color}\n onLegendItemMouseEnter={() =>\n !isDeselected && onLegendItemMouseEnter([currentSeries])\n }\n onLegendItemMouseLeave={() =>\n !isDeselected && onLegendItemMouseLeave([currentSeries])\n }\n onLegendItemClick={() => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length;\n\n const isOnlyVisible =\n selectedSeries[name ?? ''] && selectedSeriesLength === 1;\n\n onToggleLegendVisibility?.(\n name,\n isAllSeriesSelected,\n isOnlyVisible,\n series,\n );\n }}\n hasButtons={hasMoreThanOneItem}\n selected={\n !isAllSeriesVisible && selectedSeries[currentSeries.name ?? '']\n }\n deSelected={isDeselected}\n >\n {name}\n </LegendItem>\n );\n })}\n\n {overflowItemsNames.length > 0 && (\n <Tooltip type=\"simple\">\n <Tooltip.Trigger hasButtonWrapper>\n <LegendItem\n name=\"ndl-overflow-items\"\n color={tokens.palette.neutral[30]}\n selected={\n !isAllSeriesVisible &&\n overflowItemsNames.every(\n (item) => selectedSeries[item.name ?? ''],\n )\n }\n deSelected={isOverflowItemsDeselected}\n onLegendItemMouseEnter={() =>\n !isOverflowItemsDeselected &&\n onLegendItemMouseEnter(overflowItemsNames)\n }\n onLegendItemMouseLeave={() =>\n !isOverflowItemsDeselected &&\n onLegendItemMouseLeave(overflowItemsNames)\n }\n onLegendItemClick={() => {\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const isOnlyOverflowItemsVisible =\n selectedSeriesLength === overflowItemsNames.length &&\n overflowItemsNames.every(\n (item) => selectedSeries[item.name ?? ''],\n );\n\n if (isOnlyOverflowItemsVisible) {\n onSetAllVisible();\n return;\n }\n\n overflowItemsNames.forEach((item, index) => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length && index === 0;\n\n onToggleLegendVisibility?.(\n item.name,\n isAllSeriesSelected,\n false,\n series,\n );\n });\n }}\n >\n {overflowItemsNames.length} more\n </LegendItem>\n </Tooltip.Trigger>\n <Tooltip.Content>\n {overflowItemsNames.map((item) => (\n <p key={item.name}>{item.name}</p>\n ))}\n </Tooltip.Content>\n </Tooltip>\n )}\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"Legend.js","sourceRoot":"","sources":["../../../src/charts/Legend.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EACL,eAAe,EACf,OAAO,EACP,UAAU,EACV,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,E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4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { tokens } from '@neo4j-ndl/base';\nimport {\n ConditionalWrap,\n Tooltip,\n Typography,\n useResizeObserver,\n} from '@neo4j-ndl/react';\nimport { CheckIconOutline } from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { type EChartsType, getInstanceByDom } from 'echarts';\nimport type React from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport {\n type LegendItemProps,\n type LegendOverflowProps,\n type LegendProps,\n} from './chart-types';\nimport {\n getComputedElementWidth,\n highlightOrDownplaySeries,\n isThresholdLine,\n resetAllSeriesHighlight,\n useLegendVisibility,\n} from './legend-utils';\nimport { type CommonProps } from './types';\n\nconst LegendItem = function LegendItemComponent({\n children,\n as,\n className,\n name,\n selected,\n deSelected,\n onLegendItemClick,\n color,\n hasButtons = true,\n ref,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n ...restProps\n}: LegendItemProps) {\n const Component = as ?? (hasButtons ? 'button' : 'div');\n\n const classes = classNames(\n 'ndl-chart-legend-item',\n {\n 'ndl-chart-legend-item-deselected': deSelected,\n 'ndl-chart-legend-item-selected': selected,\n },\n className,\n );\n\n // We don't want to display threshold lines in the legend\n if (isThresholdLine(name) ?? false) {\n return null;\n }\n\n return (\n <Component\n className={classes}\n ref={ref}\n data-labelname={name}\n title={name}\n onClick={hasButtons ? onLegendItemClick : undefined}\n onMouseEnter={onLegendItemMouseEnter}\n onMouseLeave={onLegendItemMouseLeave}\n {...restProps}\n >\n <span\n className=\"ndl-chart-legend-item-square\"\n style={\n {\n '--ndl-chart-legend-item-color': color,\n backgroundColor: deSelected === true ? 'transparent' : color,\n } as React.CSSProperties\n }\n >\n {selected === true && (\n <CheckIconOutline className=\"ndl-chart-legend-item-square-checkmark\" />\n )}\n </span>\n <Typography variant=\"body-medium\" className=\"ndl-chart-legend-item-text\">\n {children}\n </Typography>\n </Component>\n );\n};\n\nexport const Legend = function LegendComponent({\n className,\n wrappingType = 'wrapping',\n series,\n chartRef,\n selectedRef,\n ref,\n htmlAttributes,\n ...restProps\n}: CommonProps<'div', LegendProps>) {\n const initialSelected = Object.fromEntries(\n series.map((s) => [s.name ?? '', true]),\n );\n const [selectedSeries, setSelectedSeries] =\n useState<Record<string, boolean>>(initialSelected);\n\n // Keep the shared ref in sync so Chart can read the latest selection state\n // when building setOption. This is the single source of truth for legend filters.\n useEffect(() => {\n if (selectedRef) {\n selectedRef.current = selectedSeries;\n }\n }, [selectedRef, selectedSeries]);\n\n const highlightTimeOut = useRef<ReturnType<typeof setTimeout> | null>(null);\n const downplayTimeOut = useRef<ReturnType<typeof setTimeout> | null>(null);\n const hoverTimeOut = 80;\n\n const highlightSeries = (\n seriesToUpdate: { name: string; color: string }[],\n ) => {\n // Clear the downplay timeout when a new item is hovered\n if (downplayTimeOut.current) {\n clearTimeout(downplayTimeOut.current);\n }\n\n // Delay the highlight to avoid flickering when quickly hovering the legend items\n highlightTimeOut.current = setTimeout(() => {\n highlightOrDownplaySeries(\n chartRef,\n series,\n selectedSeries,\n seriesToUpdate,\n 'highlight',\n );\n }, hoverTimeOut);\n };\n\n const downplaySeries = (\n seriesToUpdate: { name: string; color: string }[],\n ) => {\n // Clear the highlight timeout when the mouse is leaving the legend item\n if (highlightTimeOut.current) {\n clearTimeout(highlightTimeOut.current);\n }\n\n // Delay the downplay to avoid flickering when moving the highlight between legend items (no downplay needed in between)\n downplayTimeOut.current = setTimeout(() => {\n highlightOrDownplaySeries(\n chartRef,\n series,\n selectedSeries,\n seriesToUpdate,\n 'downplay',\n );\n }, hoverTimeOut);\n };\n\n useEffect(() => {\n // Preserve existing legend selection state across re-renders.\n // Only new series default to visible (true); removed series are dropped.\n const prev = selectedRef?.current ?? {};\n const next: Record<string, boolean> = {};\n for (const s of series) {\n const name = s.name ?? '';\n next[name] = prev[name] ?? true;\n }\n setSelectedSeries(next);\n\n if (chartRef.current === null) {\n return;\n }\n const chart = getInstanceByDom(chartRef.current);\n\n const eventTypes = [\n 'legendselectchanged',\n 'legendselectall',\n 'legendselected',\n 'legendunselected',\n ] as const;\n\n eventTypes.forEach((eventType) => {\n chart?.on(eventType, (params) => {\n if (\n typeof params === 'object' &&\n params !== null &&\n 'selected' in params &&\n params.selected !== null\n ) {\n const selected = params.selected ?? {};\n const filteredSelected = Object.fromEntries(\n Object.entries(selected).filter(\n ([key]) => !(isThresholdLine(key) ?? false),\n ),\n );\n\n // Reset the series highlight to avoid series to stay blurred on selection change\n if (eventType === 'legendselectchanged') {\n resetAllSeriesHighlight(chart as EChartsType);\n }\n\n setSelectedSeries(filteredSelected);\n }\n });\n });\n\n return () => {\n eventTypes.forEach((eventType) => {\n chart?.off(eventType);\n });\n };\n }, [chartRef, series]);\n\n const classes = classNames(\n `ndl-chart-legend`,\n {\n 'ndl-chart-legend-truncation': wrappingType === 'truncation',\n 'ndl-chart-legend-wrapping': wrappingType === 'wrapping',\n },\n className,\n );\n\n const { toggleLegendVisibility, setAllVisible } = useLegendVisibility(\n chartRef,\n selectedSeries,\n );\n\n return (\n <div\n ref={ref}\n className=\"ndl-chart-legend-container\"\n {...restProps}\n {...htmlAttributes}\n >\n {wrappingType === 'truncation' || wrappingType === 'wrapping' ? (\n <div className={classes}>\n {series.map((currentSeries, index) => {\n const hasMoreThanOneItem = series.length > 1;\n\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n\n const color = currentSeries.color;\n\n const isDeselected =\n currentSeries.name === undefined\n ? false\n : !selectedSeries[currentSeries.name];\n\n return (\n <ConditionalWrap\n key={index}\n shouldWrap={wrappingType === 'truncation'}\n wrap={(children) => (\n <Tooltip type=\"simple\" key={index}>\n <Tooltip.Trigger hasButtonWrapper>\n {children}\n </Tooltip.Trigger>\n </Tooltip>\n )}\n >\n <LegendItem\n name={currentSeries.name}\n color={color}\n hasButtons={\n hasMoreThanOneItem && currentSeries.name !== undefined\n }\n onLegendItemMouseEnter={() => {\n !isDeselected && highlightSeries([currentSeries]);\n }}\n onLegendItemMouseLeave={() => {\n !isDeselected && downplaySeries([currentSeries]);\n }}\n onLegendItemClick={() => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length;\n\n const isOnlyVisible =\n selectedSeries[currentSeries.name ?? ''] &&\n selectedSeriesLength === 1;\n\n toggleLegendVisibility(\n currentSeries.name,\n isAllSeriesSelected,\n isOnlyVisible,\n );\n }}\n selected={\n !isAllSeriesVisible &&\n selectedSeries[currentSeries.name ?? '']\n }\n deSelected={isDeselected}\n >\n {currentSeries.name ?? `Series ${index}`}\n </LegendItem>\n </ConditionalWrap>\n );\n })}\n </div>\n ) : (\n <LegendOverflowType\n className={classes}\n selectedSeries={selectedSeries}\n wrappingType={wrappingType}\n chartRef={chartRef}\n series={series}\n onSetAllVisible={setAllVisible}\n onLegendItemMouseEnter={(seriesToUpdate) =>\n highlightSeries(seriesToUpdate)\n }\n onLegendItemMouseLeave={(seriesToUpdate) =>\n downplaySeries(seriesToUpdate)\n }\n onToggleLegendVisibility={(\n name,\n isAllSeriesSelected,\n isOnlyVisible,\n ) => {\n toggleLegendVisibility(name, isAllSeriesSelected, isOnlyVisible);\n }}\n />\n )}\n </div>\n );\n};\n\nconst LegendOverflowType = function LegendOverflow({\n className,\n series,\n onSetAllVisible,\n onToggleLegendVisibility,\n selectedSeries,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n}: LegendOverflowProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n const [nonOverflowItemsNames, setNonOverflowItemsNames] = useState<string[]>(\n series.map((s) => s.name),\n );\n\n useEffect(() => {\n setNonOverflowItemsNames(series.map((s) => s.name));\n }, [series]);\n\n const overflowItemsNames = series.filter(\n (item) => !nonOverflowItemsNames.includes(item.name),\n );\n\n const [width, setWidth] = useState(Infinity);\n useResizeObserver({\n // TODO: remove type cast. use-hooks.ts 3.1.1 has a type issue with the ref, it should be HTMLElement | null\n // https://github.com/juliencrn/usehooks-ts/pull/680\n onResize: (entry) => {\n if (entry.width === undefined) {\n return;\n }\n if (width < entry.width) {\n setNonOverflowItemsNames(series.map((s) => s.name));\n }\n setWidth(entry.width);\n },\n ref: containerRef as React.RefObject<HTMLElement>,\n });\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return;\n }\n\n let elements = Array.from(container.children);\n if (elements.length === 0 || series.length === 0) {\n return;\n }\n\n let totalWidth = 0;\n\n if (overflowItemsNames.length > 0) {\n const lastElementItem = elements[elements.length - 1];\n const lastItemWidth = getComputedElementWidth(lastElementItem);\n\n elements = elements.slice(0, elements.length - 1);\n totalWidth += lastItemWidth;\n }\n\n elements.forEach((element) => {\n const elementWidth = getComputedElementWidth(element);\n totalWidth += elementWidth;\n const textContent = element.textContent;\n if (!textContent) {\n return;\n }\n const itemName = element.getAttribute('data-labelname');\n if (itemName === null) {\n return;\n }\n if (totalWidth > width) {\n setNonOverflowItemsNames((oldNames) =>\n oldNames.filter((name) => name !== itemName),\n );\n }\n });\n }, [overflowItemsNames.length, series.length, width]);\n\n const classes = classNames(\n {\n 'ndl-chart-legend-calculating': width === Infinity,\n },\n className,\n );\n\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const hasMoreThanOneItem = nonOverflowItemsNames.length > 1;\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n\n const isOverflowItemsDeselected = overflowItemsNames.every(\n (item) => !selectedSeries[item.name ?? ''],\n );\n\n return (\n <div className={classes} ref={containerRef}>\n {nonOverflowItemsNames.map((name) => {\n const currentSeries = series.find((s) => s.name === name);\n if (currentSeries === undefined) {\n return null;\n }\n\n const isDeselected =\n currentSeries.name === undefined\n ? false\n : !selectedSeries[currentSeries.name];\n\n return (\n <LegendItem\n key={name}\n name={name}\n color={currentSeries.color}\n onLegendItemMouseEnter={() =>\n !isDeselected && onLegendItemMouseEnter([currentSeries])\n }\n onLegendItemMouseLeave={() =>\n !isDeselected && onLegendItemMouseLeave([currentSeries])\n }\n onLegendItemClick={() => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length;\n\n const isOnlyVisible =\n selectedSeries[name ?? ''] && selectedSeriesLength === 1;\n\n onToggleLegendVisibility?.(\n name,\n isAllSeriesSelected,\n isOnlyVisible,\n series,\n );\n }}\n hasButtons={hasMoreThanOneItem}\n selected={\n !isAllSeriesVisible && selectedSeries[currentSeries.name ?? '']\n }\n deSelected={isDeselected}\n >\n {name}\n </LegendItem>\n );\n })}\n\n {overflowItemsNames.length > 0 && (\n <Tooltip type=\"simple\">\n <Tooltip.Trigger hasButtonWrapper>\n <LegendItem\n name=\"ndl-overflow-items\"\n color={tokens.palette.neutral[30]}\n selected={\n !isAllSeriesVisible &&\n overflowItemsNames.every(\n (item) => selectedSeries[item.name ?? ''],\n )\n }\n deSelected={isOverflowItemsDeselected}\n onLegendItemMouseEnter={() =>\n !isOverflowItemsDeselected &&\n onLegendItemMouseEnter(overflowItemsNames)\n }\n onLegendItemMouseLeave={() =>\n !isOverflowItemsDeselected &&\n onLegendItemMouseLeave(overflowItemsNames)\n }\n onLegendItemClick={() => {\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const isOnlyOverflowItemsVisible =\n selectedSeriesLength === overflowItemsNames.length &&\n overflowItemsNames.every(\n (item) => selectedSeries[item.name ?? ''],\n );\n\n if (isOnlyOverflowItemsVisible) {\n onSetAllVisible();\n return;\n }\n\n overflowItemsNames.forEach((item, index) => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length && index === 0;\n\n onToggleLegendVisibility?.(\n item.name,\n isAllSeriesSelected,\n false,\n series,\n );\n });\n }}\n >\n {overflowItemsNames.length} more\n </LegendItem>\n </Tooltip.Trigger>\n <Tooltip.Content>\n {overflowItemsNames.map((item) => (\n <p key={item.name}>{item.name}</p>\n ))}\n </Tooltip.Content>\n </Tooltip>\n )}\n </div>\n );\n};\n"]}