@neo4j-ndl/react-charts 1.1.0 → 1.1.2

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 (185) hide show
  1. package/lib/cjs/charts/Chart.js +56 -462
  2. package/lib/cjs/charts/Chart.js.map +1 -1
  3. package/lib/cjs/charts/ChartContainer.js +71 -0
  4. package/lib/cjs/charts/ChartContainer.js.map +1 -0
  5. package/lib/cjs/charts/ChartEmpty.js.map +1 -1
  6. package/lib/cjs/charts/ChartRender.js +97 -0
  7. package/lib/cjs/charts/ChartRender.js.map +1 -0
  8. package/lib/cjs/charts/ChartTooltip.js.map +1 -1
  9. package/lib/cjs/charts/Legend.js +32 -246
  10. package/lib/cjs/charts/Legend.js.map +1 -1
  11. package/lib/cjs/charts/LegendItem.js +68 -0
  12. package/lib/cjs/charts/LegendItem.js.map +1 -0
  13. package/lib/cjs/charts/LegendLayout.js +363 -0
  14. package/lib/cjs/charts/LegendLayout.js.map +1 -0
  15. package/lib/cjs/charts/hooks/use-chart-instance.js +133 -0
  16. package/lib/cjs/charts/hooks/use-chart-instance.js.map +1 -0
  17. package/lib/cjs/charts/hooks/use-chart-option.js +79 -0
  18. package/lib/cjs/charts/hooks/use-chart-option.js.map +1 -0
  19. package/lib/cjs/charts/hooks/use-chart-refs.js +52 -0
  20. package/lib/cjs/charts/hooks/use-chart-refs.js.map +1 -0
  21. package/lib/cjs/charts/hooks/use-chart-zoom.js +117 -0
  22. package/lib/cjs/charts/hooks/use-chart-zoom.js.map +1 -0
  23. package/lib/cjs/charts/hooks/use-legend-interactions.js +149 -0
  24. package/lib/cjs/charts/hooks/use-legend-interactions.js.map +1 -0
  25. package/lib/cjs/charts/hooks/use-legend-series.js +181 -0
  26. package/lib/cjs/charts/hooks/use-legend-series.js.map +1 -0
  27. package/lib/cjs/charts/hooks/use-legend-visibility.js +91 -0
  28. package/lib/cjs/charts/hooks/use-legend-visibility.js.map +1 -0
  29. package/lib/cjs/charts/index.js +1 -1
  30. package/lib/cjs/charts/index.js.map +1 -1
  31. package/lib/cjs/charts/tests/chart-test-utils.js +56 -9
  32. package/lib/cjs/charts/tests/chart-test-utils.js.map +1 -1
  33. package/lib/cjs/charts/themes/ndl-echarts-theme.js.map +1 -1
  34. package/lib/cjs/charts/{aria-description.js → utils/aria-description.js} +4 -45
  35. package/lib/cjs/charts/utils/aria-description.js.map +1 -0
  36. package/lib/cjs/charts/utils/build-chart-option.js +74 -0
  37. package/lib/cjs/charts/utils/build-chart-option.js.map +1 -0
  38. package/lib/cjs/charts/utils/chart-tooltip-formatter.js +86 -0
  39. package/lib/cjs/charts/utils/chart-tooltip-formatter.js.map +1 -0
  40. package/lib/cjs/charts/utils/chart-types.js.map +1 -0
  41. package/lib/cjs/charts/utils/defaults.js.map +1 -0
  42. package/lib/cjs/charts/{utils.js → utils/format-utils.js} +3 -19
  43. package/lib/cjs/charts/utils/format-utils.js.map +1 -0
  44. package/lib/cjs/charts/utils/legend-layout.js +65 -0
  45. package/lib/cjs/charts/utils/legend-layout.js.map +1 -0
  46. package/lib/cjs/charts/{legend-utils.js → utils/legend-utils.js} +1 -78
  47. package/lib/cjs/charts/utils/legend-utils.js.map +1 -0
  48. package/lib/cjs/charts/utils/threshold.js +114 -0
  49. package/lib/cjs/charts/utils/threshold.js.map +1 -0
  50. package/lib/cjs/charts/{user-option-utils.js → utils/user-option-utils.js} +7 -16
  51. package/lib/cjs/charts/utils/user-option-utils.js.map +1 -0
  52. package/lib/esm/charts/Chart.js +50 -457
  53. package/lib/esm/charts/Chart.js.map +1 -1
  54. package/lib/esm/charts/ChartContainer.js +67 -0
  55. package/lib/esm/charts/ChartContainer.js.map +1 -0
  56. package/lib/esm/charts/ChartEmpty.js.map +1 -1
  57. package/lib/esm/charts/ChartRender.js +93 -0
  58. package/lib/esm/charts/ChartRender.js.map +1 -0
  59. package/lib/esm/charts/ChartTooltip.js.map +1 -1
  60. package/lib/esm/charts/Legend.js +32 -243
  61. package/lib/esm/charts/Legend.js.map +1 -1
  62. package/lib/esm/charts/LegendItem.js +61 -0
  63. package/lib/esm/charts/LegendItem.js.map +1 -0
  64. package/lib/esm/charts/LegendLayout.js +323 -0
  65. package/lib/esm/charts/LegendLayout.js.map +1 -0
  66. package/lib/esm/charts/hooks/use-chart-instance.js +128 -0
  67. package/lib/esm/charts/hooks/use-chart-instance.js.map +1 -0
  68. package/lib/esm/charts/hooks/use-chart-option.js +76 -0
  69. package/lib/esm/charts/hooks/use-chart-option.js.map +1 -0
  70. package/lib/esm/charts/hooks/use-chart-refs.js +48 -0
  71. package/lib/esm/charts/hooks/use-chart-refs.js.map +1 -0
  72. package/lib/esm/charts/hooks/use-chart-zoom.js +114 -0
  73. package/lib/esm/charts/hooks/use-chart-zoom.js.map +1 -0
  74. package/lib/esm/charts/hooks/use-legend-interactions.js +145 -0
  75. package/lib/esm/charts/hooks/use-legend-interactions.js.map +1 -0
  76. package/lib/esm/charts/hooks/use-legend-series.js +178 -0
  77. package/lib/esm/charts/hooks/use-legend-series.js.map +1 -0
  78. package/lib/esm/charts/hooks/use-legend-visibility.js +87 -0
  79. package/lib/esm/charts/hooks/use-legend-visibility.js.map +1 -0
  80. package/lib/esm/charts/index.js +1 -1
  81. package/lib/esm/charts/index.js.map +1 -1
  82. package/lib/esm/charts/tests/chart-test-utils.js +53 -8
  83. package/lib/esm/charts/tests/chart-test-utils.js.map +1 -1
  84. package/lib/esm/charts/themes/ndl-echarts-theme.js.map +1 -1
  85. package/lib/esm/charts/{aria-description.js → utils/aria-description.js} +4 -45
  86. package/lib/esm/charts/utils/aria-description.js.map +1 -0
  87. package/lib/esm/charts/utils/build-chart-option.js +69 -0
  88. package/lib/esm/charts/utils/build-chart-option.js.map +1 -0
  89. package/lib/esm/charts/utils/chart-tooltip-formatter.js +82 -0
  90. package/lib/esm/charts/utils/chart-tooltip-formatter.js.map +1 -0
  91. package/lib/esm/charts/utils/chart-types.js.map +1 -0
  92. package/lib/esm/charts/utils/defaults.js.map +1 -0
  93. package/lib/esm/charts/{utils.js → utils/format-utils.js} +2 -17
  94. package/lib/esm/charts/utils/format-utils.js.map +1 -0
  95. package/lib/esm/charts/utils/legend-layout.js +59 -0
  96. package/lib/esm/charts/utils/legend-layout.js.map +1 -0
  97. package/lib/esm/charts/{legend-utils.js → utils/legend-utils.js} +1 -75
  98. package/lib/esm/charts/utils/legend-utils.js.map +1 -0
  99. package/lib/esm/charts/utils/threshold.js +106 -0
  100. package/lib/esm/charts/utils/threshold.js.map +1 -0
  101. package/lib/esm/charts/{user-option-utils.js → utils/user-option-utils.js} +5 -14
  102. package/lib/esm/charts/utils/user-option-utils.js.map +1 -0
  103. package/lib/types/charts/Chart.d.ts +2 -2
  104. package/lib/types/charts/Chart.d.ts.map +1 -1
  105. package/lib/{esm/charts/types.js → types/charts/ChartContainer.d.ts} +14 -1
  106. package/lib/types/charts/ChartContainer.d.ts.map +1 -0
  107. package/lib/types/charts/ChartEmpty.d.ts +1 -1
  108. package/lib/types/charts/ChartEmpty.d.ts.map +1 -1
  109. package/lib/types/charts/ChartRender.d.ts +36 -0
  110. package/lib/types/charts/ChartRender.d.ts.map +1 -0
  111. package/lib/types/charts/ChartTooltip.d.ts +1 -1
  112. package/lib/types/charts/ChartTooltip.d.ts.map +1 -1
  113. package/lib/types/charts/Legend.d.ts +15 -3
  114. package/lib/types/charts/Legend.d.ts.map +1 -1
  115. package/lib/{cjs/charts/types.js → types/charts/LegendItem.d.ts} +10 -3
  116. package/lib/types/charts/LegendItem.d.ts.map +1 -0
  117. package/lib/types/charts/LegendLayout.d.ts +38 -0
  118. package/lib/types/charts/LegendLayout.d.ts.map +1 -0
  119. package/lib/types/charts/hooks/use-chart-instance.d.ts +62 -0
  120. package/lib/types/charts/hooks/use-chart-instance.d.ts.map +1 -0
  121. package/lib/types/charts/hooks/use-chart-option.d.ts +48 -0
  122. package/lib/types/charts/hooks/use-chart-option.d.ts.map +1 -0
  123. package/lib/types/charts/hooks/use-chart-refs.d.ts +38 -0
  124. package/lib/types/charts/hooks/use-chart-refs.d.ts.map +1 -0
  125. package/lib/types/charts/hooks/use-chart-zoom.d.ts +36 -0
  126. package/lib/types/charts/hooks/use-chart-zoom.d.ts.map +1 -0
  127. package/lib/types/charts/hooks/use-legend-interactions.d.ts +56 -0
  128. package/lib/types/charts/hooks/use-legend-interactions.d.ts.map +1 -0
  129. package/lib/types/charts/hooks/use-legend-series.d.ts +42 -0
  130. package/lib/types/charts/hooks/use-legend-series.d.ts.map +1 -0
  131. package/lib/types/charts/hooks/use-legend-visibility.d.ts +24 -0
  132. package/lib/types/charts/hooks/use-legend-visibility.d.ts.map +1 -0
  133. package/lib/types/charts/index.d.ts +2 -2
  134. package/lib/types/charts/index.d.ts.map +1 -1
  135. package/lib/types/charts/tests/chart-test-utils.d.ts +7 -1
  136. package/lib/types/charts/tests/chart-test-utils.d.ts.map +1 -1
  137. package/lib/types/charts/themes/ndl-echarts-theme.d.ts +1 -1
  138. package/lib/types/charts/themes/ndl-echarts-theme.d.ts.map +1 -1
  139. package/lib/types/charts/utils/aria-description.d.ts.map +1 -0
  140. package/lib/types/charts/utils/build-chart-option.d.ts +52 -0
  141. package/lib/types/charts/utils/build-chart-option.d.ts.map +1 -0
  142. package/lib/types/charts/utils/chart-tooltip-formatter.d.ts +37 -0
  143. package/lib/types/charts/utils/chart-tooltip-formatter.d.ts.map +1 -0
  144. package/lib/types/charts/{chart-types.d.ts → utils/chart-types.d.ts} +23 -22
  145. package/lib/types/charts/utils/chart-types.d.ts.map +1 -0
  146. package/lib/types/charts/utils/defaults.d.ts.map +1 -0
  147. package/lib/types/charts/{utils.d.ts → utils/format-utils.d.ts} +2 -4
  148. package/lib/types/charts/utils/format-utils.d.ts.map +1 -0
  149. package/lib/types/charts/utils/legend-layout.d.ts +37 -0
  150. package/lib/types/charts/utils/legend-layout.d.ts.map +1 -0
  151. package/lib/types/charts/{legend-utils.d.ts → utils/legend-utils.d.ts} +1 -11
  152. package/lib/types/charts/utils/legend-utils.d.ts.map +1 -0
  153. package/lib/types/charts/utils/threshold.d.ts +45 -0
  154. package/lib/types/charts/utils/threshold.d.ts.map +1 -0
  155. package/lib/types/charts/utils/user-option-utils.d.ts.map +1 -0
  156. package/package.json +3 -3
  157. package/lib/cjs/charts/aria-description.js.map +0 -1
  158. package/lib/cjs/charts/chart-types.js.map +0 -1
  159. package/lib/cjs/charts/defaults.js.map +0 -1
  160. package/lib/cjs/charts/legend-utils.js.map +0 -1
  161. package/lib/cjs/charts/types.js.map +0 -1
  162. package/lib/cjs/charts/user-option-utils.js.map +0 -1
  163. package/lib/cjs/charts/utils.js.map +0 -1
  164. package/lib/esm/charts/aria-description.js.map +0 -1
  165. package/lib/esm/charts/chart-types.js.map +0 -1
  166. package/lib/esm/charts/defaults.js.map +0 -1
  167. package/lib/esm/charts/legend-utils.js.map +0 -1
  168. package/lib/esm/charts/types.js.map +0 -1
  169. package/lib/esm/charts/user-option-utils.js.map +0 -1
  170. package/lib/esm/charts/utils.js.map +0 -1
  171. package/lib/types/charts/aria-description.d.ts.map +0 -1
  172. package/lib/types/charts/chart-types.d.ts.map +0 -1
  173. package/lib/types/charts/defaults.d.ts.map +0 -1
  174. package/lib/types/charts/legend-utils.d.ts.map +0 -1
  175. package/lib/types/charts/types.d.ts +0 -44
  176. package/lib/types/charts/types.d.ts.map +0 -1
  177. package/lib/types/charts/user-option-utils.d.ts.map +0 -1
  178. package/lib/types/charts/utils.d.ts.map +0 -1
  179. /package/lib/cjs/charts/{chart-types.js → utils/chart-types.js} +0 -0
  180. /package/lib/cjs/charts/{defaults.js → utils/defaults.js} +0 -0
  181. /package/lib/esm/charts/{chart-types.js → utils/chart-types.js} +0 -0
  182. /package/lib/esm/charts/{defaults.js → utils/defaults.js} +0 -0
  183. /package/lib/types/charts/{aria-description.d.ts → utils/aria-description.d.ts} +0 -0
  184. /package/lib/types/charts/{defaults.d.ts → utils/defaults.d.ts} +0 -0
  185. /package/lib/types/charts/{user-option-utils.d.ts → utils/user-option-utils.d.ts} +0 -0
