@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
@@ -1,135 +1,96 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.js");
7
+ let echarts = require("echarts");
8
+ // src/charts/utils/legend-utils.ts
2
9
  /*!
3
- *
4
- * Copyright (c) "Neo4j"
5
- * Neo4j Sweden AB [http://neo4j.com]
6
- *
7
- * This file is part of Neo4j.
8
- *
9
- * Neo4j is free software: you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation, either version 3 of the License, or
12
- * (at your option) any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
- */
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.highlightOrDownplaySeries = exports.resetAllSeriesHighlight = void 0;
24
- const echarts_1 = require("echarts");
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
+ */
25
29
  const resetAllSeriesHighlight = (chart) => {
26
- const option = chart.getOption();
27
- const seriesList = option.series || [];
28
- seriesList.forEach((_series, seriesIndex) => {
29
- chart.dispatchAction({
30
- seriesIndex,
31
- type: 'downplay',
32
- });
33
- });
30
+ (chart.getOption().series || []).forEach((_series, seriesIndex) => {
31
+ chart.dispatchAction({
32
+ seriesIndex,
33
+ type: "downplay"
34
+ });
35
+ });
34
36
  };
35
- exports.resetAllSeriesHighlight = resetAllSeriesHighlight;
36
37
  const highlightOrDownplayLineAndBarSeries = (chart, currentSeriesToDispatch, action, currentChartOptions) => {
37
- var _a;
38
- const isDownplay = action === 'downplay';
39
- const allChartOptionSeries = (currentChartOptions === null || currentChartOptions === void 0 ? void 0 : currentChartOptions.series) ||
40
- [];
41
- // Change emphasis state to add opacity on the non highlighted items.
42
- // Scatter keeps emphasis enabled: that state is what fills the circle when
43
- // a point is hovered, and disabling it on legend mouse-leave would turn the
44
- // fill off too.
45
- chart === null || chart === void 0 ? void 0 : chart.setOption({
46
- series: allChartOptionSeries === null || allChartOptionSeries === void 0 ? void 0 : allChartOptionSeries.map((seriesItem) => seriesItem.type === 'scatter'
47
- ? seriesItem
48
- : Object.assign(Object.assign({}, seriesItem), { emphasis: Object.assign(Object.assign({}, seriesItem.emphasis), { disabled: isDownplay }) })),
49
- });
50
- const seriesWithSeriesIndex = (_a = allChartOptionSeries === null || allChartOptionSeries === void 0 ? void 0 : allChartOptionSeries
51
- // Since the series index does not exist in the data we extract it from the series index
52
- .map((seriesItem, index) => (Object.assign(Object.assign({}, seriesItem), { seriesIndex: index })))) === null || _a === void 0 ? void 0 : _a.filter((seriesItem) => currentSeriesToDispatch.some((series) => series.name === seriesItem.name));
53
- if (!seriesWithSeriesIndex.length) {
54
- return;
55
- }
56
- chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
57
- seriesIndex: seriesWithSeriesIndex.map((series) => series.seriesIndex),
58
- type: action,
59
- });
38
+ var _allChartOptionSeries;
39
+ const isDownplay = action === "downplay";
40
+ const allChartOptionSeries = (currentChartOptions === null || currentChartOptions === void 0 ? void 0 : currentChartOptions.series) || [];
41
+ chart === null || chart === void 0 || chart.setOption({ series: allChartOptionSeries === null || allChartOptionSeries === void 0 ? void 0 : allChartOptionSeries.map((seriesItem) => seriesItem.type === "scatter" ? seriesItem : require_objectSpread2.default(require_objectSpread2.default({}, seriesItem), {}, { emphasis: require_objectSpread2.default(require_objectSpread2.default({}, seriesItem.emphasis), {}, { disabled: isDownplay }) })) });
42
+ const seriesWithSeriesIndex = allChartOptionSeries === null || allChartOptionSeries === void 0 || (_allChartOptionSeries = allChartOptionSeries.map((seriesItem, index) => require_objectSpread2.default(require_objectSpread2.default({}, seriesItem), {}, { seriesIndex: index }))) === null || _allChartOptionSeries === void 0 ? void 0 : _allChartOptionSeries.filter((seriesItem) => currentSeriesToDispatch.some((series) => series.name === seriesItem.name));
43
+ if (!seriesWithSeriesIndex.length) return;
44
+ chart === null || chart === void 0 || chart.dispatchAction({
45
+ seriesIndex: seriesWithSeriesIndex.map((series) => series.seriesIndex),
46
+ type: action
47
+ });
60
48
  };
