@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,384 +1,456 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeToolbox = exports.mergeDataZoom = exports.isVerticalSlider = exports.getDataZoomTargetAxes = exports.mergeYAxis = exports.mergeXAxis = exports.mergeSeries = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ const require_charts_ChartTooltip = require("../ChartTooltip.js");
7
+ const require_charts_utils_chart_tooltip_formatter = require("./chart-tooltip-formatter.js");
8
+ const require_charts_utils_defaults = require("./defaults.js");
9
+ const require_charts_utils_format_utils = require("./format-utils.js");
10
+ const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/objectSpread2.js");
11
+ let react_jsx_runtime = require("react/jsx-runtime");
12
+ let _neo4j_ndl_base = require("@neo4j-ndl/base");
13
+ let react_dom_server = require("react-dom/server");
14
+ // src/charts/utils/user-option-utils.tsx
5
15
  /*!
6
- *
7
- * Copyright (c) "Neo4j"
8
- * Neo4j Sweden AB [http://neo4j.com]
9
- *
10
- * This file is part of Neo4j.
11
- *
12
- * Neo4j is free software: you can redistribute it and/or modify
13
- * it under the terms of the GNU General Public License as published by
14
- * the Free Software Foundation, either version 3 of the License, or
15
- * (at your option) any later version.
16
- *
17
- * This program is distributed in the hope that it will be useful,
18
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- * GNU General Public License for more details.
21
- *
22
- * You should have received a copy of the GNU General Public License
23
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
24
- */
25
- const base_1 = require("@neo4j-ndl/base");
26
- const server_1 = require("react-dom/server");
27
- const ChartTooltip_1 = require("../ChartTooltip");
28
- const chart_tooltip_formatter_1 = require("./chart-tooltip-formatter");
29
- const defaults_1 = require("./defaults");
30
- const format_utils_1 = require("./format-utils");
31
- const defaultColors = Object.values(base_1.tokens.categorical);
32
- const mergeAxisTooltip = (tooltip) => (Object.assign({ formatter: (params) => {
33
- var _a;
34
- return ((_a = params.isTruncated) === null || _a === void 0 ? void 0 : _a.call(params)) === true
35
- ? (0, server_1.renderToString)((0, jsx_runtime_1.jsx)("span", { className: "ndl-tooltip-content ndl-tooltip-content-simple", children: params.name }))
36
- : undefined;
37
- }, show: true }, tooltip));
38
- const mergeSeries = (series, theme = 'light', userOption, palette) => {
39
- const colors = palette !== null && palette !== void 0 ? palette : defaultColors;
40
- return series.map((option, index = 0) => {
41
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
42
- if (option === undefined) {
43
- return {};
44
- }
45
- const color = Array.isArray(option.color)
46
- ? option.color[index]
47
- : ((_a = option.color) !== null && _a !== void 0 ? _a : colors[index % colors.length]);
48
- if (option.type === 'thresholdLine') {
49
- const { notificationType } = option;
50
- // Needed to differentiate between normal lines and threshold lines
51
- // as we are unable to inject custom properties into echarts series lines.
52
- const thresholdLineName = `thresholdLine-${notificationType}`;
53
- return Object.assign(Object.assign({ symbolSize: 9, symbol: 'none', condition: defaults_1.defaultThresholdLineSeriesOption.condition }, option), { lineStyle: Object.assign({ type: 'dashed', width: 2 }, option.lineStyle), name: thresholdLineName, type: 'line', data: [
54
- [option.xAxis[0], option.yAxis],
55
- [option.xAxis[1], option.yAxis],
56
- ] });
57
- }
58
- if (option.type === 'line') {
59
- const shadow = base_1.tokens.theme[theme].boxShadow.raised;
60
- const shadowParts = shadow.split(/ (?=\d+px|rgba?\()/);
61
- return Object.assign(Object.assign({ type: 'line', symbolSize: 9, color, symbol: 'none' }, option), { lineStyle: Object.assign({ type: 'solid', width: 2 }, option.lineStyle), emphasis: Object.assign(Object.assign(Object.assign({ disabled: true, focus: 'series' }, option.emphasis), { itemStyle: Object.assign({ borderColor: base_1.tokens.theme[theme].color.neutral.bg.weak, shadowBlur: parseInt(shadowParts[2]), shadowColor: shadowParts[4], shadowOffsetX: parseInt(shadowParts[0]), shadowOffsetY: parseInt(shadowParts[1]) }, (_b = option.emphasis) === null || _b === void 0 ? void 0 : _b.itemStyle), label: { show: false } }), option.emphasis) });
62
- }
63
- if (option.type === 'pie') {
64
- const valueFormatter = (0, chart_tooltip_formatter_1.getTooltipValueFormatter)(userOption);
65
- return Object.assign(Object.assign({ animationDuration: 600, animationType: 'scale', selectedMode: 'single' }, option), {
66
- // Blur opacity is set to 1 to prevent other slices from
67
- // being opacitated when hovering a slice where the emphasis is enabled (used for scale effect)
68
- blur: Object.assign({ itemStyle: Object.assign({ opacity: 1 }, (_c = option.blur) === null || _c === void 0 ? void 0 : _c.itemStyle), label: Object.assign({ opacity: 1 }, (_d = option.blur) === null || _d === void 0 ? void 0 : _d.label) }, option.blur),
69
- // Emphasis is enabled and used to apply the scale effect when hovering the pie chart slices.
70
- emphasis: Object.assign({ disabled: false, focus: 'self', scale: true, scaleSize: 5 }, option.emphasis), itemStyle: Object.assign({ borderColor: base_1.tokens.theme[theme].color.neutral.bg.weak, borderWidth: 1 }, option.itemStyle), label: Object.assign({ backgroundColor: 'transparent', color: base_1.tokens.theme[theme].color.neutral.text.weak, formatter: '{d}%' }, option.label), labelLine: Object.assign({ length: 5, show: true }, option.labelLine), tooltip: Object.assign({ trigger: 'item', confine: true,
71
- // Reset the default tooltip css styling
72
- padding: 0, borderRadius: 0, borderWidth: 0, extraCssText: defaults_1.tooltipExtraCssText, formatter: function (params) {
73
- var _a;
74
- const paramsArray = Array.isArray(params) ? params : [params];
75
- const firstParam = paramsArray[0];
76
- const sliceName = (_a = firstParam === null || firstParam === void 0 ? void 0 : firstParam.value[0]) !== null && _a !== void 0 ? _a : firstParam.seriesName;
77
- // Only dates are formatted, so a numeric name like a year keeps
78
- // its digits as they are.
79
- const sliceLabel = sliceName instanceof Date
80
- ? (0, format_utils_1.formatTimeAxisDate)(sliceName)
81
- : sliceName;
82
- return `${(0, server_1.renderToString)((0, jsx_runtime_1.jsx)("span", { className: "ndl-charts-chart-tooltip", children: (0, jsx_runtime_1.jsx)(ChartTooltip_1.ChartTooltip.Content, { leadingElement: sliceLabel, trailingElement: valueFormatter(Array.isArray(firstParam.value)
83
- ? firstParam.value[1]
84
- : firstParam.value), indentSquareColor: firstParam.color }, sliceLabel) }))}`;
85
- } }, option.tooltip) });
86
- }
87
- if (option.type === 'scatter') {
88
- // `emptyCircle` always fills with white, so the interior is a real
89
- // circle painted with the theme's surface color. The ring is the border,
90
- // drawn on top of that fill. Hover replaces the interior with the
91
- // series color and leaves the ring in place. `focus` stays 'none':
92
- // any other value blurs the series, and blur wins over emphasis, so
93
- // the circle would never fill.
94
- const interiorColor = base_1.tokens.theme[theme].color.neutral.bg.weak;
95
- return Object.assign(Object.assign({ color, symbol: 'circle', symbolSize: 10 }, option), { itemStyle: Object.assign({ borderColor: color, borderWidth: 2, color: interiorColor }, option.itemStyle), emphasis: Object.assign(Object.assign({ disabled: false, focus: 'none' }, option.emphasis), { itemStyle: Object.assign({ borderColor: color, color }, (_e = option.emphasis) === null || _e === void 0 ? void 0 : _e.itemStyle) }) });
96
- }
97
- if (option.type === 'bar') {
98
- const valueFormatter = (0, chart_tooltip_formatter_1.getTooltipValueFormatter)(userOption);
99
- return Object.assign(Object.assign({ barMaxWidth: 16 }, option), { blur: Object.assign({ itemStyle: Object.assign({ opacity: 0.3 }, (_f = option.blur) === null || _f === void 0 ? void 0 : _f.itemStyle) }, option.blur), emphasis: Object.assign({ disabled: true, focus: 'series' }, option.emphasis), itemStyle: Object.assign({ borderWidth: 20, color }, option.itemStyle), markLine: {
100
- emphasis: Object.assign({ disabled: true, lineStyle: Object.assign({ width: 20 }, (_h = (_g = option.markLine) === null || _g === void 0 ? void 0 : _g.emphasis) === null || _h === void 0 ? void 0 : _h.lineStyle) }, (_j = option.markLine) === null || _j === void 0 ? void 0 : _j.emphasis),
101
- lineStyle: Object.assign({ width: 20 }, (_k = option.markLine) === null || _k === void 0 ? void 0 : _k.lineStyle),
102
- }, tooltip: Object.assign({ trigger: 'axis', confine: true,
103
- // Reset the default tooltip css styling
104
- padding: 0, borderRadius: 0, borderWidth: 0, extraCssText: defaults_1.tooltipExtraCssText, formatter: function (params) {
105
- var _a;
106
- const paramsArray = Array.isArray(params) ? params : [params];
107
- const firstParam = paramsArray[0];
108
- return `${(0, server_1.renderToString)((0, jsx_runtime_1.jsxs)("span", { className: "ndl-charts-chart-tooltip", children: [(0, jsx_runtime_1.jsx)(ChartTooltip_1.ChartTooltip.Title, { children: firstParam.name }), (0, jsx_runtime_1.jsx)(ChartTooltip_1.ChartTooltip.Content, { leadingElement: firstParam.seriesName, trailingElement: valueFormatter(Array.isArray(firstParam.value)
109
- ? firstParam.value[1]
110
- : firstParam.value), indentSquareColor: firstParam.color }, (_a = firstParam === null || firstParam === void 0 ? void 0 : firstParam.value[0]) !== null && _a !== void 0 ? _a : firstParam.seriesName)] }))}`;
111
- } }, option.tooltip) });
112
- }
113
- return option;
114
- });
16
+ *
17
+ * Copyright (c) "Neo4j"
18
+ * Neo4j Sweden AB [http://neo4j.com]
19
+ *
20
+ * This file is part of Neo4j.
21
+ *
22
+ * Neo4j is free software: you can redistribute it and/or modify
23
+ * it under the terms of the GNU General Public License as published by
24
+ * the Free Software Foundation, either version 3 of the License, or
25
+ * (at your option) any later version.
26
+ *
27
+ * This program is distributed in the hope that it will be useful,
28
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
+ * GNU General Public License for more details.
31
+ *
32
+ * You should have received a copy of the GNU General Public License
33
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
34
+ */
35
+ const defaultColors = Object.values(_neo4j_ndl_base.tokens.categorical);
36
+ const mergeAxisTooltip = (tooltip) => require_objectSpread2.default({
37
+ formatter: (params) => {
38
+ var _params$isTruncated;
39
+ return ((_params$isTruncated = params.isTruncated) === null || _params$isTruncated === void 0 ? void 0 : _params$isTruncated.call(params)) === true ? (0, react_dom_server.renderToString)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
40
+ className: "ndl-tooltip-content ndl-tooltip-content-simple",
41
+ children: params.name
42
+ })) : void 0;
43
+ },
44
+ show: true
45
+ }, tooltip);
46
+ const mergeSeries = (series, theme = "light", userOption, palette) => {
47
+ const colors = palette !== null && palette !== void 0 ? palette : defaultColors;
48
+ return series.map((option, index = 0) => {
49
+ var _option$color;
50
+ if (option === void 0) return {};
51
+ const color = Array.isArray(option.color) ? option.color[index] : (_option$color = option.color) !== null && _option$color !== void 0 ? _option$color : colors[index % colors.length];
52
+ if (option.type === "thresholdLine") {
53
+ const { notificationType } = option;
54
+ const thresholdLineName = `thresholdLine-${notificationType}`;
55
+ return require_objectSpread2.default(require_objectSpread2.default({
56
+ symbolSize: 9,
57
+ symbol: "none",
58
+ condition: require_charts_utils_defaults.defaultThresholdLineSeriesOption.condition
59
+ }, option), {}, {
60
+ lineStyle: require_objectSpread2.default({
61
+ type: "dashed",
62
+ width: 2
63
+ }, option.lineStyle),
64
+ name: thresholdLineName,
65
+ type: "line",
66
+ data: [[option.xAxis[0], option.yAxis], [option.xAxis[1], option.yAxis]]
67
+ });
68
+ }
69
+ if (option.type === "line") {
70
+ var _option$emphasis;
71
+ const shadowParts = _neo4j_ndl_base.tokens.theme[theme].boxShadow.raised.split(/ (?=\d+px|rgba?\()/);
72
+ return require_objectSpread2.default(require_objectSpread2.default({
73
+ type: "line",
74
+ symbolSize: 9,
75
+ color,
76
+ symbol: "none"
77
+ }, option), {}, {
78
+ lineStyle: require_objectSpread2.default({
79
+ type: "solid",
80
+ width: 2
81
+ }, option.lineStyle),
82
+ emphasis: require_objectSpread2.default(require_objectSpread2.default({
83
+ disabled: true,
84
+ focus: "series"
85
+ }, option.emphasis), {}, {
86
+ itemStyle: require_objectSpread2.default({
87
+ borderColor: _neo4j_ndl_base.tokens.theme[theme].color.neutral.bg.weak,
88
+ shadowBlur: parseInt(shadowParts[2]),
89
+ shadowColor: shadowParts[4],
90
+ shadowOffsetX: parseInt(shadowParts[0]),
91
+ shadowOffsetY: parseInt(shadowParts[1])
92
+ }, (_option$emphasis = option.emphasis) === null || _option$emphasis === void 0 ? void 0 : _option$emphasis.itemStyle),
93
+ label: { show: false }
94
+ }, option.emphasis)
95
+ });
96
+ }
97
+ if (option.type === "pie") {
98
+ var _option$blur, _option$blur2;
99
+ const valueFormatter = require_charts_utils_chart_tooltip_formatter.getTooltipValueFormatter(userOption);
100
+ return require_objectSpread2.default(require_objectSpread2.default({
101
+ animationDuration: 600,
102
+ animationType: "scale",
103
+ selectedMode: "single"
104
+ }, option), {}, {
105
+ blur: require_objectSpread2.default({
106
+ itemStyle: require_objectSpread2.default({ opacity: 1 }, (_option$blur = option.blur) === null || _option$blur === void 0 ? void 0 : _option$blur.itemStyle),
107
+ label: require_objectSpread2.default({ opacity: 1 }, (_option$blur2 = option.blur) === null || _option$blur2 === void 0 ? void 0 : _option$blur2.label)
108
+ }, option.blur),
109
+ emphasis: require_objectSpread2.default({
110
+ disabled: false,
111
+ focus: "self",
112
+ scale: true,
113
+ scaleSize: 5
114
+ }, option.emphasis),
115
+ itemStyle: require_objectSpread2.default({
116
+ borderColor: _neo4j_ndl_base.tokens.theme[theme].color.neutral.bg.weak,
117
+ borderWidth: 1
118
+ }, option.itemStyle),
119
+ label: require_objectSpread2.default({
120
+ backgroundColor: "transparent",
121
+ color: _neo4j_ndl_base.tokens.theme[theme].color.neutral.text.weak,
122
+ formatter: "{d}%"
123
+ }, option.label),
124
+ labelLine: require_objectSpread2.default({
125
+ length: 5,
126
+ show: true
127
+ }, option.labelLine),
128
+ tooltip: require_objectSpread2.default({
129
+ trigger: "item",
130
+ confine: true,
131
+ padding: 0,
132
+ borderRadius: 0,
133
+ borderWidth: 0,
134
+ extraCssText: require_charts_utils_defaults.tooltipExtraCssText,
135
+ formatter: function(params) {
136
+ var _firstParam$value$;
137
+ const firstParam = (Array.isArray(params) ? params : [params])[0];
138
+ const sliceName = (_firstParam$value$ = firstParam === null || firstParam === void 0 ? void 0 : firstParam.value[0]) !== null && _firstParam$value$ !== void 0 ? _firstParam$value$ : firstParam.seriesName;
139
+ const sliceLabel = sliceName instanceof Date ? require_charts_utils_format_utils.formatTimeAxisDate(sliceName) : sliceName;
140
+ return `${(0, react_dom_server.renderToString)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
141
+ className: "ndl-charts-chart-tooltip",
142
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_charts_ChartTooltip.ChartTooltip.Content, {
143
+ leadingElement: sliceLabel,
144
+ trailingElement: valueFormatter(Array.isArray(firstParam.value) ? firstParam.value[1] : firstParam.value),
145
+ indentSquareColor: firstParam.color
146
+ }, sliceLabel)
147
+ }))}`;
148
+ }
149
+ }, option.tooltip)
150
+ });
151
+ }
152
+ if (option.type === "scatter") {
153
+ var _option$emphasis2;
154
+ const interiorColor = _neo4j_ndl_base.tokens.theme[theme].color.neutral.bg.weak;
155
+ return require_objectSpread2.default(require_objectSpread2.default({
156
+ color,
157
+ symbol: "circle",
158
+ symbolSize: 10
159
+ }, option), {}, {
160
+ itemStyle: require_objectSpread2.default({
161
+ borderColor: color,
162
+ borderWidth: 2,
163
+ color: interiorColor
164
+ }, option.itemStyle),
165
+ emphasis: require_objectSpread2.default(require_objectSpread2.default({
166
+ disabled: false,
167
+ focus: "none"
168
+ }, option.emphasis), {}, { itemStyle: require_objectSpread2.default({
169
+ borderColor: color,
170
+ color
171
+ }, (_option$emphasis2 = option.emphasis) === null || _option$emphasis2 === void 0 ? void 0 : _option$emphasis2.itemStyle) })
172
+ });
173
+ }
174
+ if (option.type === "bar") {
175
+ var _option$blur3, _option$markLine, _option$markLine2, _option$markLine3;
176
+ const valueFormatter = require_charts_utils_chart_tooltip_formatter.getTooltipValueFormatter(userOption);
177
+ return require_objectSpread2.default(require_objectSpread2.default({ barMaxWidth: 16 }, option), {}, {
178
+ blur: require_objectSpread2.default({ itemStyle: require_objectSpread2.default({ opacity: .3 }, (_option$blur3 = option.blur) === null || _option$blur3 === void 0 ? void 0 : _option$blur3.itemStyle) }, option.blur),
179
+ emphasis: require_objectSpread2.default({
180
+ disabled: true,
181
+ focus: "series"
182
+ }, option.emphasis),
183
+ itemStyle: require_objectSpread2.default({
184
+ borderWidth: 20,
185
+ color
186
+ }, option.itemStyle),
187
+ markLine: {
188
+ emphasis: require_objectSpread2.default({
189
+ disabled: true,
190
+ lineStyle: require_objectSpread2.default({ width: 20 }, (_option$markLine = option.markLine) === null || _option$markLine === void 0 || (_option$markLine = _option$markLine.emphasis) === null || _option$markLine === void 0 ? void 0 : _option$markLine.lineStyle)
191
+ }, (_option$markLine2 = option.markLine) === null || _option$markLine2 === void 0 ? void 0 : _option$markLine2.emphasis),
192
+ lineStyle: require_objectSpread2.default({ width: 20 }, (_option$markLine3 = option.markLine) === null || _option$markLine3 === void 0 ? void 0 : _option$markLine3.lineStyle)
193
+ },
194
+ tooltip: require_objectSpread2.default({
195
+ trigger: "axis",
196
+ confine: true,
197
+ padding: 0,
198
+ borderRadius: 0,
199
+ borderWidth: 0,
200
+ extraCssText: require_charts_utils_defaults.tooltipExtraCssText,
201
+ formatter: function(params) {
202
+ var _firstParam$value$2;
203
+ const firstParam = (Array.isArray(params) ? params : [params])[0];
204
+ return `${(0, react_dom_server.renderToString)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
205
+ className: "ndl-charts-chart-tooltip",
206
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_charts_ChartTooltip.ChartTooltip.Title, { children: firstParam.name }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_charts_ChartTooltip.ChartTooltip.Content, {
207
+ leadingElement: firstParam.seriesName,
208
+ trailingElement: valueFormatter(Array.isArray(firstParam.value) ? firstParam.value[1] : firstParam.value),
209
+ indentSquareColor: firstParam.color
210
+ }, (_firstParam$value$2 = firstParam === null || firstParam === void 0 ? void 0 : firstParam.value[0]) !== null && _firstParam$value$2 !== void 0 ? _firstParam$value$2 : firstParam.seriesName)]
211
+ }))}`;
212
+ }
213
+ }, option.tooltip)
214
+ });
215
+ }
216
+ return option;
217
+ });
115
218
  };
116
- exports.mergeSeries = mergeSeries;
117
- const mergeXAxis = (xAxis, theme = 'light') => {
118
- var _a, _b;
119
- if (xAxis === undefined) {
120
- return [];
121
- }
122
- if (Array.isArray(xAxis)) {
123
- return xAxis.map((axis) => (0, exports.mergeXAxis)(axis, theme));
124
- }
125
- const baseXAxis = Object.assign(Object.assign({}, xAxis), { axisLabel: Object.assign({ formatter: {
126
- day: '{dd} {MMM}',
127
- hour: '{HH}:{mm}',
128
- millisecond: '{hh}:{mm}:{ss} {SSS}',
129
- minute: '{HH}:{mm}',
130
- month: '{MMM}',
131
- none: '{yyyy}-{MM}-{dd} {hh}:{mm}:{ss} {SSS}',
132
- second: '{HH}:{mm}:{ss}',
133
- year: '{yearStyle|{yyyy}}\n{monthStyle|{MMM}}',
134
- }, margin: 16, overflow: 'truncate' }, xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisLabel), axisLine: Object.assign({ lineStyle: Object.assign({}, (_a = xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisLine) === null || _a === void 0 ? void 0 : _a.lineStyle) }, xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisLine), axisTick: Object.assign(Object.assign(Object.assign({}, xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisTick), { lineStyle: Object.assign({}, (_b = xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisTick) === null || _b === void 0 ? void 0 : _b.lineStyle), show: true }), xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisTick), splitLine: Object.assign({ show: false }, xAxis === null || xAxis === void 0 ? void 0 : xAxis.splitLine), tooltip: mergeAxisTooltip(xAxis.tooltip) });
135
- if (xAxis.type === 'time') {
136
- const timeXAxis = Object.assign(Object.assign({}, baseXAxis), { axisLabel: Object.assign({ hideOverlap: true }, baseXAxis.axisLabel) });
137
- return timeXAxis;
138
- }
139
- if (xAxis.type === 'value' || xAxis.type === 'log') {
140
- const xAxisFormatter = xAxis.axisLabel && 'formatter' in xAxis.axisLabel
141
- ? xAxis.axisLabel.formatter
142
- : undefined;
143
- const valueXAxis = Object.assign(Object.assign({}, baseXAxis), { axisLabel: Object.assign(Object.assign({}, baseXAxis.axisLabel), { formatter: xAxisFormatter !== null && xAxisFormatter !== void 0 ? xAxisFormatter : format_utils_1.formatNumberEnUS }) });
144
- return valueXAxis;
145
- }
146
- if (xAxis.type === 'category') {
147
- const categoryXAxis = Object.assign(Object.assign({}, baseXAxis), { axisLabel: Object.assign({ width: 80 }, baseXAxis === null || baseXAxis === void 0 ? void 0 : baseXAxis.axisLabel), axisTick: Object.assign({ alignWithLabel: true }, baseXAxis === null || baseXAxis === void 0 ? void 0 : baseXAxis.axisTick) });
148
- return categoryXAxis;
149
- }
150
- return baseXAxis;
219
+ const mergeXAxis = (xAxis, theme = "light") => {
220
+ var _xAxis$axisLine, _xAxis$axisTick;
221
+ if (xAxis === void 0) return [];
222
+ if (Array.isArray(xAxis)) return xAxis.map((axis) => mergeXAxis(axis, theme));
223
+ const baseXAxis = require_objectSpread2.default(require_objectSpread2.default({}, xAxis), {}, {
224
+ axisLabel: require_objectSpread2.default({
225
+ formatter: {
226
+ day: "{dd} {MMM}",
227
+ hour: "{HH}:{mm}",
228
+ millisecond: "{hh}:{mm}:{ss} {SSS}",
229
+ minute: "{HH}:{mm}",
230
+ month: "{MMM}",
231
+ none: "{yyyy}-{MM}-{dd} {hh}:{mm}:{ss} {SSS}",
232
+ second: "{HH}:{mm}:{ss}",
233
+ year: "{yearStyle|{yyyy}}\n{monthStyle|{MMM}}"
234
+ },
235
+ margin: 16,
236
+ overflow: "truncate"
237
+ }, xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisLabel),
238
+ axisLine: require_objectSpread2.default({ lineStyle: require_objectSpread2.default({}, xAxis === null || xAxis === void 0 || (_xAxis$axisLine = xAxis.axisLine) === null || _xAxis$axisLine === void 0 ? void 0 : _xAxis$axisLine.lineStyle) }, xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisLine),
239
+ axisTick: require_objectSpread2.default(require_objectSpread2.default({}, xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisTick), {}, {
240
+ lineStyle: require_objectSpread2.default({}, xAxis === null || xAxis === void 0 || (_xAxis$axisTick = xAxis.axisTick) === null || _xAxis$axisTick === void 0 ? void 0 : _xAxis$axisTick.lineStyle),
241
+ show: true
242
+ }, xAxis === null || xAxis === void 0 ? void 0 : xAxis.axisTick),
243
+ splitLine: require_objectSpread2.default({ show: false }, xAxis === null || xAxis === void 0 ? void 0 : xAxis.splitLine),
244
+ tooltip: mergeAxisTooltip(xAxis.tooltip)
245
+ });
246
+ if (xAxis.type === "time") return require_objectSpread2.default(require_objectSpread2.default({}, baseXAxis), {}, { axisLabel: require_objectSpread2.default({ hideOverlap: true }, baseXAxis.axisLabel) });
247
+ if (xAxis.type === "value" || xAxis.type === "log") {
248
+ const xAxisFormatter = xAxis.axisLabel && "formatter" in xAxis.axisLabel ? xAxis.axisLabel.formatter : void 0;
249
+ return require_objectSpread2.default(require_objectSpread2.default({}, baseXAxis), {}, { axisLabel: require_objectSpread2.default(require_objectSpread2.default({}, baseXAxis.axisLabel), {}, { formatter: xAxisFormatter !== null && xAxisFormatter !== void 0 ? xAxisFormatter : require_charts_utils_format_utils.formatNumberEnUS }) });
250
+ }
251
+ if (xAxis.type === "category") return require_objectSpread2.default(require_objectSpread2.default({}, baseXAxis), {}, {
252
+ axisLabel: require_objectSpread2.default({ width: 80 }, baseXAxis === null || baseXAxis === void 0 ? void 0 : baseXAxis.axisLabel),
253
+ axisTick: require_objectSpread2.default({ alignWithLabel: true }, baseXAxis === null || baseXAxis === void 0 ? void 0 : baseXAxis.axisTick)
254
+ });
255
+ return baseXAxis;
151
256
  };
152
- exports.mergeXAxis = mergeXAxis;
153
- const mergeYAxis = (yAxis, theme = 'light') => {
154
- var _a, _b;
155
- if (yAxis === undefined) {
156
- return [];
157
- }
158
- if (Array.isArray(yAxis)) {
159
- return yAxis.map((axis) => (0, exports.mergeYAxis)(axis, theme));
160
- }
161
- const baseYAxis = Object.assign(Object.assign({}, yAxis), { axisLabel: Object.assign({ margin: 8, overflow: 'truncate' }, yAxis === null || yAxis === void 0 ? void 0 : yAxis.axisLabel), axisLine: Object.assign(Object.assign({}, yAxis === null || yAxis === void 0 ? void 0 : yAxis.axisLine), { lineStyle: Object.assign({}, (_a = yAxis === null || yAxis === void 0 ? void 0 : yAxis.axisLine) === null || _a === void 0 ? void 0 : _a.lineStyle), show: true }), axisTick: Object.assign(Object.assign({ show: false }, yAxis === null || yAxis === void 0 ? void 0 : yAxis.axisTick), { lineStyle: Object.assign({ width: 1 }, (_b = yAxis === null || yAxis === void 0 ? void 0 : yAxis.axisTick) === null || _b === void 0 ? void 0 : _b.lineStyle) }), splitLine: Object.assign({ show: true }, yAxis === null || yAxis === void 0 ? void 0 : yAxis.splitLine), tooltip: mergeAxisTooltip(yAxis.tooltip) });
162
- if (yAxis.type === 'time') {
163
- const timeYAxis = Object.assign(Object.assign({}, baseYAxis), { axisLabel: Object.assign({ hideOverlap: true }, baseYAxis.axisLabel), splitLine: Object.assign({ show: false }, baseYAxis === null || baseYAxis === void 0 ? void 0 : baseYAxis.splitLine) });
164
- return timeYAxis;
165
- }
166
- if (yAxis.type === 'value' || yAxis.type === 'log') {
167
- const yAxisFormatter = yAxis.axisLabel && 'formatter' in yAxis.axisLabel
168
- ? yAxis.axisLabel.formatter
169
- : undefined;
170
- const valueYAxis = Object.assign(Object.assign({}, baseYAxis), { axisLabel: Object.assign(Object.assign({ hideOverlap: true }, baseYAxis.axisLabel), { formatter: yAxisFormatter !== null && yAxisFormatter !== void 0 ? yAxisFormatter : format_utils_1.formatNumberEnUS }), splitLine: Object.assign({ show: false }, baseYAxis === null || baseYAxis === void 0 ? void 0 : baseYAxis.splitLine) });
171
- return valueYAxis;
172
- }
173
- if (yAxis.type === 'category') {
174
- const categoryYAxis = Object.assign(Object.assign({}, baseYAxis), { axisLabel: Object.assign({ width: 100 }, baseYAxis === null || baseYAxis === void 0 ? void 0 : baseYAxis.axisLabel) });
175
- return categoryYAxis;
176
- }
177
- return baseYAxis;
257
+ const mergeYAxis = (yAxis, theme = "light") => {
258
+ var _yAxis$axisLine, _yAxis$axisTick;
259
+ if (yAxis === void 0) return [];
260
+ if (Array.isArray(yAxis)) return yAxis.map((axis) => mergeYAxis(axis, theme));
261
+ const baseYAxis = require_objectSpread2.default(require_objectSpread2.default({}, yAxis), {}, {
262
+ axisLabel: require_objectSpread2.default({
263
+ margin: 8,
264
+ overflow: "truncate"
265
+ }, yAxis === null || yAxis === void 0 ? void 0 : yAxis.axisLabel),
266
+ axisLine: require_objectSpread2.default(require_objectSpread2.default({}, yAxis === null || yAxis === void 0 ? void 0 : yAxis.axisLine), {}, {
267
+ lineStyle: require_objectSpread2.default({}, yAxis === null || yAxis === void 0 || (_yAxis$axisLine = yAxis.axisLine) === null || _yAxis$axisLine === void 0 ? void 0 : _yAxis$axisLine.lineStyle),
268
+ show: true
269
+ }),
270
+ axisTick: require_objectSpread2.default(require_objectSpread2.default({ show: false }, yAxis === null || yAxis === void 0 ? void 0 : yAxis.axisTick), {}, { lineStyle: require_objectSpread2.default({ width: 1 }, yAxis === null || yAxis === void 0 || (_yAxis$axisTick = yAxis.axisTick) === null || _yAxis$axisTick === void 0 ? void 0 : _yAxis$axisTick.lineStyle) }),
271
+ splitLine: require_objectSpread2.default({ show: true }, yAxis === null || yAxis === void 0 ? void 0 : yAxis.splitLine),
272
+ tooltip: mergeAxisTooltip(yAxis.tooltip)
273
+ });
274
+ if (yAxis.type === "time") return require_objectSpread2.default(require_objectSpread2.default({}, baseYAxis), {}, {
275
+ axisLabel: require_objectSpread2.default({ hideOverlap: true }, baseYAxis.axisLabel),
276
+ splitLine: require_objectSpread2.default({ show: false }, baseYAxis === null || baseYAxis === void 0 ? void 0 : baseYAxis.splitLine)
277
+ });
278
+ if (yAxis.type === "value" || yAxis.type === "log") {
279
+ const yAxisFormatter = yAxis.axisLabel && "formatter" in yAxis.axisLabel ? yAxis.axisLabel.formatter : void 0;
280
+ return require_objectSpread2.default(require_objectSpread2.default({}, baseYAxis), {}, {
281
+ axisLabel: require_objectSpread2.default(require_objectSpread2.default({ hideOverlap: true }, baseYAxis.axisLabel), {}, { formatter: yAxisFormatter !== null && yAxisFormatter !== void 0 ? yAxisFormatter : require_charts_utils_format_utils.formatNumberEnUS }),
282
+ splitLine: require_objectSpread2.default({ show: false }, baseYAxis === null || baseYAxis === void 0 ? void 0 : baseYAxis.splitLine)
283
+ });
284
+ }
285
+ if (yAxis.type === "category") return require_objectSpread2.default(require_objectSpread2.default({}, baseYAxis), {}, { axisLabel: require_objectSpread2.default({ width: 100 }, baseYAxis === null || baseYAxis === void 0 ? void 0 : baseYAxis.axisLabel) });
286
+ return baseYAxis;
178
287
  };
179
- exports.mergeYAxis = mergeYAxis;
180
288
  const normalizeAxisIndices = (axisIndex) => {
181
- if (typeof axisIndex === 'number') {
182
- return [axisIndex];
183
- }
184
- if (Array.isArray(axisIndex)) {
185
- return axisIndex.filter((index) => {
186
- return typeof index === 'number';
187
- });
188
- }
189
- return [];
289
+ if (typeof axisIndex === "number") return [axisIndex];
290
+ if (Array.isArray(axisIndex)) return axisIndex.filter((index) => {
291
+ return typeof index === "number";
292
+ });
293
+ return [];
190
294
  };
191
295
  /**
192
- * Resolves the axes a single dataZoom entry targets, mirroring ECharts' own
193
- * resolution order: explicit `xAxisIndex`/`yAxisIndex` win (`false` meaning
194
- * "not this axis"); when no index is given, `orient: 'vertical'` targets the
195
- * first y-axis and horizontal/unset targets the first x-axis.
196
- */
296
+ * Resolves the axes a single dataZoom entry targets, mirroring ECharts' own
297
+ * resolution order: explicit `xAxisIndex`/`yAxisIndex` win (`false` meaning
298
+ * "not this axis"); when no index is given, `orient: 'vertical'` targets the
299
+ * first y-axis and horizontal/unset targets the first x-axis.
300
+ */
197
301
  const getSingleDataZoomTargets = (dataZoom) => {
198
- if ((dataZoom === null || dataZoom === void 0 ? void 0 : dataZoom.type) !== 'slider' && (dataZoom === null || dataZoom === void 0 ? void 0 : dataZoom.type) !== 'inside') {
199
- return { xAxisIndices: [], yAxisIndices: [] };
200
- }
201
- const hasAxisIndex = dataZoom.xAxisIndex !== undefined || dataZoom.yAxisIndex !== undefined;
202
- if (hasAxisIndex) {
203
- return {
204
- xAxisIndices: normalizeAxisIndices(dataZoom.xAxisIndex),
205
- yAxisIndices: normalizeAxisIndices(dataZoom.yAxisIndex),
206
- };
207
- }
208
- return dataZoom.orient === 'vertical'
209
- ? { xAxisIndices: [], yAxisIndices: [0] }
210
- : { xAxisIndices: [0], yAxisIndices: [] };
302
+ if ((dataZoom === null || dataZoom === void 0 ? void 0 : dataZoom.type) !== "slider" && (dataZoom === null || dataZoom === void 0 ? void 0 : dataZoom.type) !== "inside") return {
303
+ xAxisIndices: [],
304
+ yAxisIndices: []
305
+ };
306
+ if (dataZoom.xAxisIndex !== void 0 || dataZoom.yAxisIndex !== void 0) return {
307
+ xAxisIndices: normalizeAxisIndices(dataZoom.xAxisIndex),
308
+ yAxisIndices: normalizeAxisIndices(dataZoom.yAxisIndex)
309
+ };
310
+ return dataZoom.orient === "vertical" ? {
311
+ xAxisIndices: [],
312
+ yAxisIndices: [0]
313
+ } : {
314
+ xAxisIndices: [0],
315
+ yAxisIndices: []
316
+ };
211
317
  };
212
318
  /**
213
- * Union of the axis indices targeted by all slider/inside entries in a
214
- * dataZoom config, using the same per-entry resolution as ECharts (explicit
215
- * axis indices first, then orientation).
216
- */
319
+ * Union of the axis indices targeted by all slider/inside entries in a
320
+ * dataZoom config, using the same per-entry resolution as ECharts (explicit
321
+ * axis indices first, then orientation).
322
+ */
217
323
  const getDataZoomTargetAxes = (dataZoom) => {
218
- const entries = Array.isArray(dataZoom) ? dataZoom : [dataZoom];
219
- const targets = { xAxisIndices: [], yAxisIndices: [] };
220
- for (const entry of entries) {
221
- const entryTargets = getSingleDataZoomTargets(entry);
222
- for (const index of entryTargets.xAxisIndices) {
223
- if (!targets.xAxisIndices.includes(index)) {
224
- targets.xAxisIndices.push(index);
225
- }
226
- }
227
- for (const index of entryTargets.yAxisIndices) {
228
- if (!targets.yAxisIndices.includes(index)) {
229
- targets.yAxisIndices.push(index);
230
- }
231
- }
232
- }
233
- return targets;
324
+ const entries = Array.isArray(dataZoom) ? dataZoom : [dataZoom];
325
+ const targets = {
326
+ xAxisIndices: [],
327
+ yAxisIndices: []
328
+ };
329
+ for (const entry of entries) {
330
+ const entryTargets = getSingleDataZoomTargets(entry);
331
+ for (const index of entryTargets.xAxisIndices) if (!targets.xAxisIndices.includes(index)) targets.xAxisIndices.push(index);
332
+ for (const index of entryTargets.yAxisIndices) if (!targets.yAxisIndices.includes(index)) targets.yAxisIndices.push(index);
333
+ }
334
+ return targets;
234
335
  };
235
- exports.getDataZoomTargetAxes = getDataZoomTargetAxes;
236
336
  /**
237
- * A slider is vertical when the consumer sets `orient: 'vertical'`, or when it
238
- * only targets a y-axis, which makes ECharts infer the vertical orientation.
239
- */
337
+ * A slider is vertical when the consumer sets `orient: 'vertical'`, or when it
338
+ * only targets a y-axis, which makes ECharts infer the vertical orientation.
339
+ */
240
340
  const isVerticalSlider = (dataZoom) => {
241
- if ((dataZoom === null || dataZoom === void 0 ? void 0 : dataZoom.type) !== 'slider') {
242
- return false;
243
- }
244
- if (dataZoom.orient !== undefined) {
245
- return dataZoom.orient === 'vertical';
246
- }
247
- const targets = getSingleDataZoomTargets(dataZoom);
248
- return targets.yAxisIndices.length > 0 && targets.xAxisIndices.length === 0;
341
+ if ((dataZoom === null || dataZoom === void 0 ? void 0 : dataZoom.type) !== "slider") return false;
342
+ if (dataZoom.orient !== void 0) return dataZoom.orient === "vertical";
343
+ const targets = getSingleDataZoomTargets(dataZoom);
344
+ return targets.yAxisIndices.length > 0 && targets.xAxisIndices.length === 0;
249
345
  };
250
- exports.isVerticalSlider = isVerticalSlider;
251
346
  /**
252
- * Axis types where windowing (`filterMode: 'none'`) beats ECharts' default
253
- * data filtering. Filtering a continuous axis removes whole data items outside
254
- * the window, which makes bars and points vanish instead of clipping them.
255
- * Category axes keep the `'filter'` default so paging through categories still
256
- * rescales the opposite value axis to the visible data.
257
- */
258
- const WINDOWED_FILTER_AXIS_TYPES = ['log', 'time', 'value'];
347
+ * Axis types where windowing (`filterMode: 'none'`) beats ECharts' default
348
+ * data filtering. Filtering a continuous axis removes whole data items outside
349
+ * the window, which makes bars and points vanish instead of clipping them.
350
+ * Category axes keep the `'filter'` default so paging through categories still
351
+ * rescales the opposite value axis to the visible data.
352
+ */
353
+ const WINDOWED_FILTER_AXIS_TYPES = [
354
+ "log",
355
+ "time",
356
+ "value"
357
+ ];
259
358
  const getSingleAxisOption = (axis, axisIndex) => {
260
- if (!Array.isArray(axis)) {
261
- return axis;
262
- }
263
- const index = typeof axisIndex === 'number'
264
- ? axisIndex
265
- : Array.isArray(axisIndex) && typeof axisIndex[0] === 'number'
266
- ? axisIndex[0]
267
- : 0;
268
- return axis[index];
359
+ if (!Array.isArray(axis)) return axis;
360
+ return axis[typeof axisIndex === "number" ? axisIndex : Array.isArray(axisIndex) && typeof axisIndex[0] === "number" ? axisIndex[0] : 0];
269
361
  };
270
362
  /**
271
- * Resolves the slider's target axis the way ECharts does (explicit axis index
272
- * first, then orientation) and returns `'none'` when that axis is continuous.
273
- * Returns `undefined` (keep ECharts' `'filter'` default) for category axes and
274
- * for sliders that target both axes at once.
275
- */
363
+ * Resolves the slider's target axis the way ECharts does (explicit axis index
364
+ * first, then orientation) and returns `'none'` when that axis is continuous.
365
+ * Returns `undefined` (keep ECharts' `'filter'` default) for category axes and
366
+ * for sliders that target both axes at once.
367
+ */
276
368
  const getSliderDefaultFilterMode = (dataZoom, axes) => {
277
- const targets = getSingleDataZoomTargets(dataZoom);
278
- const isXAxisTarget = targets.xAxisIndices.length > 0;
279
- const isYAxisTarget = targets.yAxisIndices.length > 0;
280
- if (isXAxisTarget === isYAxisTarget) {
281
- return undefined;
282
- }
283
- const targetAxis = isYAxisTarget
284
- ? getSingleAxisOption(axes === null || axes === void 0 ? void 0 : axes.yAxis, dataZoom.yAxisIndex)
285
- : getSingleAxisOption(axes === null || axes === void 0 ? void 0 : axes.xAxis, dataZoom.xAxisIndex);
286
- return (targetAxis === null || targetAxis === void 0 ? void 0 : targetAxis.type) !== undefined &&
287
- WINDOWED_FILTER_AXIS_TYPES.includes(targetAxis.type)
288
- ? 'none'
289
- : undefined;
369
+ const targets = getSingleDataZoomTargets(dataZoom);
370
+ const isXAxisTarget = targets.xAxisIndices.length > 0;
371
+ const isYAxisTarget = targets.yAxisIndices.length > 0;
372
+ if (isXAxisTarget === isYAxisTarget) return;
373
+ const targetAxis = isYAxisTarget ? getSingleAxisOption(axes === null || axes === void 0 ? void 0 : axes.yAxis, dataZoom.yAxisIndex) : getSingleAxisOption(axes === null || axes === void 0 ? void 0 : axes.xAxis, dataZoom.xAxisIndex);
374
+ return (targetAxis === null || targetAxis === void 0 ? void 0 : targetAxis.type) !== void 0 && WINDOWED_FILTER_AXIS_TYPES.includes(targetAxis.type) ? "none" : void 0;
290
375
  };
291
376
  const VERTICAL_SLIDER_RIGHT = 10;
292
377
  const VERTICAL_SLIDER_WIDTH = 28;
293
378
  const mergeDataZoom = (dataZoom, axes) => {
294
- if (Array.isArray(dataZoom)) {
295
- return dataZoom.map((option) => (0, exports.mergeDataZoom)(option, axes));
296
- }
297
- const isSlider = (dataZoom === null || dataZoom === void 0 ? void 0 : dataZoom.type) === 'slider';
298
- const isInside = (dataZoom === null || dataZoom === void 0 ? void 0 : dataZoom.type) === 'inside';
299
- if (isSlider) {
300
- const filterMode = getSliderDefaultFilterMode(dataZoom, axes);
301
- const layoutDefaults = (0, exports.isVerticalSlider)(dataZoom)
302
- ? {
303
- right: VERTICAL_SLIDER_RIGHT,
304
- textStyle: {
305
- overflow: 'truncate',
306
- width: 2 * (VERTICAL_SLIDER_RIGHT + VERTICAL_SLIDER_WIDTH / 2),
307
- },
308
- width: VERTICAL_SLIDER_WIDTH,
309
- }
310
- : { bottom: 10, height: 28 };
311
- return Object.assign(Object.assign(Object.assign(Object.assign({}, (filterMode !== undefined && { filterMode })), layoutDefaults), { show: true, type: 'slider' }), dataZoom);
312
- }
313
- else if (isInside) {
314
- // Only pin the default x-axis binding on entries that actually target the
315
- // x-axis; y-targeting entries (explicit `yAxisIndex` or
316
- // `orient: 'vertical'`) keep their own binding.
317
- const targets = getSingleDataZoomTargets(dataZoom);
318
- const hasDefaultXAxisTarget = dataZoom.xAxisIndex === undefined && targets.xAxisIndices.length > 0;
319
- return Object.assign(Object.assign(Object.assign({ filterMode: 'none' }, (hasDefaultXAxisTarget && { xAxisIndex: [0] })), { zoomOnMouseWheel: false }), dataZoom);
320
- }
321
- return dataZoom;
379
+ if (Array.isArray(dataZoom)) return dataZoom.map((option) => mergeDataZoom(option, axes));
380
+ const isSlider = (dataZoom === null || dataZoom === void 0 ? void 0 : dataZoom.type) === "slider";
381
+ const isInside = (dataZoom === null || dataZoom === void 0 ? void 0 : dataZoom.type) === "inside";
382
+ if (isSlider) {
383
+ const filterMode = getSliderDefaultFilterMode(dataZoom, axes);
384
+ const layoutDefaults = isVerticalSlider(dataZoom) ? {
385
+ right: VERTICAL_SLIDER_RIGHT,
386
+ textStyle: {
387
+ overflow: "truncate",
388
+ width: 48
389
+ },
390
+ width: VERTICAL_SLIDER_WIDTH
391
+ } : {
392
+ bottom: 10,
393
+ height: 28
394
+ };
395
+ return require_objectSpread2.default(require_objectSpread2.default(require_objectSpread2.default({}, filterMode !== void 0 && { filterMode }), layoutDefaults), {}, {
396
+ show: true,
397
+ type: "slider"
398
+ }, dataZoom);
399
+ } else if (isInside) {
400
+ const targets = getSingleDataZoomTargets(dataZoom);
401
+ const hasDefaultXAxisTarget = dataZoom.xAxisIndex === void 0 && targets.xAxisIndices.length > 0;
402
+ return require_objectSpread2.default(require_objectSpread2.default({ filterMode: "none" }, hasDefaultXAxisTarget && { xAxisIndex: [0] }), {}, { zoomOnMouseWheel: false }, dataZoom);
403
+ }
404
+ return dataZoom;
322
405
  };
323
- exports.mergeDataZoom = mergeDataZoom;
324
406
  const isContinuousAxisOption = (axisOption) => {
325
- return ((axisOption === null || axisOption === void 0 ? void 0 : axisOption.type) !== undefined &&
326
- WINDOWED_FILTER_AXIS_TYPES.includes(axisOption.type));
407
+ return (axisOption === null || axisOption === void 0 ? void 0 : axisOption.type) !== void 0 && WINDOWED_FILTER_AXIS_TYPES.includes(axisOption.type);
327
408
  };
328
409
  const areTargetAxesContinuous = (axis, axisIndices) => {
329
- if (axisIndices === 'all') {
330
- const axisOptions = Array.isArray(axis) ? axis : [axis];
331
- return (axisOptions.length > 0 &&
332
- axisOptions.every((axisOption) => {
333
- return isContinuousAxisOption(axisOption);
334
- }));
335
- }
336
- return axisIndices.every((axisIndex) => {
337
- return isContinuousAxisOption(getSingleAxisOption(axis, axisIndex));
338
- });
410
+ if (axisIndices === "all") {
411
+ const axisOptions = Array.isArray(axis) ? axis : [axis];
412
+ return axisOptions.length > 0 && axisOptions.every((axisOption) => {
413
+ return isContinuousAxisOption(axisOption);
414
+ });
415
+ }
416
+ return axisIndices.every((axisIndex) => {
417
+ return isContinuousAxisOption(getSingleAxisOption(axis, axisIndex));
418
+ });
339
419
  };
340
420
  /**
341
- * Returns `'none'` when every axis targeted by the drag-to-zoom brush is
342
- * continuous (`value`/`time`/`log`), matching the slider rule: filtering a
343
- * continuous axis removes whole data items outside the selection instead of
344
- * clipping them. Category (or unknown) targets keep ECharts' `'filter'`
345
- * default.
346
- */
421
+ * Returns `'none'` when every axis targeted by the drag-to-zoom brush is
422
+ * continuous (`value`/`time`/`log`), matching the slider rule: filtering a
423
+ * continuous axis removes whole data items outside the selection instead of
424
+ * clipping them. Category (or unknown) targets keep ECharts' `'filter'`
425
+ * default.
426
+ */
347
427
  const getBrushDefaultFilterMode = (context, xAxisTargets, yAxisTargets) => {
348
- const checks = [];
349
- if (xAxisTargets !== false) {
350
- checks.push(areTargetAxesContinuous(context === null || context === void 0 ? void 0 : context.xAxis, xAxisTargets));
351
- }
352
- if (yAxisTargets !== false) {
353
- checks.push(areTargetAxesContinuous(context === null || context === void 0 ? void 0 : context.yAxis, yAxisTargets));
354
- }
355
- return checks.length > 0 && checks.every(Boolean) ? 'none' : undefined;
428
+ const checks = [];
429
+ if (xAxisTargets !== false) checks.push(areTargetAxesContinuous(context === null || context === void 0 ? void 0 : context.xAxis, xAxisTargets));
430
+ if (yAxisTargets !== false) checks.push(areTargetAxesContinuous(context === null || context === void 0 ? void 0 : context.yAxis, yAxisTargets));
431
+ return checks.length > 0 && checks.every(Boolean) ? "none" : void 0;
356
432
  };
357
433
  const mergeToolbox = (toolbox, context) => {
358
- var _a;
359
- if (Array.isArray(toolbox)) {
360
- return toolbox.map((option) => (0, exports.mergeToolbox)(option, context));
361
- }
362
- // The drag-to-zoom brush follows the axes the dataZoom config targets, so
363
- // zoom direction is configured in one place. Without any dataZoom config it
364
- // keeps the historical default: all x-axes on, y off.
365
- const targets = (0, exports.getDataZoomTargetAxes)(context === null || context === void 0 ? void 0 : context.dataZoom);
366
- const hasTargets = targets.xAxisIndices.length > 0 || targets.yAxisIndices.length > 0;
367
- const xAxisTargets = hasTargets
368
- ? targets.xAxisIndices.length > 0 && targets.xAxisIndices
369
- : 'all';
370
- const yAxisTargets = targets.yAxisIndices.length > 0 && targets.yAxisIndices;
371
- const filterMode = getBrushDefaultFilterMode(context, xAxisTargets, yAxisTargets);
372
- return {
373
- feature: {
374
- dataZoom: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (filterMode !== undefined && { filterMode })), (xAxisTargets !== 'all' && { xAxisIndex: xAxisTargets })), { yAxisIndex: yAxisTargets }), (_a = toolbox === null || toolbox === void 0 ? void 0 : toolbox.feature) === null || _a === void 0 ? void 0 : _a.dataZoom), { icon: {
375
- // This hack removes the icons.
376
- // Due to: https://github.com/apache/echarts/issues/10274
377
- back: '-',
378
- zoom: '-',
379
- }, show: true }),
380
- },
381
- };
434
+ var _toolbox$feature;
435
+ if (Array.isArray(toolbox)) return toolbox.map((option) => mergeToolbox(option, context));
436
+ const targets = getDataZoomTargetAxes(context === null || context === void 0 ? void 0 : context.dataZoom);
437
+ const xAxisTargets = targets.xAxisIndices.length > 0 || targets.yAxisIndices.length > 0 ? targets.xAxisIndices.length > 0 && targets.xAxisIndices : "all";
438
+ const yAxisTargets = targets.yAxisIndices.length > 0 && targets.yAxisIndices;
439
+ const filterMode = getBrushDefaultFilterMode(context, xAxisTargets, yAxisTargets);
440
+ return { feature: { dataZoom: require_objectSpread2.default(require_objectSpread2.default(require_objectSpread2.default(require_objectSpread2.default({}, filterMode !== void 0 && { filterMode }), xAxisTargets !== "all" && { xAxisIndex: xAxisTargets }), {}, { yAxisIndex: yAxisTargets }, toolbox === null || toolbox === void 0 || (_toolbox$feature = toolbox.feature) === null || _toolbox$feature === void 0 ? void 0 : _toolbox$feature.dataZoom), {}, {
441
+ icon: {
442
+ back: "-",
443
+ zoom: "-"
444
+ },
445
+ show: true
446
+ }) } };
382
447
  };
448
+ exports.getDataZoomTargetAxes = getDataZoomTargetAxes;
449
+ exports.isVerticalSlider = isVerticalSlider;
450
+ exports.mergeDataZoom = mergeDataZoom;
451
+ exports.mergeSeries = mergeSeries;
383
452
  exports.mergeToolbox = mergeToolbox;
453
+ exports.mergeXAxis = mergeXAxis;
454
+ exports.mergeYAxis = mergeYAxis;
455
+
384
456
  //# sourceMappingURL=user-option-utils.js.map