@@ -0,0 +1,87 @@
1
+ /**
2
+ *
3
+ * Copyright (c) "Neo4j"
4
+ * Neo4j Sweden AB [http://neo4j.com]
5
+ *
6
+ * This file is part of Neo4j.
7
+ *
8
+ * Neo4j is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+ import { getInstanceByDom } from 'echarts';
22
+ import { useCallback } from 'react';
23
+ import { isThresholdLine } from '../utils/threshold';
24
+ import { useChartRefsContext } from './use-chart-refs';
25
+ export const useLegendVisibility = (selectedSeries) => {
26
+ const { chartEchartRef } = useChartRefsContext();
27
+ const setOnlyVisible = useCallback((name) => {
28
+ if (chartEchartRef.current === null) {
29
+ return;
30
+ }
31
+ const chart = getInstanceByDom(chartEchartRef.current);
32
+ chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
33
+ name: name,
34
+ type: 'legendSelect',
35
+ });
36
+ const otherNames = Object.keys(selectedSeries).filter((n) => n !== name);
37
+ otherNames.forEach((name) => {
38
+ if (isThresholdLine(name)) {
39
+ return;
40
+ }
41
+ chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
42
+ name: name,
43
+ type: 'legendUnSelect',
44
+ });
45
+ });
46
+ }, [chartEchartRef, selectedSeries]);
47
+ const setAllVisible = useCallback(() => {
48
+ if (chartEchartRef.current === null) {
49
+ return;
50
+ }
51
+ const chart = getInstanceByDom(chartEchartRef.current);
52
+ chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
53
+ type: 'legendAllSelect',
54
+ });
55
+ }, [chartEchartRef]);
56
+ /**
57
+ * Toggle the visibility of a legend series
58
+ *
59
+ * The toggle logic depends on the current state of the series:
60
+ * - If only the legend series that was selected is visible: show all series
61
+ * - If all series are visible: hide all except the series that was selected
62
+ * - Otherwise: toggle the legend series
63
+ *
64
+ * The isOnlyVisible and isAllSeriesSelected states can't be calculated in this
65
+ * function since different legend types require different logic.
66
+ */
67
+ const toggleLegendVisibility = useCallback((name, isAllSeriesSelected, isOnlyVisible) => {
68
+ if (chartEchartRef.current === null || name === undefined) {
69
+ return;
70
+ }
71
+ if (isOnlyVisible) {
72
+ setAllVisible();
73
+ }
74
+ else if (isAllSeriesSelected) {
75
+ setOnlyVisible(name);
76
+ }
77
+ else {
78
+ const chart = getInstanceByDom(chartEchartRef.current);
79
+ chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
80
+ name: name,
81
+ type: 'legendToggleSelect',
82
+ });
83
+ }
84
+ }, [chartEchartRef, setOnlyVisible, setAllVisible]);
85
+ return { toggleLegendVisibility };
86
+ };
87
+ //# sourceMappingURL=use-legend-visibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-legend-visibility.js","sourceRoot":"","sources":["../../../../src/charts/hooks/use-legend-visibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,cAAuC,EACvC,EAAE;IACF,MAAM,EAAE,cAAc,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAEjD,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,IAAwB,EAAE,EAAE;QAC3B,IAAI,cAAc,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YAC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AC;QAED,IAAI,aAAa,EAAE,CAAC;YAClB,aAAa,EAAE,CAAC;QAClB,CAAC;aAAM,IAAI,mBAAmB,EAAE,CAAC;YAC/B,cAAc,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,GAAG,gBAAgB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAEvD,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,CAAC;gBACpB,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,oBAAoB;aAC3B,CAAC,CAAC;QACL,CAAC;IACH,CAAC,EACD,CAAC,cAAc,EAAE,cAAc,EAAE,aAAa,CAAC,CAChD,CAAC;IAEF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AACpC,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 { getInstanceByDom } from 'echarts';\nimport { useCallback } from 'react';\n\nimport { isThresholdLine } from '../utils/threshold';\nimport { useChartRefsContext } from './use-chart-refs';\n\nexport const useLegendVisibility = (\n selectedSeries: Record<string, boolean>,\n) => {\n const { chartEchartRef } = useChartRefsContext();\n\n const setOnlyVisible = useCallback(\n (name: string | undefined) => {\n if (chartEchartRef.current === null) {\n return;\n }\n const chart = getInstanceByDom(chartEchartRef.current);\n\n chart?.dispatchAction({\n name: name,\n type: 'legendSelect',\n });\n\n const otherNames = Object.keys(selectedSeries).filter((n) => n !== name);\n otherNames.forEach((name) => {\n if (isThresholdLine(name)) {\n return;\n }\n\n chart?.dispatchAction({\n name: name,\n type: 'legendUnSelect',\n });\n });\n },\n [chartEchartRef, selectedSeries],\n );\n\n const setAllVisible = useCallback(() => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef.current);\n\n chart?.dispatchAction({\n type: 'legendAllSelect',\n });\n }, [chartEchartRef]);\n\n /**\n * Toggle the visibility of a legend series\n *\n * The toggle logic depends on the current state of the series:\n * - If only the legend series that was selected is visible: show all series\n * - If all series are visible: hide all except the series that was selected\n * - Otherwise: toggle the legend series\n *\n * The isOnlyVisible and isAllSeriesSelected states can't be calculated in this\n * function since different legend types require different logic.\n */\n const toggleLegendVisibility = useCallback(\n (\n name: string | undefined,\n isAllSeriesSelected: boolean,\n isOnlyVisible: boolean,\n ) => {\n if (chartEchartRef.current === null || name === undefined) {\n return;\n }\n\n if (isOnlyVisible) {\n setAllVisible();\n } else if (isAllSeriesSelected) {\n setOnlyVisible(name);\n } else {\n const chart = getInstanceByDom(chartEchartRef.current);\n\n chart?.dispatchAction({\n name: name,\n type: 'legendToggleSelect',\n });\n }\n },\n [chartEchartRef, setOnlyVisible, setAllVisible],\n );\n\n return { toggleLegendVisibility };\n};\n"]}
@@ -21,5 +21,5 @@
21
21
  export * from './Chart';