61
49
  /**
62
- * Highlight or downplay pie chart dataset item
63
- */
50
+ * Highlight or downplay pie chart dataset item
51
+ */
64
52
  const highlightOrDownplayPieSlices = (chart, currentSeriesToDispatch, action, currentChartOptions) => {
65
- var _a;
66
- const isDownplay = action === 'downplay';
67
- const allChartOptionSeries = (currentChartOptions === null || currentChartOptions === void 0 ? void 0 : currentChartOptions.series) ||
68
- [];
69
- // Change blur state to add opacity on the non highlighted items in the pie chart
70
- chart === null || chart === void 0 ? void 0 : chart.setOption({
71
- series: allChartOptionSeries === null || allChartOptionSeries === void 0 ? void 0 : allChartOptionSeries.map((seriesItem) => (Object.assign(Object.assign({}, seriesItem), { blur: {
72
- itemStyle: {
73
- opacity: isDownplay ? 1 : 0.3,
74
- },
75
- label: {
76
- opacity: isDownplay ? 1 : 0.3,
77
- },
78
- } }))),
79
- });
80
- // The dataIndex that we want to dispatch can be found in the dataset[0] source array, where the first item is the name of the series
81
- const chartOptionDataset = currentChartOptions === null || currentChartOptions === void 0 ? void 0 : currentChartOptions.dataset;
82
- const datasetArray = Array.isArray(chartOptionDataset)
83
- ? chartOptionDataset
84
- : [chartOptionDataset];
85
- const sourceArray = (_a = datasetArray === null || datasetArray === void 0 ? void 0 : datasetArray[0]) === null || _a === void 0 ? void 0 : _a.source;
86
- // Find the dataIndexes that we want to dispatch
87
- const currentDataSeriesIndexes = currentSeriesToDispatch.map((series) => {
88
- const index = (sourceArray === null || sourceArray === void 0 ? void 0 : sourceArray.findIndex((item) => item[0] === series.name)) - 1;
89
- return index;
90
- });
91
- if (action === 'highlight') {
92
- // Downplay other data indexes to make sure the other slices are not highlighted
93
- const otherSeriesIndexes = sourceArray
94
- .map((_row, index) => index)
95
- .filter((dataIndex) => !currentDataSeriesIndexes.includes(dataIndex));
96
- chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
97
- dataIndex: otherSeriesIndexes,
98
- seriesIndex: [0], // pie charts only has one series so seriesIndex is always 0
99
- type: 'downplay',
100
- });
101
- }
102
- chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
103
- dataIndex: currentDataSeriesIndexes,
104
- seriesIndex: [0], // pie charts only has one series so otherSeriesIndexes is always 0
105
- type: action,
106
- });
53
+ var _datasetArray$;
54
+ const isDownplay = action === "downplay";
55
+ const allChartOptionSeries = (currentChartOptions === null || currentChartOptions === void 0 ? void 0 : currentChartOptions.series) || [];
56
+ chart === null || chart === void 0 || chart.setOption({ series: allChartOptionSeries === null || allChartOptionSeries === void 0 ? void 0 : allChartOptionSeries.map((seriesItem) => require_objectSpread2.default(require_objectSpread2.default({}, seriesItem), {}, { blur: {
57
+ itemStyle: { opacity: isDownplay ? 1 : .3 },
58
+ label: { opacity: isDownplay ? 1 : .3 }
59
+ } })) });
60
+ const chartOptionDataset = currentChartOptions === null || currentChartOptions === void 0 ? void 0 : currentChartOptions.dataset;
61
+ const datasetArray = Array.isArray(chartOptionDataset) ? chartOptionDataset : [chartOptionDataset];
62
+ const sourceArray = datasetArray === null || datasetArray === void 0 || (_datasetArray$ = datasetArray[0]) === null || _datasetArray$ === void 0 ? void 0 : _datasetArray$.source;
63
+ const currentDataSeriesIndexes = currentSeriesToDispatch.map((series) => {
64
+ return (sourceArray === null || sourceArray === void 0 ? void 0 : sourceArray.findIndex((item) => item[0] === series.name)) - 1;
65
+ });
66
+ if (action === "highlight") {
67
+ const otherSeriesIndexes = sourceArray.map((_row, index) => index).filter((dataIndex) => !currentDataSeriesIndexes.includes(dataIndex));
68
+ chart === null || chart === void 0 || chart.dispatchAction({
69
+ dataIndex: otherSeriesIndexes,
70
+ seriesIndex: [0],
71
+ type: "downplay"
72
+ });
73
+ }
74
+ chart === null || chart === void 0 || chart.dispatchAction({
75
+ dataIndex: currentDataSeriesIndexes,
76
+ seriesIndex: [0],
77
+ type: action
78
+ });
107
79
  };
