@neo4j-ndl/react-charts 2.1.21 → 2.2.0

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 (209) hide show
  1. package/lib/LICENSES.txt +0 -295
  2. package/lib/NOTICE.txt +1383 -1392
  3. package/lib/{esm/charts/index.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/defineProperty.js} +13 -5
  4. package/lib/cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.js +46 -0
  5. package/lib/{esm/charts/tests/ChartWrapperWithTooltipFormatter.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutProperties.js} +12 -13
  6. package/lib/{esm/index.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutPropertiesLoose.js} +13 -2
  7. package/lib/cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPrimitive.js +35 -0
  8. package/lib/{esm/charts/utils/chart-types.js → cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPropertyKey.js} +10 -2
  9. package/lib/cjs/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/typeof.js +37 -0
  10. package/lib/cjs/_virtual/_rolldown/runtime.js +44 -0
  11. package/lib/cjs/charts/Chart.js +121 -111
  12. package/lib/cjs/charts/Chart.js.map +1 -1
  13. package/lib/cjs/charts/ChartContainer.js +67 -62
  14. package/lib/cjs/charts/ChartContainer.js.map +1 -1
  15. package/lib/cjs/charts/ChartEmpty.js +45 -30
  16. package/lib/cjs/charts/ChartEmpty.js.map +1 -1
  17. package/lib/cjs/charts/ChartRender.js +112 -87
  18. package/lib/cjs/charts/ChartRender.js.map +1 -1
  19. package/lib/cjs/charts/ChartTooltip.js +111 -65
  20. package/lib/cjs/charts/ChartTooltip.js.map +1 -1
  21. package/lib/cjs/charts/Legend.js +81 -69
  22. package/lib/cjs/charts/Legend.js.map +1 -1
  23. package/lib/cjs/charts/LegendItem.js +83 -62
  24. package/lib/cjs/charts/LegendItem.js.map +1 -1
  25. package/lib/cjs/charts/LegendLayout.js +330 -348
  26. package/lib/cjs/charts/LegendLayout.js.map +1 -1
  27. package/lib/cjs/charts/hooks/use-chart-instance.js +115 -122
  28. package/lib/cjs/charts/hooks/use-chart-instance.js.map +1 -1
  29. package/lib/cjs/charts/hooks/use-chart-option.js +79 -80
  30. package/lib/cjs/charts/hooks/use-chart-option.js.map +1 -1
  31. package/lib/cjs/charts/hooks/use-chart-refs.js +47 -44
  32. package/lib/cjs/charts/hooks/use-chart-refs.js.map +1 -1
  33. package/lib/cjs/charts/hooks/use-chart-zoom.js +102 -127
  34. package/lib/cjs/charts/hooks/use-chart-zoom.js.map +1 -1
  35. package/lib/cjs/charts/hooks/use-legend-interactions.js +127 -132
  36. package/lib/cjs/charts/hooks/use-legend-interactions.js.map +1 -1
  37. package/lib/cjs/charts/hooks/use-legend-series.js +143 -174
  38. package/lib/cjs/charts/hooks/use-legend-series.js.map +1 -1
  39. package/lib/cjs/charts/hooks/use-legend-visibility.js +66 -85
  40. package/lib/cjs/charts/hooks/use-legend-visibility.js.map +1 -1
  41. package/lib/cjs/charts/index.js +31 -40
  42. package/lib/cjs/charts/index.js.map +1 -1
  43. package/lib/cjs/charts/themes/ndl-echarts-theme.js +136 -168
  44. package/lib/cjs/charts/themes/ndl-echarts-theme.js.map +1 -1
  45. package/lib/cjs/charts/utils/aria-description.js +150 -214
  46. package/lib/cjs/charts/utils/aria-description.js.map +1 -1
  47. package/lib/cjs/charts/utils/build-chart-option.js +166 -174
  48. package/lib/cjs/charts/utils/build-chart-option.js.map +1 -1
  49. package/lib/cjs/charts/utils/chart-tooltip-formatter.js +156 -172
  50. package/lib/cjs/charts/utils/chart-tooltip-formatter.js.map +1 -1
  51. package/lib/cjs/charts/utils/chart-types.js +25 -20
  52. package/lib/cjs/charts/utils/chart-types.js.map +1 -1
  53. package/lib/cjs/charts/utils/defaults.js +69 -67
  54. package/lib/cjs/charts/utils/defaults.js.map +1 -1
  55. package/lib/cjs/charts/utils/format-utils.js +55 -66
  56. package/lib/cjs/charts/utils/format-utils.js.map +1 -1
  57. package/lib/cjs/charts/utils/legend-layout.js +54 -53
  58. package/lib/cjs/charts/utils/legend-layout.js.map +1 -1
  59. package/lib/cjs/charts/utils/legend-utils.js +82 -121
  60. package/lib/cjs/charts/utils/legend-utils.js.map +1 -1
  61. package/lib/cjs/charts/utils/scatter-tooltip-points.js +191 -266
  62. package/lib/cjs/charts/utils/scatter-tooltip-points.js.map +1 -1
  63. package/lib/cjs/charts/utils/threshold.js +89 -102
  64. package/lib/cjs/charts/utils/threshold.js.map +1 -1
  65. package/lib/cjs/charts/utils/user-option-utils.js +419 -347
  66. package/lib/cjs/charts/utils/user-option-utils.js.map +1 -1
  67. package/lib/cjs/index.js +31 -35
  68. package/lib/cjs/index.js.map +1 -1
  69. package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/defineProperty.mjs +11 -0
  70. package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.mjs +24 -0
  71. package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutProperties.mjs +12 -0
  72. package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutPropertiesLoose.mjs +11 -0
  73. package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPrimitive.mjs +13 -0
  74. package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/toPropertyKey.mjs +8 -0
  75. package/lib/esm/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/typeof.mjs +10 -0
  76. package/lib/esm/charts/Chart.mjs +123 -0
  77. package/lib/esm/charts/Chart.mjs.map +1 -0
  78. package/lib/esm/charts/ChartContainer.mjs +71 -0
  79. package/lib/esm/charts/ChartContainer.mjs.map +1 -0
  80. package/lib/esm/charts/ChartEmpty.mjs +46 -0
  81. package/lib/esm/charts/ChartEmpty.mjs.map +1 -0
  82. package/lib/esm/charts/ChartRender.mjs +113 -0
  83. package/lib/esm/charts/ChartRender.mjs.map +1 -0
  84. package/lib/esm/charts/ChartTooltip.mjs +109 -0
  85. package/lib/esm/charts/ChartTooltip.mjs.map +1 -0
  86. package/lib/esm/charts/Legend.mjs +82 -0
  87. package/lib/esm/charts/Legend.mjs.map +1 -0
  88. package/lib/esm/charts/LegendItem.mjs +82 -0
  89. package/lib/esm/charts/LegendItem.mjs.map +1 -0
  90. package/lib/esm/charts/LegendLayout.mjs +337 -0
  91. package/lib/esm/charts/LegendLayout.mjs.map +1 -0
  92. package/lib/esm/charts/hooks/use-chart-instance.mjs +119 -0
  93. package/lib/esm/charts/hooks/use-chart-instance.mjs.map +1 -0
  94. package/lib/esm/charts/hooks/use-chart-option.mjs +79 -0
  95. package/lib/esm/charts/hooks/use-chart-option.mjs.map +1 -0
  96. package/lib/esm/charts/hooks/use-chart-refs.mjs +49 -0
  97. package/lib/esm/charts/hooks/use-chart-refs.mjs.map +1 -0
  98. package/lib/esm/charts/hooks/use-chart-zoom.mjs +102 -0
  99. package/lib/esm/charts/hooks/use-chart-zoom.mjs.map +1 -0
  100. package/lib/esm/charts/hooks/use-legend-interactions.mjs +138 -0
  101. package/lib/esm/charts/hooks/use-legend-interactions.mjs.map +1 -0
  102. package/lib/esm/charts/hooks/use-legend-series.mjs +151 -0
  103. package/lib/esm/charts/hooks/use-legend-series.mjs.map +1 -0
  104. package/lib/esm/charts/hooks/use-legend-visibility.mjs +67 -0
  105. package/lib/esm/charts/hooks/use-legend-visibility.mjs.map +1 -0
  106. package/lib/esm/charts/index.mjs +27 -0
  107. package/lib/esm/charts/index.mjs.map +1 -0
  108. package/lib/esm/charts/themes/ndl-echarts-theme.mjs +139 -0
  109. package/lib/esm/charts/themes/ndl-echarts-theme.mjs.map +1 -0
  110. package/lib/esm/charts/utils/aria-description.mjs +162 -0
  111. package/lib/esm/charts/utils/aria-description.mjs.map +1 -0
  112. package/lib/esm/charts/utils/build-chart-option.mjs +184 -0
  113. package/lib/esm/charts/utils/build-chart-option.mjs.map +1 -0
  114. package/lib/esm/charts/utils/chart-tooltip-formatter.mjs +159 -0
  115. package/lib/esm/charts/utils/chart-tooltip-formatter.mjs.map +1 -0
  116. package/lib/esm/charts/utils/chart-types.mjs +24 -0
  117. package/lib/esm/charts/utils/chart-types.mjs.map +1 -0
  118. package/lib/esm/charts/utils/defaults.mjs +73 -0
  119. package/lib/esm/charts/utils/defaults.mjs.map +1 -0
  120. package/lib/esm/charts/utils/format-utils.mjs +61 -0
  121. package/lib/esm/charts/utils/format-utils.mjs.map +1 -0
  122. package/lib/esm/charts/utils/legend-layout.mjs +57 -0
  123. package/lib/esm/charts/utils/legend-layout.mjs.map +1 -0
  124. package/lib/esm/charts/utils/legend-utils.mjs +90 -0
  125. package/lib/esm/charts/utils/legend-utils.mjs.map +1 -0
  126. package/lib/esm/charts/utils/scatter-tooltip-points.mjs +215 -0
  127. package/lib/esm/charts/utils/scatter-tooltip-points.mjs.map +1 -0
  128. package/lib/esm/charts/utils/threshold.mjs +92 -0
  129. package/lib/esm/charts/utils/threshold.mjs.map +1 -0
  130. package/lib/esm/charts/utils/user-option-utils.mjs +445 -0
  131. package/lib/esm/charts/utils/user-option-utils.mjs.map +1 -0
  132. package/lib/esm/index.mjs +27 -0
  133. package/lib/esm/index.mjs.map +1 -0
  134. package/package.json +12 -16
  135. package/skills/ndl-react-charts/SKILL.md +2 -2
  136. package/lib/cjs/charts/tests/ChartWrapperWithTooltipFormatter.js +0 -38
  137. package/lib/cjs/charts/tests/ChartWrapperWithTooltipFormatter.js.map +0 -1
  138. package/lib/cjs/charts/tests/ChartZoomHarness.js +0 -113
  139. package/lib/cjs/charts/tests/ChartZoomHarness.js.map +0 -1
  140. package/lib/cjs/charts/tests/HorizontalBarWithVerticalSlider.js +0 -78
  141. package/lib/cjs/charts/tests/HorizontalBarWithVerticalSlider.js.map +0 -1
  142. package/lib/cjs/charts/tests/PieChartWithRerender.js +0 -46
  143. package/lib/cjs/charts/tests/PieChartWithRerender.js.map +0 -1
  144. package/lib/cjs/charts/tests/chart-test-utils.js +0 -527
  145. package/lib/cjs/charts/tests/chart-test-utils.js.map +0 -1
  146. package/lib/esm/charts/Chart.js +0 -114
  147. package/lib/esm/charts/Chart.js.map +0 -1
  148. package/lib/esm/charts/ChartContainer.js +0 -67
  149. package/lib/esm/charts/ChartContainer.js.map +0 -1
  150. package/lib/esm/charts/ChartEmpty.js +0 -33
  151. package/lib/esm/charts/ChartEmpty.js.map +0 -1
  152. package/lib/esm/charts/ChartRender.js +0 -89
  153. package/lib/esm/charts/ChartRender.js.map +0 -1
  154. package/lib/esm/charts/ChartTooltip.js +0 -64
  155. package/lib/esm/charts/ChartTooltip.js.map +0 -1
  156. package/lib/esm/charts/Legend.js +0 -71
  157. package/lib/esm/charts/Legend.js.map +0 -1
  158. package/lib/esm/charts/LegendItem.js +0 -61
  159. package/lib/esm/charts/LegendItem.js.map +0 -1
  160. package/lib/esm/charts/LegendLayout.js +0 -323
  161. package/lib/esm/charts/LegendLayout.js.map +0 -1
  162. package/lib/esm/charts/hooks/use-chart-instance.js +0 -128
  163. package/lib/esm/charts/hooks/use-chart-instance.js.map +0 -1
  164. package/lib/esm/charts/hooks/use-chart-option.js +0 -82
  165. package/lib/esm/charts/hooks/use-chart-option.js.map +0 -1
  166. package/lib/esm/charts/hooks/use-chart-refs.js +0 -48
  167. package/lib/esm/charts/hooks/use-chart-refs.js.map +0 -1
  168. package/lib/esm/charts/hooks/use-chart-zoom.js +0 -129
  169. package/lib/esm/charts/hooks/use-chart-zoom.js.map +0 -1
  170. package/lib/esm/charts/hooks/use-legend-interactions.js +0 -145
  171. package/lib/esm/charts/hooks/use-legend-interactions.js.map +0 -1
  172. package/lib/esm/charts/hooks/use-legend-series.js +0 -184
  173. package/lib/esm/charts/hooks/use-legend-series.js.map +0 -1
  174. package/lib/esm/charts/hooks/use-legend-visibility.js +0 -87
  175. package/lib/esm/charts/hooks/use-legend-visibility.js.map +0 -1
  176. package/lib/esm/charts/index.js.map +0 -1
  177. package/lib/esm/charts/tests/ChartWrapperWithTooltipFormatter.js.map +0 -1
  178. package/lib/esm/charts/tests/ChartZoomHarness.js +0 -109
  179. package/lib/esm/charts/tests/ChartZoomHarness.js.map +0 -1
  180. package/lib/esm/charts/tests/HorizontalBarWithVerticalSlider.js +0 -74
  181. package/lib/esm/charts/tests/HorizontalBarWithVerticalSlider.js.map +0 -1
  182. package/lib/esm/charts/tests/PieChartWithRerender.js +0 -43
  183. package/lib/esm/charts/tests/PieChartWithRerender.js.map +0 -1
  184. package/lib/esm/charts/tests/chart-test-utils.js +0 -500
  185. package/lib/esm/charts/tests/chart-test-utils.js.map +0 -1
  186. package/lib/esm/charts/themes/ndl-echarts-theme.js +0 -172
  187. package/lib/esm/charts/themes/ndl-echarts-theme.js.map +0 -1
  188. package/lib/esm/charts/utils/aria-description.js +0 -228
  189. package/lib/esm/charts/utils/aria-description.js.map +0 -1
  190. package/lib/esm/charts/utils/build-chart-option.js +0 -193
  191. package/lib/esm/charts/utils/build-chart-option.js.map +0 -1
  192. package/lib/esm/charts/utils/chart-tooltip-formatter.js +0 -177
  193. package/lib/esm/charts/utils/chart-tooltip-formatter.js.map +0 -1
  194. package/lib/esm/charts/utils/chart-types.js.map +0 -1
  195. package/lib/esm/charts/utils/defaults.js +0 -73
  196. package/lib/esm/charts/utils/defaults.js.map +0 -1
  197. package/lib/esm/charts/utils/format-utils.js +0 -74
  198. package/lib/esm/charts/utils/format-utils.js.map +0 -1
  199. package/lib/esm/charts/utils/legend-layout.js +0 -59
  200. package/lib/esm/charts/utils/legend-layout.js.map +0 -1
  201. package/lib/esm/charts/utils/legend-utils.js +0 -131
  202. package/lib/esm/charts/utils/legend-utils.js.map +0 -1
  203. package/lib/esm/charts/utils/scatter-tooltip-points.js +0 -291
  204. package/lib/esm/charts/utils/scatter-tooltip-points.js.map +0 -1
  205. package/lib/esm/charts/utils/threshold.js +0 -106
  206. package/lib/esm/charts/utils/threshold.js.map +0 -1
  207. package/lib/esm/charts/utils/user-option-utils.js +0 -374
  208. package/lib/esm/charts/utils/user-option-utils.js.map +0 -1
  209. package/lib/esm/index.js.map +0 -1