22
22
  export * from './ChartEmpty';
23
23
  // Export utils and types that were previously exported from Chart.tsx. Not sure that they are needed, but keeping them to not be breaking.
24
- export { defaultThresholdLineSeriesOption } from './defaults';
24
+ export { defaultThresholdLineSeriesOption } from './utils/defaults';
25
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/charts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,2IAA2I;AAC3I,OAAO,EAAE,gCAAgC,EAAE,MAAM,YAAY,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\nexport * from './Chart';\nexport * from './ChartEmpty';\n// Export utils and types that were previously exported from Chart.tsx. Not sure that they are needed, but keeping them to not be breaking.\nexport { defaultThresholdLineSeriesOption } from './defaults';\nexport {\n type ChartEmptyProps,\n type ThresholdLineSeriesOption,\n type Values,\n type SeriesOption,\n type EchartsSeries,\n type NeedleSeries,\n} from './chart-types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/charts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,2IAA2I;AAC3I,OAAO,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,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\nexport * from './Chart';\nexport * from './ChartEmpty';\n// Export utils and types that were previously exported from Chart.tsx. Not sure that they are needed, but keeping them to not be breaking.\nexport { defaultThresholdLineSeriesOption } from './utils/defaults';\nexport {\n type ChartEmptyProps,\n type ThresholdLineSeriesOption,\n type Values,\n type SeriesOption,\n type EchartsSeries,\n type NeedleSeries,\n} from './utils/chart-types';\n"]}
@@ -127,7 +127,6 @@ export const multiSeriesChartProps = {
127
127
  },