108
80
  /**
109
- * Highlight or downplay the series in the chart to toggle between emphasized and non-emphasized state
110
- */
81
+ * Highlight or downplay the series in the chart to toggle between emphasized and non-emphasized state
82
+ */
111
83
  const highlightOrDownplaySeries = (chartRef, series, currentSelectedSeries, currentSeriesToDispatch, action) => {
112
- var _a, _b;
113
- const hasOnlyOneSeries = series.length === 1;
114
- const isOnlyOneSeriesSelected = Object.values(currentSelectedSeries).filter(Boolean).length === 1;
115
- if (isOnlyOneSeriesSelected ||
116
- currentSeriesToDispatch.length === 0 ||
117
- chartRef.current === null ||
118
- hasOnlyOneSeries) {
119
- return;
120
- }
121
- const chart = (0, echarts_1.getInstanceByDom)(chartRef.current);
122
- if (!chart) {
123
- return;
124
- }
125
- const currentChartOptions = chart.getOption();
126
- const seriesType = (_b = (_a = currentChartOptions === null || currentChartOptions === void 0 ? void 0 : currentChartOptions.series) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.type;
127
- if (seriesType === 'pie') {
128
- highlightOrDownplayPieSlices(chart, currentSeriesToDispatch, action, currentChartOptions);
129
- }
130
- else {
131
- highlightOrDownplayLineAndBarSeries(chart, currentSeriesToDispatch, action, currentChartOptions);
132
- }
84
+ var _ref;
85
+ const hasOnlyOneSeries = series.length === 1;
86
+ if (Object.values(currentSelectedSeries).filter(Boolean).length === 1 || currentSeriesToDispatch.length === 0 || chartRef.current === null || hasOnlyOneSeries) return;
87
+ const chart = (0, echarts.getInstanceByDom)(chartRef.current);
88
+ if (!chart) return;
89
+ const currentChartOptions = chart.getOption();
90
+ if ((currentChartOptions === null || currentChartOptions === void 0 || (_ref = currentChartOptions.series) === null || _ref === void 0 || (_ref = _ref[0]) === null || _ref === void 0 ? void 0 : _ref.type) === "pie") highlightOrDownplayPieSlices(chart, currentSeriesToDispatch, action, currentChartOptions);
91
+ else highlightOrDownplayLineAndBarSeries(chart, currentSeriesToDispatch, action, currentChartOptions);
133
92
  };
134
93
  exports.highlightOrDownplaySeries = highlightOrDownplaySeries;
94
+ exports.resetAllSeriesHighlight = resetAllSeriesHighlight;
95
+
135
96
  //# sourceMappingURL=legend-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"legend-utils.js","sourceRoot":"","sources":["../../../../src/charts/utils/legend-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,qCAIiB;AAEV,MAAM,uBAAuB,GAAG,CAAC,KAAkB,EAAE,EAAE;IAC5D,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,UAAU,GAAI,MAAM,CAAC,MAAgC,IAAI,EAAE,CAAC;IAElE,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,WAAmB,EAAE,EAAE;QAClD,KAAK,CAAC,cAAc,CAAC;YACnB,WAAW;YACX,IAAI,EAAE,UAAU;SACjB,CAAC,CAAC;IACL,CAAC,CAAC,CA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,KAAK,CAAC;QACpC,QAAQ,CAAC,OAAO,KAAK,IAAI;QACzB,gBAAgB,EAChB,CAAC;QACD,OAAO;IACT,CAAC;IAED,MAAM,KAAK,GAAG,IAAA,0BAAgB,EAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAEjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IACD,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAE9C,MAAM,UAAU,GAAG,MAAA,MACjB,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,MACtB,0CAAG,CAAC,CAAC,0CAAE,IAAI,CAAC;IAEb,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;QACzB,4BAA4B,CAC1B,KAAK,EACL,uBAAuB,EACvB,MAAM,EACN,mBAAmB,CACpB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,mCAAmC,CACjC,KAAK,EACL,uBAAuB,EACvB,MAAM,EACN,mBAAmB,CACpB,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEO,8DAAyB","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport {\n type EChartsOption,\n type EChartsType,\n getInstanceByDom,\n} from 'echarts';\n\nexport const resetAllSeriesHighlight = (chart: EChartsType) => {\n const option = chart.getOption();\n const seriesList = (option.series as unknown[] | undefined) || [];\n\n seriesList.forEach((_series, seriesIndex: number) => {\n chart.dispatchAction({\n seriesIndex,\n type: 'downplay',\n });\n });\n};\n\nconst highlightOrDownplayLineAndBarSeries = (\n chart: EChartsType,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n currentChartOptions: ReturnType<EChartsType['getOption']>,\n) => {\n const isDownplay = action === 'downplay';\n const allChartOptionSeries =\n (currentChartOptions?.series as Record<string, unknown>[] | undefined) ||\n [];\n\n // Change emphasis state to add opacity on the non highlighted items.\n // Scatter keeps emphasis enabled: that state is what fills the circle when\n // a point is hovered, and disabling it on legend mouse-leave would turn the\n // fill off too.\n chart?.setOption({\n series: allChartOptionSeries?.map((seriesItem: Record<string, unknown>) =>\n seriesItem.type === 'scatter'\n ? seriesItem\n : {\n ...seriesItem,\n emphasis: {\n ...(seriesItem.emphasis as Record<string, unknown>),\n disabled: isDownplay,\n },\n },\n ),\n });\n\n const seriesWithSeriesIndex = allChartOptionSeries\n // Since the series index does not exist in the data we extract it from the series index\n ?.map((seriesItem, index) => ({\n ...seriesItem,\n seriesIndex: index,\n }))\n // Select the series that are in the currentSeriesToDispatch array\n ?.filter((seriesItem: Record<string, unknown>) =>\n currentSeriesToDispatch.some((series) => series.name === seriesItem.name),\n );\n\n if (!seriesWithSeriesIndex.length) {\n return;\n }\n\n chart?.dispatchAction({\n seriesIndex: seriesWithSeriesIndex.map((series) => series.seriesIndex),\n type: action,\n });\n};\n\n/**\n * Highlight or downplay pie chart dataset item\n */\nconst highlightOrDownplayPieSlices = (\n chart: EChartsType,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n currentChartOptions: ReturnType<EChartsType['getOption']>,\n) => {\n const isDownplay = action === 'downplay';\n const allChartOptionSeries =\n (currentChartOptions?.series as Record<string, unknown>[] | undefined) ||\n [];\n\n // Change blur state to add opacity on the non highlighted items in the pie chart\n chart?.setOption({\n series: allChartOptionSeries?.map(\n (seriesItem: Record<string, unknown>) => ({\n ...seriesItem,\n blur: {\n itemStyle: {\n opacity: isDownplay ? 1 : 0.3,\n },\n label: {\n opacity: isDownplay ? 1 : 0.3,\n },\n },\n }),\n ),\n });\n\n // The dataIndex that we want to dispatch can be found in the dataset[0] source array, where the first item is the name of the series\n const chartOptionDataset =\n currentChartOptions?.dataset as EChartsOption['dataset'];\n const datasetArray = Array.isArray(chartOptionDataset)\n ? chartOptionDataset\n : [chartOptionDataset];\n const sourceArray = datasetArray?.[0]?.source as unknown[][];\n\n // Find the dataIndexes that we want to dispatch\n const currentDataSeriesIndexes = currentSeriesToDispatch.map((series) => {\n const index = sourceArray?.findIndex((item) => item[0] === series.name) - 1;\n return index;\n });\n\n if (action === 'highlight') {\n // Downplay other data indexes to make sure the other slices are not highlighted\n const otherSeriesIndexes = sourceArray\n .map((_row, index) => index)\n .filter((dataIndex) => !currentDataSeriesIndexes.includes(dataIndex));\n\n chart?.dispatchAction({\n dataIndex: otherSeriesIndexes,\n seriesIndex: [0], // pie charts only has one series so seriesIndex is always 0\n type: 'downplay',\n });\n }\n\n chart?.dispatchAction({\n dataIndex: currentDataSeriesIndexes,\n seriesIndex: [0], // pie charts only has one series so otherSeriesIndexes is always 0\n type: action,\n });\n};\n\n/**\n * Highlight or downplay the series in the chart to toggle between emphasized and non-emphasized state\n */\nconst highlightOrDownplaySeries = (\n chartRef: React.RefObject<HTMLDivElement | null>,\n series: { name: string; color: string }[],\n currentSelectedSeries: Record<string, boolean>,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n) => {\n const hasOnlyOneSeries = series.length === 1;\n\n const isOnlyOneSeriesSelected =\n Object.values(currentSelectedSeries).filter(Boolean).length === 1;\n\n if (\n isOnlyOneSeriesSelected ||\n currentSeriesToDispatch.length === 0 ||\n chartRef.current === null ||\n hasOnlyOneSeries\n ) {\n return;\n }\n\n const chart = getInstanceByDom(chartRef.current);\n\n if (!chart) {\n return;\n }\n const currentChartOptions = chart.getOption();\n\n const seriesType = (\n currentChartOptions?.series as Record<string, unknown>[]\n )?.[0]?.type;\n\n if (seriesType === 'pie') {\n highlightOrDownplayPieSlices(\n chart,\n currentSeriesToDispatch,\n action,\n currentChartOptions,\n );\n } else {\n highlightOrDownplayLineAndBarSeries(\n chart,\n currentSeriesToDispatch,\n action,\n currentChartOptions,\n );\n }\n};\n\nexport { highlightOrDownplaySeries };\n"]}
1
+ {"version":3,"file":"legend-utils.js","names":["getInstanceByDom"],"sources":["../../../../src/charts/utils/legend-utils.ts"],"sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport {\n type EChartsOption,\n type EChartsType,\n getInstanceByDom,\n} from 'echarts';\n\nexport const resetAllSeriesHighlight = (chart: EChartsType) => {\n const option = chart.getOption();\n const seriesList = (option.series as unknown[] | undefined) || [];\n\n seriesList.forEach((_series, seriesIndex: number) => {\n chart.dispatchAction({\n seriesIndex,\n type: 'downplay',\n });\n });\n};\n\nconst highlightOrDownplayLineAndBarSeries = (\n chart: EChartsType,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n currentChartOptions: ReturnType<EChartsType['getOption']>,\n) => {\n const isDownplay = action === 'downplay';\n const allChartOptionSeries =\n (currentChartOptions?.series as Record<string, unknown>[] | undefined) ||\n [];\n\n // Change emphasis state to add opacity on the non highlighted items.\n // Scatter keeps emphasis enabled: that state is what fills the circle when\n // a point is hovered, and disabling it on legend mouse-leave would turn the\n // fill off too.\n chart?.setOption({\n series: allChartOptionSeries?.map((seriesItem: Record<string, unknown>) =>\n seriesItem.type === 'scatter'\n ? seriesItem\n : {\n ...seriesItem,\n emphasis: {\n ...(seriesItem.emphasis as Record<string, unknown>),\n disabled: isDownplay,\n },\n },\n ),\n });\n\n const seriesWithSeriesIndex = allChartOptionSeries\n // Since the series index does not exist in the data we extract it from the series index\n ?.map((seriesItem, index) => ({\n ...seriesItem,\n seriesIndex: index,\n }))\n // Select the series that are in the currentSeriesToDispatch array\n ?.filter((seriesItem: Record<string, unknown>) =>\n currentSeriesToDispatch.some((series) => series.name === seriesItem.name),\n );\n\n if (!seriesWithSeriesIndex.length) {\n return;\n }\n\n chart?.dispatchAction({\n seriesIndex: seriesWithSeriesIndex.map((series) => series.seriesIndex),\n type: action,\n });\n};\n\n/**\n * Highlight or downplay pie chart dataset item\n */\nconst highlightOrDownplayPieSlices = (\n chart: EChartsType,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n currentChartOptions: ReturnType<EChartsType['getOption']>,\n) => {\n const isDownplay = action === 'downplay';\n const allChartOptionSeries =\n (currentChartOptions?.series as Record<string, unknown>[] | undefined) ||\n [];\n\n // Change blur state to add opacity on the non highlighted items in the pie chart\n chart?.setOption({\n series: allChartOptionSeries?.map(\n (seriesItem: Record<string, unknown>) => ({\n ...seriesItem,\n blur: {\n itemStyle: {\n opacity: isDownplay ? 1 : 0.3,\n },\n label: {\n opacity: isDownplay ? 1 : 0.3,\n },\n },\n }),\n ),\n });\n\n // The dataIndex that we want to dispatch can be found in the dataset[0] source array, where the first item is the name of the series\n const chartOptionDataset =\n currentChartOptions?.dataset as EChartsOption['dataset'];\n const datasetArray = Array.isArray(chartOptionDataset)\n ? chartOptionDataset\n : [chartOptionDataset];\n const sourceArray = datasetArray?.[0]?.source as unknown[][];\n\n // Find the dataIndexes that we want to dispatch\n const currentDataSeriesIndexes = currentSeriesToDispatch.map((series) => {\n const index = sourceArray?.findIndex((item) => item[0] === series.name) - 1;\n return index;\n });\n\n if (action === 'highlight') {\n // Downplay other data indexes to make sure the other slices are not highlighted\n const otherSeriesIndexes = sourceArray\n .map((_row, index) => index)\n .filter((dataIndex) => !currentDataSeriesIndexes.includes(dataIndex));\n\n chart?.dispatchAction({\n dataIndex: otherSeriesIndexes,\n seriesIndex: [0], // pie charts only has one series so seriesIndex is always 0\n type: 'downplay',\n });\n }\n\n chart?.dispatchAction({\n dataIndex: currentDataSeriesIndexes,\n seriesIndex: [0], // pie charts only has one series so otherSeriesIndexes is always 0\n type: action,\n });\n};\n\n/**\n * Highlight or downplay the series in the chart to toggle between emphasized and non-emphasized state\n */\nconst highlightOrDownplaySeries = (\n chartRef: React.RefObject<HTMLDivElement | null>,\n series: { name: string; color: string }[],\n currentSelectedSeries: Record<string, boolean>,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n) => {\n const hasOnlyOneSeries = series.length === 1;\n\n const isOnlyOneSeriesSelected =\n Object.values(currentSelectedSeries).filter(Boolean).length === 1;\n\n if (\n isOnlyOneSeriesSelected ||\n currentSeriesToDispatch.length === 0 ||\n chartRef.current === null ||\n hasOnlyOneSeries\n ) {\n return;\n }\n\n const chart = getInstanceByDom(chartRef.current);\n\n if (!chart) {\n return;\n }\n const currentChartOptions = chart.getOption();\n\n const seriesType = (\n currentChartOptions?.series as Record<string, unknown>[]\n )?.[0]?.type;\n\n if (seriesType === 'pie') {\n highlightOrDownplayPieSlices(\n chart,\n currentSeriesToDispatch,\n action,\n currentChartOptions,\n );\n } else {\n highlightOrDownplayLineAndBarSeries(\n chart,\n currentSeriesToDispatch,\n action,\n currentChartOptions,\n );\n }\n};\n\nexport { highlightOrDownplaySeries };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,2BAA2B,UAAuB;CAI7D,CAHe,MAAM,UACI,CAAC,CAAC,UAAoC,CAAC,EAAA,CAErD,SAAS,SAAS,gBAAwB;EACnD,MAAM,eAAe;GACnB;GACA,MAAM;EACR,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