@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 +0,0 @@
1
- {"version":3,"file":"build-chart-option.js","sourceRoot":"","sources":["../../../../src/charts/utils/build-chart-option.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EACL,0BAA0B,EAC1B,6BAA6B,GAE9B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAErE,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAmBvC,MAAM,eAAe,GAAG,CAAC,QAAmC,EAAE,EAAE,CAC9D,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAElD;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAAmC;IAEnC,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC,IAAI,CACnC,CAAC,cAAmD,EAAE,EAAE,CACtD,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,MAAK,QAAQ,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CACzE,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAmC;IAEnC,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC,IAAI,CACnC,CAAC,cAAmD,EAAE,EAAE,CACtD,gBAAgB,CAAC,cAAc,CAAC,CACnC,CAAC;AACJ,CAAC;AAUD,MAAM,aA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C,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;SAC1C,EACD,KAAK;QACL,KAAK,IACL;AACJ,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport type { DataZoomComponentOption, EChartsOption } from 'echarts';\n\nimport { generateThresholdAriaDescription } from './aria-description';\nimport {\n createAxisTooltipFormatter,\n createScatterTooltipFormatter,\n type SeriesAxisNames,\n} from './chart-tooltip-formatter';\nimport type { ChartProps, EchartsSeries } from './chart-types';\nimport { tooltipExtraCssText } from './defaults';\nimport type { ScatterTooltipChart } from './scatter-tooltip-points';\nimport type { NormalizedThresholdLine } from './threshold';\nimport { isVerticalSlider, mergeToolbox } from './user-option-utils';\n\nconst SLIDER_OUTER_BOUND_GAP = 8;\nconst SLIDER_OUTER_BOUND_FALLBACK = 60;\n\ntype BuildChartOptionParams = {\n dataZoom: EChartsOption['dataZoom'];\n dataset: ChartProps['dataset'];\n getChartInstance?: () => ScatterTooltipChart | undefined;\n getLegendSelected?: () => Record<string, boolean> | undefined;\n hasCategoryXAxis: boolean;\n legendSelected: Record<string, boolean>;\n propsSeries: ChartProps['series'];\n series: EchartsSeries;\n thresholdLines: NormalizedThresholdLine[];\n toolboxOptions: EChartsOption['toolbox'];\n userOption: ChartProps['option'];\n xAxis: EChartsOption['xAxis'];\n yAxis: EChartsOption['yAxis'];\n hasMarkArea: boolean;\n};\n\nconst toDataZoomArray = (dataZoom: EChartsOption['dataZoom']) =>\n Array.isArray(dataZoom) ? dataZoom : [dataZoom];\n\n/**\n * Horizontal slider zoom needs extra bottom grid space for ECharts' slider\n * control.\n */\nexport function hasHorizontalSliderZoom(\n dataZoom: EChartsOption['dataZoom'],\n): boolean {\n return toDataZoomArray(dataZoom).some(\n (dataZoomOption: DataZoomComponentOption | undefined) =>\n dataZoomOption?.type === 'slider' && !isVerticalSlider(dataZoomOption),\n );\n}\n\n/**\n * Vertical slider zoom needs extra right grid space for ECharts' slider\n * control.\n */\nexport function hasVerticalSliderZoom(\n dataZoom: EChartsOption['dataZoom'],\n): boolean {\n return toDataZoomArray(dataZoom).some(\n (dataZoomOption: DataZoomComponentOption | undefined) =>\n isVerticalSlider(dataZoomOption),\n );\n}\n\ntype SliderDataZoomLayout = DataZoomComponentOption & {\n bottom?: number | string;\n height?: number | string;\n orient?: 'horizontal' | 'vertical';\n right?: number | string;\n width?: number | string;\n};\n\nconst getPixelValue = (value: number | string | undefined) => {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return value;\n }\n\n if (typeof value !== 'string' || !/^-?\\d+(?:\\.\\d+)?px$/.test(value)) {\n return undefined;\n }\n\n return Number.parseFloat(value);\n};\n\n/**\n * Reserves the area occupied by bottom-positioned horizontal slider controls.\n *\n * ECharts lays data zoom controls outside the Cartesian grid, so its automatic\n * axis outer bounds do not account for them. Normalized sliders use pixel\n * values; custom percentage-based layouts fall back to the previous 60px\n * reserve because they cannot be resolved without the rendered chart size.\n */\nexport function getSliderBottomOuterBound(\n dataZoom: EChartsOption['dataZoom'],\n): number | undefined {\n const sliderOuterBounds = toDataZoomArray(dataZoom).flatMap((option) => {\n const slider = option as SliderDataZoomLayout | undefined;\n if (slider?.type !== 'slider' || isVerticalSlider(slider)) {\n return [];\n }\n\n const bottom = getPixelValue(slider.bottom);\n const height = getPixelValue(slider.height);\n if (bottom === undefined || height === undefined) {\n return [SLIDER_OUTER_BOUND_FALLBACK];\n }\n\n return [bottom + height + SLIDER_OUTER_BOUND_GAP];\n });\n\n return sliderOuterBounds.length > 0\n ? Math.max(...sliderOuterBounds)\n : undefined;\n}\n\n/**\n * Reserves the area occupied by right-positioned vertical slider controls,\n * mirroring `getSliderBottomOuterBound` for horizontal ones. Normalized\n * sliders use pixel values; custom percentage-based layouts fall back to the\n * 60px reserve because they cannot be resolved without the rendered chart\n * size.\n */\nexport function getSliderRightOuterBound(\n dataZoom: EChartsOption['dataZoom'],\n): number | undefined {\n const sliderOuterBounds = toDataZoomArray(dataZoom).flatMap((option) => {\n const slider = option as SliderDataZoomLayout | undefined;\n if (!isVerticalSlider(slider)) {\n return [];\n }\n\n const right = getPixelValue(slider?.right);\n const width = getPixelValue(slider?.width);\n if (right === undefined || width === undefined) {\n return [SLIDER_OUTER_BOUND_FALLBACK];\n }\n\n return [right + width + SLIDER_OUTER_BOUND_GAP];\n });\n\n return sliderOuterBounds.length > 0\n ? Math.max(...sliderOuterBounds)\n : undefined;\n}\n\n/**\n * Mark area needs extra top grid space to fit inside the chart.\n */\nexport const hasMarkAreaInSeries = (series: EchartsSeries) =>\n Array.isArray(series)\n ? series.some((option) => !!option.markArea)\n : !!series.markArea;\n\n/**\n * Reads the `name` of the axis at `axisIndex`, which scatter tooltips use to\n * label their x and y rows.\n */\nfunction getAxisName(\n axis: EChartsOption['xAxis'] | EChartsOption['yAxis'],\n axisIndex = 0,\n): string | undefined {\n const axisOption = (\n Array.isArray(axis) ? axis[axisIndex] : axisIndex === 0 ? axis : undefined\n ) as { name?: unknown } | undefined;\n\n return typeof axisOption?.name === 'string' && axisOption.name.length > 0\n ? axisOption.name\n : undefined;\n}\n\n/**\n * Category x-axes use slightly wider grid padding to avoid clipped labels.\n */\nexport function hasCategoryXAxis(xAxis: EChartsOption['xAxis']): boolean {\n return Array.isArray(xAxis)\n ? xAxis.some((axis) => axis.type === 'category')\n : xAxis?.type === 'category';\n}\n\n/**\n * Builds the ECharts option object from Needle chart props and derived values.\n * Applying the option to an ECharts instance happens in `useChartOption`.\n */\nexport function buildChartOption({\n dataZoom,\n dataset,\n getChartInstance,\n getLegendSelected,\n hasCategoryXAxis,\n legendSelected,\n propsSeries,\n series,\n thresholdLines,\n toolboxOptions,\n userOption,\n xAxis,\n yAxis,\n hasMarkArea,\n}: BuildChartOptionParams): EChartsOption {\n const customAriaDescription = generateThresholdAriaDescription(\n propsSeries,\n dataset,\n );\n const sliderBottomOuterBound = getSliderBottomOuterBound(dataZoom);\n const sliderRightOuterBound = getSliderRightOuterBound(dataZoom);\n const hasVerticalSlider = hasVerticalSliderZoom(dataZoom);\n const hasHorizontalSlider = hasHorizontalSliderZoom(dataZoom);\n const gridBottom = hasHorizontalSlider ? 60 : hasVerticalSlider ? 25 : 10;\n const gridHorizontalInset = hasCategoryXAxis ? 15 : 10;\n const gridRight = hasVerticalSlider\n ? 60\n : hasHorizontalSlider\n ? 45\n : gridHorizontalInset;\n const outerBoundsTop = hasMarkArea ? 20 : 10;\n const gridTop = hasVerticalSlider ? 20 : outerBoundsTop;\n const seriesList = Array.isArray(series) ? series : [series];\n const isScatterChart =\n seriesList.length > 0 &&\n seriesList.every((seriesOption) => seriesOption.type === 'scatter');\n const seriesAxisNames: SeriesAxisNames[] = seriesList.map((seriesOption) => {\n const { xAxisIndex, yAxisIndex } = seriesOption as {\n xAxisIndex?: number;\n yAxisIndex?: number;\n };\n\n return {\n // oxlint-disable-next-line id-length\n x: getAxisName(xAxis, xAxisIndex),\n // oxlint-disable-next-line id-length\n y: getAxisName(yAxis, yAxisIndex),\n };\n });\n\n return {\n ...userOption,\n aria: {\n decal: {\n show: false,\n },\n enabled: true,\n ...(customAriaDescription !== undefined && {\n label: { description: customAriaDescription },\n }),\n ...(userOption?.aria as EChartsOption['aria']),\n },\n dataZoom,\n dataset,\n grid: {\n bottom: `${gridBottom}px`,\n left: `${gridHorizontalInset}px`,\n outerBounds: {\n bottom: sliderBottomOuterBound ?? gridBottom,\n left: gridHorizontalInset,\n right: sliderRightOuterBound ?? gridHorizontalInset,\n top: outerBoundsTop,\n },\n outerBoundsContain: 'all',\n right: `${gridRight}px`,\n top: `${gridTop}px`,\n type: 'solid',\n ...(userOption?.grid as EChartsOption['grid']),\n },\n legend: {\n // ECharts mutates option.legend.selected internally; callers pass a\n // copied object so the React ref remains the source of truth.\n selected: { ...legendSelected },\n show: false,\n },\n series,\n toolbox: mergeToolbox(toolboxOptions, { dataZoom, xAxis, yAxis }),\n tooltip: {\n borderRadius: 0,\n borderWidth: 0,\n confine: true,\n extraCssText: tooltipExtraCssText,\n formatter: isScatterChart\n ? createScatterTooltipFormatter({\n dataset,\n getChartInstance,\n getLegendSelected,\n series,\n seriesAxisNames,\n userOption,\n })\n : createAxisTooltipFormatter({ thresholdLines, userOption }),\n padding: 0,\n // Scatter needs item trigger so the unique per-point `encode.tooltip`\n // value can title the tooltip. Axis trigger would group every point\n // that shares an x (or y) value.\n trigger: isScatterChart ? 'item' : 'axis',\n },\n xAxis,\n yAxis,\n };\n}\n"]}
@@ -1,177 +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
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
- import { renderToString } from 'react-dom/server';
24
- import { ChartTooltip } from '../ChartTooltip';
25
- import { capitalizeFirstLetter, extractValueFromTooltipSeries, formatTimeAxisDate, formatTooltipValue, } from './format-utils';
26
- import { encodedDimensionLabel, extraTooltipRefs, findNearbyScatterPoints, getEncodedAxisRefs, getScatterSymbolSize, readEncodedValue, } from './scatter-tooltip-points';
27
- import { evaluateThresholdCondition } from './threshold';
28
- import { getThresholdLineDisplayName, isThresholdLine, } from './threshold';
29
- export function getTooltipValueFormatter(userOption) {
30
- if (typeof (userOption === null || userOption === void 0 ? void 0 : userOption.tooltip) === 'object' &&
31
- userOption.tooltip !== null &&
32
- 'valueFormatter' in userOption.tooltip) {
33
- return userOption.tooltip.valueFormatter;
34
- }
35
- return formatTooltipValue;
36
- }
37
- /**
38
- * Upper bound on the points one tooltip lists, so a dense cluster cannot grow
39
- * a tooltip that covers the chart.
40
- */
41
- const MAX_TOOLTIP_POINTS = 5;
42
- /**
43
- * Builds the ECharts axis-tooltip formatter used by line-like charts.
44
- * It renders Needle tooltip markup and augments non-threshold series with
45
- * threshold notifications when their current value crosses a threshold line.
46
- */
47
- export function createAxisTooltipFormatter({ thresholdLines, userOption, }) {
48
- const valueFormatter = getTooltipValueFormatter(userOption);
49
- return function axisTooltipFormatter(params) {
50
- var _a;
51
- const paramsArray = Array.isArray(params) ? params : [params];
52
- const firstParam = paramsArray[0];
53
- return `${renderToString(_jsxs("span", { className: "ndl-charts-chart-tooltip", children: [_jsx(ChartTooltip.Title, { children: (_a = firstParam === null || firstParam === void 0 ? void 0 : firstParam.axisValueLabel) !== null && _a !== void 0 ? _a : '' }), paramsArray.map((series) => {
54
- const value = extractValueFromTooltipSeries(series.value, series.encode, series.axisDim);
55
- const seriesValue = typeof value === 'number' ? value : Number(value);
56
- const isSeriesThresholdLine = isThresholdLine(series.seriesName);
57
- const notifications = thresholdLines.flatMap((threshold) => {
58
- if (isSeriesThresholdLine || Number.isNaN(seriesValue)) {
59
- return [];
60
- }
61
- const { notificationType, value: thresholdValue, condition, customConditionText, customCondition, } = threshold;
62
- const conditionEvaluation = customCondition
63
- ? {
64
- conditionText: customConditionText,
65
- isConditionMet: customCondition(seriesValue, thresholdValue),
66
- }
67
- : evaluateThresholdCondition(seriesValue, condition, thresholdValue);
68
- if (!conditionEvaluation.isConditionMet) {
69
- return [];
70
- }
71
- return [
72
- {
73
- id: `threshold-${notificationType}`,
74
- leadingElement: customCondition
75
- ? conditionEvaluation.conditionText
76
- : `${conditionEvaluation.conditionText} threshold`,
77
- notificationType,
78
- trailingElement: valueFormatter(thresholdValue),
79
- },
80
- ];
81
- });
82
- return (_jsx(ChartTooltip.Content, { leadingElement: isSeriesThresholdLine
83
- ? `${capitalizeFirstLetter(getThresholdLineDisplayName(series.seriesName))} threshold`
84
- : series.seriesName, trailingElement: valueFormatter(value), indentSquareColor: series.color, notifications: notifications }, series.seriesName));
85
- })] }))}`;
86
- };
87
- }
88
- /**
89
- * Builds the ECharts item-tooltip formatter used by scatter charts.
90
- *
91
- * The title comes from ECharts `encode.tooltip`, then `encode.itemName`, then
92
- * an extra data dimension, and otherwise the series name. x and y are listed
93
- * underneath. See https://echarts.apache.org/en/option.html#series-scatter.encode
94
- *
95
- * `tooltip.valueFormatter` runs on the x and y values only. Those calls pass
96
- * `{ axis: 'x' | 'y' }` (`TooltipValueContext`) as the third argument. The
97
- * title is shown unchanged.
98
- *
99
- * Points whose symbols overlap the hovered one are listed in the same tooltip,
100
- * closest first, so a cluster is readable without zooming in. Each point gets
101
- * its own block: the series color sits once on the block title, and the rows
102
- * are labelled with the axis `name` when the consumer set one, falling back to
103
- * the dataset dimension name.
104
- */
105
- export function createScatterTooltipFormatter({ dataset, getChartInstance, getLegendSelected, series, seriesAxisNames, userOption, }) {
106
- const valueFormatter = getTooltipValueFormatter(userOption);
107
- const radius = getScatterSymbolSize(series);
108
- const seriesList = Array.isArray(series) ? series : [series];
109
- const renderPoint = (point, key) => {
110
- var _a, _b, _c, _d;
111
- // ECharts only copies x/y into the hovered point's `encode`. The dimension
112
- // the consumer set on `encode.tooltip` (or `itemName`) still lives on the
113
- // series option, which is what the nearby points are already read from.
114
- const seriesOption = seriesList[(_a = point.seriesIndex) !== null && _a !== void 0 ? _a : 0];
115
- // The hovered point's own color is its theme-colored interior. The swatch
116
- // uses the series color, which is the ring.
117
- const swatchColor = typeof (seriesOption === null || seriesOption === void 0 ? void 0 : seriesOption.color) === 'string'
118
- ? seriesOption.color
119
- : point.color;
120
- const seriesEncode = seriesOption === null || seriesOption === void 0 ? void 0 : seriesOption.encode;
121
- const titleRef = extraTooltipRefs(Object.assign(Object.assign({}, point), { encode: Object.assign(Object.assign(Object.assign({}, point.encode), ((seriesEncode === null || seriesEncode === void 0 ? void 0 : seriesEncode.tooltip) !== undefined && {
122
- tooltip: seriesEncode.tooltip,
123
- })), ((seriesEncode === null || seriesEncode === void 0 ? void 0 : seriesEncode.itemName) !== undefined && {
124
- itemName: seriesEncode.itemName,
125
- })) }))[0];
126
- // ECharts reports `name` as '' when a point has no name dimension, which
127
- // would hide the title and the color swatch. The series name fills that in.
128
- const pointName = point.name !== undefined && point.name !== ''
129
- ? point.name
130
- : point.seriesName;
131
- const titleValue = titleRef !== undefined
132
- ? readEncodedValue(point.value, titleRef, point.dimensionNames)
133
- : pointName;
134
- // The title identifies the point, so it is not run through
135
- // `valueFormatter`. Only string and number titles are renderable children,
136
- // so dates are formatted like the time axis.
137
- const titleText = titleValue instanceof Date
138
- ? formatTimeAxisDate(titleValue)
139
- : typeof titleValue === 'string' || typeof titleValue === 'number'
140
- ? titleValue
141
- : undefined;
142
- const refs = getEncodedAxisRefs(point.encode);
143
- const xValue = readEncodedValue(point.value, refs.x, point.dimensionNames);
144
- const yValue = readEncodedValue(point.value, refs.y, point.dimensionNames);
145
- const axisNames = seriesAxisNames === null || seriesAxisNames === void 0 ? void 0 : seriesAxisNames[(_b = point.seriesIndex) !== null && _b !== void 0 ? _b : 0];
146
- return (_jsxs("div", { className: "ndl-charts-chart-tooltip-point", children: [titleText !== undefined && titleText !== '' && (_jsx(ChartTooltip.Title, { indentSquareColor: swatchColor, children: titleText })), xValue !== undefined && (_jsx(ChartTooltip.Content, { leadingElement: (_c = axisNames === null || axisNames === void 0 ? void 0 : axisNames.x) !== null && _c !== void 0 ? _c : encodedDimensionLabel(refs.x, point.dimensionNames, 'x'), trailingElement: valueFormatter(xValue, point.dataIndex, {
147
- axis: 'x',
148
- }) })), yValue !== undefined && (_jsx(ChartTooltip.Content, { leadingElement: (_d = axisNames === null || axisNames === void 0 ? void 0 : axisNames.y) !== null && _d !== void 0 ? _d : encodedDimensionLabel(refs.y, point.dimensionNames, 'y'), trailingElement: valueFormatter(yValue, point.dataIndex, {
149
- axis: 'y',
150
- }) }))] }, key));
151
- };
152
- return function scatterTooltipFormatter(params) {
153
- const hovered = (Array.isArray(params) ? params[0] : params);
154
- let points = [hovered];
155
- // A tooltip that throws leaves the chart without any tooltip at all, so a
156
- // failed neighbor lookup falls back to the hovered point.
157
- try {
158
- points = findNearbyScatterPoints({
159
- chart: getChartInstance === null || getChartInstance === void 0 ? void 0 : getChartInstance(),
160
- dataset,
161
- hovered,
162
- legendSelected: getLegendSelected === null || getLegendSelected === void 0 ? void 0 : getLegendSelected(),
163
- maxPoints: MAX_TOOLTIP_POINTS,
164
- radius,
165
- series,
166
- });
167
- }
168
- catch (_a) {
169
- points = [hovered];
170
- }
171
- return `${renderToString(_jsx("span", { className: "ndl-charts-chart-tooltip", children: points.map((point, index) => {
172
- var _a;
173
- return renderPoint(point, `${point.seriesIndex}-${(_a = point.dataIndex) !== null && _a !== void 0 ? _a : index}`);
174
- }) }))}`;
175
- };
176
- }
177
- //# sourceMappingURL=chart-tooltip-formatter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chart-tooltip-formatter.js","sourceRoot":"","sources":["../../../../src/charts/utils/chart-tooltip-formatter.tsx"],"names":[],"mappings":";AAsBA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,gBAAgB,CA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AM,GAAG,CAAC,OAAO,CAAC,CAAC;QAEvB,0EAA0E;QAC1E,0DAA0D;QAC1D,IAAI,CAAC;YACH,MAAM,GAAG,uBAAuB,CAAC;gBAC/B,KAAK,EAAE,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,EAAI;gBAC3B,OAAO;gBACP,OAAO;gBACP,cAAc,EAAE,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,EAAI;gBACrC,SAAS,EAAE,kBAAkB;gBAC7B,MAAM;gBACN,MAAM;aACP,CAAC,CAAC;QACL,CAAC;QAAC,WAAM,CAAC;YACP,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;QAED,OAAO,GAAG,cAAc,CACtB,eAAM,SAAS,EAAC,0BAA0B,YACvC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;;gBAC3B,OAAA,WAAW,CACT,KAAK,EACL,GAAG,KAAK,CAAC,WAAW,IAAI,MAAA,KAAK,CAAC,SAAS,mCAAI,KAAK,EAAE,CACnD,CAAA;aAAA,CACF,GACI,CACR,EAAE,CAAC;IACN,CAAC,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 React from 'react';\nimport { renderToString } from 'react-dom/server';\n\nimport { ChartTooltip } from '../ChartTooltip';\nimport type { ChartProps, EchartsSeries } from './chart-types';\nimport {\n capitalizeFirstLetter,\n extractValueFromTooltipSeries,\n formatTimeAxisDate,\n formatTooltipValue,\n} from './format-utils';\nimport {\n encodedDimensionLabel,\n extraTooltipRefs,\n findNearbyScatterPoints,\n getEncodedAxisRefs,\n getScatterSymbolSize,\n readEncodedValue,\n type ScatterTooltipChart,\n type ScatterTooltipPoint,\n} from './scatter-tooltip-points';\nimport { evaluateThresholdCondition } from './threshold';\nimport {\n getThresholdLineDisplayName,\n isThresholdLine,\n type NormalizedThresholdLine,\n} from './threshold';\n\n/**\n * Where a scatter tooltip value comes from. Passed to `tooltip.valueFormatter`\n * as its third argument for the x and y rows, so one formatter can give them\n * different units. The title is not passed to the formatter.\n */\nexport type TooltipValueContext = {\n axis: 'x' | 'y';\n};\n\ntype TooltipValueFormatter = (\n value: unknown,\n dataIndex?: number,\n context?: TooltipValueContext,\n) => React.ReactNode;\n\nexport function getTooltipValueFormatter(\n userOption: ChartProps['option'],\n): TooltipValueFormatter {\n if (\n typeof userOption?.tooltip === 'object' &&\n userOption.tooltip !== null &&\n 'valueFormatter' in userOption.tooltip\n ) {\n return userOption.tooltip.valueFormatter as TooltipValueFormatter;\n }\n\n return formatTooltipValue as TooltipValueFormatter;\n}\n\n/**\n * `name` of the x and y axes one series is bound to. `seriesAxisNames` holds\n * one entry per series, indexed by series index.\n */\nexport type SeriesAxisNames = {\n // oxlint-disable-next-line id-length\n x?: string;\n // oxlint-disable-next-line id-length\n y?: string;\n};\n\ntype CreateAxisTooltipFormatterParams = {\n thresholdLines: NormalizedThresholdLine[];\n userOption: ChartProps['option'];\n};\n\ntype CreateScatterTooltipFormatterParams = {\n dataset: ChartProps['dataset'];\n getChartInstance?: () => ScatterTooltipChart | undefined;\n getLegendSelected?: () => Record<string, boolean> | undefined;\n series: EchartsSeries;\n seriesAxisNames?: Array<SeriesAxisNames | undefined>;\n userOption: ChartProps['option'];\n};\n\n/**\n * Upper bound on the points one tooltip lists, so a dense cluster cannot grow\n * a tooltip that covers the chart.\n */\nconst MAX_TOOLTIP_POINTS = 5;\n\n/**\n * Builds the ECharts axis-tooltip formatter used by line-like charts.\n * It renders Needle tooltip markup and augments non-threshold series with\n * threshold notifications when their current value crosses a threshold line.\n */\nexport function createAxisTooltipFormatter({\n thresholdLines,\n userOption,\n}: CreateAxisTooltipFormatterParams) {\n const valueFormatter = getTooltipValueFormatter(userOption);\n\n return function axisTooltipFormatter(params: unknown) {\n const paramsArray = Array.isArray(params) ? params : [params];\n const firstParam = paramsArray[0];\n\n return `${renderToString(\n <span className=\"ndl-charts-chart-tooltip\">\n <ChartTooltip.Title>\n {firstParam?.axisValueLabel ?? ''}\n </ChartTooltip.Title>\n {paramsArray.map((series) => {\n const value = extractValueFromTooltipSeries(\n series.value,\n series.encode,\n series.axisDim,\n );\n\n const seriesValue = typeof value === 'number' ? value : Number(value);\n\n const isSeriesThresholdLine = isThresholdLine(series.seriesName);\n\n const notifications = thresholdLines.flatMap((threshold) => {\n if (isSeriesThresholdLine || Number.isNaN(seriesValue)) {\n return [];\n }\n\n const {\n notificationType,\n value: thresholdValue,\n condition,\n customConditionText,\n customCondition,\n } = threshold;\n const conditionEvaluation = customCondition\n ? {\n conditionText: customConditionText,\n isConditionMet: customCondition(seriesValue, thresholdValue),\n }\n : evaluateThresholdCondition(\n seriesValue,\n condition,\n thresholdValue,\n );\n\n if (!conditionEvaluation.isConditionMet) {\n return [];\n }\n\n return [\n {\n id: `threshold-${notificationType}`,\n leadingElement: customCondition\n ? conditionEvaluation.conditionText\n : `${conditionEvaluation.conditionText} threshold`,\n notificationType,\n trailingElement: valueFormatter(thresholdValue),\n },\n ];\n });\n\n return (\n <ChartTooltip.Content\n key={series.seriesName}\n leadingElement={\n isSeriesThresholdLine\n ? `${capitalizeFirstLetter(\n getThresholdLineDisplayName(series.seriesName),\n )} threshold`\n : series.seriesName\n }\n trailingElement={valueFormatter(value)}\n indentSquareColor={series.color}\n notifications={notifications}\n />\n );\n })}\n </span>,\n )}`;\n };\n}\n\n/**\n * Builds the ECharts item-tooltip formatter used by scatter charts.\n *\n * The title comes from ECharts `encode.tooltip`, then `encode.itemName`, then\n * an extra data dimension, and otherwise the series name. x and y are listed\n * underneath. See https://echarts.apache.org/en/option.html#series-scatter.encode\n *\n * `tooltip.valueFormatter` runs on the x and y values only. Those calls pass\n * `{ axis: 'x' | 'y' }` (`TooltipValueContext`) as the third argument. The\n * title is shown unchanged.\n *\n * Points whose symbols overlap the hovered one are listed in the same tooltip,\n * closest first, so a cluster is readable without zooming in. Each point gets\n * its own block: the series color sits once on the block title, and the rows\n * are labelled with the axis `name` when the consumer set one, falling back to\n * the dataset dimension name.\n */\nexport function createScatterTooltipFormatter({\n dataset,\n getChartInstance,\n getLegendSelected,\n series,\n seriesAxisNames,\n userOption,\n}: CreateScatterTooltipFormatterParams) {\n const valueFormatter = getTooltipValueFormatter(userOption);\n const radius = getScatterSymbolSize(series);\n const seriesList = Array.isArray(series) ? series : [series];\n\n const renderPoint = (point: ScatterTooltipPoint, key: string) => {\n // ECharts only copies x/y into the hovered point's `encode`. The dimension\n // the consumer set on `encode.tooltip` (or `itemName`) still lives on the\n // series option, which is what the nearby points are already read from.\n const seriesOption = seriesList[point.seriesIndex ?? 0] as\n | { color?: unknown; encode?: Record<string, unknown> }\n | undefined;\n // The hovered point's own color is its theme-colored interior. The swatch\n // uses the series color, which is the ring.\n const swatchColor =\n typeof seriesOption?.color === 'string'\n ? seriesOption.color\n : point.color;\n const seriesEncode = seriesOption?.encode;\n const titleRef = extraTooltipRefs({\n ...point,\n encode: {\n ...point.encode,\n ...(seriesEncode?.tooltip !== undefined && {\n tooltip: seriesEncode.tooltip,\n }),\n ...(seriesEncode?.itemName !== undefined && {\n itemName: seriesEncode.itemName,\n }),\n },\n })[0];\n // ECharts reports `name` as '' when a point has no name dimension, which\n // would hide the title and the color swatch. The series name fills that in.\n const pointName =\n point.name !== undefined && point.name !== ''\n ? point.name\n : point.seriesName;\n const titleValue =\n titleRef !== undefined\n ? readEncodedValue(point.value, titleRef, point.dimensionNames)\n : pointName;\n // The title identifies the point, so it is not run through\n // `valueFormatter`. Only string and number titles are renderable children,\n // so dates are formatted like the time axis.\n const titleText =\n titleValue instanceof Date\n ? formatTimeAxisDate(titleValue)\n : typeof titleValue === 'string' || typeof titleValue === 'number'\n ? titleValue\n : undefined;\n const refs = getEncodedAxisRefs(point.encode);\n const xValue = readEncodedValue(point.value, refs.x, point.dimensionNames);\n const yValue = readEncodedValue(point.value, refs.y, point.dimensionNames);\n const axisNames = seriesAxisNames?.[point.seriesIndex ?? 0];\n\n return (\n <div className=\"ndl-charts-chart-tooltip-point\" key={key}>\n {titleText !== undefined && titleText !== '' && (\n <ChartTooltip.Title indentSquareColor={swatchColor}>\n {titleText}\n </ChartTooltip.Title>\n )}\n {xValue !== undefined && (\n <ChartTooltip.Content\n leadingElement={\n axisNames?.x ??\n encodedDimensionLabel(refs.x, point.dimensionNames, 'x')\n }\n trailingElement={valueFormatter(xValue, point.dataIndex, {\n axis: 'x',\n })}\n />\n )}\n {yValue !== undefined && (\n <ChartTooltip.Content\n leadingElement={\n axisNames?.y ??\n encodedDimensionLabel(refs.y, point.dimensionNames, 'y')\n }\n trailingElement={valueFormatter(yValue, point.dataIndex, {\n axis: 'y',\n })}\n />\n )}\n </div>\n );\n };\n\n return function scatterTooltipFormatter(params: unknown) {\n const hovered = (\n Array.isArray(params) ? params[0] : params\n ) as ScatterTooltipPoint;\n\n let points = [hovered];\n\n // A tooltip that throws leaves the chart without any tooltip at all, so a\n // failed neighbor lookup falls back to the hovered point.\n try {\n points = findNearbyScatterPoints({\n chart: getChartInstance?.(),\n dataset,\n hovered,\n legendSelected: getLegendSelected?.(),\n maxPoints: MAX_TOOLTIP_POINTS,\n radius,\n series,\n });\n } catch {\n points = [hovered];\n }\n\n return `${renderToString(\n <span className=\"ndl-charts-chart-tooltip\">\n {points.map((point, index) =>\n renderPoint(\n point,\n `${point.seriesIndex}-${point.dataIndex ?? index}`,\n ),\n )}\n </span>,\n )}`;\n };\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"chart-types.js","sourceRoot":"","sources":["../../../../src/charts/utils/chart-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport {\n type EChartsOption,\n type LineSeriesOption,\n type RegisteredSeriesOption,\n type SetOptionOpts,\n} from 'echarts';\n\nexport type HexColor = `#${string}`;\n\nexport type Condition =\n | 'greater'\n | 'greaterOrEqual'\n | 'less'\n | 'lessOrEqual'\n | 'equal'\n | 'notEqual';\n\nexport type Values<T> = T[keyof T];\nexport type SeriesOption = Values<RegisteredSeriesOption>;\n\nexport type EchartsSeries = SeriesOption | SeriesOption[];\n\ntype CustomCondition = (\n lineValue: unknown,\n thresholdLineValue: unknown,\n) => boolean;\n\nexport interface ThresholdLineSeriesOption<\n T extends NotificationType,\n> extends Omit<LineSeriesOption, 'type'> {\n type: 'thresholdLine';\n yAxis: number;\n xAxis: [number, number];\n notificationType: T;\n color?: string;\n condition?: Condition;\n customConditionText?: string;\n customCondition?: CustomCondition;\n}\n\n// Only one threshold line of each type is allowed.\nexport type NeedleSeries =\n | [\n ThresholdLineSeriesOption<'warning'>,\n ThresholdLineSeriesOption<'danger'>,\n ...SeriesOption[],\n ]\n | [ThresholdLineSeriesOption<'danger'>, ...SeriesOption[]]\n | [ThresholdLineSeriesOption<'warning'>, ...SeriesOption[]]\n | SeriesOption[];\n\n/** The zoom window of one configured `dataZoom` component, as reported by `onZoom`. */\nexport type ChartZoomEntry = {\n id?: string | number;\n xAxisIndex?: number | number[] | false;\n yAxisIndex?: number | number[] | false;\n /** Percent, 0–100. */\n startPercent: number;\n /** Percent, 0–100. */\n endPercent: number;\n /** Data value; the category index on a category axis. */\n startValue?: number;\n /** Data value; the category index on a category axis. */\n endValue?: number;\n};\n\nexport interface ChartProps {\n /** The dataset configuration for the chart. Can be a single dataset or an array of datasets. */\n dataset: EChartsOption['dataset'];\n /** The series configuration for the chart. Defines what data to display and how to display it. */\n series: NeedleSeries;\n /** X-axis configuration for the chart. */\n xAxis?: EChartsOption['xAxis'];\n /** Y-axis configuration for the chart. */\n yAxis?: EChartsOption['yAxis'];\n /** Legend configuration for the chart. */\n legend?: {\n /** Whether the legend is visible. */\n isVisible?: boolean;\n };\n /** Additional ECharts options to merge with the chart configuration. */\n option?: Omit<\n EChartsOption,\n 'series' | 'dataset' | 'legend' | 'xAxis' | 'yAxis'\n >;\n /** Custom CSS styles to apply to the chart container. */\n style?: React.CSSProperties;\n /**\n * Settings for how ECharts should update the chart. Defaults to replacing the\n * components the chart owns (`series`, `dataset`, axes, and similar) while\n * merging the rest, which drops data that disappeared without discarding the\n * ECharts components behind zoom interactions. Passing `notMerge: true`\n * re-creates those components on every update and breaks drag-to-zoom.\n */\n settings?: SetOptionOpts;\n /** Whether the chart is in a loading state. */\n isLoading?: boolean;\n /** Callback functions for chart interactions. */\n callbacks?: {\n /**\n * Called after every zoom change: slider or inside drag, drag-to-zoom and\n * the double-click reset. Only fires when `dataZoom` is configured; to\n * track drag-to-zoom on its own, add `dataZoom: [{ type: 'inside' }]`.\n *\n * `dataZoom` holds one entry per `dataZoom` component you configured, in\n * config order, so the values can be passed back as\n * `startValue`/`endValue` to restore the zoom. `id` and the axis indices\n * are copied from the config, so they are `undefined` when not set there.\n */\n onZoom?: (params: {\n // TODO v6: remove startValue and endValue\n /** @deprecated Only reflects the first `dataZoom` entry, use `dataZoom[0].startValue` instead. */\n startValue: number;\n /** @deprecated Only reflects the first `dataZoom` entry, use `dataZoom[0].endValue` instead. */\n endValue: number;\n dataZoom: ChartZoomEntry[];\n }) => void;\n };\n /** Data zoom configuration for the chart. */\n dataZoom?: EChartsOption['dataZoom'];\n /** Whether the zoom in the chart is disabled */\n isChartZoomDisabled?: boolean;\n /** Custom color palette that overrides the default categorical colors. */\n palette?: HexColor[];\n}\n\nexport interface ChartEmptyProps {\n /** A text displayed to the user when the chart is empty. */\n message?: React.ReactNode;\n /** The type of chart. This is used to render the appropriate icon. */\n type?: 'line' | 'pie' | 'bar';\n /** Optional element (preferably a TextButton) that should provide the user with an action. */\n action?: React.ReactNode;\n}\n\n/**\n * Chart tooltip\n */\n\n/**\n * Client coordinates used to anchor a floating element at a fixed point (e.g.\n * the cursor position), instead of at an anchor element.\n */\ntype AnchorPosition = {\n // oxlint-disable-next-line id-length\n x: number;\n // oxlint-disable-next-line id-length\n y: number;\n};\n\nexport interface ChartTooltipProps {\n children: React.ReactNode;\n className?: string;\n isOpen?: boolean;\n style?: React.CSSProperties;\n anchorPosition?: AnchorPosition;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport type NotificationType = 'warning' | 'danger';\n\nexport type Notification = {\n leadingElement: React.ReactNode;\n trailingElement: React.ReactNode;\n notificationType: NotificationType;\n id: string;\n};\n\nexport type ChartTooltipContentProps = {\n leadingElement?: React.ReactNode;\n trailingElement?: React.ReactNode;\n indentSquareColor?: string;\n notifications?: Notification[];\n ref?: React.Ref<HTMLDivElement>;\n};\n\n/**\n * Legend\n */\nexport interface LegendItemProps {\n name: string;\n children: React.ReactNode;\n as?: 'button' | 'div';\n className?: string;\n color?: string;\n isSelected?: boolean;\n isDeselected?: boolean;\n onLegendItemClick?: () => void;\n hasButtons?: boolean;\n onLegendItemMouseEnter?: () => void;\n onLegendItemMouseLeave?: () => void;\n ref?: React.Ref<HTMLButtonElement> & React.Ref<HTMLDivElement>;\n}\n\nexport type LegendProps = {\n series: {\n name: string;\n color: string;\n }[];\n ref?: React.Ref<HTMLDivElement>;\n};\n\nexport type HtmlAttributes<T extends React.ElementType> =\n React.ComponentPropsWithoutRef<T> & {\n [key: `data-${string}`]: string | undefined;\n };\n\ntype BaseProps<T extends React.ElementType> = {\n /**\n * Additional classnames will be applied to the root element.\n */\n className?: string;\n /**\n * Additional css styling. Will be applied to the root element.\n */\n style?: React.CSSProperties;\n\n /**\n * Html attributes to apply to the root element. This will override any default html attributes, use with caution.\n */\n htmlAttributes?: HtmlAttributes<T>;\n\n /**\n * A ref to apply to the root element.\n */\n ref?: React.ComponentPropsWithRef<T>['ref'];\n};\n\nexport type CommonProps<T extends React.ElementType, P> = P & BaseProps<T>;\n"]}
@@ -1,73 +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
- const defaultThresholdLineSeriesOption = {
22
- condition: 'greater',
23
- };
24
- const tooltipMaxWidth = 400;
25
- /**
26
- * ECharts writes `white-space: nowrap` inline on the tooltip container, so a
27
- * long series name or category label stretches the tooltip across the chart
28
- * until the max width and normal wrapping override it. `overflow-wrap` is
29
- * needed on top of that: the tooltip rows are flex items, and only `anywhere`
30
- * lets their min-content size drop below the longest word.
31
- */
32
- const tooltipExtraCssText = [
33
- 'box-shadow: none',
34
- 'background-color: transparent',
35
- `max-width: ${tooltipMaxWidth}px`,
36
- 'white-space: normal',
37
- 'overflow-wrap: anywhere',
38
- ].join('; ');
39
- /**
40
- * ECharts component main types that `buildChartOption` always writes in full,
41
- * so replacing them gives the same "drop what disappeared" behavior as
42
- * `notMerge`. Every entry has to be a registered component main type, which is
43
- * only asserted by ECharts in development builds.
44
- *
45
- * `toolbox` is deliberately absent: it has to keep its view instance across
46
- * updates, see `defaultChartSettings`.
47
- */
48
- const needleOwnedComponents = [
49
- 'dataZoom',
50
- 'dataset',
51
- 'grid',
52
- 'legend',
53
- 'series',
54
- 'tooltip',
55
- 'xAxis',
56
- 'yAxis',
57
- ];
58
- /**
59
- * `notMerge` rebuilds every component view on each `setOption`. That makes
60
- * ECharts mount a fresh toolbox brush controller while the previous one stays
61
- * attached to the renderer, because `ToolboxView.dispose` iterates its feature
62
- * map with `zrUtil.each` and so never disposes anything. Every leftover
63
- * controller then re-applies the same drag, each time against an axis the
64
- * previous one already zoomed, which shrinks the selected range.
65
- */
66
- const defaultChartSettings = {
67
- lazyUpdate: false,
68
- notMerge: false,
69
- replaceMerge: needleOwnedComponents,
70
- silent: false,
71
- };
72
- export { defaultChartSettings, defaultThresholdLineSeriesOption, needleOwnedComponents, tooltipExtraCssText, tooltipMaxWidth, };
73
- //# sourceMappingURL=defaults.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../../src/charts/utils/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,MAAM,gCAAgC,GAElC;IACF,SAAS,EAAE,SAAS;CACrB,CAAC;AAEF,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG;IAC1B,kBAAkB;IAClB,+BAA+B;IAC/B,cAAc,eAAe,IAAI;IACjC,qBAAqB;IACrB,yBAAyB;CAC1B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb;;;;;;;;GAQG;AACH,MAAM,qBAAqB,GAAG;IAC5B,UAAU;IACV,SAAS;IACT,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,OAAO;IACP,OAAO;CACR,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,oBAAoB,GAAwC;IAChE,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,KAAK;IACf,YAAY,EAAE,qBAAqB;IACnC,MAAM,EAAE,KAAK;CACd,CAAC;AAEF,OAAO,EACL,oBAAoB,EACpB,gCAAgC,EAChC,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,GAChB,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, Condition } from './chart-types';\n\nconst defaultThresholdLineSeriesOption: {\n condition: Condition;\n} = {\n condition: 'greater',\n};\n\nconst tooltipMaxWidth = 400;\n\n/**\n * ECharts writes `white-space: nowrap` inline on the tooltip container, so a\n * long series name or category label stretches the tooltip across the chart\n * until the max width and normal wrapping override it. `overflow-wrap` is\n * needed on top of that: the tooltip rows are flex items, and only `anywhere`\n * lets their min-content size drop below the longest word.\n */\nconst tooltipExtraCssText = [\n 'box-shadow: none',\n 'background-color: transparent',\n `max-width: ${tooltipMaxWidth}px`,\n 'white-space: normal',\n 'overflow-wrap: anywhere',\n].join('; ');\n\n/**\n * ECharts component main types that `buildChartOption` always writes in full,\n * so replacing them gives the same \"drop what disappeared\" behavior as\n * `notMerge`. Every entry has to be a registered component main type, which is\n * only asserted by ECharts in development builds.\n *\n * `toolbox` is deliberately absent: it has to keep its view instance across\n * updates, see `defaultChartSettings`.\n */\nconst needleOwnedComponents = [\n 'dataZoom',\n 'dataset',\n 'grid',\n 'legend',\n 'series',\n 'tooltip',\n 'xAxis',\n 'yAxis',\n];\n\n/**\n * `notMerge` rebuilds every component view on each `setOption`. That makes\n * ECharts mount a fresh toolbox brush controller while the previous one stays\n * attached to the renderer, because `ToolboxView.dispose` iterates its feature\n * map with `zrUtil.each` and so never disposes anything. Every leftover\n * controller then re-applies the same drag, each time against an axis the\n * previous one already zoomed, which shrinks the selected range.\n */\nconst defaultChartSettings: NonNullable<ChartProps['settings']> = {\n lazyUpdate: false,\n notMerge: false,\n replaceMerge: needleOwnedComponents,\n silent: false,\n};\n\nexport {\n defaultChartSettings,\n defaultThresholdLineSeriesOption,\n needleOwnedComponents,\n tooltipExtraCssText,\n tooltipMaxWidth,\n};\n"]}
@@ -1,74 +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 { time } from 'echarts';
22
- const capitalizeFirstLetter = (str) => {
23
- if (!str) {
24
- return str;
25
- }
26
- return str.charAt(0).toUpperCase() + str.substring(1);
27
- };
28
- const enUSNumberFormatter = new Intl.NumberFormat('en-US');
29
- /**
30
- * Formats finite number values with en-US separators and returns all other
31
- * values unchanged.
32
- */
33
- const formatNumberEnUS = (value) => {
34
- if (typeof value === 'number') {
35
- return Number.isFinite(value) ? enUSNumberFormatter.format(value) : value;
36
- }
37
- return value;
38
- };
39
- /**
40
- * Formats a date the way ECharts labels a time axis, so tooltips match it.
41
- */
42
- const formatTimeAxisDate = (date) => time.format(date, '{yyyy}-{MM}-{dd} {HH}:{mm}:{ss}', false);
43
- /**
44
- * Default tooltip formatting. Numbers get en-US separators and dates use
45
- * `formatTimeAxisDate`. Other values are returned unchanged.
46
- */
47
- const formatTooltipValue = (value) => {
48
- if (value instanceof Date) {
49
- return formatTimeAxisDate(value);
50
- }
51
- return formatNumberEnUS(value);
52
- };
53
- /**
54
- * Extract the tooltip value from the series depending on the axisDim and encode properties
55
- * If the value is a single value, return it as it is
56
- * If the encode property does not exist fallback to 1
57
- */
58
- const extractValueFromTooltipSeries = (value, encode,
59
- // We currently only support x and y axes
60
- axisDim = 'x') => {
61
- var _a, _b;
62
- if (!Array.isArray(value)) {
63
- return value;
64
- }
65
- // The axisDim is the axis that the tooltip was triggered on,
66
- // if it was triggered on the x axis the value should be read from the y axis and vice versa
67
- const encodeValueToRead = axisDim === 'x' ? encode === null || encode === void 0 ? void 0 : encode.y : ((_a = encode === null || encode === void 0 ? void 0 : encode.x) !== null && _a !== void 0 ? _a : 1);
68
- const seriesValueIdx = Array.isArray(encodeValueToRead)
69
- ? encodeValueToRead[0]
70
- : encodeValueToRead;
71
- return (_b = value[seriesValueIdx]) !== null && _b !== void 0 ? _b : value;
72
- };
73
- export { capitalizeFirstLetter, extractValueFromTooltipSeries, formatNumberEnUS, formatTimeAxisDate, formatTooltipValue, };
74
- //# sourceMappingURL=format-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-utils.js","sourceRoot":"","sources":["../../../../src/charts/utils/format-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAE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AAK,GAAG,CAAC,CAAC,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,CAAC,mCAAI,CAAC,CAAC,CAAC;IAEzE,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC;QACrD,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;QACtB,CAAC,CAAC,iBAAiB,CAAC;IAEtB,OAAO,MAAA,KAAK,CAAC,cAAc,CAAC,mCAAI,KAAK,CAAC;AACxC,CAAC,CAAC;AAEF,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,GACnB,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 { time } from 'echarts';\n\nconst capitalizeFirstLetter = (str: string) => {\n if (!str) {\n return str;\n }\n return str.charAt(0).toUpperCase() + str.substring(1);\n};\n\nconst enUSNumberFormatter = new Intl.NumberFormat('en-US');\n\n/**\n * Formats finite number values with en-US separators and returns all other\n * values unchanged.\n */\nconst formatNumberEnUS = <T>(value: T): string | T => {\n if (typeof value === 'number') {\n return Number.isFinite(value) ? enUSNumberFormatter.format(value) : value;\n }\n\n return value;\n};\n\n/**\n * Formats a date the way ECharts labels a time axis, so tooltips match it.\n */\nconst formatTimeAxisDate = (date: Date) =>\n time.format(date, '{yyyy}-{MM}-{dd} {HH}:{mm}:{ss}', false);\n\n/**\n * Default tooltip formatting. Numbers get en-US separators and dates use\n * `formatTimeAxisDate`. Other values are returned unchanged.\n */\nconst formatTooltipValue = <T>(value: T): string | T => {\n if (value instanceof Date) {\n return formatTimeAxisDate(value);\n }\n\n return formatNumberEnUS(value);\n};\n\n/**\n * Extract the tooltip value from the series depending on the axisDim and encode properties\n * If the value is a single value, return it as it is\n * If the encode property does not exist fallback to 1\n */\nconst extractValueFromTooltipSeries = (\n value: string | number | (number | string)[],\n encode: {\n // E-Charts uses encode.x and encode.y - https://echarts.apache.org/en/option.html#series-line.encode\n // oxlint-disable-next-line id-length\n x: number | number[];\n // oxlint-disable-next-line id-length\n y: number | number[];\n },\n // We currently only support x and y axes\n axisDim: 'x' | 'y' | 'angle' | 'radius' | 'single' = 'x',\n) => {\n if (!Array.isArray(value)) {\n return value;\n }\n\n // The axisDim is the axis that the tooltip was triggered on,\n // if it was triggered on the x axis the value should be read from the y axis and vice versa\n const encodeValueToRead = axisDim === 'x' ? encode?.y : (encode?.x ?? 1);\n\n const seriesValueIdx = Array.isArray(encodeValueToRead)\n ? encodeValueToRead[0]\n : encodeValueToRead;\n\n return value[seriesValueIdx] ?? value;\n};\n\nexport {\n capitalizeFirstLetter,\n extractValueFromTooltipSeries,\n formatNumberEnUS,\n formatTimeAxisDate,\n formatTooltipValue,\n};\n"]}
@@ -1,59 +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
- export const COLLAPSED_LEGEND_ROWS = 2;
22
- export const COLLAPSED_LEGEND_MAX_HEIGHT = 64;
23
- /**
24
- * Get the computed element width, including both paddings and margins
25
- */
26
- export const getComputedElementWidth = (element) => {
27
- const elementRect = element.getBoundingClientRect();
28
- const elementComputedStyle = window.getComputedStyle(element);
29
- const elementMarginLeft = parseFloat(elementComputedStyle.marginLeft);
30
- const elementMarginRight = parseFloat(elementComputedStyle.marginRight);
31
- return elementRect.width + elementMarginLeft + elementMarginRight;
32
- };
33
- export const getItemCountThatFitsRow = (itemWidths, availableWidth, { keepOversizedFirstItem = true } = {}) => {
34
- let rowWidth = 0;
35
- let count = 0;
36
- for (const itemWidth of itemWidths) {
37
- if (count === 0 && itemWidth > availableWidth) {
38
- return keepOversizedFirstItem ? 1 : 0;
39
- }
40
- if (rowWidth + itemWidth > availableWidth) {
41
- return count;
42
- }
43
- rowWidth += itemWidth;
44
- count += 1;
45
- }
46
- return count;
47
- };
48
- /**
49
- * Calculates how many legend items fit in the two-row collapsed layout.
50
- *
51
- * The second row reserves space for the "View more" action so that control
52
- * remains visible at the end of the collapsed legend.
53
- */
54
- export const getCollapsedVisibleItemCount = (itemWidths, availableRowWidth, viewMoreButtonWidth) => {
55
- const firstRowItemCount = getItemCountThatFitsRow(itemWidths, availableRowWidth);
56
- const secondRowItemCount = getItemCountThatFitsRow(itemWidths.slice(firstRowItemCount), availableRowWidth - viewMoreButtonWidth, { keepOversizedFirstItem: false });
57
- return firstRowItemCount + secondRowItemCount;
58
- };
59
- //# sourceMappingURL=legend-layout.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legend-layout.js","sourceRoot":"","sources":["../../../../src/charts/utils/legend-layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAA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AAuB,CAC/C,UAAU,EACV,iBAAiB,CAClB,CAAC;IACF,MAAM,kBAAkB,GAAG,uBAAuB,CAChD,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,EACnC,iBAAiB,GAAG,mBAAmB,EACvC,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAClC,CAAC;IAEF,OAAO,iBAAiB,GAAG,kBAAkB,CAAC;AAChD,CAAC,CAAC","sourcesContent":["/*!\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nexport const COLLAPSED_LEGEND_ROWS = 2;\nexport const COLLAPSED_LEGEND_MAX_HEIGHT = 64;\n\n/**\n * Get the computed element width, including both paddings and margins\n */\nexport const getComputedElementWidth = (element: Element) => {\n const elementRect = element.getBoundingClientRect();\n const elementComputedStyle = window.getComputedStyle(element);\n const elementMarginLeft = parseFloat(elementComputedStyle.marginLeft);\n const elementMarginRight = parseFloat(elementComputedStyle.marginRight);\n\n return elementRect.width + elementMarginLeft + elementMarginRight;\n};\n\nexport const getItemCountThatFitsRow = (\n itemWidths: number[],\n availableWidth: number,\n { keepOversizedFirstItem = true } = {},\n) => {\n let rowWidth = 0;\n let count = 0;\n\n for (const itemWidth of itemWidths) {\n if (count === 0 && itemWidth > availableWidth) {\n return keepOversizedFirstItem ? 1 : 0;\n }\n\n if (rowWidth + itemWidth > availableWidth) {\n return count;\n }\n\n rowWidth += itemWidth;\n count += 1;\n }\n\n return count;\n};\n\n/**\n * Calculates how many legend items fit in the two-row collapsed layout.\n *\n * The second row reserves space for the \"View more\" action so that control\n * remains visible at the end of the collapsed legend.\n */\nexport const getCollapsedVisibleItemCount = (\n itemWidths: number[],\n availableRowWidth: number,\n viewMoreButtonWidth: number,\n) => {\n const firstRowItemCount = getItemCountThatFitsRow(\n itemWidths,\n availableRowWidth,\n );\n const secondRowItemCount = getItemCountThatFitsRow(\n itemWidths.slice(firstRowItemCount),\n availableRowWidth - viewMoreButtonWidth,\n { keepOversizedFirstItem: false },\n );\n\n return firstRowItemCount + secondRowItemCount;\n};\n"]}