128
128
  legend: {
129
129
  show: true,
130
- wrappingType: 'wrapping',
131
130
  },
132
131
  option: {},
133
132
  series: [
@@ -174,14 +173,58 @@ export const pieChartWithTooltipFormatter = ({ seriesName, value, rgbSeriesColor
174
173
  export const barChartWithTooltipFormatter = ({ seriesName, value, rgbSeriesColor, chartProps, width = '100%', height = '400px', }) => (_jsx("div", { style: { height, width }, children: _jsx(ChartWrapperWithTooltipFormatter, Object.assign({}, barChartProps(seriesName, value, rgbSeriesColor), chartProps)) }));
175
174
  export const barChart = ({ seriesName, value, rgbSeriesColor, chartProps, width = '100%', height = '400px', }) => (_jsx("div", { style: { height, width }, children: _jsx(Chart, Object.assign({}, barChartProps(seriesName, value, rgbSeriesColor), chartProps)) }));
176
175
  export const expectChartElementVisible = (page) => __awaiter(void 0, void 0, void 0, function* () {
177
- yield expect(page.locator('svg')).toBeVisible();
176
+ yield expect(page.locator('svg').first()).toBeVisible();
178
177
  yield expect(page.locator('.ndl-chart-legend')).toBeVisible();
179
178
  });
179
+ export const startLegendMeasuringObserver = (page_1, ...args_1) => __awaiter(void 0, [page_1, ...args_1], void 0, function* (page, options = {}) {
180
+ yield page.evaluate(({ chartLayoutSelector }) => {
181
+ var _a;
182
+ const windowWithLegendObserver = window;
183
+ const legendElement = document.querySelector('.ndl-chart-legend');
184
+ const chartLayout = chartLayoutSelector
185
+ ? document.querySelector(chartLayoutSelector)
186
+ : undefined;
187
+ windowWithLegendObserver.__chartHeightDuringLegendMeasurement = undefined;
188
+ windowWithLegendObserver.__legendMeasuringClassWasAdded = false;
189
+ (_a = windowWithLegendObserver.__legendMeasuringObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
190
+ if (!legendElement) {
191
+ return;
192
+ }
193
+ const observer = new MutationObserver(() => {
194
+ if (!legendElement.classList.contains('ndl-chart-legend-calculating')) {
195
+ return;
196
+ }
197
+ windowWithLegendObserver.__legendMeasuringClassWasAdded = true;
198
+ if (chartLayout &&
199
+ windowWithLegendObserver.__chartHeightDuringLegendMeasurement ===
200
+ undefined) {
201
+ windowWithLegendObserver.__chartHeightDuringLegendMeasurement =
202
+ chartLayout.getBoundingClientRect().height;
203
+ }
204
+ });
205
+ observer.observe(legendElement, {
206
+ attributeFilter: ['class'],
207
+ attributes: true,
208
+ });
209
+ windowWithLegendObserver.__legendMeasuringObserver = observer;
210
+ }, options);
211
+ });
212
+ export const getLegendMeasuringObserverResult = (page) => __awaiter(void 0, void 0, void 0, function* () {
213
+ return page.evaluate(() => {
214
+ var _a, _b;
215
+ const windowWithLegendObserver = window;
216
+ (_a = windowWithLegendObserver.__legendMeasuringObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
217
+ return {
218
+ chartHeightDuringMeasurement: windowWithLegendObserver.__chartHeightDuringLegendMeasurement,
219
+ didAddMeasuringClass: (_b = windowWithLegendObserver.__legendMeasuringClassWasAdded) !== null && _b !== void 0 ? _b : false,
220
+ };
221
+ });
222
+ });
180
223
  const SELECTORS = {
181
- CHECKMARK: '.ndl-chart-legend-item-square-checkmark',
182
- DESELECTED: '.ndl-chart-legend-item-deselected',
183
- seriesCheckmark: (name) => `[data-labelname="${name}"] .ndl-chart-legend-item-square-checkmark`,
184
- seriesDeselected: (name) => `[data-labelname="${name}"].ndl-chart-legend-item-deselected`,
224
+ CHECKMARK: '.ndl-chart-legend > .ndl-chart-legend-item .ndl-chart-legend-item-square-checkmark',
225
+ DESELECTED: '.ndl-chart-legend > .ndl-chart-legend-item-deselected',
226
+ seriesCheckmark: (name) => `.ndl-chart-legend > [data-labelname="${name}"] .ndl-chart-legend-item-square-checkmark`,
227
+ seriesDeselected: (name) => `.ndl-chart-legend > [data-labelname="${name}"].ndl-chart-legend-item-deselected`,
185
228
  };
186
229
  const getGraphPaletteColorFromSeriesIndex = (index) => {
187
230
  const hexColor = tokens.categorical[index];
@@ -258,7 +301,7 @@ export const expectLegendSeriesToBeHighlightedInChart = (page, seriesNamesToBeHi
258
301
  export const expectLegendSeriesToBeVisibleInChart = (page, seriesNamesToBeVisible) => __awaiter(void 0, void 0, void 0, function* () {
259
302
  yield expect(page.locator('svg path').first()).toBeAttached();
260
303
  for (const name of seriesNamesToBeVisible) {
261
- const visibleLegendItem = page.locator(`[data-labelname="${name}"]`);
304
+ const visibleLegendItem = page.locator(`.ndl-chart-legend > [data-labelname="${name}"]`);
262
305
  if ((yield visibleLegendItem.count()) > 0) {
263
306
  yield expect(visibleLegendItem).not.toHaveClass(/ndl-chart-legend-item-deselected/);
264
307
  }
@@ -295,7 +338,9 @@ export const expectAllLegendsNeutral = (page) => __awaiter(void 0, void 0, void
295
338
  * This is needed to make sure the series has the correct color when looking for them in the chart in later steps.
296
339
  */
297
340
  export const clickSeries = (page, seriesName) => __awaiter(void 0, void 0, void 0, function* () {
298
- yield page.locator(`[data-labelname="${seriesName}"]`).click();
341
+ yield page
342
+ .locator(`.ndl-chart-legend > [data-labelname="${seriesName}"]`)
343
+ .click();
299
344
  yield page.hover('.ndl-chart');
300
345
  });
301
346
  export const expectFormattedTooltipToBeVisible = (page, seriesName, value, rgbSeriesColor) => __awaiter(void 0, void 0, void 0, function* () {
@@ -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,m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AAO,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 wrappingType: 'wrapping' as const,\n },\n option: {},\n series: [\n {\n encode: { x: 'day', y: 'first' },\n name: 'First Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'second' },\n name: 'Second Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'third' },\n name: 'Third Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'fourth' },\n name: 'Fourth Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'fifth' },\n name: 'Fifth Series',\n type: 'line' as const,\n },\n {\n encode: { x: 'day', y: 'sixth' },\n name: 'Sixth Series',\n type: 'line' as const,\n },\n ],\n xAxis: {\n type: 'category' as const,\n },\n yAxis: {\n type: 'value' as const,\n },\n};\n\nexport const multiSeriesChart = ({\n chartProps,\n width = '100%',\n height = '400px',\n}: {\n chartProps?: Partial<ComponentProps<typeof Chart>>;\n width?: string;\n height?: string;\n}) => (\n <div style={{ height, width }} className=\"ndl-chart\">\n <Chart {...multiSeriesChartProps} {...chartProps} />\n </div>\n);\n\nexport const pieChartWithTooltipFormatter = ({\n seriesName,\n value,\n rgbSeriesColor,\n chartProps,\n width = '100%',\n height = '400px',\n}: {\n chartProps?: Partial<ComponentProps<typeof Chart>>;\n width?: string;\n height?: string;\n seriesName: string;\n value: number;\n rgbSeriesColor: string;\n}) => (\n <div style={{ height, width }}>\n <ChartWrapperWithTooltipFormatter\n {...pieChartProps(seriesName, value, rgbSeriesColor)}\n {...chartProps}\n />\n </div>\n);\n\nexport const barChartWithTooltipFormatter = ({\n seriesName,\n value,\n rgbSeriesColor,\n chartProps,\n width = '100%',\n height = '400px',\n}: {\n chartProps?: Partial<ComponentProps<typeof Chart>>;\n width?: string;\n height?: string;\n seriesName: string;\n value: number;\n rgbSeriesColor: string;\n}) => (\n <div style={{ height, width }}>\n <ChartWrapperWithTooltipFormatter\n {...barChartProps(seriesName, value, rgbSeriesColor)}\n {...chartProps}\n />\n </div>\n);\n\nexport const 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')).toBeVisible();\n await expect(page.locator('.ndl-chart-legend')).toBeVisible();\n};\n\nconst SELECTORS = {\n CHECKMARK: '.ndl-chart-legend-item-square-checkmark',\n DESELECTED: '.ndl-chart-legend-item-deselected',\n seriesCheckmark: (name: string) =>\n `[data-labelname=\"${name}\"] .ndl-chart-legend-item-square-checkmark`,\n seriesDeselected: (name: string) =>\n `[data-labelname=\"${name}\"].ndl-chart-legend-item-deselected`,\n} as const;\n\nconst getGraphPaletteColorFromSeriesIndex = (index: string): string => {\n const hexColor = tokens.categorical[index as keyof typeof tokens.categorical];\n if (!hexColor) {\n throw new Error(`Categorical palette index ${index} not found`);\n }\n\n return hexColor;\n};\n\n/**\n * Checks so a single series is not blurred.\n */\nexport const expectSingleSeriesNotToBeBlurred = async (\n page: Page,\n seriesName: string,\n) => {\n const allChartSeries = multiSeriesChartProps.series;\n\n const seriesIndex =\n allChartSeries.findIndex((seriesItem) => seriesItem.name === seriesName) +\n 1;\n\n const rgbSeriesColor = chartColorsAfterHighlighting[seriesIndex];\n const hexSeriesColor = getGraphPaletteColorFromSeriesIndex(\n seriesIndex.toString(),\n );\n\n // More flexible color matching - try both with and without spaces\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n const hexRgb = convertHexToRGB(hexSeriesColor);\n const rgbWithoutSpaces = hexRgb.replace(/, /g, ',');\n\n const pathLocator = page\n .locator(`path[stroke=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[stroke=\"${rgbWithSpaces}\"]`))\n .or(page.locator(`path[stroke=\"${hexSeriesColor}\"]`))\n .or(page.locator(`path[stroke=\"${convertHexToRGB(hexSeriesColor)}\"]`))\n .or(page.locator(`path[stroke=\"${rgbWithoutSpaces}\"]`));\n\n // Wait for the element to be attached to the DOM before checking its attributes\n await expect(pathLocator).toBeAttached({ timeout: 10000 });\n await expect(pathLocator).not.toHaveAttribute('stroke-opacity');\n};\n\n/**\n * Checks so that the seriesNamesToBeHighlighted are visible in the chart and that other series are blurred.\n */\nexport const expectLegendSeriesToBeHighlightedInChart = async (\n page: Page,\n seriesNamesToBeHighlighted: string[],\n) => {\n const allChartSeries = multiSeriesChartProps.series;\n\n for (const name of seriesNamesToBeHighlighted) {\n const highlightedSeriesIndex =\n allChartSeries.findIndex((seriesItem) => seriesItem.name === name) + 1;\n\n const rgbSeriesColor = chartColorsAfterHighlighting[highlightedSeriesIndex];\n const hexSeriesColor = getGraphPaletteColorFromSeriesIndex(\n highlightedSeriesIndex.toString(),\n );\n\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n const hexRgb = convertHexToRGB(hexSeriesColor);\n const rgbWithoutSpaces = hexRgb.replace(/, /g, ',');\n\n const pathLocator = page\n .locator(`path[stroke=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[stroke=\"${rgbWithSpaces}\"]`))\n .or(page.locator(`path[stroke=\"${hexSeriesColor}\"]`))\n .or(page.locator(`path[stroke=\"${convertHexToRGB(hexSeriesColor)}\"]`))\n .or(page.locator(`path[stroke=\"${rgbWithoutSpaces}\"]`));\n\n await expect(pathLocator).not.toHaveAttribute('stroke-opacity');\n }\n\n const seriesToBeBlurred = allChartSeries.filter(\n (series) => !seriesNamesToBeHighlighted.includes(series.name),\n );\n\n for (const series of seriesToBeBlurred) {\n const blurredSeriesIndex =\n allChartSeries.findIndex(\n (seriesItem) => seriesItem.name === series.name,\n ) + 1;\n\n const rgbSeriesColor = chartColorsAfterHighlighting[blurredSeriesIndex];\n const hexSeriesColor = getGraphPaletteColorFromSeriesIndex(\n blurredSeriesIndex.toString(),\n );\n\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n const hexRgb = convertHexToRGB(hexSeriesColor);\n const rgbWithoutSpaces = hexRgb.replace(/, /g, ',');\n\n const pathLocator = page\n .locator(`path[stroke=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`path[stroke=\"${rgbWithSpaces}\"]`))\n .or(page.locator(`path[stroke=\"${hexSeriesColor}\"]`))\n .or(page.locator(`path[stroke=\"${convertHexToRGB(hexSeriesColor)}\"]`))\n .or(page.locator(`path[stroke=\"${rgbWithoutSpaces}\"]`));\n\n await expect(pathLocator).toHaveAttribute('stroke-opacity');\n }\n};\n\n/**\n * Identifies if the series are visible / not visible in the chart by checking\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(`[data-labelname=\"${name}\"]`);\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.locator(`[data-labelname=\"${seriesName}\"]`).click();\n await page.hover('.ndl-chart');\n};\n\nexport const expectFormattedTooltipToBeVisible = async (\n page: Page,\n seriesName: string,\n value: number,\n rgbSeriesColor: string,\n) => {\n const rgbWithSpaces = rgbSeriesColor.replace(/,/g, ', ');\n\n await expect(\n page\n .locator(`path[fill=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`fill[stroke=\"${rgbWithSpaces}\"]`)),\n ).toBeVisible();\n await page\n .locator(`path[fill=\"${rgbSeriesColor}\"]`)\n .or(page.locator(`fill[stroke=\"${rgbWithSpaces}\"]`))\n .hover();\n const tooltip = page.getByText(`${seriesName}formatted ${value}`);\n await expect(tooltip).toBeVisible();\n};\n\nexport const 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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AG,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 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 __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 __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 +1 @@
1
- {"version":3,"file":"ndl-echarts-theme.js","sourceRoot":"","sources":["../../../../src/charts/themes/ndl-echarts-theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,2BAA2B;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAIzC,MAAM,UAAU,GAAG,CAAC,KAAuB,EAAE,EAAE,CAAC,CAAC;IAC/C,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM;QACpD,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,UAAU;QACtD,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,QAAQ;KACnD;IACD,QAAQ,EAAE;QACR,SAAS,EAAE;YACT,GAAG,EAAE,QAAQ;YACb,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM;YACtD,KAAK,EAAE,CAAC;SACT;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE,CAAC;QACT,SAAS,EAAE;YACT,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM;YACtD,KAAK,EAAE,CAAC;SACT;QACD,IAAI,EAAE,IAAI;KACX;IACD,cAAc,EAAE;QACd,SAAS,EAAE;YACT,KAAK,EAAE,MAAM,CAAC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AClB,QAAQ,EAAE,EAAE;QACZ,kBAAkB;QAClB,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC;QAC3B,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC;QAC1B,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC;QAC5B,YAAY,EAAE,UAAU,CAAC,KAAK,CAAC;QAC/B,IAAI,EAAE;YACJ,MAAM,EAAE,QAAQ;SACjB;QACD,kBAAkB;QAClB,KAAK,EAAE,EAAE;QACT,kBAAkB;QAClB,KAAK,EAAE,EAAE;QACT,kBAAkB;QAClB,WAAW,EAAE,EAAE;KAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n// oxlint-disable sort-keys\nimport { tokens } from '@neo4j-ndl/base';\n\nimport { type HexColor } from '../chart-types';\n\nconst axisCommon = (theme: 'light' | 'dark') => ({\n axisLabel: {\n color: tokens.theme[theme].color.neutral.text.weaker,\n fontFamily: tokens.typography['body-small'].fontFamily,\n fontSize: tokens.typography['body-small'].fontSize,\n },\n axisLine: {\n lineStyle: {\n cap: 'square',\n color: tokens.theme[theme].color.neutral.border.strong,\n width: 2,\n },\n },\n axisTick: {\n length: 8,\n lineStyle: {\n color: tokens.theme[theme].color.neutral.border.strong,\n width: 1,\n },\n show: true,\n },\n minorSplitLine: {\n lineStyle: {\n color: tokens.theme[theme].color.neutral.border.weak,\n },\n },\n splitArea: {\n areaStyle: {\n color: [tokens.theme[theme].color.neutral.hover, 'transparent'],\n },\n },\n splitLine: {\n lineStyle: {\n color: tokens.theme[theme].color.neutral.border.weak,\n },\n },\n});\n\nexport const ndlEchartsTheme = (\n theme: 'light' | 'dark',\n palette?: HexColor[],\n) => {\n return {\n darkMode: theme === 'dark',\n color: palette ?? Object.values(tokens.categorical),\n backgroundColor: 'transparent',\n\n axisPointer: {\n crossStyle: {\n color: tokens.theme[theme].color.neutral.border.strong,\n },\n label: {\n color: tokens.theme[theme].color.neutral.text.weaker,\n },\n lineStyle: {\n color: tokens.theme[theme].color.neutral.border.strong,\n },\n },\n // We use a custom legend so this does not affect anything\n legend: {},\n textStyle: {\n color: tokens.theme[theme].color.neutral.text.weaker,\n },\n // We are not using the echarts title so this does not affect anything\n title: {},\n toolbox: {},\n\n dataZoom: {\n backgroundColor: 'transparent',\n borderColor: tokens.theme[theme].color.neutral.border.weak,\n borderRadius: parseInt(tokens.borderRadius.sm.replace('px', '')),\n dataBackground: {\n areaStyle: {\n color: tokens.theme[theme].color.neutral.bg.default,\n opacity: 1,\n },\n lineStyle: {\n color: tokens.theme[theme].color.neutral.border.weak,\n opacity: 1,\n width: 1,\n },\n },\n emphasis: {\n handleLabel: {},\n handleStyle: {\n borderColor: tokens.theme[theme].color.neutral.border.strong,\n color: tokens.theme[theme].color.neutral.bg.strong,\n opacity: 1,\n },\n moveHandleStyle: {\n borderColor: tokens.theme[theme].color.neutral.border.strong,\n color: tokens.theme[theme].color.neutral.border.strong,\n opacity: 1,\n },\n },\n fillerColor: `rgb( from ${tokens.theme[theme].color.neutral.hover} r g b / 0.1)`,\n handleIcon:\n 'M2 0.5h4s1.5 0 1.5 1.5v16s0 1.5 -1.5 1.5h-4s-1.5 0 -1.5 -1.5v-16s0 -1.5 1.5 -1.5',\n handleSize: '80%',\n handleStyle: {\n borderColor: tokens.theme[theme].color.neutral.border.strong,\n color: tokens.theme[theme].color.neutral.bg.weak,\n\n // borderRadius: 0, // Doesn't work\n },\n moveHandleSize: 6,\n moveHandleStyle: {\n backgroundColor: tokens.theme[theme].color.neutral.bg.strong,\n color: tokens.theme[theme].color.neutral.bg.strong,\n opacity: 1, // 0.3,\n },\n selectedDataBackground: {\n areaStyle: {\n color: tokens.theme[theme].color.neutral.bg['on-bg-weak'],\n opacity: 1,\n shadowBlur: 0,\n },\n lineStyle: {\n color: tokens.theme[theme].color.neutral.border.strong,\n opacity: 1,\n width: 1,\n },\n },\n textStyle: {\n color: tokens.theme[theme].color.neutral.text.weaker,\n },\n },\n // Not implemented\n visualMap: {},\n // Not implemented\n timeline: {},\n // Not implemented\n calendar: {},\n timeAxis: axisCommon(theme),\n logAxis: axisCommon(theme),\n valueAxis: axisCommon(theme),\n categoryAxis: axisCommon(theme),\n line: {\n symbol: 'circle',\n },\n // Not implemented\n graph: {},\n // Not implemented\n gauge: {},\n // Not implemented\n candlestick: {},\n };\n};\n"]}
1
+ {"version":3,"file":"ndl-echarts-theme.js","sourceRoot":"","sources":["../../../../src/charts/themes/ndl-echarts-theme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,2BAA2B;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAIzC,MAAM,UAAU,GAAG,CAAC,KAAuB,EAAE,EAAE,CAAC,CAAC;IAC/C,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM;QACpD,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,UAAU;QACtD,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,QAAQ;KACnD;IACD,QAAQ,EAAE;QACR,SAAS,EAAE;YACT,GAAG,EAAE,QAAQ;YACb,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CA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oBACT,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM;oBACtD,OAAO,EAAE,CAAC;oBACV,KAAK,EAAE,CAAC;iBACT;aACF;YACD,SAAS,EAAE;gBACT,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM;aACrD;SACF;QACD,kBAAkB;QAClB,SAAS,EAAE,EAAE;QACb,kBAAkB;QAClB,QAAQ,EAAE,EAAE;QACZ,kBAAkB;QAClB,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,UAAU,CAAC,KAAK,CAAC;QAC3B,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC;QAC1B,SAAS,EAAE,UAAU,CAAC,KAAK,CAAC;QAC5B,YAAY,EAAE,UAAU,CAAC,KAAK,CAAC;QAC/B,IAAI,EAAE;YACJ,MAAM,EAAE,QAAQ;SACjB;QACD,kBAAkB;QAClB,KAAK,EAAE,EAAE;QACT,kBAAkB;QAClB,KAAK,EAAE,EAAE;QACT,kBAAkB;QAClB,WAAW,EAAE,EAAE;KAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n// oxlint-disable sort-keys\nimport { tokens } from '@neo4j-ndl/base';\n\nimport { type HexColor } from '../utils/chart-types';\n\nconst axisCommon = (theme: 'light' | 'dark') => ({\n axisLabel: {\n color: tokens.theme[theme].color.neutral.text.weaker,\n fontFamily: tokens.typography['body-small'].fontFamily,\n fontSize: tokens.typography['body-small'].fontSize,\n },\n axisLine: {\n lineStyle: {\n cap: 'square',\n color: tokens.theme[theme].color.neutral.border.strong,\n width: 2,\n },\n },\n axisTick: {\n length: 8,\n lineStyle: {\n color: tokens.theme[theme].color.neutral.border.strong,\n width: 1,\n },\n show: true,\n },\n minorSplitLine: {\n lineStyle: {\n color: tokens.theme[theme].color.neutral.border.weak,\n },\n },\n splitArea: {\n areaStyle: {\n color: [tokens.theme[theme].color.neutral.hover, 'transparent'],\n },\n },\n splitLine: {\n lineStyle: {\n color: tokens.theme[theme].color.neutral.border.weak,\n },\n },\n});\n\nexport const ndlEchartsTheme = (\n theme: 'light' | 'dark',\n palette?: HexColor[],\n) => {\n return {\n darkMode: theme === 'dark',\n color: palette ?? Object.values(tokens.categorical),\n backgroundColor: 'transparent',\n\n axisPointer: {\n crossStyle: {\n color: tokens.theme[theme].color.neutral.border.strong,\n },\n label: {\n color: tokens.theme[theme].color.neutral.text.weaker,\n },\n lineStyle: {\n color: tokens.theme[theme].color.neutral.border.strong,\n },\n },\n // We use a custom legend so this does not affect anything\n legend: {},\n textStyle: {\n color: tokens.theme[theme].color.neutral.text.weaker,\n },\n // We are not using the echarts title so this does not affect anything\n title: {},\n toolbox: {},\n\n dataZoom: {\n backgroundColor: 'transparent',\n borderColor: tokens.theme[theme].color.neutral.border.weak,\n borderRadius: parseInt(tokens.borderRadius.sm.replace('px', '')),\n dataBackground: {\n areaStyle: {\n color: tokens.theme[theme].color.neutral.bg.default,\n opacity: 1,\n },\n lineStyle: {\n color: tokens.theme[theme].color.neutral.border.weak,\n opacity: 1,\n width: 1,\n },\n },\n emphasis: {\n handleLabel: {},\n handleStyle: {\n borderColor: tokens.theme[theme].color.neutral.border.strong,\n color: tokens.theme[theme].color.neutral.bg.strong,\n opacity: 1,\n },\n moveHandleStyle: {\n borderColor: tokens.theme[theme].color.neutral.border.strong,\n color: tokens.theme[theme].color.neutral.border.strong,\n opacity: 1,\n },\n },\n fillerColor: `rgb( from ${tokens.theme[theme].color.neutral.hover} r g b / 0.1)`,\n handleIcon:\n 'M2 0.5h4s1.5 0 1.5 1.5v16s0 1.5 -1.5 1.5h-4s-1.5 0 -1.5 -1.5v-16s0 -1.5 1.5 -1.5',\n handleSize: '80%',\n handleStyle: {\n borderColor: tokens.theme[theme].color.neutral.border.strong,\n color: tokens.theme[theme].color.neutral.bg.weak,\n\n // borderRadius: 0, // Doesn't work\n },\n moveHandleSize: 6,\n moveHandleStyle: {\n backgroundColor: tokens.theme[theme].color.neutral.bg.strong,\n color: tokens.theme[theme].color.neutral.bg.strong,\n opacity: 1, // 0.3,\n },\n selectedDataBackground: {\n areaStyle: {\n color: tokens.theme[theme].color.neutral.bg['on-bg-weak'],\n opacity: 1,\n shadowBlur: 0,\n },\n lineStyle: {\n color: tokens.theme[theme].color.neutral.border.strong,\n opacity: 1,\n width: 1,\n },\n },\n textStyle: {\n color: tokens.theme[theme].color.neutral.text.weaker,\n },\n },\n // Not implemented\n visualMap: {},\n // Not implemented\n timeline: {},\n // Not implemented\n calendar: {},\n timeAxis: axisCommon(theme),\n logAxis: axisCommon(theme),\n valueAxis: axisCommon(theme),\n categoryAxis: axisCommon(theme),\n line: {\n symbol: 'circle',\n },\n // Not implemented\n graph: {},\n // Not implemented\n gauge: {},\n // Not implemented\n candlestick: {},\n };\n};\n"]}
@@ -19,48 +19,7 @@
19
19
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
  */
21
21
  import { defaultThresholdLineSeriesOption } from './defaults';
22
- /**
23
- * Returns a human-readable description of a condition.
24
- */
25
- function conditionToText(condition) {
26
- switch (condition) {
27
- case 'greater':
28
- return 'greater than';
29
- case 'greaterOrEqual':
30
- return 'greater than or equal to';
31
- case 'less':
32
- return 'less than';
33
- case 'lessOrEqual':
34
- return 'less than or equal to';
35
- case 'equal':
36
- return 'equal to';
37
- case 'notEqual':
38
- return 'not equal to';
39
- default:
40
- return 'compared to';
41
- }
42
- }
43
- /**
44
- * Checks if a value meets a threshold condition.
45
- */
46
- function meetsCondition(value, condition, threshold) {
47
- switch (condition) {
48
- case 'greater':
49
- return value > threshold;
50
- case 'greaterOrEqual':
51
- return value >= threshold;
52
- case 'less':
53
- return value < threshold;
54
- case 'lessOrEqual':
55
- return value <= threshold;
56
- case 'equal':
57
- return value === threshold;
58
- case 'notEqual':
59
- return value !== threshold;
60
- default:
61
- return false;
62
- }
63
- }
22
+ import { evaluateThresholdCondition, thresholdConditionToText, } from './threshold';
64
23
  /**
65
24
  * Extract numeric y-values from inline series data.
66
25
  * Handles formats: [x, y], [x, y, ...], or single number.
@@ -242,7 +201,7 @@ export function generateThresholdAriaDescription(propsSeries, dataset) {
242
201
  for (const threshold of thresholds) {
243
202
  const conditionText = threshold.hasCustomCondition
244
203
  ? ((_c = threshold.customConditionText) !== null && _c !== void 0 ? _c : 'custom condition')
245
- : conditionToText(threshold.condition);
204
+ : thresholdConditionToText(threshold.condition);
246
205
  parts.push(`${threshold.notificationType === 'warning' ? 'Warning' : 'Danger'} threshold at ${threshold.yAxisValue}: triggers when values are ${conditionText} ${threshold.yAxisValue}.`);
247
206
  }
248
207
  // 4. Report threshold violations per data series
@@ -257,10 +216,10 @@ export function generateThresholdAriaDescription(propsSeries, dataset) {
257
216
  if (threshold.hasCustomCondition) {
258
217
  continue;
259
218
  }
260
- const violatingValues = values.filter((v) => meetsCondition(v, threshold.condition, threshold.yAxisValue));
219
+ const violatingValues = values.filter((v) => evaluateThresholdCondition(v, threshold.condition, threshold.yAxisValue).isConditionMet);
261
220
  if (violatingValues.length > 0) {
262
221
  const count = violatingValues.length;
263
- parts.push(`${name} has ${count} ${pluralize(count, 'value')} ${conditionToText(threshold.condition)} the ${threshold.notificationType} threshold of ${threshold.yAxisValue}.`);
222
+ parts.push(`${name} has ${count} ${pluralize(count, 'value')} ${thresholdConditionToText(threshold.condition)} the ${threshold.notificationType} threshold of ${threshold.yAxisValue}.`);
264
223
  }
265
224
  }
266
225
  }
@@ -0,0 +1 @@
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,MAAqD;IAErD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GACV,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,CAAC,MAAK,SAAS,IAAI,OAAO,MAAM,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzE,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;QACzB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YAC1C,SAAS;QACX,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;YAC1B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3C,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;QACH,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,M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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?: { 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"]}
@@ -0,0 +1,69 @@
1
+ /**
2
+ *
3
+ * Copyright (c) "Neo4j"
4
+ * Neo4j Sweden AB [http://neo4j.com]
5
+ *
6
+ * This file is part of Neo4j.
7
+ *
8
+ * Neo4j is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+ import { generateThresholdAriaDescription } from './aria-description';
22
+ import { createAxisTooltipFormatter } from './chart-tooltip-formatter';
23
+ import { mergeToolbox } from './user-option-utils';
24
+ /**
25
+ * Slider zoom needs extra bottom grid space for ECharts' slider control.
26
+ */
27
+ export function hasSliderDataZoom(dataZoom) {
28
+ return Array.isArray(dataZoom)
29
+ ? dataZoom.some((dataZoomOption) => {
30
+ return (dataZoomOption === null || dataZoomOption === void 0 ? void 0 : dataZoomOption.type) === 'slider';
31
+ })
32
+ : (dataZoom === null || dataZoom === void 0 ? void 0 : dataZoom.type) === 'slider';
33
+ }
34
+ /**
35
+ * Category x-axes use slightly wider grid padding to avoid clipped labels.
36
+ */
37
+ export function hasCategoryXAxis(xAxis) {
38
+ return Array.isArray(xAxis)
39
+ ? xAxis.some((x) => x.type === 'category')
40
+ : (xAxis === null || xAxis === void 0 ? void 0 : xAxis.type) === 'category';
41
+ }
42
+ /**
43
+ * Builds the ECharts option object from Needle chart props and derived values.
44
+ * Applying the option to an ECharts instance happens in `useChartOption`.
45
+ */
46
+ export function buildChartOption({ dataZoom, dataset, hasCategoryXAxis, hasSliderZoom, legendSelected, propsSeries, series, thresholdLines, toolboxOptions, userOption, xAxis, yAxis, }) {
47
+ const customAriaDescription = generateThresholdAriaDescription(propsSeries, dataset);
48
+ return Object.assign(Object.assign({}, userOption), { aria: Object.assign(Object.assign({ decal: {
49
+ show: false,
50
+ }, enabled: true }, (customAriaDescription !== undefined && {
51
+ label: { description: customAriaDescription },
52
+ })), userOption === null || userOption === void 0 ? void 0 : userOption.aria), dataZoom,
53
+ dataset, grid: Object.assign({ bottom: hasSliderZoom ? '60px' : '10px', containLabel: true, left: hasCategoryXAxis ? '15px' : '10px', right: hasCategoryXAxis ? '15px' : '10px', top: '10px', type: 'solid' }, userOption === null || userOption === void 0 ? void 0 : userOption.grid), legend: {
54
+ // ECharts mutates option.legend.selected internally; callers pass a
55
+ // copied object so the React ref remains the source of truth.
56
+ selected: Object.assign({}, legendSelected),
57
+ show: false,
58
+ }, series, toolbox: mergeToolbox(toolboxOptions), tooltip: {
59
+ borderRadius: 0,
60
+ borderWidth: 0,
61
+ confine: true,
62
+ extraCssText: 'box-shadow: none; background-color: transparent;',
63
+ formatter: createAxisTooltipFormatter({ thresholdLines, userOption }),
64
+ padding: 0,
65
+ trigger: 'axis',
66
+ }, xAxis,
67
+ yAxis });
68
+ }
69
+ //# sourceMappingURL=build-chart-option.js.map
@@ -0,0 +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;AAiBnD;;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;AAED;;GAEG;AAC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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\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};\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\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}: BuildChartOptionParams): EChartsOption {\n const customAriaDescription = generateThresholdAriaDescription(\n propsSeries,\n dataset,\n );\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: hasSliderZoom ? '60px' : '10px',\n containLabel: true,\n left: hasCategoryXAxis ? '15px' : '10px',\n right: hasCategoryXAxis ? '15px' : '10px',\n top: '10px',\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"]}