@@ -0,0 +1,46 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Typography } from "@neo4j-ndl/react";
3
+ import { ChartPieIconOutline, PresentationChartBarIconOutline, PresentationChartLineIconOutline } from "@neo4j-ndl/react/icons";
4
+ // src/charts/ChartEmpty.tsx
5
+ /*!
6
+ *
7
+ * Copyright (c) "Neo4j"
8
+ * Neo4j Sweden AB [http://neo4j.com]
9
+ *
10
+ * This file is part of Neo4j.
11
+ *
12
+ * Neo4j is free software: you can redistribute it and/or modify
13
+ * it under the terms of the GNU General Public License as published by
14
+ * the Free Software Foundation, either version 3 of the License, or
15
+ * (at your option) any later version.
16
+ *
17
+ * This program is distributed in the hope that it will be useful,
18
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ * GNU General Public License for more details.
21
+ *
22
+ * You should have received a copy of the GNU General Public License
23
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
24
+ */
25
+ const chartEmptyIcons = {
26
+ bar: PresentationChartBarIconOutline,
27
+ line: PresentationChartLineIconOutline,
28
+ pie: ChartPieIconOutline
29
+ };
30
+ function ChartEmpty({ action, message = "No data available", type = "line" }) {
31
+ const Icon = chartEmptyIcons[type];
32
+ return /* @__PURE__ */ jsxs("div", {
33
+ className: "ndl-chart-empty-state",
34
+ children: [
35
+ /* @__PURE__ */ jsx(Icon, { className: "ndl-chart-empty-state-icon" }),
36
+ /* @__PURE__ */ jsx(Typography, {
37
+ variant: "body-medium",
38
+ children: message
39
+ }),
40
+ action
41
+ ]
42
+ });
43
+ }
44
+ export { ChartEmpty };
45
+
46
+ //# sourceMappingURL=ChartEmpty.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartEmpty.mjs","names":[],"sources":["../../../src/charts/ChartEmpty.tsx"],"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 */\nimport { Typography } from '@neo4j-ndl/react';\nimport {\n ChartPieIconOutline,\n PresentationChartBarIconOutline,\n PresentationChartLineIconOutline,\n} from '@neo4j-ndl/react/icons';\n\nimport { type ChartEmptyProps } from './utils/chart-types';\n\nconst chartEmptyIcons = {\n bar: PresentationChartBarIconOutline,\n line: PresentationChartLineIconOutline,\n pie: ChartPieIconOutline,\n} satisfies Record<\n NonNullable<ChartEmptyProps['type']>,\n React.ComponentType<{ className?: string }>\n>;\n\nexport function ChartEmpty({\n action,\n message = 'No data available',\n type = 'line',\n}: ChartEmptyProps): React.JSX.Element {\n const Icon = chartEmptyIcons[type];\n\n return (\n <div className=\"ndl-chart-empty-state\">\n <Icon className=\"ndl-chart-empty-state-icon\" />\n <Typography variant=\"body-medium\">{message}</Typography>\n {action}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,kBAAkB;CACtB,KAAK;CACL,MAAM;CACN,KAAK;AACP;AAKA,SAAgB,WAAW,EACzB,QACA,UAAU,qBACV,OAAO,UAC8B;CACrC,MAAM,OAAO,gBAAgB;CAE7B,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACE,oBAAC,MAAD,EAAM,WAAU,6BAA8B,CAAA;GAC9C,oBAAC,YAAD;IAAY,SAAQ;IAAe,UAAA;GAAoB,CAAA;GACtD;EACE;;AAET"}
@@ -0,0 +1,113 @@
1
+ import { useChartLifecycle, useChartLoading, useChartResize } from "./hooks/use-chart-instance.mjs";
2
+ import { useChartOption } from "./hooks/use-chart-option.mjs";
3
+ import { useChartRefsContext } from "./hooks/use-chart-refs.mjs";
4
+ import { useChartZoom } from "./hooks/use-chart-zoom.mjs";
5
+ import { hasCategoryXAxis, hasMarkAreaInSeries } from "./utils/build-chart-option.mjs";
6
+ import { defaultChartSettings } from "./utils/defaults.mjs";
7
+ import { normalizeThresholdLines } from "./utils/threshold.mjs";
8
+ import { mergeDataZoom, mergeSeries, mergeXAxis, mergeYAxis } from "./utils/user-option-utils.mjs";
9
+ import { useEffect, useMemo } from "react";
10
+ import { jsx } from "react/jsx-runtime";
11
+ import { useNeedleTheme } from "@neo4j-ndl/react";
12
+ // src/charts/ChartRender.tsx
13
+ /*!
14
+ *
15
+ * Copyright (c) "Neo4j"
16
+ * Neo4j Sweden AB [http://neo4j.com]
17
+ *
18
+ * This file is part of Neo4j.
19
+ *
20
+ * Neo4j is free software: you can redistribute it and/or modify
21
+ * it under the terms of the GNU General Public License as published by
22
+ * the Free Software Foundation, either version 3 of the License, or
23
+ * (at your option) any later version.
24
+ *
25
+ * This program is distributed in the hope that it will be useful,
26
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28
+ * GNU General Public License for more details.
29
+ *
30
+ * You should have received a copy of the GNU General Public License
31
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
32
+ */
33
+ /**
34
+ * Owns the ECharts instance element and coordinates chart-specific hooks.
35
+ *
36
+ * The component normalizes user props into Needle-themed ECharts options,
37
+ * initializes/resizes the chart instance, applies loading and zoom behavior, and
38
+ * reports derived chart state back to `Chart` for legend rendering.
39
+ */
40
+ const ChartRender = ({ callbacks, dataset, isChartZoomDisabled = false, isLoading, onChartOptionChange, onFirstResizeChange, option: userOption, palette, series: propsSeries, settings = defaultChartSettings, xAxis: propXAxis, yAxis: propYAxis }) => {
41
+ const { chartEchartRef } = useChartRefsContext();
42
+ const dataZoomOptions = userOption === null || userOption === void 0 ? void 0 : userOption.dataZoom;
43
+ const toolboxOptions = userOption === null || userOption === void 0 ? void 0 : userOption.toolbox;
44
+ const { theme } = useNeedleTheme();
45
+ const thresholdLines = useMemo(() => normalizeThresholdLines(propsSeries), [propsSeries]);
46
+ const dataZoom = useMemo(() => mergeDataZoom(dataZoomOptions, {
47
+ xAxis: propXAxis,
48
+ yAxis: propYAxis
49
+ }), [
50
+ dataZoomOptions,
51
+ propXAxis,
52
+ propYAxis
53
+ ]);
54
+ const series = useMemo(() => mergeSeries(propsSeries, theme, userOption, palette), [
55
+ palette,
56
+ propsSeries,
57
+ theme,
58
+ userOption
59
+ ]);
60
+ const xAxis = useMemo(() => mergeXAxis(propXAxis, theme), [propXAxis, theme]);
61
+ const yAxis = useMemo(() => mergeYAxis(propYAxis, theme), [propYAxis, theme]);
62
+ const hasCategoryXAxis$1 = hasCategoryXAxis(xAxis);
63
+ const hasMarkArea = hasMarkAreaInSeries(series);
64
+ /**
65
+ * Hook responsibilities:
66
+ * - `useChartLifecycle` creates/disposes the ECharts instance and updates theme data.
67
+ * - `useChartResize` keeps the canvas sized to its container before first render.
68
+ * - `useChartOption` builds and applies the merged ECharts option.
69
+ * - `useChartZoom` attaches consumer zoom callbacks.
70
+ * - `useChartLoading` synchronizes the loading overlay with chart readiness.
71
+ */
72
+ useChartLifecycle({
73
+ palette,
74
+ theme
75
+ });
76
+ const { isWaitingForFirstResize } = useChartResize();
77
+ const chartOption = useChartOption({
78
+ dataZoom,
79
+ dataset,
80
+ hasCategoryXAxis: hasCategoryXAxis$1,
81
+ hasMarkArea,
82
+ propsSeries,
83
+ series,
84
+ settings,
85
+ thresholdLines,
86
+ toolboxOptions,
87
+ userOption,
88
+ xAxis,
89
+ yAxis
90
+ });
91
+ useChartZoom({
92
+ callbacks,
93
+ isChartZoomDisabled
94
+ });
95
+ useChartLoading({
96
+ isLoading,
97
+ isWaitingForFirstResize,
98
+ theme
99
+ });
100
+ useEffect(() => {
101
+ onFirstResizeChange(isWaitingForFirstResize);
102
+ }, [isWaitingForFirstResize, onFirstResizeChange]);
103
+ useEffect(() => {
104
+ onChartOptionChange(chartOption);
105
+ }, [chartOption, onChartOptionChange]);
106
+ return /* @__PURE__ */ jsx("div", {
107
+ ref: chartEchartRef,
108
+ className: "ndl-chart-echart"
109
+ });
110
+ };
111
+ export { ChartRender };
112
+
113
+ //# sourceMappingURL=ChartRender.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartRender.mjs","names":["hasCategoryXAxis","getHasCategoryXAxis"],"sources":["../../../src/charts/ChartRender.tsx"],"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 { useNeedleTheme } from '@neo4j-ndl/react';\nimport type { EChartsOption } from 'echarts';\nimport { useEffect, useMemo } from 'react';\n\nimport {\n useChartLifecycle,\n useChartLoading,\n useChartResize,\n} from './hooks/use-chart-instance';\nimport { useChartOption } from './hooks/use-chart-option';\nimport { useChartRefsContext } from './hooks/use-chart-refs';\nimport { useChartZoom } from './hooks/use-chart-zoom';\nimport {\n hasCategoryXAxis as getHasCategoryXAxis,\n hasMarkAreaInSeries,\n} from './utils/build-chart-option';\nimport type { ChartProps } from './utils/chart-types';\nimport { defaultChartSettings } from './utils/defaults';\nimport { normalizeThresholdLines } from './utils/threshold';\nimport {\n mergeDataZoom,\n mergeSeries,\n mergeXAxis,\n mergeYAxis,\n} from './utils/user-option-utils';\n\ntype ChartRenderProps = Omit<ChartProps, 'legend' | 'style'> & {\n onChartOptionChange: (chartOption: EChartsOption | undefined) => void;\n onFirstResizeChange: (isWaitingForFirstResize: boolean) => void;\n};\n\n/**\n * Owns the ECharts instance element and coordinates chart-specific hooks.\n *\n * The component normalizes user props into Needle-themed ECharts options,\n * initializes/resizes the chart instance, applies loading and zoom behavior, and\n * reports derived chart state back to `Chart` for legend rendering.\n */\nexport const ChartRender = ({\n callbacks,\n dataset,\n isChartZoomDisabled = false,\n isLoading,\n onChartOptionChange,\n onFirstResizeChange,\n option: userOption,\n palette,\n series: propsSeries,\n settings = defaultChartSettings,\n xAxis: propXAxis,\n yAxis: propYAxis,\n}: ChartRenderProps) => {\n const { chartEchartRef } = useChartRefsContext();\n const dataZoomOptions = (userOption as EChartsOption)?.dataZoom;\n const toolboxOptions = (userOption as EChartsOption)?.toolbox;\n const { theme } = useNeedleTheme();\n\n const thresholdLines = useMemo(\n () => normalizeThresholdLines(propsSeries),\n [propsSeries],\n );\n const dataZoom = useMemo(\n () =>\n mergeDataZoom(dataZoomOptions, { xAxis: propXAxis, yAxis: propYAxis }),\n [dataZoomOptions, propXAxis, propYAxis],\n );\n const series = useMemo(\n () => mergeSeries(propsSeries, theme, userOption, palette),\n [palette, propsSeries, theme, userOption],\n );\n const xAxis = useMemo(() => mergeXAxis(propXAxis, theme), [propXAxis, theme]);\n const yAxis = useMemo(() => mergeYAxis(propYAxis, theme), [propYAxis, theme]);\n const hasCategoryXAxis = getHasCategoryXAxis(xAxis);\n const hasMarkArea = hasMarkAreaInSeries(series);\n\n /**\n * Hook responsibilities:\n * - `useChartLifecycle` creates/disposes the ECharts instance and updates theme data.\n * - `useChartResize` keeps the canvas sized to its container before first render.\n * - `useChartOption` builds and applies the merged ECharts option.\n * - `useChartZoom` attaches consumer zoom callbacks.\n * - `useChartLoading` synchronizes the loading overlay with chart readiness.\n */\n useChartLifecycle({ palette, theme });\n const { isWaitingForFirstResize } = useChartResize();\n const chartOption = useChartOption({\n dataZoom,\n dataset,\n hasCategoryXAxis,\n hasMarkArea,\n propsSeries,\n series,\n settings,\n thresholdLines,\n toolboxOptions,\n userOption,\n xAxis,\n yAxis,\n });\n useChartZoom({ callbacks, isChartZoomDisabled });\n useChartLoading({\n isLoading,\n isWaitingForFirstResize,\n theme,\n });\n\n useEffect(() => {\n onFirstResizeChange(isWaitingForFirstResize);\n }, [isWaitingForFirstResize, onFirstResizeChange]);\n\n useEffect(() => {\n onChartOptionChange(chartOption);\n }, [chartOption, onChartOptionChange]);\n\n return <div ref={chartEchartRef} className=\"ndl-chart-echart\" />;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAa,eAAe,EAC1B,WACA,SACA,sBAAsB,OACtB,WACA,qBACA,qBACA,QAAQ,YACR,SACA,QAAQ,aACR,WAAW,sBACX,OAAO,WACP,OAAO,gBACe;CACtB,MAAM,EAAE,mBAAmB,oBAAoB;CAC/C,MAAM,kBAAA,eAAA,QAAA,eAAA,KAAA,IAAA,KAAA,IAAmB,WAA8B;CACvD,MAAM,iBAAA,eAAA,QAAA,eAAA,KAAA,IAAA,KAAA,IAAkB,WAA8B;CACtD,MAAM,EAAE,UAAU,eAAe;CAEjC,MAAM,iBAAiB,cACf,wBAAwB,WAAW,GACzC,CAAC,WAAW,CACd;CACA,MAAM,WAAW,cAEb,cAAc,iBAAiB;EAAE,OAAO;EAAW,OAAO;CAAU,CAAC,GACvE;EAAC;EAAiB;EAAW;CAAS,CACxC;CACA,MAAM,SAAS,cACP,YAAY,aAAa,OAAO,YAAY,OAAO,GACzD;EAAC;EAAS;EAAa;EAAO;CAAU,CAC1C;CACA,MAAM,QAAQ,cAAc,WAAW,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,CAAC;CAC5E,MAAM,QAAQ,cAAc,WAAW,WAAW,KAAK,GAAG,CAAC,WAAW,KAAK,CAAC;CAC5E,MAAMA,qBAAmBC,iBAAoB,KAAK;CAClD,MAAM,cAAc,oBAAoB,MAAM;;;;;;;;;CAU9C,kBAAkB;EAAE;EAAS;CAAM,CAAC;CACpC,MAAM,EAAE,4BAA4B,eAAe;CACnD,MAAM,cAAc,eAAe;EACjC;EACA;EACA,kBAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,aAAa;EAAE;EAAW;CAAoB,CAAC;CAC/C,gBAAgB;EACd;EACA;EACA;CACF,CAAC;CAED,gBAAgB;EACd,oBAAoB,uBAAuB;CAC7C,GAAG,CAAC,yBAAyB,mBAAmB,CAAC;CAEjD,gBAAgB;EACd,oBAAoB,WAAW;CACjC,GAAG,CAAC,aAAa,mBAAmB,CAAC;CAErC,OAAO,oBAAC,OAAD;EAAK,KAAK;EAAgB,WAAU;CAAoB,CAAA;AACjE"}
@@ -0,0 +1,109 @@
1
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutProperties.mjs";
2
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.mjs";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { Popover, StatusIndicator, TextLink, Typography } from "@neo4j-ndl/react";
5
+ import classNames from "classnames";
6
+ // src/charts/ChartTooltip.tsx
7
+ /*!
8
+ *
9
+ * Copyright (c) "Neo4j"
10
+ * Neo4j Sweden AB [http://neo4j.com]
11
+ *
12
+ * This file is part of Neo4j.
13
+ *
14
+ * Neo4j is free software: you can redistribute it and/or modify
15
+ * it under the terms of the GNU General Public License as published by
16
+ * the Free Software Foundation, either version 3 of the License, or
17
+ * (at your option) any later version.
18
+ *
19
+ * This program is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ * GNU General Public License for more details.
23
+ *
24
+ * You should have received a copy of the GNU General Public License
25
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
26
+ */
27
+ const _excluded = ["ref"];
28
+ const ChartTooltipComponent = function ChartTooltipComponent({ children, isOpen, style, anchorPosition, ref }) {
29
+ return /* @__PURE__ */ jsx(Popover, {
30
+ isOpen,
31
+ anchorPosition,
32
+ placement: "middle-end-middle-start",
33
+ children: /* @__PURE__ */ jsx(Popover.Content, {
34
+ ref,
35
+ style,
36
+ children
37
+ })
38
+ });
39
+ };
40
+ const ChartTooltip = Object.assign(ChartTooltipComponent, {
41
+ Content: function ChartTooltipContent({ leadingElement, trailingElement, indentSquareColor, notifications, ref }) {
42
+ const classes = classNames(`ndl-charts-chart-tooltip-content`);
43
+ return /* @__PURE__ */ jsxs("div", {
44
+ ref,
45
+ className: classes,
46
+ children: [/* @__PURE__ */ jsxs("div", {
47
+ className: "ndl-charts-chart-tooltip-content-line",
48
+ children: [
49
+ indentSquareColor && /* @__PURE__ */ jsx("div", {
50
+ className: "ndl-charts-chart-tooltip-content-indent-square",
51
+ style: { backgroundColor: indentSquareColor }
52
+ }),
53
+ leadingElement && /* @__PURE__ */ jsx(Typography, {
54
+ variant: trailingElement ? "body-medium" : "label",
55
+ className: "ndl-charts-chart-tooltip-content-left-element",
56
+ children: leadingElement
57
+ }),
58
+ trailingElement && /* @__PURE__ */ jsx(Typography, {
59
+ variant: "label",
60
+ className: "ndl-charts-chart-tooltip-content-trailing-element",
61
+ children: trailingElement
62
+ })
63
+ ]
64
+ }), notifications && notifications.map((notification) => {
65
+ const { id, notificationType, leadingElement, trailingElement } = notification;
66
+ return /* @__PURE__ */ jsxs("div", {
67
+ className: `ndl-charts-chart-tooltip-content-notification ndl-notification-${notificationType}`,
68
+ children: [
69
+ /* @__PURE__ */ jsx(StatusIndicator, { variant: notificationType }),
70
+ /* @__PURE__ */ jsx(Typography, {
71
+ variant: "body-medium",
72
+ className: "ndl-charts-chart-tooltip-content-notification-left-element",
73
+ children: leadingElement
74
+ }),
75
+ /* @__PURE__ */ jsx(Typography, {
76
+ variant: "label",
77
+ className: "ndl-charts-chart-tooltip-content-notification-trailing-element",
78
+ children: trailingElement
79
+ })
80
+ ]
81
+ }, `notification-${id}`);
82
+ })]
83
+ });
84
+ },
85
+ Link: function ChartTooltipAction(_ref) {
86
+ let { ref } = _ref, restProps = _objectWithoutProperties(_ref, _excluded);
87
+ return /* @__PURE__ */ jsx(TextLink, _objectSpread2({ ref }, restProps));
88
+ },
89
+ Title: function ChartTooltipTitle({ children, indentSquareColor, ref }) {
90
+ const classes = classNames(`ndl-charts-chart-tooltip-title`);
91
+ const title = /* @__PURE__ */ jsx(Typography, {
92
+ ref,
93
+ variant: "body-small",
94
+ className: classes,
95
+ children
96
+ });
97
+ if (indentSquareColor === void 0) return title;
98
+ return /* @__PURE__ */ jsxs("div", {
99
+ className: "ndl-charts-chart-tooltip-title-line",
100
+ children: [/* @__PURE__ */ jsx("div", {
101
+ className: "ndl-charts-chart-tooltip-title-indent-square",
102
+ style: { backgroundColor: indentSquareColor }
103
+ }), title]
104
+ });
105
+ }
106
+ });
107
+ export { ChartTooltip, ChartTooltipComponent };
108
+
109
+ //# sourceMappingURL=ChartTooltip.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartTooltip.mjs","names":[],"sources":["../../../src/charts/ChartTooltip.tsx"],"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 */\nimport {\n Popover,\n StatusIndicator,\n TextLink,\n Typography,\n} from '@neo4j-ndl/react';\nimport classNames from 'classnames';\nimport type React from 'react';\n\nimport {\n type ChartTooltipContentProps,\n type ChartTooltipProps,\n} from './utils/chart-types';\n\nexport const ChartTooltipComponent = function ChartTooltipComponent({\n children,\n isOpen,\n style,\n anchorPosition,\n ref,\n}: ChartTooltipProps) {\n return (\n <Popover\n isOpen={isOpen}\n anchorPosition={anchorPosition}\n placement=\"middle-end-middle-start\"\n >\n <Popover.Content ref={ref} style={style}>\n {children}\n </Popover.Content>\n </Popover>\n );\n};\n\ntype ChartTooltipTitleProps = {\n children: React.ReactNode;\n /**\n * Color swatch shown before the title, for tooltips where every row below\n * the title belongs to the same series and the rows carry no swatch.\n */\n indentSquareColor?: string;\n ref?: React.Ref<HTMLSpanElement>;\n};\n\nconst ChartTooltipTitle = function ChartTooltipTitle({\n children,\n indentSquareColor,\n ref,\n}: ChartTooltipTitleProps) {\n const classes = classNames(`ndl-charts-chart-tooltip-title`);\n\n const title = (\n <Typography ref={ref} variant=\"body-small\" className={classes}>\n {children}\n </Typography>\n );\n\n if (indentSquareColor === undefined) {\n return title;\n }\n\n return (\n <div className=\"ndl-charts-chart-tooltip-title-line\">\n <div\n className=\"ndl-charts-chart-tooltip-title-indent-square\"\n style={{ backgroundColor: indentSquareColor }}\n />\n {title}\n </div>\n );\n};\n\nconst ChartTooltipContent = function ChartTooltipContent({\n leadingElement,\n trailingElement,\n indentSquareColor,\n notifications,\n ref,\n}: ChartTooltipContentProps) {\n const classes = classNames(`ndl-charts-chart-tooltip-content`);\n\n return (\n <div ref={ref} className={classes}>\n <div className=\"ndl-charts-chart-tooltip-content-line\">\n {indentSquareColor && (\n <div\n className=\"ndl-charts-chart-tooltip-content-indent-square\"\n style={{ backgroundColor: indentSquareColor }}\n />\n )}\n {leadingElement && (\n <Typography\n variant={trailingElement ? 'body-medium' : 'label'}\n className=\"ndl-charts-chart-tooltip-content-left-element\"\n >\n {leadingElement}\n </Typography>\n )}\n {trailingElement && (\n <Typography\n variant=\"label\"\n className=\"ndl-charts-chart-tooltip-content-trailing-element\"\n >\n {trailingElement}\n </Typography>\n )}\n </div>\n\n {notifications &&\n notifications.map((notification) => {\n const { id, notificationType, leadingElement, trailingElement } =\n notification;\n\n return (\n <div\n key={`notification-${id}`}\n className={`ndl-charts-chart-tooltip-content-notification ndl-notification-${notificationType}`}\n >\n <StatusIndicator variant={notificationType} />\n <Typography\n variant=\"body-medium\"\n className=\"ndl-charts-chart-tooltip-content-notification-left-element\"\n >\n {leadingElement}\n </Typography>\n <Typography\n variant=\"label\"\n className=\"ndl-charts-chart-tooltip-content-notification-trailing-element\"\n >\n {trailingElement}\n </Typography>\n </div>\n );\n })}\n </div>\n );\n};\n\nconst ChartTooltipLink = function ChartTooltipAction({\n ref,\n ...restProps\n}: React.ComponentProps<typeof TextLink>) {\n return <TextLink ref={ref} {...restProps} />;\n};\n\nconst ChartTooltip = Object.assign(ChartTooltipComponent, {\n Content: ChartTooltipContent,\n Link: ChartTooltipLink,\n Title: ChartTooltipTitle,\n});\n\nexport { ChartTooltip };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+JE,MAAA,YAAA,CAAA,KAAA;AA7HF,MAAa,wBAAwB,SAAS,sBAAsB,EAClE,UACA,QACA,OACA,gBACA,OACoB;CACpB,OACE,oBAAC,SAAD;EACU;EACQ;EAChB,WAAU;EAEV,UAAA,oBAAC,QAAQ,SAAT;GAAsB;GAAY;GAC/B;EACc,CAAA;CACV,CAAA;AAEb;AAiHA,MAAM,eAAe,OAAO,OAAO,uBAAuB;CACxD,SAAS,SA1E0B,oBAAoB,EACvD,gBACA,iBACA,mBACA,eACA,OAC2B;EAC3B,MAAM,UAAU,WAAW,kCAAkC;EAE7D,OACE,qBAAC,OAAD;GAAU;GAAK,WAAW;GAA1B,UAAA,CACE,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACG,qBACC,oBAAC,OAAD;MACE,WAAU;MACV,OAAO,EAAE,iBAAiB,kBAAkB;KAC7C,CAAA;KAEF,kBACC,oBAAC,YAAD;MACE,SAAS,kBAAkB,gBAAgB;MAC3C,WAAU;MAET,UAAA;KACS,CAAA;KAEb,mBACC,oBAAC,YAAD;MACE,SAAQ;MACR,WAAU;MAET,UAAA;KACS,CAAA;IAEX;GAEJ,CAAA,GAAA,iBACC,cAAc,KAAK,iBAAiB;IAClC,MAAM,EAAE,IAAI,kBAAkB,gBAAgB,oBAC5C;IAEF,OACE,qBAAC,OAAD;KAEE,WAAW,kEAAkE;KAF/E,UAAA;MAIE,oBAAC,iBAAD,EAAiB,SAAS,iBAAmB,CAAA;MAC7C,oBAAC,YAAD;OACE,SAAQ;OACR,WAAU;OAET,UAAA;MACS,CAAA;MACZ,oBAAC,YAAD;OACE,SAAQ;OACR,WAAU;OAET,UAAA;MACS,CAAA;KACT;IAhBE,GAAA,gBAAgB,IAgBlB;GAET,CAAC,CACA;;CAET;CAWE,MAAM,SAT0B,mBAAmB,MAGX;EAHW,IAAA,EACnD,QAAA,MACG,YAAA,yBAAA,MAAA,SAAA;EAEH,OAAO,oBAAC,UAAA,eAAA,EAAc,IAAA,GAAS,SAAY,CAAA;CAC7C;CAKE,OAAO,SAxG0B,kBAAkB,EACnD,UACA,mBACA,OACyB;EACzB,MAAM,UAAU,WAAW,gCAAgC;EAE3D,MAAM,QACJ,oBAAC,YAAD;GAAiB;GAAK,SAAQ;GAAa,WAAW;GACnD;EACS,CAAA;EAGd,IAAI,sBAAsB,KAAA,GACxB,OAAO;EAGT,OACE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,oBAAC,OAAD;IACE,WAAU;IACV,OAAO,EAAE,iBAAiB,kBAAkB;GAC7C,CAAA,GACA,KACE;;CAET;AA+EA,CAAC"}
@@ -0,0 +1,82 @@
1
+ import { useLegendHoverHighlight, useLegendSelection } from "./hooks/use-legend-interactions.mjs";
2
+ import { useLegendVisibility } from "./hooks/use-legend-visibility.mjs";
3
+ import { LegendItem } from "./LegendItem.mjs";
4
+ import { LegendLayout } from "./LegendLayout.mjs";
5
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutProperties.mjs";
6
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.mjs";
7
+ import { jsx } from "react/jsx-runtime";
8
+ // src/charts/Legend.tsx
9
+ /*!
10
+ *
11
+ * Copyright (c) "Neo4j"
12
+ * Neo4j Sweden AB [http://neo4j.com]
13
+ *
14
+ * This file is part of Neo4j.
15
+ *
16
+ * Neo4j is free software: you can redistribute it and/or modify
17
+ * it under the terms of the GNU General Public License as published by
18
+ * the Free Software Foundation, either version 3 of the License, or
19
+ * (at your option) any later version.
20
+ *
21
+ * This program is distributed in the hope that it will be useful,
22
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ * GNU General Public License for more details.
25
+ *
26
+ * You should have received a copy of the GNU General Public License
27
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
28
+ */
29
+ const _excluded = [
30
+ "className",
31
+ "series",
32
+ "isLayoutReady",
33
+ "onLayoutReady",
34
+ "htmlAttributes"
35
+ ];
36
+ /**
37
+ * Renders the interactive chart legend and keeps legend state synchronized with
38
+ * ECharts.
39
+ *
40
+ * The component owns the React-side selected-series state, mirrors it into the
41
+ * shared ref consumed when rebuilding chart options, and wires item hover/click
42
+ * interactions back to the ECharts instance.
43
+ */
44
+ const Legend = (_ref) => {
45
+ let { className, series, isLayoutReady = true, onLayoutReady, htmlAttributes } = _ref, restProps = _objectWithoutProperties(_ref, _excluded);
46
+ const { renderedSelectedSeries } = useLegendSelection({ series });
47
+ const { toggleHighlight } = useLegendHoverHighlight({
48
+ selectedSeries: renderedSelectedSeries,
49
+ series
50
+ });
51
+ const { toggleLegendVisibility } = useLegendVisibility(renderedSelectedSeries);
52
+ const selectedSeriesLength = Object.values(renderedSelectedSeries).filter(Boolean).length;
53
+ const isAllSeriesVisible = selectedSeriesLength === series.length;
54
+ const hasMoreThanOneItem = series.length > 1;
55
+ return /* @__PURE__ */ jsx(LegendLayout, _objectSpread2(_objectSpread2({
56
+ className,
57
+ isLayoutReady,
58
+ itemCount: series.length,
59
+ onLayoutReady,
60
+ htmlAttributes
61
+ }, restProps), {}, { children: series.map((currentSeries, index) => {
62
+ var _currentSeries$name, _currentSeries$name3, _currentSeries$name4;
63
+ return /* @__PURE__ */ jsx(LegendItem, {
64
+ name: currentSeries.name,
65
+ color: currentSeries.color,
66
+ hasButtons: hasMoreThanOneItem && currentSeries.name !== void 0,
67
+ onLegendItemMouseEnter: () => toggleHighlight(currentSeries, true),
68
+ onLegendItemMouseLeave: () => toggleHighlight(currentSeries, false),
69
+ onLegendItemClick: () => {
70
+ var _currentSeries$name2;
71
+ const isOnlyVisible = renderedSelectedSeries[(_currentSeries$name2 = currentSeries.name) !== null && _currentSeries$name2 !== void 0 ? _currentSeries$name2 : ""] && selectedSeriesLength === 1;
72
+ toggleLegendVisibility(currentSeries.name, isAllSeriesVisible, isOnlyVisible);
73
+ },
74
+ isSelected: !isAllSeriesVisible && renderedSelectedSeries[(_currentSeries$name3 = currentSeries.name) !== null && _currentSeries$name3 !== void 0 ? _currentSeries$name3 : ""],
75
+ isDeselected: currentSeries.name === void 0 ? false : !renderedSelectedSeries[currentSeries.name],
76
+ children: (_currentSeries$name4 = currentSeries.name) !== null && _currentSeries$name4 !== void 0 ? _currentSeries$name4 : `Series ${index}`
77
+ }, (_currentSeries$name = currentSeries.name) !== null && _currentSeries$name !== void 0 ? _currentSeries$name : index);
78
+ }) }));
79
+ };
80
+ export { Legend };
81
+
82
+ //# sourceMappingURL=Legend.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Legend.mjs","names":[],"sources":["../../../src/charts/Legend.tsx"],"sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport {\n useLegendHoverHighlight,\n useLegendSelection,\n} from './hooks/use-legend-interactions';\nimport { useLegendVisibility } from './hooks/use-legend-visibility';\nimport { LegendItem } from './LegendItem';\nimport { LegendLayout } from './LegendLayout';\nimport { type CommonProps, type LegendProps } from './utils/chart-types';\n\ntype LegendComponentProps = LegendProps & {\n isLayoutReady?: boolean;\n onLayoutReady?: () => void;\n};\n\n/**\n * Renders the interactive chart legend and keeps legend state synchronized with\n * ECharts.\n *\n * The component owns the React-side selected-series state, mirrors it into the\n * shared ref consumed when rebuilding chart options, and wires item hover/click\n * interactions back to the ECharts instance.\n */\nexport const Legend = ({\n className,\n series,\n isLayoutReady = true,\n onLayoutReady,\n htmlAttributes,\n ...restProps\n}: Omit<CommonProps<'div', LegendComponentProps>, 'ref'>) => {\n const { renderedSelectedSeries } = useLegendSelection({\n series,\n });\n\n const { toggleHighlight } = useLegendHoverHighlight({\n selectedSeries: renderedSelectedSeries,\n series,\n });\n\n const { toggleLegendVisibility } = useLegendVisibility(\n renderedSelectedSeries,\n );\n\n const selectedSeriesLength = Object.values(renderedSelectedSeries).filter(\n Boolean,\n ).length;\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n const hasMoreThanOneItem = series.length > 1;\n\n return (\n <LegendLayout\n className={className}\n isLayoutReady={isLayoutReady}\n itemCount={series.length}\n onLayoutReady={onLayoutReady}\n htmlAttributes={htmlAttributes}\n {...restProps}\n >\n {series.map((currentSeries, index) => (\n <LegendItem\n key={currentSeries.name ?? index}\n name={currentSeries.name}\n color={currentSeries.color}\n hasButtons={hasMoreThanOneItem && currentSeries.name !== undefined}\n onLegendItemMouseEnter={() => toggleHighlight(currentSeries, true)}\n onLegendItemMouseLeave={() => toggleHighlight(currentSeries, false)}\n onLegendItemClick={() => {\n const isOnlyVisible =\n renderedSelectedSeries[currentSeries.name ?? ''] &&\n selectedSeriesLength === 1;\n\n toggleLegendVisibility(\n currentSeries.name,\n isAllSeriesVisible,\n isOnlyVisible,\n );\n }}\n isSelected={\n !isAllSeriesVisible &&\n renderedSelectedSeries[currentSeries.name ?? '']\n }\n isDeselected={\n currentSeries.name === undefined\n ? false\n : !renderedSelectedSeries[currentSeries.name]\n }\n >\n {currentSeries.name ?? `Series ${index}`}\n </LegendItem>\n ))}\n </LegendLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CE;CACA;CACA;CACA;CACA;;;;;;;;;;AALF,MAAa,UAAU,SAOsC;CAPtC,IAAA,EACrB,WACA,QACA,gBAAgB,MAChB,eACA,mBAAA,MACG,YAAA,yBAAA,MAAA,SAAA;CAEH,MAAM,EAAE,2BAA2B,mBAAmB,EACpD,OACF,CAAC;CAED,MAAM,EAAE,oBAAoB,wBAAwB;EAClD,gBAAgB;EAChB;CACF,CAAC;CAED,MAAM,EAAE,2BAA2B,oBACjC,sBACF;CAEA,MAAM,uBAAuB,OAAO,OAAO,sBAAsB,CAAC,CAAC,OACjE,OACF,CAAC,CAAC;CACF,MAAM,qBAAqB,yBAAyB,OAAO;CAC3D,MAAM,qBAAqB,OAAO,SAAS;CAE3C,OACE,oBAAC,cAAA,eAAA,eAAA;EACY;EACI;EACf,WAAW,OAAO;EACH;EACC;CACZ,GAAA,SAAA,GAAA,CAAA,GAAA,EAAA,UAEH,OAAO,KAAK,eAAe,UAC1B;;EAAC,OAAA,oBAAA,YAAD;GAEE,MAAM,cAAc;GACpB,OAAO,cAAc;GACrB,YAAY,sBAAsB,cAAc,SAAS,KAAA;GACzD,8BAA8B,gBAAgB,eAAe,IAAI;GACjE,8BAA8B,gBAAgB,eAAe,KAAK;GAClE,yBAAyB;;IACvB,MAAM,gBACJ,wBAAA,uBAAuB,cAAc,UAAA,QAAA,yBAAA,KAAA,IAAA,uBAAQ,OAC7C,yBAAyB;IAE3B,uBACE,cAAc,MACd,oBACA,aACF;GACF;GACA,YACE,CAAC,sBACD,wBAAA,uBAAuB,cAAc,UAAA,QAAA,yBAAA,KAAA,IAAA,uBAAQ;GAE/C,cACE,cAAc,SAAS,KAAA,IACnB,QACA,CAAC,uBAAuB,cAAc;GAG3C,WAAA,uBAAA,cAAc,UAAA,QAAA,yBAAA,KAAA,IAAA,uBAAQ,UAAU;EACvB,IAAA,sBA5BL,cAAc,UAAA,QAAA,wBAAA,KAAA,IAAA,sBAAQ,KA4BjB;CACb,CAAA,EAAA,CACW,CAAA;AAElB"}
@@ -0,0 +1,82 @@
1
+ import { isThresholdLine } from "./utils/threshold.mjs";
2
+ import _objectWithoutProperties from "../_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectWithoutProperties.mjs";
3
+ import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.mjs";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { Typography } from "@neo4j-ndl/react";
6
+ import classNames from "classnames";
7
+ import { CheckIconOutline } from "@neo4j-ndl/react/icons";
8
+ // src/charts/LegendItem.tsx
9
+ /*!
10
+ *
11
+ * Copyright (c) "Neo4j"
12
+ * Neo4j Sweden AB [http://neo4j.com]
13
+ *
14
+ * This file is part of Neo4j.
15
+ *
16
+ * Neo4j is free software: you can redistribute it and/or modify
17
+ * it under the terms of the GNU General Public License as published by
18
+ * the Free Software Foundation, either version 3 of the License, or
19
+ * (at your option) any later version.
20
+ *
21
+ * This program is distributed in the hope that it will be useful,
22
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ * GNU General Public License for more details.
25
+ *
26
+ * You should have received a copy of the GNU General Public License
27
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
28
+ */
29
+ const _excluded = [
30
+ "children",
31
+ "as",
32
+ "className",
33
+ "name",
34
+ "isSelected",
35
+ "isDeselected",
36
+ "onLegendItemClick",
37
+ "color",
38
+ "hasButtons",
39
+ "ref",
40
+ "onLegendItemMouseEnter",
41
+ "onLegendItemMouseLeave"
42
+ ];
43
+ /**
44
+ * Renders a single legend entry with its series color, selection indicator, and
45
+ * optional button semantics.
46
+ *
47
+ * Threshold-line series are intentionally skipped because they are chart
48
+ * annotations rather than user-toggleable data series.
49
+ */
50
+ const LegendItem = (_ref) => {
51
+ var _isThresholdLine;
52
+ let { children, as, className, name, isSelected, isDeselected, onLegendItemClick, color, hasButtons = true, ref, onLegendItemMouseEnter, onLegendItemMouseLeave } = _ref, restProps = _objectWithoutProperties(_ref, _excluded);
53
+ const Component = as !== null && as !== void 0 ? as : hasButtons ? "button" : "div";
54
+ const classes = classNames("ndl-chart-legend-item", {
55
+ "ndl-chart-legend-item-deselected": isDeselected,
56
+ "ndl-chart-legend-item-selected": isSelected
57
+ }, className);
58
+ if ((_isThresholdLine = isThresholdLine(name)) !== null && _isThresholdLine !== void 0 ? _isThresholdLine : false) return null;
59
+ return /* @__PURE__ */ jsxs(Component, _objectSpread2(_objectSpread2({
60
+ className: classes,
61
+ ref,
62
+ "data-labelname": name,
63
+ title: name,
64
+ onClick: hasButtons ? onLegendItemClick : void 0,
65
+ onMouseEnter: onLegendItemMouseEnter,
66
+ onMouseLeave: onLegendItemMouseLeave
67
+ }, restProps), {}, { children: [/* @__PURE__ */ jsx("span", {
68
+ className: "ndl-chart-legend-item-square",
69
+ style: {
70
+ "--ndl-chart-legend-item-color": color,
71
+ backgroundColor: isDeselected === true ? "transparent" : color
72
+ },
73
+ children: isSelected === true && /* @__PURE__ */ jsx(CheckIconOutline, { className: "ndl-chart-legend-item-square-checkmark" })
74
+ }), /* @__PURE__ */ jsx(Typography, {
75
+ variant: "body-medium",
76
+ className: "ndl-chart-legend-item-text",
77
+ children
78
+ })] }));
79
+ };
80
+ export { LegendItem };
81
+
82
+ //# sourceMappingURL=LegendItem.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LegendItem.mjs","names":[],"sources":["../../../src/charts/LegendItem.tsx"],"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 { Typography } from '@neo4j-ndl/react';\nimport { CheckIconOutline } from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport type React from 'react';\n\nimport { type LegendItemProps } from './utils/chart-types';\nimport { isThresholdLine } from './utils/threshold';\n\n/**\n * Renders a single legend entry with its series color, selection indicator, and\n * optional button semantics.\n *\n * Threshold-line series are intentionally skipped because they are chart\n * annotations rather than user-toggleable data series.\n */\nexport const LegendItem = ({\n children,\n as,\n className,\n name,\n isSelected,\n isDeselected,\n onLegendItemClick,\n color,\n hasButtons = true,\n ref,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n ...restProps\n}: LegendItemProps) => {\n const Component = as ?? (hasButtons ? 'button' : 'div');\n\n const classes = classNames(\n 'ndl-chart-legend-item',\n {\n 'ndl-chart-legend-item-deselected': isDeselected,\n 'ndl-chart-legend-item-selected': isSelected,\n },\n className,\n );\n\n // We don't want to display threshold lines in the legend\n if (isThresholdLine(name) ?? false) {\n return null;\n }\n\n return (\n <Component\n className={classes}\n ref={ref}\n data-labelname={name}\n title={name}\n onClick={hasButtons ? onLegendItemClick : undefined}\n onMouseEnter={onLegendItemMouseEnter}\n onMouseLeave={onLegendItemMouseLeave}\n {...restProps}\n >\n <span\n className=\"ndl-chart-legend-item-square\"\n style={\n {\n '--ndl-chart-legend-item-color': color,\n backgroundColor: isDeselected === true ? 'transparent' : color,\n } as React.CSSProperties\n }\n >\n {isSelected === true && (\n <CheckIconOutline className=\"ndl-chart-legend-item-square-checkmark\" />\n )}\n </span>\n <Typography variant=\"body-medium\" className=\"ndl-chart-legend-item-text\">\n {children}\n </Typography>\n </Component>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;;;;;;;;AAZF,MAAa,cAAc,SAcJ;;CAdI,IAAA,EACzB,UACA,IACA,WACA,MACA,YACA,cACA,mBACA,OACA,aAAa,MACb,KACA,wBACA,2BAAA,MACG,YAAA,yBAAA,MAAA,SAAA;CAEH,MAAM,YAAY,OAAA,QAAA,OAAA,KAAA,IAAA,KAAO,aAAa,WAAW;CAEjD,MAAM,UAAU,WACd,yBACA;EACE,oCAAoC;EACpC,kCAAkC;CACpC,GACA,SACF;CAGA,KAAA,mBAAI,gBAAgB,IAAI,OAAA,QAAA,qBAAA,KAAA,IAAA,mBAAK,OAC3B,OAAO;CAGT,OACE,qBAAC,WAAA,eAAA,eAAA;EACC,WAAW;EACN;EACL,kBAAgB;EAChB,OAAO;EACP,SAAS,aAAa,oBAAoB,KAAA;EAC1C,cAAc;EACd,cAAc;CACV,GAAA,SAAA,GAAA,CAAA,GAAA,EAAA,UARN,CAUE,oBAAC,QAAD;EACE,WAAU;EACV,OACE;GACE,iCAAiC;GACjC,iBAAiB,iBAAiB,OAAO,gBAAgB;EAC3D;EAGD,UAAA,eAAe,QACd,oBAAC,kBAAD,EAAkB,WAAU,yCAA0C,CAAA;CAEpE,CAAA,GACN,oBAAC,YAAD;EAAY,SAAQ;EAAc,WAAU;EACzC;CACS,CAAA,CACH,EAAA,CAAA,CAAA;AAEf"}