@neo4j-ndl/react-charts 1.2.11 → 1.2.13

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.
Files changed (59) hide show
  1. package/lib/cjs/charts/LegendLayout.js +1 -1
  2. package/lib/cjs/charts/LegendLayout.js.map +1 -1
  3. package/lib/cjs/charts/hooks/use-legend-interactions.js +4 -4
  4. package/lib/cjs/charts/hooks/use-legend-interactions.js.map +1 -1
  5. package/lib/cjs/charts/hooks/use-legend-series.js +1 -1
  6. package/lib/cjs/charts/hooks/use-legend-series.js.map +1 -1
  7. package/lib/cjs/charts/hooks/use-legend-visibility.js +1 -1
  8. package/lib/cjs/charts/hooks/use-legend-visibility.js.map +1 -1
  9. package/lib/cjs/charts/tests/ChartZoomHarness.js +3 -1
  10. package/lib/cjs/charts/tests/ChartZoomHarness.js.map +1 -1
  11. package/lib/cjs/charts/tests/PieChartWithRerender.js +1 -1
  12. package/lib/cjs/charts/tests/PieChartWithRerender.js.map +1 -1
  13. package/lib/cjs/charts/tests/chart-test-utils.js +19 -8
  14. package/lib/cjs/charts/tests/chart-test-utils.js.map +1 -1
  15. package/lib/cjs/charts/utils/aria-description.js +7 -7
  16. package/lib/cjs/charts/utils/aria-description.js.map +1 -1
  17. package/lib/cjs/charts/utils/build-chart-option.js +1 -1
  18. package/lib/cjs/charts/utils/build-chart-option.js.map +1 -1
  19. package/lib/cjs/charts/utils/chart-types.js.map +1 -1
  20. package/lib/cjs/charts/utils/format-utils.js.map +1 -1
  21. package/lib/cjs/charts/utils/legend-utils.js +2 -2
  22. package/lib/cjs/charts/utils/legend-utils.js.map +1 -1
  23. package/lib/cjs/charts/utils/user-option-utils.js +2 -2
  24. package/lib/cjs/charts/utils/user-option-utils.js.map +1 -1
  25. package/lib/esm/charts/LegendLayout.js +1 -1
  26. package/lib/esm/charts/LegendLayout.js.map +1 -1
  27. package/lib/esm/charts/hooks/use-legend-interactions.js +4 -4
  28. package/lib/esm/charts/hooks/use-legend-interactions.js.map +1 -1
  29. package/lib/esm/charts/hooks/use-legend-series.js +1 -1
  30. package/lib/esm/charts/hooks/use-legend-series.js.map +1 -1
  31. package/lib/esm/charts/hooks/use-legend-visibility.js +1 -1
  32. package/lib/esm/charts/hooks/use-legend-visibility.js.map +1 -1
  33. package/lib/esm/charts/tests/ChartZoomHarness.js +3 -1
  34. package/lib/esm/charts/tests/ChartZoomHarness.js.map +1 -1
  35. package/lib/esm/charts/tests/PieChartWithRerender.js +1 -1
  36. package/lib/esm/charts/tests/PieChartWithRerender.js.map +1 -1
  37. package/lib/esm/charts/tests/chart-test-utils.js +19 -8
  38. package/lib/esm/charts/tests/chart-test-utils.js.map +1 -1
  39. package/lib/esm/charts/utils/aria-description.js +7 -7
  40. package/lib/esm/charts/utils/aria-description.js.map +1 -1
  41. package/lib/esm/charts/utils/build-chart-option.js +1 -1
  42. package/lib/esm/charts/utils/build-chart-option.js.map +1 -1
  43. package/lib/esm/charts/utils/chart-types.js.map +1 -1
  44. package/lib/esm/charts/utils/format-utils.js.map +1 -1
  45. package/lib/esm/charts/utils/legend-utils.js +2 -2
  46. package/lib/esm/charts/utils/legend-utils.js.map +1 -1
  47. package/lib/esm/charts/utils/user-option-utils.js +2 -2
  48. package/lib/esm/charts/utils/user-option-utils.js.map +1 -1
  49. package/lib/types/charts/hooks/use-legend-visibility.d.ts.map +1 -1
  50. package/lib/types/charts/tests/ChartZoomHarness.d.ts.map +1 -1
  51. package/lib/types/charts/tests/chart-test-utils.d.ts.map +1 -1
  52. package/lib/types/charts/utils/aria-description.d.ts.map +1 -1
  53. package/lib/types/charts/utils/chart-types.d.ts.map +1 -1
  54. package/lib/types/charts/utils/format-utils.d.ts.map +1 -1
  55. package/lib/types/charts/utils/user-option-utils.d.ts.map +1 -1
  56. package/package.json +3 -3
  57. package/skills/ndl-react-charts/SKILL.md +31 -0
  58. package/skills/ndl-react-charts/components/charts.md +91 -22
  59. package/skills/ndl-react-charts/references/styling.md +142 -0
@@ -35,7 +35,7 @@ import { ChartWrapperWithTooltipFormatter } from './ChartWrapperWithTooltipForma
35
35
  /**
36
36
  * Convert hex color to rgb format
37
37
  *
38
- * @param hex color in hex code format
38
+ * @param hex - Color in hex code format
39
39
  * @returns color in rgb format rgb(_, _, _)
40
40
  */
