@neo4j-ndl/react-charts 2.1.22 → 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,131 +0,0 @@
1
- /*!
2
- *
3
- * Copyright (c) "Neo4j"
4
- * Neo4j Sweden AB [http://neo4j.com]
5
- *
6
- * This file is part of Neo4j.
7
- *
8
- * Neo4j is free software: you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation, either version 3 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
- */
21
- import { getInstanceByDom, } from 'echarts';
22
- export const resetAllSeriesHighlight = (chart) => {
23
- const option = chart.getOption();
24
- const seriesList = option.series || [];
25
- seriesList.forEach((_series, seriesIndex) => {
26
- chart.dispatchAction({
27
- seriesIndex,
28
- type: 'downplay',
29
- });
30
- });
31
- };
32
- const highlightOrDownplayLineAndBarSeries = (chart, currentSeriesToDispatch, action, currentChartOptions) => {
33
- var _a;
34
- const isDownplay = action === 'downplay';
35
- const allChartOptionSeries = (currentChartOptions === null || currentChartOptions === void 0 ? void 0 : currentChartOptions.series) ||
36
- [];
37
- // Change emphasis state to add opacity on the non highlighted items.
38
- // Scatter keeps emphasis enabled: that state is what fills the circle when
39
- // a point is hovered, and disabling it on legend mouse-leave would turn the
40
- // fill off too.
41
- chart === null || chart === void 0 ? void 0 : chart.setOption({
42
- series: allChartOptionSeries === null || allChartOptionSeries === void 0 ? void 0 : allChartOptionSeries.map((seriesItem) => seriesItem.type === 'scatter'
43
- ? seriesItem
44
- : Object.assign(Object.assign({}, seriesItem), { emphasis: Object.assign(Object.assign({}, seriesItem.emphasis), { disabled: isDownplay }) })),
45
- });
46
- const seriesWithSeriesIndex = (_a = allChartOptionSeries === null || allChartOptionSeries === void 0 ? void 0 : allChartOptionSeries
47
- // Since the series index does not exist in the data we extract it from the series index
48
- .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));
49
- if (!seriesWithSeriesIndex.length) {
50
- return;
51
- }
52
- chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
53
- seriesIndex: seriesWithSeriesIndex.map((series) => series.seriesIndex),
54
- type: action,
55
- });
56
- };
57
- /**
58
- * Highlight or downplay pie chart dataset item
59
- */
60
- const highlightOrDownplayPieSlices = (chart, currentSeriesToDispatch, action, currentChartOptions) => {
61
- var _a;
62
- const isDownplay = action === 'downplay';
63
- const allChartOptionSeries = (currentChartOptions === null || currentChartOptions === void 0 ? void 0 : currentChartOptions.series) ||
64
- [];
65
- // Change blur state to add opacity on the non highlighted items in the pie chart
66
- chart === null || chart === void 0 ? void 0 : chart.setOption({
67
- series: allChartOptionSeries === null || allChartOptionSeries === void 0 ? void 0 : allChartOptionSeries.map((seriesItem) => (Object.assign(Object.assign({}, seriesItem), { blur: {
68
- itemStyle: {
69
- opacity: isDownplay ? 1 : 0.3,
70
- },
71
- label: {
72
- opacity: isDownplay ? 1 : 0.3,
73
- },
74
- } }))),
75
- });
76
- // 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
77
- const chartOptionDataset = currentChartOptions === null || currentChartOptions === void 0 ? void 0 : currentChartOptions.dataset;
78
- const datasetArray = Array.isArray(chartOptionDataset)
79
- ? chartOptionDataset
80
- : [chartOptionDataset];
81
- const sourceArray = (_a = datasetArray === null || datasetArray === void 0 ? void 0 : datasetArray[0]) === null || _a === void 0 ? void 0 : _a.source;
82
- // Find the dataIndexes that we want to dispatch
83
- const currentDataSeriesIndexes = currentSeriesToDispatch.map((series) => {
84
- const index = (sourceArray === null || sourceArray === void 0 ? void 0 : sourceArray.findIndex((item) => item[0] === series.name)) - 1;
85
- return index;
86
- });
87
- if (action === 'highlight') {
88
- // Downplay other data indexes to make sure the other slices are not highlighted
89
- const otherSeriesIndexes = sourceArray
90
- .map((_row, index) => index)
91
- .filter((dataIndex) => !currentDataSeriesIndexes.includes(dataIndex));
92
- chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
93
- dataIndex: otherSeriesIndexes,
94
- seriesIndex: [0], // pie charts only has one series so seriesIndex is always 0
95
- type: 'downplay',
96
- });
97
- }
98
- chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
99
- dataIndex: currentDataSeriesIndexes,
100
- seriesIndex: [0], // pie charts only has one series so otherSeriesIndexes is always 0
101
- type: action,
102
- });
103
- };
104
- /**
105
- * Highlight or downplay the series in the chart to toggle between emphasized and non-emphasized state
106
- */
107
- const highlightOrDownplaySeries = (chartRef, series, currentSelectedSeries, currentSeriesToDispatch, action) => {
108
- var _a, _b;
109
- const hasOnlyOneSeries = series.length === 1;
110
- const isOnlyOneSeriesSelected = Object.values(currentSelectedSeries).filter(Boolean).length === 1;
111
- if (isOnlyOneSeriesSelected ||
112
- currentSeriesToDispatch.length === 0 ||
113
- chartRef.current === null ||
114
- hasOnlyOneSeries) {
115
- return;
116
- }
117
- const chart = getInstanceByDom(chartRef.current);
118
- if (!chart) {
119
- return;
120
- }
121
- const currentChartOptions = chart.getOption();
122
- 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;
123
- if (seriesType === 'pie') {
124
- highlightOrDownplayPieSlices(chart, currentSeriesToDispatch, action, currentChartOptions);
125
- }
126
- else {
127
- highlightOrDownplayLineAndBarSeries(chart, currentSeriesToDispatch, action, currentChartOptions);
128
- }
129
- };
130
- export { highlightOrDownplaySeries };
131
- //# sourceMappingURL=legend-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legend-utils.js","sourceRoot":"","sources":["../../../../src/charts/utils/legend-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAGL,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAkB,EAAE,EAAE;IAC5D,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,UAAU,GAAI,MAAM,CAAC,MAAgC,IAAI,EAAE,CAAC;IAElE,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,WAAmB,EAAE,EAAE;QAClD,KAAK,CAAC,cAAc,CAAC;YACnB,WAAW;YACX,IAAI,EAAE,UAAU;SACjB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,mCAAmC,GAAG,CAC1C,KAAkB,EAClB,uBAA0D,EAC1D,MAAgC,EAChC,mBAAyD,EACzD,EAAE;;IACF,MAAM,UAAU,GAAG,MAAM,KAAK,UAAU,CAAC;IACzC,MAAM,oBAAoB,GACxB,CAAC,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,MAAgD;QACtE,EAAE,CAAC;IAEL,qEAAqE;IACrE,2EAA2E;IAC3E,4EAA4E;IAC5E,gBAAgB;IAChB,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,SAAS,CAAC;QACf,MAAM,EAAE,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAE,GAAG,CAAC,CAAC,UAAmC,EAAE,EAAE,CACxE,UAAU,CAAC,IAAI,KAAK,SAAS;YAC3B,CAAC,CAAC,UAAU;YACZ,CAAC,iCACM,UAAU,KACb,QAAQ,kCACF,UAAU,CAAC,QAAoC,KACnD,QAAQ,EAAE,UAAU,MAEvB,CACN;KACF,CAAC,CAAC;IAEH,MAAM,q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Content":["/*!\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,291 +0,0 @@
1
- /*!
2
- *
3
- * Copyright (c) "Neo4j"
4
- * Neo4j Sweden AB [http://neo4j.com]
5
- *
6
- * This file is part of Neo4j.
7
- *
8
- * Neo4j is free software: you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation, either version 3 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
- */
21
- /**
22
- * Scanning stops past this many points so a dense chart cannot turn every hover
23
- * into a long walk over the dataset.
24
- */
25
- const MAX_SCANNED_POINTS = 20000;
26
- /** Symbol width ECharts falls back to when a series sets no numeric size. */
27
- const DEFAULT_SYMBOL_SIZE = 10;
28
- const toArray = (value) => {
29
- if (value === undefined) {
30
- return [];
31
- }
32
- return Array.isArray(value) ? value : [value];
33
- };
34
- export const encodeRefs = (encode, key) => {
35
- if (encode === undefined) {
36
- return [];
37
- }
38
- const raw = encode[key];
39
- const refs = Array.isArray(raw) ? raw : [raw];
40
- return refs.filter((ref) => typeof ref === 'number' || typeof ref === 'string');
41
- };
42
- export const readEncodedValue = (value, ref, dimensionNames) => {
43
- if (Array.isArray(value)) {
44
- if (typeof ref === 'number') {
45
- return value[ref];
46
- }
47
- const dimensionIndex = dimensionNames === null || dimensionNames === void 0 ? void 0 : dimensionNames.indexOf(ref);
48
- return dimensionIndex !== undefined && dimensionIndex >= 0
49
- ? value[dimensionIndex]
50
- : undefined;
51
- }
52
- if (value !== null && typeof value === 'object') {
53
- const record = value;
54
- if (typeof ref === 'string' && ref in record) {
55
- return record[ref];
56
- }
57
- if (typeof ref === 'number') {
58
- const dimensionName = dimensionNames === null || dimensionNames === void 0 ? void 0 : dimensionNames[ref];
59
- if (dimensionName !== undefined && dimensionName in record) {
60
- return record[dimensionName];
61
- }
62
- }
63
- }
64
- return undefined;
65
- };
66
- export const encodedDimensionLabel = (ref, dimensionNames, fallback) => {
67
- if (typeof ref === 'string') {
68
- return ref;
69
- }
70
- const dimensionName = dimensionNames === null || dimensionNames === void 0 ? void 0 : dimensionNames[ref];
71
- if (typeof dimensionName === 'string' && dimensionName.length > 0) {
72
- return dimensionName;
73
- }
74
- return fallback;
75
- };
76
- /**
77
- * Dimensions holding the unique per-point value: `encode.tooltip` first, then
78
- * `encode.itemName`, and finally any dimension the axes do not already use.
79
- */
80
- export const extraTooltipRefs = (point) => {
81
- const xRefs = encodeRefs(point.encode, 'x');
82
- const yRefs = encodeRefs(point.encode, 'y');
83
- const isAxisRef = (ref) => xRefs.includes(ref) || yRefs.includes(ref);
84
- const tooltipRefs = encodeRefs(point.encode, 'tooltip').filter((ref) => !isAxisRef(ref));
85
- if (tooltipRefs.length > 0) {
86
- return tooltipRefs;
87
- }
88
- const itemNameRefs = encodeRefs(point.encode, 'itemName');
89
- if (itemNameRefs.length > 0) {
90
- return itemNameRefs;
91
- }
92
- if (Array.isArray(point.value) && point.value.length > 2) {
93
- const usedIndices = new Set([...xRefs, ...yRefs].filter((ref) => typeof ref === 'number'));
94
- if (usedIndices.size === 0) {
95
- usedIndices.add(0);
96
- usedIndices.add(1);
97
- }
98
- return point.value.flatMap((_value, index) => usedIndices.has(index) ? [] : [index]);
99
- }
100
- return [];
101
- };
102
- export const getEncodedAxisRefs = (encode) => {
103
- var _a, _b;
104
- return ({
105
- // oxlint-disable-next-line id-length
106
- x: (_a = encodeRefs(encode, 'x')[0]) !== null && _a !== void 0 ? _a : 0,
107
- // oxlint-disable-next-line id-length
108
- y: (_b = encodeRefs(encode, 'y')[0]) !== null && _b !== void 0 ? _b : 1,
109
- });
110
- };
111
- const toStringArray = (value) => Array.isArray(value) && value.every((entry) => typeof entry === 'string')
112
- ? value
113
- : undefined;
114
- const isHeaderRow = (row) => Array.isArray(row) &&
115
- row.length > 0 &&
116
- row.every((cell) => typeof cell === 'string');
117
- /**
118
- * Resolves the rows a series draws, together with the dimension names its
119
- * `encode` refers to. Rows are aligned with ECharts' data indices, so a sniffed
120
- * header row is dropped the way ECharts drops it.
121
- */
122
- const resolveSeriesSource = (series, datasets) => {
123
- var _a, _b;
124
- const inlineData = Array.isArray(series.data) ? series.data : undefined;
125
- const dataset = inlineData === undefined ? datasets[(_a = series.datasetIndex) !== null && _a !== void 0 ? _a : 0] : undefined;
126
- const rows = inlineData !== null && inlineData !== void 0 ? inlineData : (Array.isArray(dataset === null || dataset === void 0 ? void 0 : dataset.source) ? dataset.source : undefined);
127
- if (rows === undefined) {
128
- return undefined;
129
- }
130
- const declaredDimensions = toStringArray((_b = series.dimensions) !== null && _b !== void 0 ? _b : dataset === null || dataset === void 0 ? void 0 : dataset.dimensions);
131
- if (declaredDimensions !== undefined) {
132
- return { dimensionNames: declaredDimensions, rows };
133
- }
134
- if (isHeaderRow(rows[0]) && !isHeaderRow(rows[1])) {
135
- return { dimensionNames: rows[0], rows: rows.slice(1) };
136
- }
137
- return { rows };
138
- };
139
- const toNumericValue = (value) => {
140
- if (typeof value === 'number') {
141
- return Number.isFinite(value) ? value : undefined;
142
- }
143
- if (value instanceof Date) {
144
- return value.getTime();
145
- }
146
- if (typeof value === 'string') {
147
- const numeric = Number(value);
148
- if (Number.isFinite(numeric)) {
149
- return numeric;
150
- }
151
- const time = Date.parse(value);
152
- return Number.isFinite(time) ? time : undefined;
153
- }
154
- return undefined;
155
- };
156
- /**
157
- * Distance from the hovered value along one axis, as a share of the tolerance.
158
- * Values that cannot be compared numerically, such as category labels, only
159
- * count as near when they are identical.
160
- */
161
- const axisDistance = (value, hoveredValue, tolerance) => {
162
- const numeric = toNumericValue(value);
163
- const hoveredNumeric = toNumericValue(hoveredValue);
164
- if (numeric === undefined || hoveredNumeric === undefined) {
165
- return value === hoveredValue ? 0 : undefined;
166
- }
167
- if (tolerance <= 0) {
168
- return numeric === hoveredNumeric ? 0 : undefined;
169
- }
170
- return (numeric - hoveredNumeric) / tolerance;
171
- };
172
- const isCoordinatePair = (value) => Array.isArray(value) &&
173
- value.length >= 2 &&
174
- Number.isFinite(value[0]) &&
175
- Number.isFinite(value[1]);
176
- /**
177
- * Converts a pixel radius around the hovered point into a distance on each
178
- * axis, so points can be compared in data space instead of converting every
179
- * one of them to pixels.
180
- */
181
- const getAxisTolerances = (chart, seriesIndex, hoveredValue, radius) => {
182
- const finder = { seriesIndex };
183
- const pixel = chart.convertToPixel(finder, hoveredValue);
184
- if (!isCoordinatePair(pixel)) {
185
- return undefined;
186
- }
187
- const origin = chart.convertFromPixel(finder, [pixel[0], pixel[1]]);
188
- const offset = chart.convertFromPixel(finder, [
189
- pixel[0] + radius,
190
- pixel[1] + radius,
191
- ]);
192
- if (!isCoordinatePair(origin) || !isCoordinatePair(offset)) {
193
- return undefined;
194
- }
195
- return {
196
- // oxlint-disable-next-line id-length
197
- x: Math.abs(offset[0] - origin[0]),
198
- // oxlint-disable-next-line id-length
199
- y: Math.abs(offset[1] - origin[1]),
200
- };
201
- };
202
- /**
203
- * Widest scatter symbol in the chart, which doubles as the radius in which
204
- * points are considered to overlap the hovered one.
205
- */
206
- export function getScatterSymbolSize(series) {
207
- const sizes = toArray(series)
208
- .filter((seriesOption) => (seriesOption === null || seriesOption === void 0 ? void 0 : seriesOption.type) === 'scatter')
209
- .map((seriesOption) => typeof seriesOption.symbolSize === 'number' &&
210
- Number.isFinite(seriesOption.symbolSize)
211
- ? seriesOption.symbolSize
212
- : DEFAULT_SYMBOL_SIZE);
213
- return sizes.length > 0 ? Math.max(...sizes) : DEFAULT_SYMBOL_SIZE;
214
- }
215
- /**
216
- * Collects the points whose symbols overlap the hovered one, closest first,
217
- * with the hovered point always leading.
218
- *
219
- * Distances are measured in data space against a tolerance derived from the
220
- * pixel radius (ECharts `convertToPixel` / `convertFromPixel`), which keeps the
221
- * scan to plain arithmetic per point and works on value, time, and log axes
222
- * alike.
223
- */
224
- export function findNearbyScatterPoints({ chart, dataset, hovered, legendSelected, maxPoints, radius, series, }) {
225
- var _a;
226
- const hoveredSeriesIndex = hovered.seriesIndex;
227
- if (chart === undefined || hoveredSeriesIndex === undefined) {
228
- return [hovered];
229
- }
230
- const hoveredRefs = getEncodedAxisRefs(hovered.encode);
231
- const hoveredX = readEncodedValue(hovered.value, hoveredRefs.x, hovered.dimensionNames);
232
- const hoveredY = readEncodedValue(hovered.value, hoveredRefs.y, hovered.dimensionNames);
233
- const tolerances = getAxisTolerances(chart, hoveredSeriesIndex, [hoveredX, hoveredY], radius);
234
- if (tolerances === undefined) {
235
- return [hovered];
236
- }
237
- const seriesList = toArray(series);
238
- const datasets = toArray(dataset);
239
- const neighbors = [];
240
- let scannedPoints = 0;
241
- for (const [seriesIndex, seriesOption] of seriesList.entries()) {
242
- if ((seriesOption === null || seriesOption === void 0 ? void 0 : seriesOption.type) !== 'scatter' ||
243
- (legendSelected === null || legendSelected === void 0 ? void 0 : legendSelected[(_a = seriesOption.name) !== null && _a !== void 0 ? _a : '']) === false) {
244
- continue;
245
- }
246
- const source = resolveSeriesSource(seriesOption, datasets);
247
- if (source === undefined) {
248
- continue;
249
- }
250
- const refs = getEncodedAxisRefs(seriesOption.encode);
251
- for (const [dataIndex, row] of source.rows.entries()) {
252
- if (scannedPoints >= MAX_SCANNED_POINTS) {
253
- break;
254
- }
255
- scannedPoints += 1;
256
- if (seriesIndex === hoveredSeriesIndex &&
257
- dataIndex === hovered.dataIndex) {
258
- continue;
259
- }
260
- const xDistance = axisDistance(readEncodedValue(row, refs.x, source.dimensionNames), hoveredX, tolerances.x);
261
- const yDistance = axisDistance(readEncodedValue(row, refs.y, source.dimensionNames), hoveredY, tolerances.y);
262
- if (xDistance === undefined || yDistance === undefined) {
263
- continue;
264
- }
265
- const distance = Math.hypot(xDistance, yDistance);
266
- if (distance > 1) {
267
- continue;
268
- }
269
- neighbors.push({
270
- distance,
271
- point: {
272
- color: typeof seriesOption.color === 'string'
273
- ? seriesOption.color
274
- : undefined,
275
- dataIndex,
276
- dimensionNames: source.dimensionNames,
277
- encode: seriesOption.encode,
278
- seriesIndex,
279
- seriesName: seriesOption.name,
280
- value: row,
281
- },
282
- });
283
- }
284
- }
285
- neighbors.sort((first, second) => first.distance - second.distance);
286
- return [
287
- hovered,
288
- ...neighbors.slice(0, Math.max(maxPoints - 1, 0)).map(({ point }) => point),
289
- ];
290
- }
291
- //# sourceMappingURL=scatter-tooltip-points.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scatter-tooltip-points.js","sourceRoot":"","sources":["../../../../src/charts/utils/scatter-tooltip-points.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAkDH;;;GAGG;AACH,M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,EACR,UAAU,CAAC,CAAC,CACb,CAAC;YAEF,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBACvD,SAAS;YACX,CAAC;YAED,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YAElD,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;gBACjB,SAAS;YACX,CAAC;YAED,SAAS,CAAC,IAAI,CAAC;gBACb,QAAQ;gBACR,KAAK,EAAE;oBACL,KAAK,EACH,OAAO,YAAY,CAAC,KAAK,KAAK,QAAQ;wBACpC,CAAC,CAAC,YAAY,CAAC,KAAK;wBACpB,CAAC,CAAC,SAAS;oBACf,SAAS;oBACT,cAAc,EAAE,MAAM,CAAC,cAAc;oBACrC,MAAM,EAAE,YAAY,CAAC,MAAM;oBAC3B,WAAW;oBACX,UAAU,EAAE,YAAY,CAAC,IAAI;oBAC7B,KAAK,EAAE,GAAG;iBACX;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEpE,OAAO;QACL,OAAO;QACP,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC;KAC5E,CAAC;AACJ,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport type { ChartProps, EchartsSeries } from './chart-types';\n\ntype TooltipEncode = Record<string, unknown> | undefined;\n\n/**\n * A scatter point as the tooltip needs it. ECharts tooltip params already have\n * this shape, so the hovered point and the points found around it are\n * interchangeable.\n */\nexport type ScatterTooltipPoint = {\n color?: string;\n dataIndex?: number;\n dimensionNames?: string[];\n encode?: TooltipEncode;\n name?: string;\n seriesIndex?: number;\n seriesName?: string;\n value?: unknown;\n};\n\n/** The part of the ECharts instance the scatter tooltip reads. */\nexport type ScatterTooltipChart = {\n convertFromPixel(\n finder: { seriesIndex: number },\n value: number[],\n ): number | number[];\n convertToPixel(\n finder: { seriesIndex: number },\n value: unknown[],\n ): number | number[];\n};\n\ntype ScatterSeriesLike = {\n color?: unknown;\n data?: unknown;\n datasetIndex?: number;\n dimensions?: unknown;\n encode?: TooltipEncode;\n name?: string;\n symbolSize?: unknown;\n type?: string;\n};\n\ntype DatasetLike = {\n dimensions?: unknown;\n source?: unknown;\n};\n\n/**\n * Scanning stops past this many points so a dense chart cannot turn every hover\n * into a long walk over the dataset.\n */\nconst MAX_SCANNED_POINTS = 20000;\n\n/** Symbol width ECharts falls back to when a series sets no numeric size. */\nconst DEFAULT_SYMBOL_SIZE = 10;\n\nconst toArray = <T>(value: T | T[] | undefined): T[] => {\n if (value === undefined) {\n return [];\n }\n\n return Array.isArray(value) ? value : [value];\n};\n\nexport const encodeRefs = (\n encode: TooltipEncode,\n key: string,\n): Array<number | string> => {\n if (encode === undefined) {\n return [];\n }\n\n const raw = encode[key];\n const refs = Array.isArray(raw) ? raw : [raw];\n\n return refs.filter(\n (ref): ref is number | string =>\n typeof ref === 'number' || typeof ref === 'string',\n );\n};\n\nexport const readEncodedValue = (\n value: unknown,\n ref: number | string,\n dimensionNames?: string[],\n): unknown => {\n if (Array.isArray(value)) {\n if (typeof ref === 'number') {\n return value[ref];\n }\n\n const dimensionIndex = dimensionNames?.indexOf(ref);\n\n return dimensionIndex !== undefined && dimensionIndex >= 0\n ? value[dimensionIndex]\n : undefined;\n }\n\n if (value !== null && typeof value === 'object') {\n const record = value as Record<string, unknown>;\n\n if (typeof ref === 'string' && ref in record) {\n return record[ref];\n }\n\n if (typeof ref === 'number') {\n const dimensionName = dimensionNames?.[ref];\n\n if (dimensionName !== undefined && dimensionName in record) {\n return record[dimensionName];\n }\n }\n }\n\n return undefined;\n};\n\nexport const encodedDimensionLabel = (\n ref: number | string,\n dimensionNames: string[] | undefined,\n fallback: string,\n): string => {\n if (typeof ref === 'string') {\n return ref;\n }\n\n const dimensionName = dimensionNames?.[ref];\n\n if (typeof dimensionName === 'string' && dimensionName.length > 0) {\n return dimensionName;\n }\n\n return fallback;\n};\n\n/**\n * Dimensions holding the unique per-point value: `encode.tooltip` first, then\n * `encode.itemName`, and finally any dimension the axes do not already use.\n */\nexport const extraTooltipRefs = (\n point: ScatterTooltipPoint,\n): Array<number | string> => {\n const xRefs = encodeRefs(point.encode, 'x');\n const yRefs = encodeRefs(point.encode, 'y');\n const isAxisRef = (ref: number | string) =>\n xRefs.includes(ref) || yRefs.includes(ref);\n\n const tooltipRefs = encodeRefs(point.encode, 'tooltip').filter(\n (ref) => !isAxisRef(ref),\n );\n\n if (tooltipRefs.length > 0) {\n return tooltipRefs;\n }\n\n const itemNameRefs = encodeRefs(point.encode, 'itemName');\n\n if (itemNameRefs.length > 0) {\n return itemNameRefs;\n }\n\n if (Array.isArray(point.value) && point.value.length > 2) {\n const usedIndices = new Set(\n [...xRefs, ...yRefs].filter(\n (ref): ref is number => typeof ref === 'number',\n ),\n );\n\n if (usedIndices.size === 0) {\n usedIndices.add(0);\n usedIndices.add(1);\n }\n\n return point.value.flatMap((_value, index) =>\n usedIndices.has(index) ? [] : [index],\n );\n }\n\n return [];\n};\n\nexport const getEncodedAxisRefs = (encode: TooltipEncode) => ({\n // oxlint-disable-next-line id-length\n x: encodeRefs(encode, 'x')[0] ?? 0,\n // oxlint-disable-next-line id-length\n y: encodeRefs(encode, 'y')[0] ?? 1,\n});\n\nconst toStringArray = (value: unknown): string[] | undefined =>\n Array.isArray(value) && value.every((entry) => typeof entry === 'string')\n ? value\n : undefined;\n\nconst isHeaderRow = (row: unknown): boolean =>\n Array.isArray(row) &&\n row.length > 0 &&\n row.every((cell) => typeof cell === 'string');\n\ntype ScatterSource = {\n dimensionNames?: string[];\n rows: unknown[];\n};\n\n/**\n * Resolves the rows a series draws, together with the dimension names its\n * `encode` refers to. Rows are aligned with ECharts' data indices, so a sniffed\n * header row is dropped the way ECharts drops it.\n */\nconst resolveSeriesSource = (\n series: ScatterSeriesLike,\n datasets: DatasetLike[],\n): ScatterSource | undefined => {\n const inlineData = Array.isArray(series.data) ? series.data : undefined;\n const dataset =\n inlineData === undefined ? datasets[series.datasetIndex ?? 0] : undefined;\n const rows =\n inlineData ?? (Array.isArray(dataset?.source) ? dataset.source : undefined);\n\n if (rows === undefined) {\n return undefined;\n }\n\n const declaredDimensions = toStringArray(\n series.dimensions ?? dataset?.dimensions,\n );\n\n if (declaredDimensions !== undefined) {\n return { dimensionNames: declaredDimensions, rows };\n }\n\n if (isHeaderRow(rows[0]) && !isHeaderRow(rows[1])) {\n return { dimensionNames: rows[0] as string[], rows: rows.slice(1) };\n }\n\n return { rows };\n};\n\nconst toNumericValue = (value: unknown): number | undefined => {\n if (typeof value === 'number') {\n return Number.isFinite(value) ? value : undefined;\n }\n\n if (value instanceof Date) {\n return value.getTime();\n }\n\n if (typeof value === 'string') {\n const numeric = Number(value);\n\n if (Number.isFinite(numeric)) {\n return numeric;\n }\n\n const time = Date.parse(value);\n\n return Number.isFinite(time) ? time : undefined;\n }\n\n return undefined;\n};\n\n/**\n * Distance from the hovered value along one axis, as a share of the tolerance.\n * Values that cannot be compared numerically, such as category labels, only\n * count as near when they are identical.\n */\nconst axisDistance = (\n value: unknown,\n hoveredValue: unknown,\n tolerance: number,\n): number | undefined => {\n const numeric = toNumericValue(value);\n const hoveredNumeric = toNumericValue(hoveredValue);\n\n if (numeric === undefined || hoveredNumeric === undefined) {\n return value === hoveredValue ? 0 : undefined;\n }\n\n if (tolerance <= 0) {\n return numeric === hoveredNumeric ? 0 : undefined;\n }\n\n return (numeric - hoveredNumeric) / tolerance;\n};\n\nconst isCoordinatePair = (value: number | number[]): value is number[] =>\n Array.isArray(value) &&\n value.length >= 2 &&\n Number.isFinite(value[0]) &&\n Number.isFinite(value[1]);\n\n/**\n * Converts a pixel radius around the hovered point into a distance on each\n * axis, so points can be compared in data space instead of converting every\n * one of them to pixels.\n */\nconst getAxisTolerances = (\n chart: ScatterTooltipChart,\n seriesIndex: number,\n hoveredValue: unknown[],\n radius: number,\n) => {\n const finder = { seriesIndex };\n const pixel = chart.convertToPixel(finder, hoveredValue);\n\n if (!isCoordinatePair(pixel)) {\n return undefined;\n }\n\n const origin = chart.convertFromPixel(finder, [pixel[0], pixel[1]]);\n const offset = chart.convertFromPixel(finder, [\n pixel[0] + radius,\n pixel[1] + radius,\n ]);\n\n if (!isCoordinatePair(origin) || !isCoordinatePair(offset)) {\n return undefined;\n }\n\n return {\n // oxlint-disable-next-line id-length\n x: Math.abs(offset[0] - origin[0]),\n // oxlint-disable-next-line id-length\n y: Math.abs(offset[1] - origin[1]),\n };\n};\n\n/**\n * Widest scatter symbol in the chart, which doubles as the radius in which\n * points are considered to overlap the hovered one.\n */\nexport function getScatterSymbolSize(series: EchartsSeries): number {\n const sizes = toArray(series as ScatterSeriesLike | ScatterSeriesLike[])\n .filter((seriesOption) => seriesOption?.type === 'scatter')\n .map((seriesOption) =>\n typeof seriesOption.symbolSize === 'number' &&\n Number.isFinite(seriesOption.symbolSize)\n ? seriesOption.symbolSize\n : DEFAULT_SYMBOL_SIZE,\n );\n\n return sizes.length > 0 ? Math.max(...sizes) : DEFAULT_SYMBOL_SIZE;\n}\n\ntype FindNearbyScatterPointsParams = {\n chart: ScatterTooltipChart | undefined;\n dataset: ChartProps['dataset'];\n hovered: ScatterTooltipPoint;\n legendSelected?: Record<string, boolean>;\n maxPoints: number;\n radius: number;\n series: EchartsSeries;\n};\n\n/**\n * Collects the points whose symbols overlap the hovered one, closest first,\n * with the hovered point always leading.\n *\n * Distances are measured in data space against a tolerance derived from the\n * pixel radius (ECharts `convertToPixel` / `convertFromPixel`), which keeps the\n * scan to plain arithmetic per point and works on value, time, and log axes\n * alike.\n */\nexport function findNearbyScatterPoints({\n chart,\n dataset,\n hovered,\n legendSelected,\n maxPoints,\n radius,\n series,\n}: FindNearbyScatterPointsParams): ScatterTooltipPoint[] {\n const hoveredSeriesIndex = hovered.seriesIndex;\n\n if (chart === undefined || hoveredSeriesIndex === undefined) {\n return [hovered];\n }\n\n const hoveredRefs = getEncodedAxisRefs(hovered.encode);\n const hoveredX = readEncodedValue(\n hovered.value,\n hoveredRefs.x,\n hovered.dimensionNames,\n );\n const hoveredY = readEncodedValue(\n hovered.value,\n hoveredRefs.y,\n hovered.dimensionNames,\n );\n const tolerances = getAxisTolerances(\n chart,\n hoveredSeriesIndex,\n [hoveredX, hoveredY],\n radius,\n );\n\n if (tolerances === undefined) {\n return [hovered];\n }\n\n const seriesList = toArray(series) as ScatterSeriesLike[];\n const datasets = toArray(dataset) as DatasetLike[];\n const neighbors: Array<{ distance: number; point: ScatterTooltipPoint }> = [];\n let scannedPoints = 0;\n\n for (const [seriesIndex, seriesOption] of seriesList.entries()) {\n if (\n seriesOption?.type !== 'scatter' ||\n legendSelected?.[seriesOption.name ?? ''] === false\n ) {\n continue;\n }\n\n const source = resolveSeriesSource(seriesOption, datasets);\n\n if (source === undefined) {\n continue;\n }\n\n const refs = getEncodedAxisRefs(seriesOption.encode);\n\n for (const [dataIndex, row] of source.rows.entries()) {\n if (scannedPoints >= MAX_SCANNED_POINTS) {\n break;\n }\n\n scannedPoints += 1;\n\n if (\n seriesIndex === hoveredSeriesIndex &&\n dataIndex === hovered.dataIndex\n ) {\n continue;\n }\n\n const xDistance = axisDistance(\n readEncodedValue(row, refs.x, source.dimensionNames),\n hoveredX,\n tolerances.x,\n );\n const yDistance = axisDistance(\n readEncodedValue(row, refs.y, source.dimensionNames),\n hoveredY,\n tolerances.y,\n );\n\n if (xDistance === undefined || yDistance === undefined) {\n continue;\n }\n\n const distance = Math.hypot(xDistance, yDistance);\n\n if (distance > 1) {\n continue;\n }\n\n neighbors.push({\n distance,\n point: {\n color:\n typeof seriesOption.color === 'string'\n ? seriesOption.color\n : undefined,\n dataIndex,\n dimensionNames: source.dimensionNames,\n encode: seriesOption.encode,\n seriesIndex,\n seriesName: seriesOption.name,\n value: row,\n },\n });\n }\n }\n\n neighbors.sort((first, second) => first.distance - second.distance);\n\n return [\n hovered,\n ...neighbors.slice(0, Math.max(maxPoints - 1, 0)).map(({ point }) => point),\n ];\n}\n"]}
@@ -1,106 +0,0 @@
1
- /*!
2
- *
3
- * Copyright (c) "Neo4j"
4
- * Neo4j Sweden AB [http://neo4j.com]
5
- *
6
- * This file is part of Neo4j.
7
- *
8
- * Neo4j is free software: you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation, either version 3 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
- */
21
- import { defaultThresholdLineSeriesOption } from './defaults';
22
- export const isThresholdLine = (name) => name === null || name === void 0 ? void 0 : name.startsWith('thresholdLine');
23
- export const getThresholdLineDisplayName = (name) => name.replace('thresholdLine-', '');
24
- /**
25
- * Extracts threshold-line series and resolves defaults needed by tooltips.
26
- */
27
- export function normalizeThresholdLines(propsSeries) {
28
- const seriesArray = Array.isArray(propsSeries) ? propsSeries : [propsSeries];
29
- const thresholdLineSeries = seriesArray.filter((currentSeries) => {
30
- return currentSeries.type === 'thresholdLine';
31
- });
32
- return thresholdLineSeries.map((currentThresholdLineSeriesOption) => {
33
- var _a;
34
- return Object.assign(Object.assign({}, currentThresholdLineSeriesOption), { condition: (_a = currentThresholdLineSeriesOption.condition) !== null && _a !== void 0 ? _a : defaultThresholdLineSeriesOption.condition, value: currentThresholdLineSeriesOption.yAxis });
35
- });
36
- }
37
- /**
38
- * Evaluates a threshold condition and returns the short label used by
39
- * chart tooltip notifications.
40
- */
41
- export function evaluateThresholdCondition(value, condition, threshold) {
42
- switch (condition) {
43
- case 'greater':
44
- return {
45
- conditionText: 'Above',
46
- isConditionMet: value > threshold,
47
- };
48
- case 'greaterOrEqual':
49
- return {
50
- conditionText: value > threshold
51
- ? 'Above'
52
- : value === threshold
53
- ? 'Equal'
54
- : undefined,
55
- isConditionMet: value >= threshold,
56
- };
57
- case 'less':
58
- return {
59
- conditionText: 'Below',
60
- isConditionMet: value < threshold,
61
- };
62
- case 'lessOrEqual':
63
- return {
64
- conditionText: value < threshold
65
- ? 'Below'
66
- : value === threshold
67
- ? 'Equal'
68
- : undefined,
69
- isConditionMet: value <= threshold,
70
- };
71
- case 'equal':
72
- return {
73
- conditionText: 'Equal',
74
- isConditionMet: value === threshold,
75
- };
76
- case 'notEqual':
77
- return {
78
- conditionText: 'Not equal',
79
- isConditionMet: value !== threshold,
80
- };
81
- default:
82
- return { conditionText: undefined, isConditionMet: false };
83
- }
84
- }
85
- /**
86
- * Returns the longer condition phrase used in chart aria descriptions.
87
- */
88
- export function thresholdConditionToText(condition) {
89
- switch (condition) {
90
- case 'greater':
91
- return 'greater than';
92
- case 'greaterOrEqual':
93
- return 'greater than or equal to';
94
- case 'less':
95
- return 'less than';
96
- case 'lessOrEqual':
97
- return 'less than or equal to';
98
- case 'equal':
99
- return 'equal to';
100
- case 'notEqual':
101
- return 'not equal to';
102
- default:
103
- return 'compared to';
104
- }
105
- }
106
- //# sourceMappingURL=threshold.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"threshold.js","sourceRoot":"","sources":["../../../../src/charts/utils/threshold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAQH,OAAO,EAAE,gCAAgC,EAAE,MAAM,YAAY,CAAC;AAe9D,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAa,EAAE,EAAE,CAC/C,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,CAAC,eAAe,CAAC,CAAC;AAEpC,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,IAAY,EAAE,EAAE,CAC1D,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAErC;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,WAAyB;IAEzB,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAE7E,MAAM,mBAAmB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,EAAE;QAC/D,OAAO,aAAa,CAAC,IAAI,KAAK,eAAe,CAAC;IAChD,CAAC,CAAkD,CAAC;IAEpD,OAAO,mBAAmB,CAAC,GAAG,CAAC,CAAC,gCAAgC,EAAE,EAAE;;QAClE,uCACK,gCAAgC,KACnC,SAAS,EACP,MAAA,gCAAgC,CAAC,SAAS,mCAC1C,gCAAgC,CAAC,SAAS,EAC5C,KAAK,EAAE,gCAAgC,CAAC,KAAK,IAC7C;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,KAAa,EACb,SAAoB,EACpB,SAAiB;IAEjB,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO;gBACL,aAA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,UAAU;YACb,OAAO,cAAc,CAAC;QACxB;YACE,OAAO,aAAa,CAAC;IACzB,CAAC;AACH,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport type {\n Condition,\n NeedleSeries,\n NotificationType,\n ThresholdLineSeriesOption,\n} from './chart-types';\nimport { defaultThresholdLineSeriesOption } from './defaults';\n\nexport type NormalizedThresholdLine =\n ThresholdLineSeriesOption<NotificationType> & {\n condition: NonNullable<\n ThresholdLineSeriesOption<NotificationType>['condition']\n >;\n value: number;\n };\n\nexport type ThresholdConditionEvaluation = {\n isConditionMet: boolean;\n conditionText: string | undefined;\n};\n\nexport const isThresholdLine = (name?: string) =>\n name?.startsWith('thresholdLine');\n\nexport const getThresholdLineDisplayName = (name: string) =>\n name.replace('thresholdLine-', '');\n\n/**\n * Extracts threshold-line series and resolves defaults needed by tooltips.\n */\nexport function normalizeThresholdLines(\n propsSeries: NeedleSeries,\n): NormalizedThresholdLine[] {\n const seriesArray = Array.isArray(propsSeries) ? propsSeries : [propsSeries];\n\n const thresholdLineSeries = seriesArray.filter((currentSeries) => {\n return currentSeries.type === 'thresholdLine';\n }) as ThresholdLineSeriesOption<NotificationType>[];\n\n return thresholdLineSeries.map((currentThresholdLineSeriesOption) => {\n return {\n ...currentThresholdLineSeriesOption,\n condition:\n currentThresholdLineSeriesOption.condition ??\n defaultThresholdLineSeriesOption.condition,\n value: currentThresholdLineSeriesOption.yAxis,\n };\n });\n}\n\n/**\n * Evaluates a threshold condition and returns the short label used by\n * chart tooltip notifications.\n */\nexport function evaluateThresholdCondition(\n value: number,\n condition: Condition,\n threshold: number,\n): ThresholdConditionEvaluation {\n switch (condition) {\n case 'greater':\n return {\n conditionText: 'Above',\n isConditionMet: value > threshold,\n };\n case 'greaterOrEqual':\n return {\n conditionText:\n value > threshold\n ? 'Above'\n : value === threshold\n ? 'Equal'\n : undefined,\n isConditionMet: value >= threshold,\n };\n case 'less':\n return {\n conditionText: 'Below',\n isConditionMet: value < threshold,\n };\n case 'lessOrEqual':\n return {\n conditionText:\n value < threshold\n ? 'Below'\n : value === threshold\n ? 'Equal'\n : undefined,\n isConditionMet: value <= threshold,\n };\n case 'equal':\n return {\n conditionText: 'Equal',\n isConditionMet: value === threshold,\n };\n case 'notEqual':\n return {\n conditionText: 'Not equal',\n isConditionMet: value !== threshold,\n };\n default:\n return { conditionText: undefined, isConditionMet: false };\n }\n}\n\n/**\n * Returns the longer condition phrase used in chart aria descriptions.\n */\nexport function thresholdConditionToText(condition: Condition): string {\n switch (condition) {\n case 'greater':\n return 'greater than';\n case 'greaterOrEqual':\n return 'greater than or equal to';\n case 'less':\n return 'less than';\n case 'lessOrEqual':\n return 'less than or equal to';\n case 'equal':\n return 'equal to';\n case 'notEqual':\n return 'not equal to';\n default:\n return 'compared to';\n }\n}\n"]}