41
41
  const convertHexToRGB = (hex) => {
@@ -47,9 +47,6 @@ const convertHexToRGB = (hex) => {
47
47
  };
48
48
  export const chartColorsAfterHighlighting = {
49
49
  1: 'rgb(93,207,216)',
50
- 10: 'rgb(210,126,49)',
51
- 11: 'rgb(78,151,121)',
52
- 12: 'rgb(190,255,117)',
53
50
  2: 'rgb(84,80,223)',
54
51
  3: 'rgb(242,152,62)',
55
52
  4: 'rgb(221,75,155)',
@@ -58,6 +55,9 @@ export const chartColorsAfterHighlighting = {
58
55
  7: 'rgb(69,140,249)',
59
56
  8: 'rgb(113,69,188)',
60
57
  9: 'rgb(240,210,70)',
58
+ 10: 'rgb(210,126,49)',
59
+ 11: 'rgb(78,151,121)',
60
+ 12: 'rgb(190,255,117)',
61
61
  };
62
62
  export const pieChartProps = (seriesName, value, rgbSeriesColor) => ({
63
63
  dataset: [
@@ -96,10 +96,9 @@ export const barChartProps = (seriesName, value, rgbSeriesColor) => ({
96
96
  },
97
97
  series: [
98
98
  {
99
- encode: {
100
- x: 'Country',
101
- y: 'Sales',
102
- },
99
+ // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode
100
+ // oxlint-disable-next-line id-length
101
+ encode: { x: 'Country', y: 'Sales' },
103
102
  itemStyle: {
104
103
  color: rgbSeriesColor,
105
104
  },
@@ -131,31 +130,43 @@ export const multiSeriesChartProps = {
131
130
  option: {},
132
131
  series: [
133
132
  {
133
+ // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode
134
+ // oxlint-disable-next-line id-length
134
135
  encode: { x: 'day', y: 'first' },
135
136
  name: 'First Series',
136
137
  type: 'line',
137
138
  },
138
139
  {
140
+ // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode
141
+ // oxlint-disable-next-line id-length
139
142
  encode: { x: 'day', y: 'second' },
140
143
  name: 'Second Series',
141
144
  type: 'line',
142
145
  },
143
146
  {
147
+ // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode
148
+ // oxlint-disable-next-line id-length
144
149
  encode: { x: 'day', y: 'third' },
145
150
  name: 'Third Series',
146
151
  type: 'line',
147
152
  },
148
153
  {
154
+ // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode
155
+ // oxlint-disable-next-line id-length
149
156
  encode: { x: 'day', y: 'fourth' },
150
157
  name: 'Fourth Series',
151
158
  type: 'line',
152
159
  },
153
160
  {
161
+ // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode
162
+ // oxlint-disable-next-line id-length
154
163
  encode: { x: 'day', y: 'fifth' },
155
164
  name: 'Fifth Series',
156
165
  type: 'line',
157
166
  },
158
167
  {
168
+ // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode
169
+ // oxlint-disable-next-line id-length
159
170
  encode: { x: 'day', y: 'sixth' },
160
171
  name: 'Sixth Series',
161
172
  type: 'line',
@@ -1 +1 @@
1
- {"version":3,"file":"chart-test-utils.js","sourceRoot":"","sources":["../../../../src/charts/tests/chart-test-utils.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAI3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAEtF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,EAAE;IACtC,MAAM,aAAa,GAAG,GAAG,CAAC,OAAO,CAAC,I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,CAAC,CAAA,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAU,EAAE,QAAgB,EAAE,EAAE;IAClE,OAAO,IAAI;SACR,OAAO,CAAC,QAAQ,CAAC;SACjB,QAAQ,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","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 const normalizedHex = hex.replace(/^#/, '');\n\n const red = parseInt(normalizedHex.substring(0, 2), 16);\n const green = parseInt(normalizedHex.substring(2, 4), 16);\n const blue = parseInt(normalizedHex.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 center: ['50%', '50%'],\n encode: {\n itemName: 'product',\n value: '2012',\n },\n itemStyle: {\n color: rgbSeriesColor,\n },\n radius: '90%',\n type: 'pie' as const,\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 itemStyle: {\n color: rgbSeriesColor,\n },\n name: seriesName,\n type: 'bar' as const,\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 },\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 barChart = ({\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 <Chart\n {...barChartProps(seriesName, value, rgbSeriesColor)}\n {...chartProps}\n />\n </div>\n);\n\nexport const expectChartElementVisible = async (page: Page) => {\n await expect(page.locator('svg').first()).toBeVisible();\n await expect(page.locator('.ndl-chart-legend')).toBeVisible();\n};\n\nexport const startLegendMeasuringObserver = async (\n page: Page,\n options: { chartLayoutSelector?: string } = {},\n) => {\n await page.evaluate(({ chartLayoutSelector }) => {\n const windowWithLegendObserver = window as Window & {\n __chartHeightDuringLegendMeasurement?: number;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n __legendMeasuringClassWasAdded?: boolean;\n __legendMeasuringObserver?: MutationObserver;\n };\n const legendElement = document.querySelector('.ndl-chart-legend');\n const chartLayout = chartLayoutSelector\n ? document.querySelector(chartLayoutSelector)\n : undefined;\n\n windowWithLegendObserver.__chartHeightDuringLegendMeasurement = undefined;\n windowWithLegendObserver.__legendMeasuringClassWasAdded = false;\n windowWithLegendObserver.__legendMeasuringObserver?.disconnect();\n\n if (!legendElement) {\n return;\n }\n\n const observer = new MutationObserver(() => {\n if (!legendElement.classList.contains('ndl-chart-legend-calculating')) {\n return;\n }\n\n windowWithLegendObserver.__legendMeasuringClassWasAdded = true;\n\n if (\n chartLayout &&\n windowWithLegendObserver.__chartHeightDuringLegendMeasurement ===\n undefined\n ) {\n windowWithLegendObserver.__chartHeightDuringLegendMeasurement =\n chartLayout.getBoundingClientRect().height;\n }\n });\n\n observer.observe(legendElement, {\n attributeFilter: ['class'],\n attributes: true,\n });\n windowWithLegendObserver.__legendMeasuringObserver = observer;\n }, options);\n};\n\nexport const getLegendMeasuringObserverResult = async (page: Page) =>\n page.evaluate(() => {\n const windowWithLegendObserver = window as Window & {\n __chartHeightDuringLegendMeasurement?: number;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n __legendMeasuringClassWasAdded?: boolean;\n __legendMeasuringObserver?: MutationObserver;\n };\n\n windowWithLegendObserver.__legendMeasuringObserver?.disconnect();\n\n return {\n chartHeightDuringMeasurement:\n windowWithLegendObserver.__chartHeightDuringLegendMeasurement,\n didAddMeasuringClass:\n windowWithLegendObserver.__legendMeasuringClassWasAdded ?? false,\n };\n });\n\nconst SELECTORS = {\n CHECKMARK:\n '.ndl-chart-legend > .ndl-chart-legend-item .ndl-chart-legend-item-square-checkmark',\n DESELECTED: '.ndl-chart-legend > .ndl-chart-legend-item-deselected',\n seriesCheckmark: (name: string) =>\n `.ndl-chart-legend > [data-labelname=\"${name}\"] .ndl-chart-legend-item-square-checkmark`,\n seriesDeselected: (name: string) =>\n `.ndl-chart-legend > [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\n * component-owned legend state. ECharts rewrites generated SVG paths during\n * legend updates, which makes exact path color selectors flaky in Firefox.\n */\nexport const expectLegendSeriesToBeVisibleInChart = async (\n page: Page,\n seriesNamesToBeVisible: string[],\n) => {\n await expect(page.locator('svg path').first()).toBeAttached();\n\n for (const name of seriesNamesToBeVisible) {\n const visibleLegendItem = page.locator(\n `.ndl-chart-legend > [data-labelname=\"${name}\"]`,\n );\n\n if ((await visibleLegendItem.count()) > 0) {\n await expect(visibleLegendItem).not.toHaveClass(\n /ndl-chart-legend-item-deselected/,\n );\n }\n }\n\n const hiddenSeries = multiSeriesChartProps.series.filter(\n (series) => !seriesNamesToBeVisible.includes(series.name),\n );\n\n for (const hiddenSeriesItem of hiddenSeries) {\n const hiddenLegendItem = page.locator(\n SELECTORS.seriesDeselected(hiddenSeriesItem.name),\n );\n\n if ((await hiddenLegendItem.count()) > 0) {\n await expect(hiddenLegendItem).toBeVisible();\n }\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\n .locator(`.ndl-chart-legend > [data-labelname=\"${seriesName}\"]`)\n .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 expectDefaultFormattedTooltipToBeVisible = async (\n page: Page,\n seriesName: string,\n value: number,\n rgbSeriesColor: string,\n) => {\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n\n const chartElement = page\n .locator(`path[fill=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[fill=\"${rgbWithSpaces}\"]`));\n\n await expect(chartElement).toBeVisible();\n await chartElement.hover();\n\n const tooltip = page.locator('.ndl-charts-chart-tooltip');\n await expect(tooltip).toContainText(seriesName);\n await expect(tooltip).toContainText(\n new Intl.NumberFormat('en-US').format(value),\n );\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"]}
1
+ {"version":3,"file":"chart-test-utils.js","sourceRoot":"","sources":["../../../../src/charts/tests/chart-test-utils.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAI3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAEtF;;;;;GAKG;AACH,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,EAAE;IACtC,MAAM,aAAa,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAE5C,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEzD,OAAO,OAAO,GAAG,KAAK,KAAK,KAAK,IAAI,GAAG,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAA2B;IAClE,CAAC,EAAE,iBAAiB;IACpB,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;IACpB,EAAE,EAAE,iBAAiB;IAC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AwC,GAAG,CACtD,IAAU,EACV,UAAkB,EAClB,KAAa,EACb,cAAsB,EACtB,EAAE;IACF,MAAM,aAAa,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEzD,MAAM,YAAY,GAAG,IAAI;SACtB,OAAO,CAAC,cAAc,cAAc,IAAI,CAAC;SACzC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,aAAa,IAAI,CAAC,CAAC,CAAC;IAErD,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;IACzC,MAAM,YAAY,CAAC,KAAK,EAAE,CAAC;IAE3B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC1D,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,CACjC,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAC7C,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAU,EAAE,QAAgB,EAAE,EAAE;IAClE,OAAO,IAAI;SACR,OAAO,CAAC,QAAQ,CAAC;SACjB,QAAQ,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","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 const normalizedHex = hex.replace(/^#/, '');\n\n const red = parseInt(normalizedHex.substring(0, 2), 16);\n const green = parseInt(normalizedHex.substring(2, 4), 16);\n const blue = parseInt(normalizedHex.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 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 10: 'rgb(210,126,49)',\n 11: 'rgb(78,151,121)',\n 12: 'rgb(190,255,117)',\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 center: ['50%', '50%'],\n encode: {\n itemName: 'product',\n value: '2012',\n },\n itemStyle: {\n color: rgbSeriesColor,\n },\n radius: '90%',\n type: 'pie' as const,\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 // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode\n // oxlint-disable-next-line id-length\n encode: { x: 'Country', y: 'Sales' },\n itemStyle: {\n color: rgbSeriesColor,\n },\n name: seriesName,\n type: 'bar' as const,\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 },\n option: {},\n series: [\n {\n // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode\n // oxlint-disable-next-line id-length\n encode: { x: 'day', y: 'first' },\n name: 'First Series',\n type: 'line' as const,\n },\n {\n // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode\n // oxlint-disable-next-line id-length\n encode: { x: 'day', y: 'second' },\n name: 'Second Series',\n type: 'line' as const,\n },\n {\n // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode\n // oxlint-disable-next-line id-length\n encode: { x: 'day', y: 'third' },\n name: 'Third Series',\n type: 'line' as const,\n },\n {\n // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode\n // oxlint-disable-next-line id-length\n encode: { x: 'day', y: 'fourth' },\n name: 'Fourth Series',\n type: 'line' as const,\n },\n {\n // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode\n // oxlint-disable-next-line id-length\n encode: { x: 'day', y: 'fifth' },\n name: 'Fifth Series',\n type: 'line' as const,\n },\n {\n // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode\n // oxlint-disable-next-line id-length\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 barChart = ({\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 <Chart\n {...barChartProps(seriesName, value, rgbSeriesColor)}\n {...chartProps}\n />\n </div>\n);\n\nexport const expectChartElementVisible = async (page: Page) => {\n await expect(page.locator('svg').first()).toBeVisible();\n await expect(page.locator('.ndl-chart-legend')).toBeVisible();\n};\n\nexport const startLegendMeasuringObserver = async (\n page: Page,\n options: { chartLayoutSelector?: string } = {},\n) => {\n await page.evaluate(({ chartLayoutSelector }) => {\n const windowWithLegendObserver = window as Window & {\n __chartHeightDuringLegendMeasurement?: number;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n __legendMeasuringClassWasAdded?: boolean;\n __legendMeasuringObserver?: MutationObserver;\n };\n const legendElement = document.querySelector('.ndl-chart-legend');\n const chartLayout = chartLayoutSelector\n ? document.querySelector(chartLayoutSelector)\n : undefined;\n\n windowWithLegendObserver.__chartHeightDuringLegendMeasurement = undefined;\n windowWithLegendObserver.__legendMeasuringClassWasAdded = false;\n windowWithLegendObserver.__legendMeasuringObserver?.disconnect();\n\n if (!legendElement) {\n return;\n }\n\n const observer = new MutationObserver(() => {\n if (!legendElement.classList.contains('ndl-chart-legend-calculating')) {\n return;\n }\n\n windowWithLegendObserver.__legendMeasuringClassWasAdded = true;\n\n if (\n chartLayout &&\n windowWithLegendObserver.__chartHeightDuringLegendMeasurement ===\n undefined\n ) {\n windowWithLegendObserver.__chartHeightDuringLegendMeasurement =\n chartLayout.getBoundingClientRect().height;\n }\n });\n\n observer.observe(legendElement, {\n attributeFilter: ['class'],\n attributes: true,\n });\n windowWithLegendObserver.__legendMeasuringObserver = observer;\n }, options);\n};\n\nexport const getLegendMeasuringObserverResult = async (page: Page) =>\n page.evaluate(() => {\n const windowWithLegendObserver = window as Window & {\n __chartHeightDuringLegendMeasurement?: number;\n // eslint-disable-next-line @typescript-eslint/naming-convention\n __legendMeasuringClassWasAdded?: boolean;\n __legendMeasuringObserver?: MutationObserver;\n };\n\n windowWithLegendObserver.__legendMeasuringObserver?.disconnect();\n\n return {\n chartHeightDuringMeasurement:\n windowWithLegendObserver.__chartHeightDuringLegendMeasurement,\n didAddMeasuringClass:\n windowWithLegendObserver.__legendMeasuringClassWasAdded ?? false,\n };\n });\n\nconst SELECTORS = {\n CHECKMARK:\n '.ndl-chart-legend > .ndl-chart-legend-item .ndl-chart-legend-item-square-checkmark',\n DESELECTED: '.ndl-chart-legend > .ndl-chart-legend-item-deselected',\n seriesCheckmark: (name: string) =>\n `.ndl-chart-legend > [data-labelname=\"${name}\"] .ndl-chart-legend-item-square-checkmark`,\n seriesDeselected: (name: string) =>\n `.ndl-chart-legend > [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\n * component-owned legend state. ECharts rewrites generated SVG paths during\n * legend updates, which makes exact path color selectors flaky in Firefox.\n */\nexport const expectLegendSeriesToBeVisibleInChart = async (\n page: Page,\n seriesNamesToBeVisible: string[],\n) => {\n await expect(page.locator('svg path').first()).toBeAttached();\n\n for (const name of seriesNamesToBeVisible) {\n const visibleLegendItem = page.locator(\n `.ndl-chart-legend > [data-labelname=\"${name}\"]`,\n );\n\n if ((await visibleLegendItem.count()) > 0) {\n await expect(visibleLegendItem).not.toHaveClass(\n /ndl-chart-legend-item-deselected/,\n );\n }\n }\n\n const hiddenSeries = multiSeriesChartProps.series.filter(\n (series) => !seriesNamesToBeVisible.includes(series.name),\n );\n\n for (const hiddenSeriesItem of hiddenSeries) {\n const hiddenLegendItem = page.locator(\n SELECTORS.seriesDeselected(hiddenSeriesItem.name),\n );\n\n if ((await hiddenLegendItem.count()) > 0) {\n await expect(hiddenLegendItem).toBeVisible();\n }\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\n .locator(`.ndl-chart-legend > [data-labelname=\"${seriesName}\"]`)\n .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 expectDefaultFormattedTooltipToBeVisible = async (\n page: Page,\n seriesName: string,\n value: number,\n rgbSeriesColor: string,\n) => {\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n\n const chartElement = page\n .locator(`path[fill=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[fill=\"${rgbWithSpaces}\"]`));\n\n await expect(chartElement).toBeVisible();\n await chartElement.hover();\n\n const tooltip = page.locator('.ndl-charts-chart-tooltip');\n await expect(tooltip).toContainText(seriesName);\n await expect(tooltip).toContainText(\n new Intl.NumberFormat('en-US').format(value),\n );\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"]}
@@ -49,9 +49,9 @@ function extractInlineValues(data, encode) {
49
49
  values.push(val);
50
50
  }
51
51
  else if (Array.isArray(val)) {
52
- const v = val[yIndex];
53
- if (typeof v === 'number' && !isNaN(v)) {
54
- values.push(v);
52
+ const yValue = val[yIndex];
53
+ if (typeof yValue === 'number' && !isNaN(yValue)) {
54
+ values.push(yValue);
55
55
  }
56
56
  }
57
57
  }
@@ -84,7 +84,7 @@ function extractDatasetValues(dataset, series) {
84
84
  let columnNames;
85
85
  let dataStartIndex;
86
86
  if (Array.isArray(dimensions) && dimensions.length > 0) {
87
- columnNames = dimensions.map((d) => (typeof d === 'string' ? d : d.name));
87
+ columnNames = dimensions.map((dimension) => typeof dimension === 'string' ? dimension : dimension.name);
88
88
  dataStartIndex = 0;
89
89
  }
90
90
  else {
@@ -112,8 +112,8 @@ function extractDatasetValues(dataset, series) {
112
112
  return [];
113
113
  }
114
114
  const values = [];
115
- for (let i = dataStartIndex; i < source.length; i++) {
116
- const row = source[i];
115
+ for (let rowIndex = dataStartIndex; rowIndex < source.length; rowIndex++) {
116
+ const row = source[rowIndex];
117
117
  if (!Array.isArray(row)) {
118
118
  continue;
119
119
  }
@@ -216,7 +216,7 @@ export function generateThresholdAriaDescription(propsSeries, dataset) {
216
216
  if (threshold.hasCustomCondition) {
217
217
  continue;
218
218
  }
219
- const violatingValues = values.filter((v) => evaluateThresholdCondition(v, threshold.condition, threshold.yAxisValue).isConditionMet);
219
+ const violatingValues = values.filter((value) => evaluateThresholdCondition(value, threshold.condition, threshold.yAxisValue).isConditionMet);
220
220
  if (violatingValues.length > 0) {
221
221
  const count = violatingValues.length;
222
222
  parts.push(`${name} has ${count} ${pluralize(count, 'value')} ${thresholdConditionToText(threshold.condition)} the ${threshold.notificationType} threshold of ${threshold.yAxisValue}.`);
@@ -1 +1 @@
1
- {"version":3,"file":"aria-description.js","sourceRoot":"","sources":["../../../../src/charts/utils/aria-description.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAUH,O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/**\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 type { EChartsOption, SeriesOption } from 'echarts';\n\nimport type {\n Condition,\n NeedleSeries,\n NotificationType,\n ThresholdLineSeriesOption,\n} from './chart-types';\nimport { defaultThresholdLineSeriesOption } from './defaults';\nimport {\n evaluateThresholdCondition,\n thresholdConditionToText,\n} from './threshold';\n\ninterface ResolvedDataSeries {\n name: string;\n type: string;\n values: number[];\n}\n\ninterface ResolvedThreshold {\n notificationType: NotificationType;\n yAxisValue: number;\n condition: Condition;\n hasCustomCondition: boolean;\n customConditionText?: string;\n}\n\n/**\n * Extract numeric y-values from inline series data.\n * Handles formats: [x, y], [x, y, ...], or single number.\n */\nfunction extractInlineValues(\n data: SeriesOption['data'],\n encode?: { x?: string | number; y?: string | number },\n): number[] {\n if (!Array.isArray(data)) {\n return [];\n }\n\n const yIndex =\n encode?.y !== undefined && typeof encode.y === 'number' ? encode.y : 1;\n\n const values: number[] = [];\n for (const point of data) {\n if (point === null || point === undefined) {\n continue;\n }\n if (Array.isArray(point)) {\n const val = point[yIndex];\n if (typeof val === 'number' && !isNaN(val)) {\n values.push(val);\n }\n } else if (typeof point === 'number' && !isNaN(point)) {\n values.push(point);\n } else if (typeof point === 'object' && 'value' in point) {\n const val = point.value;\n if (typeof val === 'number' && !isNaN(val)) {\n values.push(val);\n } else if (Array.isArray(val)) {\n const v = val[yIndex];\n if (typeof v === 'number' && !isNaN(v)) {\n values.push(v);\n }\n }\n }\n }\n return values;\n}\n\n/**\n * Extract numeric y-values from a dataset source for a given series.\n */\nfunction extractDatasetValues(\n dataset: EChartsOption['dataset'],\n series: SeriesOption,\n): number[] {\n if (!dataset) {\n return [];\n }\n\n const datasets = Array.isArray(dataset) ? dataset : [dataset];\n const datasetIndex =\n 'datasetIndex' in series && typeof series.datasetIndex === 'number'\n ? series.datasetIndex\n : 0;\n const currentDataset = datasets[datasetIndex];\n\n if (!currentDataset || !Array.isArray(currentDataset.source)) {\n return [];\n }\n\n const source = currentDataset.source as (string | number)[][];\n if (source.length < 1) {\n return [];\n }\n\n // Determine column names and data start index.\n // When `dimensions` is provided, column names come from there and all\n // rows in `source` are data. Otherwise the first row is a header.\n const dimensions = currentDataset.dimensions as\n | (string | { name: string })[]\n | undefined;\n let columnNames: (string | number)[];\n let dataStartIndex: number;\n\n if (Array.isArray(dimensions) && dimensions.length > 0) {\n columnNames = dimensions.map((d) => (typeof d === 'string' ? d : d.name));\n dataStartIndex = 0;\n } else {\n const headerRow = source[0];\n if (!Array.isArray(headerRow) || source.length < 2) {\n return [];\n }\n columnNames = headerRow;\n dataStartIndex = 1;\n }\n\n // Determine which column contains the y-values\n const encode =\n 'encode' in series ? (series.encode as Record<string, unknown>) : undefined;\n let yColumnIndex = -1;\n\n if (encode?.y !== undefined) {\n if (typeof encode.y === 'number') {\n yColumnIndex = encode.y;\n } else if (typeof encode.y === 'string') {\n yColumnIndex = columnNames.indexOf(encode.y);\n }\n }\n\n if (yColumnIndex === -1) {\n // Avoid guessing a data column for aria descriptions.\n // If we cannot resolve a value column explicitly, return no values.\n return [];\n }\n\n const values: number[] = [];\n for (let i = dataStartIndex; i < source.length; i++) {\n const row = source[i];\n if (!Array.isArray(row)) {\n continue;\n }\n const val = row[yColumnIndex];\n if (typeof val === 'number' && !isNaN(val)) {\n values.push(val);\n }\n }\n\n return values;\n}\n\nfunction pluralize(count: number, singular: string, plural?: string): string {\n return count === 1 ? singular : (plural ?? `${singular}s`);\n}\n\n/**\n * Resolves y-values for a series from either inline data or a dataset.\n */\nfunction resolveSeriesValues(\n series: SeriesOption,\n dataset: EChartsOption['dataset'],\n): number[] {\n if ('data' in series && series.data) {\n const encode =\n 'encode' in series\n ? (series.encode as Record<string, unknown> | undefined)\n : undefined;\n return extractInlineValues(series.data, encode);\n }\n return extractDatasetValues(dataset, series);\n}\n\n/**\n * Generates a human-readable aria-label description for the chart\n * that includes meaningful threshold context and data relationships.\n */\nexport function generateThresholdAriaDescription(\n propsSeries: NeedleSeries,\n dataset: EChartsOption['dataset'],\n): string | undefined {\n const seriesArray = Array.isArray(propsSeries) ? propsSeries : [propsSeries];\n\n // Separate threshold lines from data series\n const thresholds: ResolvedThreshold[] = [];\n const dataSeries: ResolvedDataSeries[] = [];\n\n for (const series of seriesArray) {\n if (series.type === 'thresholdLine') {\n const threshold = series as ThresholdLineSeriesOption<NotificationType>;\n thresholds.push({\n condition:\n threshold.condition ?? defaultThresholdLineSeriesOption.condition,\n customConditionText: threshold.customConditionText,\n hasCustomCondition: typeof threshold.customCondition === 'function',\n notificationType: threshold.notificationType,\n yAxisValue: threshold.yAxis,\n });\n } else {\n const echartsSeriesOption = series as SeriesOption;\n const name =\n typeof echartsSeriesOption.name === 'string'\n ? echartsSeriesOption.name\n : `Series ${dataSeries.length + 1}`;\n\n const values = resolveSeriesValues(echartsSeriesOption, dataset);\n\n dataSeries.push({\n name,\n type: echartsSeriesOption.type ?? 'line',\n values,\n });\n }\n }\n\n if (thresholds.length === 0) {\n return undefined;\n }\n\n const parts: string[] = [];\n\n // 1. Overview\n const dataSeriesCountText =\n dataSeries.length === 1\n ? '1 data series'\n : `${dataSeries.length} data series`;\n const thresholdCountText =\n thresholds.length === 1\n ? '1 threshold line'\n : `${thresholds.length} threshold lines`;\n parts.push(\n `This chart has ${dataSeriesCountText} and ${thresholdCountText}.`,\n );\n\n // 2. Describe each data series\n for (const series of dataSeries) {\n const { name, type, values } = series;\n if (values.length > 0) {\n const min = Math.min(...values);\n const max = Math.max(...values);\n parts.push(\n `${name} is a ${type} chart with ${values.length} ${pluralize(values.length, 'data point')} ranging from ${min} to ${max}.`,\n );\n } else {\n parts.push(`${name} is a ${type} chart with no resolved data.`);\n }\n }\n\n // 3. Describe threshold lines\n for (const threshold of thresholds) {\n const conditionText = threshold.hasCustomCondition\n ? (threshold.customConditionText ?? 'custom condition')\n : thresholdConditionToText(threshold.condition);\n\n parts.push(\n `${threshold.notificationType === 'warning' ? 'Warning' : 'Danger'} threshold at ${threshold.yAxisValue}: triggers when values are ${conditionText} ${threshold.yAxisValue}.`,\n );\n }\n\n // 4. Report threshold violations per data series\n for (const series of dataSeries) {\n const { name, values } = series;\n if (values.length === 0) {\n continue;\n }\n\n for (const threshold of thresholds) {\n // Custom conditions use runtime callbacks that we cannot evaluate\n // at description-generation time, so we skip violation reporting.\n if (threshold.hasCustomCondition) {\n continue;\n }\n\n const violatingValues = values.filter(\n (v) =>\n evaluateThresholdCondition(\n v,\n threshold.condition,\n threshold.yAxisValue,\n ).isConditionMet,\n );\n\n if (violatingValues.length > 0) {\n const count = violatingValues.length;\n parts.push(\n `${name} has ${count} ${pluralize(count, 'value')} ${thresholdConditionToText(threshold.condition)} the ${threshold.notificationType} threshold of ${threshold.yAxisValue}.`,\n );\n }\n }\n }\n\n return parts.join(' ');\n}\n"]}
1
+ {"version":3,"file":"aria-description.js","sourceRoot":"","sources":["../../../../src/charts/utils/aria-description.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAUH,OAAO,EAAE,gCAAgC,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAgBrB;;;GAGG;AACH,SAAS,mBAAmB,CAC1B,IAA0B,EAC1B,MAMC;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,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AAiD;IACjD,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QAChC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,SAAS;QACX,CAAC;QAED,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,kEAAkE;YAClE,kEAAkE;YAClE,IAAI,SAAS,CAAC,kBAAkB,EAAE,CAAC;gBACjC,SAAS;YACX,CAAC;YAED,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CACnC,CAAC,KAAK,EAAE,EAAE,CACR,0BAA0B,CACxB,KAAK,EACL,SAAS,CAAC,SAAS,EACnB,SAAS,CAAC,UAAU,CACrB,CAAC,cAAc,CACnB,CAAC;YAEF,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/B,MAAM,KAAK,GAAG,eAAe,CAAC,MAAM,CAAC;gBACrC,KAAK,CAAC,IAAI,CACR,GAAG,IAAI,QAAQ,KAAK,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,wBAAwB,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,SAAS,CAAC,gBAAgB,iBAAiB,SAAS,CAAC,UAAU,GAAG,CAC7K,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,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 type { EChartsOption, SeriesOption } from 'echarts';\n\nimport type {\n Condition,\n NeedleSeries,\n NotificationType,\n ThresholdLineSeriesOption,\n} from './chart-types';\nimport { defaultThresholdLineSeriesOption } from './defaults';\nimport {\n evaluateThresholdCondition,\n thresholdConditionToText,\n} from './threshold';\n\ninterface ResolvedDataSeries {\n name: string;\n type: string;\n values: number[];\n}\n\ninterface ResolvedThreshold {\n notificationType: NotificationType;\n yAxisValue: number;\n condition: Condition;\n hasCustomCondition: boolean;\n customConditionText?: string;\n}\n\n/**\n * Extract numeric y-values from inline series data.\n * Handles formats: [x, y], [x, y, ...], or single number.\n */\nfunction extractInlineValues(\n data: SeriesOption['data'],\n encode?: {\n // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode\n // oxlint-disable-next-line id-length\n x?: string | number;\n // oxlint-disable-next-line id-length\n y?: string | number;\n },\n): number[] {\n if (!Array.isArray(data)) {\n return [];\n }\n\n const yIndex =\n encode?.y !== undefined && typeof encode.y === 'number' ? encode.y : 1;\n\n const values: number[] = [];\n for (const point of data) {\n if (point === null || point === undefined) {\n continue;\n }\n if (Array.isArray(point)) {\n const val = point[yIndex];\n if (typeof val === 'number' && !isNaN(val)) {\n values.push(val);\n }\n } else if (typeof point === 'number' && !isNaN(point)) {\n values.push(point);\n } else if (typeof point === 'object' && 'value' in point) {\n const val = point.value;\n if (typeof val === 'number' && !isNaN(val)) {\n values.push(val);\n } else if (Array.isArray(val)) {\n const yValue = val[yIndex];\n if (typeof yValue === 'number' && !isNaN(yValue)) {\n values.push(yValue);\n }\n }\n }\n }\n return values;\n}\n\n/**\n * Extract numeric y-values from a dataset source for a given series.\n */\nfunction extractDatasetValues(\n dataset: EChartsOption['dataset'],\n series: SeriesOption,\n): number[] {\n if (!dataset) {\n return [];\n }\n\n const datasets = Array.isArray(dataset) ? dataset : [dataset];\n const datasetIndex =\n 'datasetIndex' in series && typeof series.datasetIndex === 'number'\n ? series.datasetIndex\n : 0;\n const currentDataset = datasets[datasetIndex];\n\n if (!currentDataset || !Array.isArray(currentDataset.source)) {\n return [];\n }\n\n const source = currentDataset.source as (string | number)[][];\n if (source.length < 1) {\n return [];\n }\n\n // Determine column names and data start index.\n // When `dimensions` is provided, column names come from there and all\n // rows in `source` are data. Otherwise the first row is a header.\n const dimensions = currentDataset.dimensions as\n | (string | { name: string })[]\n | undefined;\n let columnNames: (string | number)[];\n let dataStartIndex: number;\n\n if (Array.isArray(dimensions) && dimensions.length > 0) {\n columnNames = dimensions.map((dimension) =>\n typeof dimension === 'string' ? dimension : dimension.name,\n );\n dataStartIndex = 0;\n } else {\n const headerRow = source[0];\n if (!Array.isArray(headerRow) || source.length < 2) {\n return [];\n }\n columnNames = headerRow;\n dataStartIndex = 1;\n }\n\n // Determine which column contains the y-values\n const encode =\n 'encode' in series ? (series.encode as Record<string, unknown>) : undefined;\n let yColumnIndex = -1;\n\n if (encode?.y !== undefined) {\n if (typeof encode.y === 'number') {\n yColumnIndex = encode.y;\n } else if (typeof encode.y === 'string') {\n yColumnIndex = columnNames.indexOf(encode.y);\n }\n }\n\n if (yColumnIndex === -1) {\n // Avoid guessing a data column for aria descriptions.\n // If we cannot resolve a value column explicitly, return no values.\n return [];\n }\n\n const values: number[] = [];\n for (let rowIndex = dataStartIndex; rowIndex < source.length; rowIndex++) {\n const row = source[rowIndex];\n if (!Array.isArray(row)) {\n continue;\n }\n const val = row[yColumnIndex];\n if (typeof val === 'number' && !isNaN(val)) {\n values.push(val);\n }\n }\n\n return values;\n}\n\nfunction pluralize(count: number, singular: string, plural?: string): string {\n return count === 1 ? singular : (plural ?? `${singular}s`);\n}\n\n/**\n * Resolves y-values for a series from either inline data or a dataset.\n */\nfunction resolveSeriesValues(\n series: SeriesOption,\n dataset: EChartsOption['dataset'],\n): number[] {\n if ('data' in series && series.data) {\n const encode =\n 'encode' in series\n ? (series.encode as Record<string, unknown> | undefined)\n : undefined;\n return extractInlineValues(series.data, encode);\n }\n return extractDatasetValues(dataset, series);\n}\n\n/**\n * Generates a human-readable aria-label description for the chart\n * that includes meaningful threshold context and data relationships.\n */\nexport function generateThresholdAriaDescription(\n propsSeries: NeedleSeries,\n dataset: EChartsOption['dataset'],\n): string | undefined {\n const seriesArray = Array.isArray(propsSeries) ? propsSeries : [propsSeries];\n\n // Separate threshold lines from data series\n const thresholds: ResolvedThreshold[] = [];\n const dataSeries: ResolvedDataSeries[] = [];\n\n for (const series of seriesArray) {\n if (series.type === 'thresholdLine') {\n const threshold = series as ThresholdLineSeriesOption<NotificationType>;\n thresholds.push({\n condition:\n threshold.condition ?? defaultThresholdLineSeriesOption.condition,\n customConditionText: threshold.customConditionText,\n hasCustomCondition: typeof threshold.customCondition === 'function',\n notificationType: threshold.notificationType,\n yAxisValue: threshold.yAxis,\n });\n } else {\n const echartsSeriesOption = series as SeriesOption;\n const name =\n typeof echartsSeriesOption.name === 'string'\n ? echartsSeriesOption.name\n : `Series ${dataSeries.length + 1}`;\n\n const values = resolveSeriesValues(echartsSeriesOption, dataset);\n\n dataSeries.push({\n name,\n type: echartsSeriesOption.type ?? 'line',\n values,\n });\n }\n }\n\n if (thresholds.length === 0) {\n return undefined;\n }\n\n const parts: string[] = [];\n\n // 1. Overview\n const dataSeriesCountText =\n dataSeries.length === 1\n ? '1 data series'\n : `${dataSeries.length} data series`;\n const thresholdCountText =\n thresholds.length === 1\n ? '1 threshold line'\n : `${thresholds.length} threshold lines`;\n parts.push(\n `This chart has ${dataSeriesCountText} and ${thresholdCountText}.`,\n );\n\n // 2. Describe each data series\n for (const series of dataSeries) {\n const { name, type, values } = series;\n if (values.length > 0) {\n const min = Math.min(...values);\n const max = Math.max(...values);\n parts.push(\n `${name} is a ${type} chart with ${values.length} ${pluralize(values.length, 'data point')} ranging from ${min} to ${max}.`,\n );\n } else {\n parts.push(`${name} is a ${type} chart with no resolved data.`);\n }\n }\n\n // 3. Describe threshold lines\n for (const threshold of thresholds) {\n const conditionText = threshold.hasCustomCondition\n ? (threshold.customConditionText ?? 'custom condition')\n : thresholdConditionToText(threshold.condition);\n\n parts.push(\n `${threshold.notificationType === 'warning' ? 'Warning' : 'Danger'} threshold at ${threshold.yAxisValue}: triggers when values are ${conditionText} ${threshold.yAxisValue}.`,\n );\n }\n\n // 4. Report threshold violations per data series\n for (const series of dataSeries) {\n const { name, values } = series;\n if (values.length === 0) {\n continue;\n }\n\n for (const threshold of thresholds) {\n // Custom conditions use runtime callbacks that we cannot evaluate\n // at description-generation time, so we skip violation reporting.\n if (threshold.hasCustomCondition) {\n continue;\n }\n\n const violatingValues = values.filter(\n (value) =>\n evaluateThresholdCondition(\n value,\n threshold.condition,\n threshold.yAxisValue,\n ).isConditionMet,\n );\n\n if (violatingValues.length > 0) {\n const count = violatingValues.length;\n parts.push(\n `${name} has ${count} ${pluralize(count, 'value')} ${thresholdConditionToText(threshold.condition)} the ${threshold.notificationType} threshold of ${threshold.yAxisValue}.`,\n );\n }\n }\n }\n\n return parts.join(' ');\n}\n"]}
@@ -79,7 +79,7 @@ export const hasMarkAreaInSeries = (series) => Array.isArray(series)
79
79
  */
80
80
  export function hasCategoryXAxis(xAxis) {
81
81
  return Array.isArray(xAxis)
82
- ? xAxis.some((x) => x.type === 'category')
82
+ ? xAxis.some((axis) => axis.type === 'category')
83
83
  : (xAxis === null || xAxis === void 0 ? void 0 : xAxis.type) === 'category';
84
84
  }
85
85
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"build-chart-option.js","sourceRoot":"","sources":["../../../../src/charts/utils/build-chart-option.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAGvE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,sBAAs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DAA8D;YAC9D,QAAQ,oBAAO,cAAc,CAAE;YAC/B,IAAI,EAAE,KAAK;SACZ,EACD,MAAM,EACN,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,EACrC,OAAO,EAAE;YACP,YAAY,EAAE,CAAC;YACf,WAAW,EAAE,CAAC;YACd,OAAO,EAAE,IAAI;YACb,YAAY,EAAE,kDAAkD;YAChE,SAAS,EAAE,0BAA0B,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC;YACrE,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,MAAM;SAChB,EACD,KAAK;QACL,KAAK,IACL;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 type { DataZoomComponentOption, EChartsOption } from 'echarts';\n\nimport { generateThresholdAriaDescription } from './aria-description';\nimport { createAxisTooltipFormatter } from './chart-tooltip-formatter';\nimport type { ChartProps, EchartsSeries } from './chart-types';\nimport type { NormalizedThresholdLine } from './threshold';\nimport { mergeToolbox } from './user-option-utils';\n\nconst SLIDER_OUTER_BOUND_GAP = 8;\nconst SLIDER_OUTER_BOUND_FALLBACK = 60;\n\ntype BuildChartOptionParams = {\n dataZoom: EChartsOption['dataZoom'];\n dataset: ChartProps['dataset'];\n hasCategoryXAxis: boolean;\n hasSliderZoom: boolean;\n legendSelected: Record<string, boolean>;\n propsSeries: ChartProps['series'];\n series: EchartsSeries;\n thresholdLines: NormalizedThresholdLine[];\n toolboxOptions: EChartsOption['toolbox'];\n userOption: ChartProps['option'];\n xAxis: EChartsOption['xAxis'];\n yAxis: EChartsOption['yAxis'];\n hasMarkArea: boolean;\n};\n\n/**\n * Slider zoom needs extra bottom grid space for ECharts' slider control.\n */\nexport function hasSliderDataZoom(\n dataZoom: EChartsOption['dataZoom'],\n): boolean {\n return Array.isArray(dataZoom)\n ? dataZoom.some((dataZoomOption: DataZoomComponentOption) => {\n return dataZoomOption?.type === 'slider';\n })\n : dataZoom?.type === 'slider';\n}\n\ntype SliderDataZoomLayout = DataZoomComponentOption & {\n bottom?: number | string;\n height?: number | string;\n orient?: 'horizontal' | 'vertical';\n};\n\nconst getPixelValue = (value: number | string | undefined) => {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return value;\n }\n\n if (typeof value !== 'string' || !/^-?\\d+(?:\\.\\d+)?px$/.test(value)) {\n return undefined;\n }\n\n return Number.parseFloat(value);\n};\n\n/**\n * Reserves the area occupied by bottom-positioned horizontal slider controls.\n *\n * ECharts lays data zoom controls outside the Cartesian grid, so its automatic\n * axis outer bounds do not account for them. Normalized sliders use pixel\n * values; custom percentage-based layouts fall back to the previous 60px\n * reserve because they cannot be resolved without the rendered chart size.\n */\nexport function getSliderBottomOuterBound(\n dataZoom: EChartsOption['dataZoom'],\n): number | undefined {\n const dataZoomOptions = Array.isArray(dataZoom) ? dataZoom : [dataZoom];\n const sliderOuterBounds = dataZoomOptions.flatMap((option) => {\n const slider = option as SliderDataZoomLayout | undefined;\n if (slider?.type !== 'slider' || slider.orient === 'vertical') {\n return [];\n }\n\n const bottom = getPixelValue(slider.bottom);\n const height = getPixelValue(slider.height);\n if (bottom === undefined || height === undefined) {\n return [SLIDER_OUTER_BOUND_FALLBACK];\n }\n\n return [bottom + height + SLIDER_OUTER_BOUND_GAP];\n });\n\n return sliderOuterBounds.length > 0\n ? Math.max(...sliderOuterBounds)\n : undefined;\n}\n\n/**\n * Mark area needs extra top grid space to fit inside the chart.\n */\nexport const hasMarkAreaInSeries = (series: EchartsSeries) =>\n Array.isArray(series)\n ? series.some((option) => !!option.markArea)\n : !!series.markArea;\n\n/**\n * Category x-axes use slightly wider grid padding to avoid clipped labels.\n */\nexport function hasCategoryXAxis(xAxis: EChartsOption['xAxis']): boolean {\n return Array.isArray(xAxis)\n ? xAxis.some((x) => x.type === 'category')\n : xAxis?.type === 'category';\n}\n\n/**\n * Builds the ECharts option object from Needle chart props and derived values.\n * Applying the option to an ECharts instance happens in `useChartOption`.\n */\nexport function buildChartOption({\n dataZoom,\n dataset,\n hasCategoryXAxis,\n hasSliderZoom,\n legendSelected,\n propsSeries,\n series,\n thresholdLines,\n toolboxOptions,\n userOption,\n xAxis,\n yAxis,\n hasMarkArea,\n}: BuildChartOptionParams): EChartsOption {\n const customAriaDescription = generateThresholdAriaDescription(\n propsSeries,\n dataset,\n );\n const sliderBottomOuterBound = getSliderBottomOuterBound(dataZoom);\n const gridBottom = hasSliderZoom ? 60 : 10;\n const gridHorizontalInset = hasCategoryXAxis ? 15 : 10;\n const gridTop = hasMarkArea ? 20 : 10;\n\n return {\n ...userOption,\n aria: {\n decal: {\n show: false,\n },\n enabled: true,\n ...(customAriaDescription !== undefined && {\n label: { description: customAriaDescription },\n }),\n ...(userOption?.aria as EChartsOption['aria']),\n },\n dataZoom,\n dataset,\n grid: {\n bottom: `${gridBottom}px`,\n left: `${gridHorizontalInset}px`,\n outerBounds: {\n bottom: sliderBottomOuterBound ?? gridBottom,\n left: gridHorizontalInset,\n right: gridHorizontalInset,\n top: gridTop,\n },\n outerBoundsContain: 'all',\n right: `${gridHorizontalInset}px`,\n top: `${gridTop}px`,\n type: 'solid',\n ...(userOption?.grid as EChartsOption['grid']),\n },\n legend: {\n // ECharts mutates option.legend.selected internally; callers pass a\n // copied object so the React ref remains the source of truth.\n selected: { ...legendSelected },\n show: false,\n },\n series,\n toolbox: mergeToolbox(toolboxOptions),\n tooltip: {\n borderRadius: 0,\n borderWidth: 0,\n confine: true,\n extraCssText: 'box-shadow: none; background-color: transparent;',\n formatter: createAxisTooltipFormatter({ thresholdLines, userOption }),\n padding: 0,\n trigger: 'axis',\n },\n xAxis,\n yAxis,\n };\n}\n"]}
1
+ {"version":3,"file":"build-chart-option.js","sourceRoot":"","sources":["../../../../src/charts/utils/build-chart-option.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAGvE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAkBvC;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAmC;IAEnC,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC5B,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,cAAuC,EAAE,EAAE;YACxD,OAAO,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,MAAK,QAAQ,CAAC;QAC3C,CAAC,CAAC;QACJ,CAAC,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,QAAQ,CAAC;AAClC,CAAC;AAQD,MAAM,aAAa,GAAG,CAAC,KAAkC,EAAE,EAAE;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACpE,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC,CAAC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E,GAAG,mBAAmB,IAAI,EAChC,WAAW,EAAE;gBACX,MAAM,EAAE,sBAAsB,aAAtB,sBAAsB,cAAtB,sBAAsB,GAAI,UAAU;gBAC5C,IAAI,EAAE,mBAAmB;gBACzB,KAAK,EAAE,mBAAmB;gBAC1B,GAAG,EAAE,OAAO;aACb,EACD,kBAAkB,EAAE,KAAK,EACzB,KAAK,EAAE,GAAG,mBAAmB,IAAI,EACjC,GAAG,EAAE,GAAG,OAAO,IAAI,EACnB,IAAI,EAAE,OAAO,IACT,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAA8B,GAEhD,MAAM,EAAE;YACN,oEAAoE;YACpE,8DAA8D;YAC9D,QAAQ,oBAAO,cAAc,CAAE;YAC/B,IAAI,EAAE,KAAK;SACZ,EACD,MAAM,EACN,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,EACrC,OAAO,EAAE;YACP,YAAY,EAAE,CAAC;YACf,WAAW,EAAE,CAAC;YACd,OAAO,EAAE,IAAI;YACb,YAAY,EAAE,kDAAkD;YAChE,SAAS,EAAE,0BAA0B,CAAC,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC;YACrE,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,MAAM;SAChB,EACD,KAAK;QACL,KAAK,IACL;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 type { DataZoomComponentOption, EChartsOption } from 'echarts';\n\nimport { generateThresholdAriaDescription } from './aria-description';\nimport { createAxisTooltipFormatter } from './chart-tooltip-formatter';\nimport type { ChartProps, EchartsSeries } from './chart-types';\nimport type { NormalizedThresholdLine } from './threshold';\nimport { mergeToolbox } from './user-option-utils';\n\nconst SLIDER_OUTER_BOUND_GAP = 8;\nconst SLIDER_OUTER_BOUND_FALLBACK = 60;\n\ntype BuildChartOptionParams = {\n dataZoom: EChartsOption['dataZoom'];\n dataset: ChartProps['dataset'];\n hasCategoryXAxis: boolean;\n hasSliderZoom: boolean;\n legendSelected: Record<string, boolean>;\n propsSeries: ChartProps['series'];\n series: EchartsSeries;\n thresholdLines: NormalizedThresholdLine[];\n toolboxOptions: EChartsOption['toolbox'];\n userOption: ChartProps['option'];\n xAxis: EChartsOption['xAxis'];\n yAxis: EChartsOption['yAxis'];\n hasMarkArea: boolean;\n};\n\n/**\n * Slider zoom needs extra bottom grid space for ECharts' slider control.\n */\nexport function hasSliderDataZoom(\n dataZoom: EChartsOption['dataZoom'],\n): boolean {\n return Array.isArray(dataZoom)\n ? dataZoom.some((dataZoomOption: DataZoomComponentOption) => {\n return dataZoomOption?.type === 'slider';\n })\n : dataZoom?.type === 'slider';\n}\n\ntype SliderDataZoomLayout = DataZoomComponentOption & {\n bottom?: number | string;\n height?: number | string;\n orient?: 'horizontal' | 'vertical';\n};\n\nconst getPixelValue = (value: number | string | undefined) => {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return value;\n }\n\n if (typeof value !== 'string' || !/^-?\\d+(?:\\.\\d+)?px$/.test(value)) {\n return undefined;\n }\n\n return Number.parseFloat(value);\n};\n\n/**\n * Reserves the area occupied by bottom-positioned horizontal slider controls.\n *\n * ECharts lays data zoom controls outside the Cartesian grid, so its automatic\n * axis outer bounds do not account for them. Normalized sliders use pixel\n * values; custom percentage-based layouts fall back to the previous 60px\n * reserve because they cannot be resolved without the rendered chart size.\n */\nexport function getSliderBottomOuterBound(\n dataZoom: EChartsOption['dataZoom'],\n): number | undefined {\n const dataZoomOptions = Array.isArray(dataZoom) ? dataZoom : [dataZoom];\n const sliderOuterBounds = dataZoomOptions.flatMap((option) => {\n const slider = option as SliderDataZoomLayout | undefined;\n if (slider?.type !== 'slider' || slider.orient === 'vertical') {\n return [];\n }\n\n const bottom = getPixelValue(slider.bottom);\n const height = getPixelValue(slider.height);\n if (bottom === undefined || height === undefined) {\n return [SLIDER_OUTER_BOUND_FALLBACK];\n }\n\n return [bottom + height + SLIDER_OUTER_BOUND_GAP];\n });\n\n return sliderOuterBounds.length > 0\n ? Math.max(...sliderOuterBounds)\n : undefined;\n}\n\n/**\n * Mark area needs extra top grid space to fit inside the chart.\n */\nexport const hasMarkAreaInSeries = (series: EchartsSeries) =>\n Array.isArray(series)\n ? series.some((option) => !!option.markArea)\n : !!series.markArea;\n\n/**\n * Category x-axes use slightly wider grid padding to avoid clipped labels.\n */\nexport function hasCategoryXAxis(xAxis: EChartsOption['xAxis']): boolean {\n return Array.isArray(xAxis)\n ? xAxis.some((axis) => axis.type === 'category')\n : xAxis?.type === 'category';\n}\n\n/**\n * Builds the ECharts option object from Needle chart props and derived values.\n * Applying the option to an ECharts instance happens in `useChartOption`.\n */\nexport function buildChartOption({\n dataZoom,\n dataset,\n hasCategoryXAxis,\n hasSliderZoom,\n legendSelected,\n propsSeries,\n series,\n thresholdLines,\n toolboxOptions,\n userOption,\n xAxis,\n yAxis,\n hasMarkArea,\n}: BuildChartOptionParams): EChartsOption {\n const customAriaDescription = generateThresholdAriaDescription(\n propsSeries,\n dataset,\n );\n const sliderBottomOuterBound = getSliderBottomOuterBound(dataZoom);\n const gridBottom = hasSliderZoom ? 60 : 10;\n const gridHorizontalInset = hasCategoryXAxis ? 15 : 10;\n const gridTop = hasMarkArea ? 20 : 10;\n\n return {\n ...userOption,\n aria: {\n decal: {\n show: false,\n },\n enabled: true,\n ...(customAriaDescription !== undefined && {\n label: { description: customAriaDescription },\n }),\n ...(userOption?.aria as EChartsOption['aria']),\n },\n dataZoom,\n dataset,\n grid: {\n bottom: `${gridBottom}px`,\n left: `${gridHorizontalInset}px`,\n outerBounds: {\n bottom: sliderBottomOuterBound ?? gridBottom,\n left: gridHorizontalInset,\n right: gridHorizontalInset,\n top: gridTop,\n },\n outerBoundsContain: 'all',\n right: `${gridHorizontalInset}px`,\n top: `${gridTop}px`,\n type: 'solid',\n ...(userOption?.grid as EChartsOption['grid']),\n },\n legend: {\n // ECharts mutates option.legend.selected internally; callers pass a\n // copied object so the React ref remains the source of truth.\n selected: { ...legendSelected },\n show: false,\n },\n series,\n toolbox: mergeToolbox(toolboxOptions),\n tooltip: {\n borderRadius: 0,\n borderWidth: 0,\n confine: true,\n extraCssText: 'box-shadow: none; background-color: transparent;',\n formatter: createAxisTooltipFormatter({ thresholdLines, userOption }),\n padding: 0,\n trigger: 'axis',\n },\n xAxis,\n yAxis,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"chart-types.js","sourceRoot":"","sources":["../../../../src/charts/utils/chart-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG","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 {\n type EChartsOption,\n type LineSeriesOption,\n type RegisteredSeriesOption,\n type SetOptionOpts,\n} from 'echarts';\n\nexport type HexColor = `#${string}`;\n\nexport type Condition =\n | 'greater'\n | 'greaterOrEqual'\n | 'less'\n | 'lessOrEqual'\n | 'equal'\n | 'notEqual';\n\nexport type Values<T> = T[keyof T];\nexport type SeriesOption = Values<RegisteredSeriesOption>;\n\nexport type EchartsSeries = SeriesOption | SeriesOption[];\n\ntype CustomCondition = (\n lineValue: unknown,\n thresholdLineValue: unknown,\n) => boolean;\n\nexport interface ThresholdLineSeriesOption<\n T extends NotificationType,\n> extends Omit<LineSeriesOption, 'type'> {\n type: 'thresholdLine';\n yAxis: number;\n xAxis: [number, number];\n notificationType: T;\n color?: string;\n condition?: Condition;\n customConditionText?: string;\n customCondition?: CustomCondition;\n}\n\n// Only one threshold line of each type is allowed.\nexport type NeedleSeries =\n | [\n ThresholdLineSeriesOption<'warning'>,\n ThresholdLineSeriesOption<'danger'>,\n ...SeriesOption[],\n ]\n | [ThresholdLineSeriesOption<'danger'>, ...SeriesOption[]]\n | [ThresholdLineSeriesOption<'warning'>, ...SeriesOption[]]\n | SeriesOption[];\n\nexport interface ChartProps {\n /** The dataset configuration for the chart. Can be a single dataset or an array of datasets. */\n dataset: EChartsOption['dataset'];\n /** The series configuration for the chart. Defines what data to display and how to display it. */\n series: NeedleSeries;\n /** X-axis configuration for the chart. */\n xAxis?: EChartsOption['xAxis'];\n /** Y-axis configuration for the chart. */\n yAxis?: EChartsOption['yAxis'];\n /** Legend configuration for the chart. */\n legend?: {\n // TODO v5: fix boolean naming convention\n // eslint-disable-next-line @typescript-eslint/naming-convention\n show?: boolean;\n // TODO v5: remove this prop\n /** @deprecated No longer has any effect since wrapping is now automatic, will be removed in v 5 */\n wrappingType?: 'wrapping' | 'truncation' | 'overflow';\n };\n /** Additional ECharts options to merge with the chart configuration. */\n option?: Omit<\n EChartsOption,\n 'series' | 'dataset' | 'legend' | 'xAxis' | 'yAxis'\n >;\n /** Custom CSS styles to apply to the chart container. */\n style?: React.CSSProperties;\n /**\n * Settings for how ECharts should update the chart. Defaults to replacing the\n * components the chart owns (`series`, `dataset`, axes, and similar) while\n * merging the rest, which drops data that disappeared without discarding the\n * ECharts components behind zoom interactions. Passing `notMerge: true`\n * re-creates those components on every update and breaks drag-to-zoom.\n */\n settings?: SetOptionOpts;\n /** Whether the chart is in a loading state. */\n isLoading?: boolean;\n /** Callback functions for chart interactions. */\n callbacks?: {\n onZoom?: (params: { startValue: number; endValue: number }) => void;\n };\n /** Data zoom configuration for the chart. */\n dataZoom?: EChartsOption['dataZoom'];\n /** Whether the zoom in the chart is disabled */\n isChartZoomDisabled?: boolean;\n /** Custom color palette that overrides the default categorical colors. */\n palette?: HexColor[];\n}\n\nexport interface ChartEmptyProps {\n /** A text displayed to the user when the chart is empty. */\n message?: React.ReactNode;\n /** The type of chart. This is used to render the appropriate icon. */\n type?: 'line' | 'pie' | 'bar';\n /** Optional element (preferably a TextButton) that should provide the user with an action. */\n action?: React.ReactNode;\n}\n\n/**\n * Chart tooltip\n */\n\nexport interface ChartTooltipProps {\n children: React.ReactNode;\n className?: string;\n isOpen?: boolean;\n style?: React.CSSProperties;\n anchorPosition?: {\n x: number;\n y: number;\n };\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport type NotificationType = 'warning' | 'danger';\n\nexport type Notification = {\n leadingElement: React.ReactNode;\n trailingElement: React.ReactNode;\n notificationType: NotificationType;\n id: string;\n};\n\nexport type ChartTooltipContentProps = {\n leadingElement?: React.ReactNode;\n trailingElement?: React.ReactNode;\n indentSquareColor?: string;\n notifications?: Notification[];\n ref?: React.Ref<HTMLDivElement>;\n};\n\n/**\n * Legend\n */\nexport interface LegendItemProps {\n name: string;\n children: React.ReactNode;\n as?: 'button' | 'div';\n className?: string;\n color?: string;\n // TODO v5: fix boolean naming convention\n // eslint-disable-next-line @typescript-eslint/naming-convention\n selected?: boolean;\n // TODO v5: fix boolean naming convention\n // eslint-disable-next-line @typescript-eslint/naming-convention\n deSelected?: boolean;\n onLegendItemClick?: () => void;\n hasButtons?: boolean;\n onLegendItemMouseEnter?: () => void;\n onLegendItemMouseLeave?: () => void;\n ref?: React.Ref<HTMLButtonElement> & React.Ref<HTMLDivElement>;\n}\n\nexport type LegendProps = {\n series: {\n name: string;\n color: string;\n }[];\n ref?: React.Ref<HTMLDivElement>;\n};\n\nexport type HtmlAttributes<T extends React.ElementType> =\n React.ComponentPropsWithoutRef<T> & {\n [key: `data-${string}`]: string | undefined;\n };\n\ntype BaseProps<T extends React.ElementType> = {\n /**\n * Additional classnames will be applied to the root element.\n */\n className?: string;\n /**\n * Additional css styling. Will be applied to the root element.\n */\n style?: React.CSSProperties;\n\n /**\n * Html attributes to apply to the root element. This will override any default html attributes, use with caution.\n */\n htmlAttributes?: HtmlAttributes<T>;\n\n /**\n * A ref to apply to the root element.\n */\n ref?: React.ComponentPropsWithRef<T>['ref'];\n};\n\nexport type CommonProps<T extends React.ElementType, P> = P & BaseProps<T>;\n"]}
1
+ {"version":3,"file":"chart-types.js","sourceRoot":"","sources":["../../../../src/charts/utils/chart-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG","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 {\n type EChartsOption,\n type LineSeriesOption,\n type RegisteredSeriesOption,\n type SetOptionOpts,\n} from 'echarts';\n\nexport type HexColor = `#${string}`;\n\nexport type Condition =\n | 'greater'\n | 'greaterOrEqual'\n | 'less'\n | 'lessOrEqual'\n | 'equal'\n | 'notEqual';\n\nexport type Values<T> = T[keyof T];\nexport type SeriesOption = Values<RegisteredSeriesOption>;\n\nexport type EchartsSeries = SeriesOption | SeriesOption[];\n\ntype CustomCondition = (\n lineValue: unknown,\n thresholdLineValue: unknown,\n) => boolean;\n\nexport interface ThresholdLineSeriesOption<\n T extends NotificationType,\n> extends Omit<LineSeriesOption, 'type'> {\n type: 'thresholdLine';\n yAxis: number;\n xAxis: [number, number];\n notificationType: T;\n color?: string;\n condition?: Condition;\n customConditionText?: string;\n customCondition?: CustomCondition;\n}\n\n// Only one threshold line of each type is allowed.\nexport type NeedleSeries =\n | [\n ThresholdLineSeriesOption<'warning'>,\n ThresholdLineSeriesOption<'danger'>,\n ...SeriesOption[],\n ]\n | [ThresholdLineSeriesOption<'danger'>, ...SeriesOption[]]\n | [ThresholdLineSeriesOption<'warning'>, ...SeriesOption[]]\n | SeriesOption[];\n\nexport interface ChartProps {\n /** The dataset configuration for the chart. Can be a single dataset or an array of datasets. */\n dataset: EChartsOption['dataset'];\n /** The series configuration for the chart. Defines what data to display and how to display it. */\n series: NeedleSeries;\n /** X-axis configuration for the chart. */\n xAxis?: EChartsOption['xAxis'];\n /** Y-axis configuration for the chart. */\n yAxis?: EChartsOption['yAxis'];\n /** Legend configuration for the chart. */\n legend?: {\n // TODO v5: fix boolean naming convention\n // eslint-disable-next-line @typescript-eslint/naming-convention\n show?: boolean;\n // TODO v5: remove this prop\n /** @deprecated No longer has any effect since wrapping is now automatic, will be removed in v 5 */\n wrappingType?: 'wrapping' | 'truncation' | 'overflow';\n };\n /** Additional ECharts options to merge with the chart configuration. */\n option?: Omit<\n EChartsOption,\n 'series' | 'dataset' | 'legend' | 'xAxis' | 'yAxis'\n >;\n /** Custom CSS styles to apply to the chart container. */\n style?: React.CSSProperties;\n /**\n * Settings for how ECharts should update the chart. Defaults to replacing the\n * components the chart owns (`series`, `dataset`, axes, and similar) while\n * merging the rest, which drops data that disappeared without discarding the\n * ECharts components behind zoom interactions. Passing `notMerge: true`\n * re-creates those components on every update and breaks drag-to-zoom.\n */\n settings?: SetOptionOpts;\n /** Whether the chart is in a loading state. */\n isLoading?: boolean;\n /** Callback functions for chart interactions. */\n callbacks?: {\n onZoom?: (params: { startValue: number; endValue: number }) => void;\n };\n /** Data zoom configuration for the chart. */\n dataZoom?: EChartsOption['dataZoom'];\n /** Whether the zoom in the chart is disabled */\n isChartZoomDisabled?: boolean;\n /** Custom color palette that overrides the default categorical colors. */\n palette?: HexColor[];\n}\n\nexport interface ChartEmptyProps {\n /** A text displayed to the user when the chart is empty. */\n message?: React.ReactNode;\n /** The type of chart. This is used to render the appropriate icon. */\n type?: 'line' | 'pie' | 'bar';\n /** Optional element (preferably a TextButton) that should provide the user with an action. */\n action?: React.ReactNode;\n}\n\n/**\n * Chart tooltip\n */\n\nexport interface ChartTooltipProps {\n children: React.ReactNode;\n className?: string;\n isOpen?: boolean;\n style?: React.CSSProperties;\n anchorPosition?: {\n // TODO v5: create componentProps type for this\n // oxlint-disable-next-line id-length\n x: number;\n // TODO v5: create componentProps type for this\n // oxlint-disable-next-line id-length\n y: number;\n };\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport type NotificationType = 'warning' | 'danger';\n\nexport type Notification = {\n leadingElement: React.ReactNode;\n trailingElement: React.ReactNode;\n notificationType: NotificationType;\n id: string;\n};\n\nexport type ChartTooltipContentProps = {\n leadingElement?: React.ReactNode;\n trailingElement?: React.ReactNode;\n indentSquareColor?: string;\n notifications?: Notification[];\n ref?: React.Ref<HTMLDivElement>;\n};\n\n/**\n * Legend\n */\nexport interface LegendItemProps {\n name: string;\n children: React.ReactNode;\n as?: 'button' | 'div';\n className?: string;\n color?: string;\n // TODO v5: fix boolean naming convention\n // eslint-disable-next-line @typescript-eslint/naming-convention\n selected?: boolean;\n // TODO v5: fix boolean naming convention\n // eslint-disable-next-line @typescript-eslint/naming-convention\n deSelected?: boolean;\n onLegendItemClick?: () => void;\n hasButtons?: boolean;\n onLegendItemMouseEnter?: () => void;\n onLegendItemMouseLeave?: () => void;\n ref?: React.Ref<HTMLButtonElement> & React.Ref<HTMLDivElement>;\n}\n\nexport type LegendProps = {\n series: {\n name: string;\n color: string;\n }[];\n ref?: React.Ref<HTMLDivElement>;\n};\n\nexport type HtmlAttributes<T extends React.ElementType> =\n React.ComponentPropsWithoutRef<T> & {\n [key: `data-${string}`]: string | undefined;\n };\n\ntype BaseProps<T extends React.ElementType> = {\n /**\n * Additional classnames will be applied to the root element.\n */\n className?: string;\n /**\n * Additional css styling. Will be applied to the root element.\n */\n style?: React.CSSProperties;\n\n /**\n * Html attributes to apply to the root element. This will override any default html attributes, use with caution.\n */\n htmlAttributes?: HtmlAttributes<T>;\n\n /**\n * A ref to apply to the root element.\n */\n ref?: React.ComponentPropsWithRef<T>['ref'];\n};\n\nexport type CommonProps<T extends React.ElementType, P> = P & BaseProps<T>;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"format-utils.js","sourceRoot":"","sources":["../../../../src/charts/utils/format-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAE,EAAE;IAC5C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AAE3D;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAI,KAAQ,EAAc,EAAE;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5E,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,6BAA6B,GAAG,CACpC,KAA4C,EAC5C,MAGC;AACD,yCAAyC;AACzC,UAAqD,GAAG,EACxD,EAAE;;IACF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6DAA6D;IAC7D,4FAA4F;IAC5F,MAAM,iBAAiB,GAAG,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,CAAC,mCAAI,CAAC,CAAC,CAAC;IAEzE,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC;QACrD,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;QACtB,CAAC,CAAC,iBAAiB,CAAC;IAEtB,OAAO,MAAA,KAAK,CAAC,cAAc,CAAC,mCAAI,KAAK,CAAC;AACxC,CAAC,CAAC;AAEF,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,gBAAgB,GACjB,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\nconst capitalizeFirstLetter = (str: string) => {\n if (!str) {\n return str;\n }\n return str.charAt(0).toUpperCase() + str.substring(1);\n};\n\nconst enUSNumberFormatter = new Intl.NumberFormat('en-US');\n\n/**\n * Formats finite number values with en-US separators and returns all other\n * values unchanged.\n */\nconst formatNumberEnUS = <T>(value: T): string | T => {\n if (typeof value === 'number') {\n return Number.isFinite(value) ? enUSNumberFormatter.format(value) : value;\n }\n\n return value;\n};\n\n/**\n * Extract the tooltip value from the series depending on the axisDim and encode properties\n * If the value is a single value, return it as it is\n * If the encode property does not exist fallback to 1\n */\nconst extractValueFromTooltipSeries = (\n value: string | number | (number | string)[],\n encode: {\n x: number | number[];\n y: number | number[];\n },\n // We currently only support x and y axes\n axisDim: 'x' | 'y' | 'angle' | 'radius' | 'single' = 'x',\n) => {\n if (!Array.isArray(value)) {\n return value;\n }\n\n // The axisDim is the axis that the tooltip was triggered on,\n // if it was triggered on the x axis the value should be read from the y axis and vice versa\n const encodeValueToRead = axisDim === 'x' ? encode?.y : (encode?.x ?? 1);\n\n const seriesValueIdx = Array.isArray(encodeValueToRead)\n ? encodeValueToRead[0]\n : encodeValueToRead;\n\n return value[seriesValueIdx] ?? value;\n};\n\nexport {\n capitalizeFirstLetter,\n extractValueFromTooltipSeries,\n formatNumberEnUS,\n};\n"]}
1
+ {"version":3,"file":"format-utils.js","sourceRoot":"","sources":["../../../../src/charts/utils/format-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAE,EAAE;IAC5C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AAE3D;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAI,KAAQ,EAAc,EAAE;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5E,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,6BAA6B,GAAG,CACpC,KAA4C,EAC5C,MAMC;AACD,yCAAyC;AACzC,UAAqD,GAAG,EACxD,EAAE;;IACF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6DAA6D;IAC7D,4FAA4F;IAC5F,MAAM,iBAAiB,GAAG,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,CAAC,mCAAI,CAAC,CAAC,CAAC;IAEzE,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC;QACrD,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;QACtB,CAAC,CAAC,iBAAiB,CAAC;IAEtB,OAAO,MAAA,KAAK,CAAC,cAAc,CAAC,mCAAI,KAAK,CAAC;AACxC,CAAC,CAAC;AAEF,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,gBAAgB,GACjB,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\nconst capitalizeFirstLetter = (str: string) => {\n if (!str) {\n return str;\n }\n return str.charAt(0).toUpperCase() + str.substring(1);\n};\n\nconst enUSNumberFormatter = new Intl.NumberFormat('en-US');\n\n/**\n * Formats finite number values with en-US separators and returns all other\n * values unchanged.\n */\nconst formatNumberEnUS = <T>(value: T): string | T => {\n if (typeof value === 'number') {\n return Number.isFinite(value) ? enUSNumberFormatter.format(value) : value;\n }\n\n return value;\n};\n\n/**\n * Extract the tooltip value from the series depending on the axisDim and encode properties\n * If the value is a single value, return it as it is\n * If the encode property does not exist fallback to 1\n */\nconst extractValueFromTooltipSeries = (\n value: string | number | (number | string)[],\n encode: {\n // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode\n // oxlint-disable-next-line id-length\n x: number | number[];\n // oxlint-disable-next-line id-length\n y: number | number[];\n },\n // We currently only support x and y axes\n axisDim: 'x' | 'y' | 'angle' | 'radius' | 'single' = 'x',\n) => {\n if (!Array.isArray(value)) {\n return value;\n }\n\n // The axisDim is the axis that the tooltip was triggered on,\n // if it was triggered on the x axis the value should be read from the y axis and vice versa\n const encodeValueToRead = axisDim === 'x' ? encode?.y : (encode?.x ?? 1);\n\n const seriesValueIdx = Array.isArray(encodeValueToRead)\n ? encodeValueToRead[0]\n : encodeValueToRead;\n\n return value[seriesValueIdx] ?? value;\n};\n\nexport {\n capitalizeFirstLetter,\n extractValueFromTooltipSeries,\n formatNumberEnUS,\n};\n"]}
@@ -22,7 +22,7 @@ import { getInstanceByDom, } from 'echarts';
22
22
  export const resetAllSeriesHighlight = (chart) => {
23
23
  const option = chart.getOption();
24
24
  const seriesList = option.series || [];
25
- seriesList.forEach((_, seriesIndex) => {
25
+ seriesList.forEach((_series, seriesIndex) => {
26
26
  chart.dispatchAction({
27
27
  seriesIndex,
28
28
  type: 'downplay',
@@ -82,7 +82,7 @@ const highlightOrDownplayPieSlices = (chart, currentSeriesToDispatch, action, cu
82
82
  if (action === 'highlight') {
83
83
  // Downplay other data indexes to make sure the other slices are not highlighted
84
84
  const otherSeriesIndexes = sourceArray
85
- .map((_, index) => index)
85
+ .map((_row, index) => index)
86
86
  .filter((dataIndex) => !currentDataSeriesIndexes.includes(dataIndex));
87
87
  chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
88
88
  seriesIndex: [0], // pie charts only has one series so seriesIndex is always 0
@@ -1 +1 @@
1
- {"version":3,"file":"legend-utils.js","sourceRoot":"","sources":["../../../../src/charts/utils/legend-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAGL,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAkB,EAAE,EAAE;IAC5D,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,UAAU,GAAI,MAAM,CAAC,MAAgC,IAAI,EAAE,CAAC;IAElE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,WAAmB,EAAE,EAAE;QAC5C,KAAK,CAAC,cAAc,CAAC;YACnB,WAAW;YACX,IAAI,EAAE,UAAU;SACjB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,mCAAmC,GAAG,CAC1C,KAAkB,EAClB,uBAA0D,EAC1D,MAAgC,EAChC,mBAAyD,EACzD,EAAE;;IACF,MAAM,UAAU,GAAG,MAAM,KAAK,UAAU,CAAC;IACzC,MAAM,oBAAoB,GACxB,CAAC,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,MAAgD;QACtE,EAAE,CAAC;IAEL,oEAAoE;IACpE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAC;QACf,MAAM,EAAE,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAE,GAAG,CAC/B,CAAC,UAAmC,EAAE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,KAAK,EACL,uBAAuB,EACvB,MAAM,EACN,mBAAmB,CACpB,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,OAAO,EAAE,yBAAyB,EAAE,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 {\n type EChartsOption,\n type EChartsType,\n getInstanceByDom,\n} from 'echarts';\n\nexport const resetAllSeriesHighlight = (chart: EChartsType) => {\n const option = chart.getOption();\n const seriesList = (option.series as unknown[] | undefined) || [];\n\n seriesList.forEach((_, seriesIndex: number) => {\n chart.dispatchAction({\n seriesIndex,\n type: 'downplay',\n });\n });\n};\n\nconst highlightOrDownplayLineAndBarSeries = (\n chart: EChartsType,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n currentChartOptions: ReturnType<EChartsType['getOption']>,\n) => {\n const isDownplay = action === 'downplay';\n const allChartOptionSeries =\n (currentChartOptions?.series as Record<string, unknown>[] | undefined) ||\n [];\n\n // Change emphasis state to add opacity on the non highlighted items\n chart?.setOption({\n series: allChartOptionSeries?.map(\n (seriesItem: Record<string, unknown>) => ({\n ...seriesItem,\n emphasis: {\n ...(seriesItem.emphasis as Record<string, unknown>),\n disabled: isDownplay,\n },\n }),\n ),\n });\n\n const seriesWithSeriesIndex = allChartOptionSeries\n // Since the series index does not exist in the data we extract it from the series index\n ?.map((seriesItem, index) => ({\n ...seriesItem,\n seriesIndex: index,\n }))\n // Select the series that are in the currentSeriesToDispatch array\n ?.filter((seriesItem: Record<string, unknown>) =>\n currentSeriesToDispatch.some((series) => series.name === seriesItem.name),\n );\n\n if (!seriesWithSeriesIndex.length) {\n return;\n }\n\n chart?.dispatchAction({\n seriesIndex: seriesWithSeriesIndex.map((series) => series.seriesIndex),\n type: action,\n });\n};\n\n/**\n * Highlight or downplay pie chart dataset item\n */\nconst highlightOrDownplayPieSlices = (\n chart: EChartsType,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n currentChartOptions: ReturnType<EChartsType['getOption']>,\n) => {\n const isDownplay = action === 'downplay';\n const allChartOptionSeries =\n (currentChartOptions?.series as Record<string, unknown>[] | undefined) ||\n [];\n\n // Change blur state to add opacity on the non highlighted items in the pie chart\n chart?.setOption({\n series: allChartOptionSeries?.map(\n (seriesItem: Record<string, unknown>) => ({\n ...seriesItem,\n blur: {\n itemStyle: {\n opacity: isDownplay ? 1 : 0.3,\n },\n label: {\n opacity: isDownplay ? 1 : 0.3,\n },\n },\n }),\n ),\n });\n\n // The dataIndex that we want to dispatch can be found in the dataset[0] source array, where the first item is the name of the series\n const chartOptionDataset =\n currentChartOptions?.dataset as EChartsOption['dataset'];\n const datasetArray = Array.isArray(chartOptionDataset)\n ? chartOptionDataset\n : [chartOptionDataset];\n const sourceArray = datasetArray?.[0]?.source as unknown[][];\n\n // Find the dataIndexes that we want to dispatch\n const currentDataSeriesIndexes = currentSeriesToDispatch.map((series) => {\n const index = sourceArray?.findIndex((item) => item[0] === series.name) - 1;\n return index;\n });\n\n if (action === 'highlight') {\n // Downplay other data indexes to make sure the other slices are not highlighted\n const otherSeriesIndexes = sourceArray\n .map((_, index) => index)\n .filter((dataIndex) => !currentDataSeriesIndexes.includes(dataIndex));\n\n chart?.dispatchAction({\n seriesIndex: [0], // pie charts only has one series so seriesIndex is always 0\n dataIndex: otherSeriesIndexes,\n type: 'downplay',\n });\n }\n\n chart?.dispatchAction({\n seriesIndex: [0], // pie charts only has one series so otherSeriesIndexes is always 0\n dataIndex: currentDataSeriesIndexes,\n type: action,\n });\n};\n\n/**\n * Highlight or downplay the series in the chart to toggle between emphasized and non-emphasized state\n */\nconst highlightOrDownplaySeries = (\n chartRef: React.RefObject<HTMLDivElement | null>,\n series: { name: string; color: string }[],\n currentSelectedSeries: Record<string, boolean>,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n) => {\n const hasOnlyOneSeries = series.length === 1;\n\n const isOnlyOneSeriesSelected =\n Object.values(currentSelectedSeries).filter(Boolean).length === 1;\n\n if (\n isOnlyOneSeriesSelected ||\n currentSeriesToDispatch.length === 0 ||\n chartRef.current === null ||\n hasOnlyOneSeries\n ) {\n return;\n }\n\n const chart = getInstanceByDom(chartRef.current);\n\n if (!chart) {\n return;\n }\n const currentChartOptions = chart.getOption();\n\n const seriesType = (\n currentChartOptions?.series as Record<string, unknown>[]\n )?.[0]?.type;\n\n if (seriesType === 'pie') {\n highlightOrDownplayPieSlices(\n chart,\n currentSeriesToDispatch,\n action,\n currentChartOptions,\n );\n } else {\n highlightOrDownplayLineAndBarSeries(\n chart,\n currentSeriesToDispatch,\n action,\n currentChartOptions,\n );\n }\n};\n\nexport { highlightOrDownplaySeries };\n"]}
1
+ {"version":3,"file":"legend-utils.js","sourceRoot":"","sources":["../../../../src/charts/utils/legend-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAGL,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAkB,EAAE,EAAE;IAC5D,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,UAAU,GAAI,MAAM,CAAC,MAAgC,IAAI,EAAE,CAAC;IAElE,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,WAAmB,EAAE,EAAE;QAClD,KAAK,CAAC,cAAc,CAAC;YACnB,WAAW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ACD,OAAO;IACT,CAAC;IAED,MAAM,KAAK,GAAG,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAEjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IACD,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAE9C,MAAM,UAAU,GAAG,MAAA,MACjB,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,MACtB,0CAAG,CAAC,CAAC,0CAAE,IAAI,CAAC;IAEb,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;QACzB,4BAA4B,CAC1B,KAAK,EACL,uBAAuB,EACvB,MAAM,EACN,mBAAmB,CACpB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,mCAAmC,CACjC,KAAK,EACL,uBAAuB,EACvB,MAAM,EACN,mBAAmB,CACpB,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,OAAO,EAAE,yBAAyB,EAAE,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 {\n type EChartsOption,\n type EChartsType,\n getInstanceByDom,\n} from 'echarts';\n\nexport const resetAllSeriesHighlight = (chart: EChartsType) => {\n const option = chart.getOption();\n const seriesList = (option.series as unknown[] | undefined) || [];\n\n seriesList.forEach((_series, seriesIndex: number) => {\n chart.dispatchAction({\n seriesIndex,\n type: 'downplay',\n });\n });\n};\n\nconst highlightOrDownplayLineAndBarSeries = (\n chart: EChartsType,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n currentChartOptions: ReturnType<EChartsType['getOption']>,\n) => {\n const isDownplay = action === 'downplay';\n const allChartOptionSeries =\n (currentChartOptions?.series as Record<string, unknown>[] | undefined) ||\n [];\n\n // Change emphasis state to add opacity on the non highlighted items\n chart?.setOption({\n series: allChartOptionSeries?.map(\n (seriesItem: Record<string, unknown>) => ({\n ...seriesItem,\n emphasis: {\n ...(seriesItem.emphasis as Record<string, unknown>),\n disabled: isDownplay,\n },\n }),\n ),\n });\n\n const seriesWithSeriesIndex = allChartOptionSeries\n // Since the series index does not exist in the data we extract it from the series index\n ?.map((seriesItem, index) => ({\n ...seriesItem,\n seriesIndex: index,\n }))\n // Select the series that are in the currentSeriesToDispatch array\n ?.filter((seriesItem: Record<string, unknown>) =>\n currentSeriesToDispatch.some((series) => series.name === seriesItem.name),\n );\n\n if (!seriesWithSeriesIndex.length) {\n return;\n }\n\n chart?.dispatchAction({\n seriesIndex: seriesWithSeriesIndex.map((series) => series.seriesIndex),\n type: action,\n });\n};\n\n/**\n * Highlight or downplay pie chart dataset item\n */\nconst highlightOrDownplayPieSlices = (\n chart: EChartsType,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n currentChartOptions: ReturnType<EChartsType['getOption']>,\n) => {\n const isDownplay = action === 'downplay';\n const allChartOptionSeries =\n (currentChartOptions?.series as Record<string, unknown>[] | undefined) ||\n [];\n\n // Change blur state to add opacity on the non highlighted items in the pie chart\n chart?.setOption({\n series: allChartOptionSeries?.map(\n (seriesItem: Record<string, unknown>) => ({\n ...seriesItem,\n blur: {\n itemStyle: {\n opacity: isDownplay ? 1 : 0.3,\n },\n label: {\n opacity: isDownplay ? 1 : 0.3,\n },\n },\n }),\n ),\n });\n\n // The dataIndex that we want to dispatch can be found in the dataset[0] source array, where the first item is the name of the series\n const chartOptionDataset =\n currentChartOptions?.dataset as EChartsOption['dataset'];\n const datasetArray = Array.isArray(chartOptionDataset)\n ? chartOptionDataset\n : [chartOptionDataset];\n const sourceArray = datasetArray?.[0]?.source as unknown[][];\n\n // Find the dataIndexes that we want to dispatch\n const currentDataSeriesIndexes = currentSeriesToDispatch.map((series) => {\n const index = sourceArray?.findIndex((item) => item[0] === series.name) - 1;\n return index;\n });\n\n if (action === 'highlight') {\n // Downplay other data indexes to make sure the other slices are not highlighted\n const otherSeriesIndexes = sourceArray\n .map((_row, index) => index)\n .filter((dataIndex) => !currentDataSeriesIndexes.includes(dataIndex));\n\n chart?.dispatchAction({\n seriesIndex: [0], // pie charts only has one series so seriesIndex is always 0\n dataIndex: otherSeriesIndexes,\n type: 'downplay',\n });\n }\n\n chart?.dispatchAction({\n seriesIndex: [0], // pie charts only has one series so otherSeriesIndexes is always 0\n dataIndex: currentDataSeriesIndexes,\n type: action,\n });\n};\n\n/**\n * Highlight or downplay the series in the chart to toggle between emphasized and non-emphasized state\n */\nconst highlightOrDownplaySeries = (\n chartRef: React.RefObject<HTMLDivElement | null>,\n series: { name: string; color: string }[],\n currentSelectedSeries: Record<string, boolean>,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n) => {\n const hasOnlyOneSeries = series.length === 1;\n\n const isOnlyOneSeriesSelected =\n Object.values(currentSelectedSeries).filter(Boolean).length === 1;\n\n if (\n isOnlyOneSeriesSelected ||\n currentSeriesToDispatch.length === 0 ||\n chartRef.current === null ||\n hasOnlyOneSeries\n ) {\n return;\n }\n\n const chart = getInstanceByDom(chartRef.current);\n\n if (!chart) {\n return;\n }\n const currentChartOptions = chart.getOption();\n\n const seriesType = (\n currentChartOptions?.series as Record<string, unknown>[]\n )?.[0]?.type;\n\n if (seriesType === 'pie') {\n highlightOrDownplayPieSlices(\n chart,\n currentSeriesToDispatch,\n action,\n currentChartOptions,\n );\n } else {\n highlightOrDownplayLineAndBarSeries(\n chart,\n currentSeriesToDispatch,\n action,\n currentChartOptions,\n );\n }\n};\n\nexport { highlightOrDownplaySeries };\n"]}
@@ -94,7 +94,7 @@ export const mergeXAxis = (xAxis, theme = 'light') => {
94
94
  return [];
95
95
  }
96
96
  if (Array.isArray(xAxis)) {
97
- return xAxis.map((x) => mergeXAxis(x, theme));
97
+ return xAxis.map((axis) => mergeXAxis(axis, theme));
98
98
  }
99
99
  const baseXAxis = Object.assign(Object.assign({}, xAxis), { splitLine: Object.assign({ show: false }, xAxis === null || xAxis === void 0 ? void 0 : xAxis.splitLine), axisLine: Object.assign({ lineStyle: Object.assign({}, (_a = xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisLine) === null || _a === void 0 ? void 0 : _a.lineStyle) }, xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisLine), axisTick: Object.assign(Object.assign(Object.assign({}, xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisTick), { lineStyle: Object.assign({}, (_b = xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisTick) === null || _b === void 0 ? void 0 : _b.lineStyle), show: true }), xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisTick), axisLabel: Object.assign({ margin: 16, formatter: {
100
100
  day: '{dd} {MMM}',
@@ -129,7 +129,7 @@ export const mergeYAxis = (yAxis, theme = 'light') => {
129
129
  return [];
130
130
  }
131
131
  if (Array.isArray(yAxis)) {
132
- return yAxis.map((y) => mergeYAxis(y, theme));
132
+ return yAxis.map((axis) => mergeYAxis(axis, theme));
133
133
  }
134
134
  const baseYAxis = Object.assign(Object.assign({}, yAxis), { axisLine: Object.assign(Object.assign({}, yAxis === null || yAxis === void 0 ? void 0 : yAxis.axisLine), { lineStyle: Object.assign({}, (_a = yAxis === null || yAxis === void 0 ? void 0 : yAxis.axisLine) === null || _a === void 0 ? void 0 : _a.lineStyle), show: true }), axisTick: Object.assign(Object.assign({ show: false }, yAxis === null || yAxis === void 0 ? void 0 : yAxis.axisTick), { lineStyle: Object.assign({ width: 1 }, (_b = yAxis === null || yAxis === void 0 ? void 0 : yAxis.axisTick) === null || _b === void 0 ? void 0 : _b.lineStyle) }), axisLabel: Object.assign({ margin: 8, overflow: 'truncate' }, yAxis === null || yAxis === void 0 ? void 0 : yAxis.axisLabel), splitLine: Object.assign({ show: true }, yAxis === null || yAxis === void 0 ? void 0 : yAxis.splitLine) });
135
135
  if (yAxis.type === 'time') {