@neo4j-ndl/react-charts 1.1.1 → 1.1.3

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 (185) hide show
  1. package/lib/cjs/charts/Chart.js +56 -462
  2. package/lib/cjs/charts/Chart.js.map +1 -1
  3. package/lib/cjs/charts/ChartContainer.js +71 -0
  4. package/lib/cjs/charts/ChartContainer.js.map +1 -0
  5. package/lib/cjs/charts/ChartEmpty.js.map +1 -1
  6. package/lib/cjs/charts/ChartRender.js +97 -0
  7. package/lib/cjs/charts/ChartRender.js.map +1 -0
  8. package/lib/cjs/charts/ChartTooltip.js.map +1 -1
  9. package/lib/cjs/charts/Legend.js +32 -246
  10. package/lib/cjs/charts/Legend.js.map +1 -1
  11. package/lib/cjs/charts/LegendItem.js +68 -0
  12. package/lib/cjs/charts/LegendItem.js.map +1 -0
  13. package/lib/cjs/charts/LegendLayout.js +363 -0
  14. package/lib/cjs/charts/LegendLayout.js.map +1 -0
  15. package/lib/cjs/charts/hooks/use-chart-instance.js +133 -0
  16. package/lib/cjs/charts/hooks/use-chart-instance.js.map +1 -0
  17. package/lib/cjs/charts/hooks/use-chart-option.js +79 -0
  18. package/lib/cjs/charts/hooks/use-chart-option.js.map +1 -0
  19. package/lib/cjs/charts/hooks/use-chart-refs.js +52 -0
  20. package/lib/cjs/charts/hooks/use-chart-refs.js.map +1 -0
  21. package/lib/cjs/charts/hooks/use-chart-zoom.js +117 -0
  22. package/lib/cjs/charts/hooks/use-chart-zoom.js.map +1 -0
  23. package/lib/cjs/charts/hooks/use-legend-interactions.js +149 -0
  24. package/lib/cjs/charts/hooks/use-legend-interactions.js.map +1 -0
  25. package/lib/cjs/charts/hooks/use-legend-series.js +181 -0
  26. package/lib/cjs/charts/hooks/use-legend-series.js.map +1 -0
  27. package/lib/cjs/charts/hooks/use-legend-visibility.js +91 -0
  28. package/lib/cjs/charts/hooks/use-legend-visibility.js.map +1 -0
  29. package/lib/cjs/charts/index.js +1 -1
  30. package/lib/cjs/charts/index.js.map +1 -1
  31. package/lib/cjs/charts/tests/chart-test-utils.js +56 -9
  32. package/lib/cjs/charts/tests/chart-test-utils.js.map +1 -1
  33. package/lib/cjs/charts/themes/ndl-echarts-theme.js.map +1 -1
  34. package/lib/cjs/charts/{aria-description.js → utils/aria-description.js} +4 -45
  35. package/lib/cjs/charts/utils/aria-description.js.map +1 -0
  36. package/lib/cjs/charts/utils/build-chart-option.js +74 -0
  37. package/lib/cjs/charts/utils/build-chart-option.js.map +1 -0
  38. package/lib/cjs/charts/utils/chart-tooltip-formatter.js +86 -0
  39. package/lib/cjs/charts/utils/chart-tooltip-formatter.js.map +1 -0
  40. package/lib/cjs/charts/utils/chart-types.js.map +1 -0
  41. package/lib/cjs/charts/utils/defaults.js.map +1 -0
  42. package/lib/cjs/charts/{utils.js → utils/format-utils.js} +3 -19
  43. package/lib/cjs/charts/utils/format-utils.js.map +1 -0
  44. package/lib/cjs/charts/utils/legend-layout.js +65 -0
  45. package/lib/cjs/charts/utils/legend-layout.js.map +1 -0
  46. package/lib/cjs/charts/{legend-utils.js → utils/legend-utils.js} +1 -78
  47. package/lib/cjs/charts/utils/legend-utils.js.map +1 -0
  48. package/lib/cjs/charts/utils/threshold.js +114 -0
  49. package/lib/cjs/charts/utils/threshold.js.map +1 -0
  50. package/lib/cjs/charts/{user-option-utils.js → utils/user-option-utils.js} +7 -16
  51. package/lib/cjs/charts/utils/user-option-utils.js.map +1 -0
  52. package/lib/esm/charts/Chart.js +50 -457
  53. package/lib/esm/charts/Chart.js.map +1 -1
  54. package/lib/esm/charts/ChartContainer.js +67 -0
  55. package/lib/esm/charts/ChartContainer.js.map +1 -0
  56. package/lib/esm/charts/ChartEmpty.js.map +1 -1
  57. package/lib/esm/charts/ChartRender.js +93 -0
  58. package/lib/esm/charts/ChartRender.js.map +1 -0
  59. package/lib/esm/charts/ChartTooltip.js.map +1 -1
  60. package/lib/esm/charts/Legend.js +32 -243
  61. package/lib/esm/charts/Legend.js.map +1 -1
  62. package/lib/esm/charts/LegendItem.js +61 -0
  63. package/lib/esm/charts/LegendItem.js.map +1 -0
  64. package/lib/esm/charts/LegendLayout.js +323 -0
  65. package/lib/esm/charts/LegendLayout.js.map +1 -0
  66. package/lib/esm/charts/hooks/use-chart-instance.js +128 -0
  67. package/lib/esm/charts/hooks/use-chart-instance.js.map +1 -0
  68. package/lib/esm/charts/hooks/use-chart-option.js +76 -0
  69. package/lib/esm/charts/hooks/use-chart-option.js.map +1 -0
  70. package/lib/esm/charts/hooks/use-chart-refs.js +48 -0
  71. package/lib/esm/charts/hooks/use-chart-refs.js.map +1 -0
  72. package/lib/esm/charts/hooks/use-chart-zoom.js +114 -0
  73. package/lib/esm/charts/hooks/use-chart-zoom.js.map +1 -0
  74. package/lib/esm/charts/hooks/use-legend-interactions.js +145 -0
  75. package/lib/esm/charts/hooks/use-legend-interactions.js.map +1 -0
  76. package/lib/esm/charts/hooks/use-legend-series.js +178 -0
  77. package/lib/esm/charts/hooks/use-legend-series.js.map +1 -0
  78. package/lib/esm/charts/hooks/use-legend-visibility.js +87 -0
  79. package/lib/esm/charts/hooks/use-legend-visibility.js.map +1 -0
  80. package/lib/esm/charts/index.js +1 -1
  81. package/lib/esm/charts/index.js.map +1 -1
  82. package/lib/esm/charts/tests/chart-test-utils.js +53 -8
  83. package/lib/esm/charts/tests/chart-test-utils.js.map +1 -1
  84. package/lib/esm/charts/themes/ndl-echarts-theme.js.map +1 -1
  85. package/lib/esm/charts/{aria-description.js → utils/aria-description.js} +4 -45
  86. package/lib/esm/charts/utils/aria-description.js.map +1 -0
  87. package/lib/esm/charts/utils/build-chart-option.js +69 -0
  88. package/lib/esm/charts/utils/build-chart-option.js.map +1 -0
  89. package/lib/esm/charts/utils/chart-tooltip-formatter.js +82 -0
  90. package/lib/esm/charts/utils/chart-tooltip-formatter.js.map +1 -0
  91. package/lib/esm/charts/utils/chart-types.js.map +1 -0
  92. package/lib/esm/charts/utils/defaults.js.map +1 -0
  93. package/lib/esm/charts/{utils.js → utils/format-utils.js} +2 -17
  94. package/lib/esm/charts/utils/format-utils.js.map +1 -0
  95. package/lib/esm/charts/utils/legend-layout.js +59 -0
  96. package/lib/esm/charts/utils/legend-layout.js.map +1 -0
  97. package/lib/esm/charts/{legend-utils.js → utils/legend-utils.js} +1 -75
  98. package/lib/esm/charts/utils/legend-utils.js.map +1 -0
  99. package/lib/esm/charts/utils/threshold.js +106 -0
  100. package/lib/esm/charts/utils/threshold.js.map +1 -0
  101. package/lib/esm/charts/{user-option-utils.js → utils/user-option-utils.js} +5 -14
  102. package/lib/esm/charts/utils/user-option-utils.js.map +1 -0
  103. package/lib/types/charts/Chart.d.ts +2 -2
  104. package/lib/types/charts/Chart.d.ts.map +1 -1
  105. package/lib/{esm/charts/types.js → types/charts/ChartContainer.d.ts} +14 -1
  106. package/lib/types/charts/ChartContainer.d.ts.map +1 -0
  107. package/lib/types/charts/ChartEmpty.d.ts +1 -1
  108. package/lib/types/charts/ChartEmpty.d.ts.map +1 -1
  109. package/lib/types/charts/ChartRender.d.ts +36 -0
  110. package/lib/types/charts/ChartRender.d.ts.map +1 -0
  111. package/lib/types/charts/ChartTooltip.d.ts +1 -1
  112. package/lib/types/charts/ChartTooltip.d.ts.map +1 -1
  113. package/lib/types/charts/Legend.d.ts +15 -3
  114. package/lib/types/charts/Legend.d.ts.map +1 -1
  115. package/lib/{cjs/charts/types.js → types/charts/LegendItem.d.ts} +10 -3
  116. package/lib/types/charts/LegendItem.d.ts.map +1 -0
  117. package/lib/types/charts/LegendLayout.d.ts +38 -0
  118. package/lib/types/charts/LegendLayout.d.ts.map +1 -0
  119. package/lib/types/charts/hooks/use-chart-instance.d.ts +62 -0
  120. package/lib/types/charts/hooks/use-chart-instance.d.ts.map +1 -0
  121. package/lib/types/charts/hooks/use-chart-option.d.ts +48 -0
  122. package/lib/types/charts/hooks/use-chart-option.d.ts.map +1 -0
  123. package/lib/types/charts/hooks/use-chart-refs.d.ts +38 -0
  124. package/lib/types/charts/hooks/use-chart-refs.d.ts.map +1 -0
  125. package/lib/types/charts/hooks/use-chart-zoom.d.ts +36 -0
  126. package/lib/types/charts/hooks/use-chart-zoom.d.ts.map +1 -0
  127. package/lib/types/charts/hooks/use-legend-interactions.d.ts +56 -0
  128. package/lib/types/charts/hooks/use-legend-interactions.d.ts.map +1 -0
  129. package/lib/types/charts/hooks/use-legend-series.d.ts +42 -0
  130. package/lib/types/charts/hooks/use-legend-series.d.ts.map +1 -0
  131. package/lib/types/charts/hooks/use-legend-visibility.d.ts +24 -0
  132. package/lib/types/charts/hooks/use-legend-visibility.d.ts.map +1 -0
  133. package/lib/types/charts/index.d.ts +2 -2
  134. package/lib/types/charts/index.d.ts.map +1 -1
  135. package/lib/types/charts/tests/chart-test-utils.d.ts +7 -1
  136. package/lib/types/charts/tests/chart-test-utils.d.ts.map +1 -1
  137. package/lib/types/charts/themes/ndl-echarts-theme.d.ts +1 -1
  138. package/lib/types/charts/themes/ndl-echarts-theme.d.ts.map +1 -1
  139. package/lib/types/charts/utils/aria-description.d.ts.map +1 -0
  140. package/lib/types/charts/utils/build-chart-option.d.ts +52 -0
  141. package/lib/types/charts/utils/build-chart-option.d.ts.map +1 -0
  142. package/lib/types/charts/utils/chart-tooltip-formatter.d.ts +37 -0
  143. package/lib/types/charts/utils/chart-tooltip-formatter.d.ts.map +1 -0
  144. package/lib/types/charts/{chart-types.d.ts → utils/chart-types.d.ts} +23 -22
  145. package/lib/types/charts/utils/chart-types.d.ts.map +1 -0
  146. package/lib/types/charts/utils/defaults.d.ts.map +1 -0
  147. package/lib/types/charts/{utils.d.ts → utils/format-utils.d.ts} +2 -4
  148. package/lib/types/charts/utils/format-utils.d.ts.map +1 -0
  149. package/lib/types/charts/utils/legend-layout.d.ts +37 -0
  150. package/lib/types/charts/utils/legend-layout.d.ts.map +1 -0
  151. package/lib/types/charts/{legend-utils.d.ts → utils/legend-utils.d.ts} +1 -11
  152. package/lib/types/charts/utils/legend-utils.d.ts.map +1 -0
  153. package/lib/types/charts/utils/threshold.d.ts +45 -0
  154. package/lib/types/charts/utils/threshold.d.ts.map +1 -0
  155. package/lib/types/charts/utils/user-option-utils.d.ts.map +1 -0
  156. package/package.json +3 -3
  157. package/lib/cjs/charts/aria-description.js.map +0 -1
  158. package/lib/cjs/charts/chart-types.js.map +0 -1
  159. package/lib/cjs/charts/defaults.js.map +0 -1
  160. package/lib/cjs/charts/legend-utils.js.map +0 -1
  161. package/lib/cjs/charts/types.js.map +0 -1
  162. package/lib/cjs/charts/user-option-utils.js.map +0 -1
  163. package/lib/cjs/charts/utils.js.map +0 -1
  164. package/lib/esm/charts/aria-description.js.map +0 -1
  165. package/lib/esm/charts/chart-types.js.map +0 -1
  166. package/lib/esm/charts/defaults.js.map +0 -1
  167. package/lib/esm/charts/legend-utils.js.map +0 -1
  168. package/lib/esm/charts/types.js.map +0 -1
  169. package/lib/esm/charts/user-option-utils.js.map +0 -1
  170. package/lib/esm/charts/utils.js.map +0 -1
  171. package/lib/types/charts/aria-description.d.ts.map +0 -1
  172. package/lib/types/charts/chart-types.d.ts.map +0 -1
  173. package/lib/types/charts/defaults.d.ts.map +0 -1
  174. package/lib/types/charts/legend-utils.d.ts.map +0 -1
  175. package/lib/types/charts/types.d.ts +0 -44
  176. package/lib/types/charts/types.d.ts.map +0 -1
  177. package/lib/types/charts/user-option-utils.d.ts.map +0 -1
  178. package/lib/types/charts/utils.d.ts.map +0 -1
  179. /package/lib/cjs/charts/{chart-types.js → utils/chart-types.js} +0 -0
  180. /package/lib/cjs/charts/{defaults.js → utils/defaults.js} +0 -0
  181. /package/lib/esm/charts/{chart-types.js → utils/chart-types.js} +0 -0
  182. /package/lib/esm/charts/{defaults.js → utils/defaults.js} +0 -0
  183. /package/lib/types/charts/{aria-description.d.ts → utils/aria-description.d.ts} +0 -0
  184. /package/lib/types/charts/{defaults.d.ts → utils/defaults.d.ts} +0 -0
  185. /package/lib/types/charts/{user-option-utils.d.ts → utils/user-option-utils.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-chart-option.js","sourceRoot":"","sources":["../../../../src/charts/utils/build-chart-option.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AA4BH,8CAQC;AAKD,4CAIC;AAMD,4CA8DC;AA7GD,yDAAsE;AACtE,uEAAuE;AAGvE,2DAAmD;AAiBnD;;GAEG;AACH,SAAgB,iBAAiB,CAC/B,QAAmC;IAEnC,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC5B,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,cAAuC,EAAE,EAAE;YACxD,OAAO,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,MAAK,QAAQ,CAAC;QAC3C,CAAC,CAAC;QACJ,CAAC,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,QAAQ,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,KAA6B;IAC5D,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC;QAC1C,CAAC,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,UAAU,CAAC;AACjC,CAAC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,OAAO,EACP,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,WAAW,EACX,MAAM,EACN,cAAc,EACd,cAAc,EACd,UAAU,EACV,KAAK,EACL,KAAK,GACkB;IACvB,MAAM,qBAAqB,GAAG,IAAA,mDAAgC,EAC5D,WAAW,EACX,OAAO,CACR,CAAC;IAEF,uCACK,UAAU,KACb,IAAI,gCACF,KAAK,EAAE;gBACL,IAAI,EAAE,KAAK;aACZ,EACD,OAAO,EAAE,IAAI,IACV,CAAC,qBAAqB,KAAK,SAAS,IAAI;YACzC,KAAK,EAAE,EAAE,WAAW,EAAE,qBAAqB,EAAE;SAC9C,CAAC,GACE,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAA8B,GAEhD,QAAQ;QACR,OAAO,EACP,IAAI,kBACF,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EACvC,YAAY,EAAE,IAAI,EAClB,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EACxC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EACzC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,OAAO,IACT,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAA8B,GAEhD,MAAM,EAAE;YACN,oEAAoE;YACpE,8DAA8D;YAC9D,QAAQ,oBAAO,cAAc,CAAE;YAC/B,IAAI,EAAE,KAAK;SACZ,EACD,MAAM,EACN,OAAO,EAAE,IAAA,gCAAY,EAAC,cAAc,CAAC,EACrC,OAAO,EAAE;YACP,YAAY,EAAE,CAAC;YACf,WAAW,EAAE,CAAC;YACd,OAAO,EAAE,IAAI;YACb,YAAY,EAAE,kDAAkD;YAChE,SAAS,EAAE,IAAA,oDAA0B,EAAC,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC;YACrE,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,MAAM;SAChB,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 { createAxisTooltipFormatter } from './chart-tooltip-formatter';\nimport type { ChartProps, EchartsSeries } from './chart-types';\nimport type { NormalizedThresholdLine } from './threshold';\nimport { mergeToolbox } from './user-option-utils';\n\ntype BuildChartOptionParams = {\n dataZoom: EChartsOption['dataZoom'];\n dataset: ChartProps['dataset'];\n hasCategoryXAxis: boolean;\n hasSliderZoom: 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};\n\n/**\n * Slider zoom needs extra bottom grid space for ECharts' slider control.\n */\nexport function hasSliderDataZoom(\n dataZoom: EChartsOption['dataZoom'],\n): boolean {\n return Array.isArray(dataZoom)\n ? dataZoom.some((dataZoomOption: DataZoomComponentOption) => {\n return dataZoomOption?.type === 'slider';\n })\n : dataZoom?.type === 'slider';\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((x) => x.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 hasCategoryXAxis,\n hasSliderZoom,\n legendSelected,\n propsSeries,\n series,\n thresholdLines,\n toolboxOptions,\n userOption,\n xAxis,\n yAxis,\n}: BuildChartOptionParams): EChartsOption {\n const customAriaDescription = generateThresholdAriaDescription(\n propsSeries,\n dataset,\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: hasSliderZoom ? '60px' : '10px',\n containLabel: true,\n left: hasCategoryXAxis ? '15px' : '10px',\n right: hasCategoryXAxis ? '15px' : '10px',\n top: '10px',\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),\n tooltip: {\n borderRadius: 0,\n borderWidth: 0,\n confine: true,\n extraCssText: 'box-shadow: none; background-color: transparent;',\n formatter: createAxisTooltipFormatter({ thresholdLines, userOption }),\n padding: 0,\n trigger: 'axis',\n },\n xAxis,\n yAxis,\n };\n}\n"]}
@@ -0,0 +1,86 @@
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
+ "use strict";
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.getTooltipValueFormatter = getTooltipValueFormatter;
25
+ exports.createAxisTooltipFormatter = createAxisTooltipFormatter;
26
+ const jsx_runtime_1 = require("react/jsx-runtime");
27
+ const server_1 = require("react-dom/server");
28
+ const ChartTooltip_1 = require("../ChartTooltip");
29
+ const format_utils_1 = require("./format-utils");
30
+ const threshold_1 = require("./threshold");
31
+ const threshold_2 = require("./threshold");
32
+ function getTooltipValueFormatter(userOption) {
33
+ if (typeof (userOption === null || userOption === void 0 ? void 0 : userOption.tooltip) === 'object' &&
34
+ userOption.tooltip !== null &&
35
+ 'valueFormatter' in userOption.tooltip) {
36
+ return userOption.tooltip.valueFormatter;
37
+ }
38
+ return format_utils_1.formatNumberEnUS;
39
+ }
40
+ /**
41
+ * Builds the ECharts axis-tooltip formatter used by line-like charts.
42
+ * It renders Needle tooltip markup and augments non-threshold series with
43
+ * threshold notifications when their current value crosses a threshold line.
44
+ */
45
+ function createAxisTooltipFormatter({ thresholdLines, userOption, }) {
46
+ const valueFormatter = getTooltipValueFormatter(userOption);
47
+ return function axisTooltipFormatter(params) {
48
+ var _a;
49
+ const paramsArray = Array.isArray(params) ? params : [params];
50
+ const firstParam = paramsArray[0];
51
+ 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: (_a = firstParam === null || firstParam === void 0 ? void 0 : firstParam.axisValueLabel) !== null && _a !== void 0 ? _a : '' }), paramsArray.map((series) => {
52
+ const value = (0, format_utils_1.extractValueFromTooltipSeries)(series.value, series.encode, series.axisDim);
53
+ const seriesValue = typeof value === 'number' ? value : Number(value);
54
+ const isSeriesThresholdLine = (0, threshold_2.isThresholdLine)(series.seriesName);
55
+ const notifications = thresholdLines.flatMap((threshold) => {
56
+ if (isSeriesThresholdLine || Number.isNaN(seriesValue)) {
57
+ return [];
58
+ }
59
+ const { notificationType, value: thresholdValue, condition, customConditionText, customCondition, } = threshold;
60
+ const conditionEvaluation = customCondition
61
+ ? {
62
+ conditionText: customConditionText,
63
+ isConditionMet: customCondition(seriesValue, thresholdValue),
64
+ }
65
+ : (0, threshold_1.evaluateThresholdCondition)(seriesValue, condition, thresholdValue);
66
+ if (!conditionEvaluation.isConditionMet) {
67
+ return [];
68
+ }
69
+ return [
70
+ {
71
+ id: `threshold-${notificationType}`,
72
+ leadingElement: customCondition
73
+ ? conditionEvaluation.conditionText
74
+ : `${conditionEvaluation.conditionText} threshold`,
75
+ notificationType,
76
+ trailingElement: valueFormatter(thresholdValue),
77
+ },
78
+ ];
79
+ });
80
+ return ((0, jsx_runtime_1.jsx)(ChartTooltip_1.ChartTooltip.Content, { leadingElement: isSeriesThresholdLine
81
+ ? `${(0, format_utils_1.capitalizeFirstLetter)((0, threshold_2.getThresholdLineDisplayName)(series.seriesName))} threshold`
82
+ : series.seriesName, trailingElement: valueFormatter(value), indentSquareColor: series.color, notifications: notifications }, series.seriesName));
83
+ })] }))}`;
84
+ };
85
+ }
86
+ //# sourceMappingURL=chart-tooltip-formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-tooltip-formatter.js","sourceRoot":"","sources":["../../../../src/charts/utils/chart-tooltip-formatter.tsx"],"names":[],"mappings":";;AAwCA,4DAYC;AAYD,gEAoFC;;AA9HD,6CAAkD;AAElD,kDAA+C;AAE/C,iDAIwB;AACxB,2CAAyD;AACzD,2CAIqB;AAIrB,SAAgB,wBAAwB,CACtC,UAAgC;IAEhC,IACE,OAAO,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,OAAO,CAAA,KAAK,QAAQ;QACvC,UAAU,CAAC,OAAO,KAAK,IAAI;QAC3B,gBAAgB,IAAI,UAAU,CAAC,OAAO,EACtC,CAAC;QACD,OAAO,UAAU,CAAC,OAAO,CAAC,cAAuC,CAAC;IACpE,CAAC;IAED,OAAO,+BAAyC,CAAC;AACnD,CAAC;AAOD;;;;GAIG;AACH,SAAgB,0BAA0B,CAAC,EACzC,cAAc,EACd,UAAU,GACuB;IACjC,MAAM,cAAc,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cAAc,CAAC;6BAC7D;4BACH,CAAC,CAAC,IAAA,sCAA0B,EACxB,WAAW,EACX,SAAS,EACT,cAAc,CACf,CAAC;wBAEN,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,CAAC;4BACxC,OAAO,EAAE,CAAC;wBACZ,CAAC;wBAED,OAAO;4BACL;gCACE,EAAE,EAAE,aAAa,gBAAgB,EAAE;gCACnC,cAAc,EAAE,eAAe;oCAC7B,CAAC,CAAC,mBAAmB,CAAC,aAAa;oCACnC,CAAC,CAAC,GAAG,mBAAmB,CAAC,aAAa,YAAY;gCACpD,gBAAgB;gCAChB,eAAe,EAAE,cAAc,CAAC,cAAc,CAAC;6BAChD;yBACF,CAAC;oBACJ,CAAC,CAAC,CAAC;oBAEH,OAAO,CACL,uBAAC,2BAAY,CAAC,OAAO,IAEnB,cAAc,EACZ,qBAAqB;4BACnB,CAAC,CAAC,GAAG,IAAA,oCAAqB,EACtB,IAAA,uCAA2B,EAAC,MAAM,CAAC,UAAU,CAAC,CAC/C,YAAY;4BACf,CAAC,CAAC,MAAM,CAAC,UAAU,EAEvB,eAAe,EAAE,cAAc,CAAC,KAAK,CAAC,EACtC,iBAAiB,EAAE,MAAM,CAAC,KAAK,EAC/B,aAAa,EAAE,aAAa,IAVvB,MAAM,CAAC,UAAU,CAWtB,CACH,CAAC;gBACJ,CAAC,CAAC,IACG,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 } from './chart-types';\nimport {\n capitalizeFirstLetter,\n extractValueFromTooltipSeries,\n formatNumberEnUS,\n} from './format-utils';\nimport { evaluateThresholdCondition } from './threshold';\nimport {\n getThresholdLineDisplayName,\n isThresholdLine,\n type NormalizedThresholdLine,\n} from './threshold';\n\ntype TooltipValueFormatter = (value: unknown) => 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 formatNumberEnUS as TooltipValueFormatter;\n}\n\ntype CreateAxisTooltipFormatterParams = {\n thresholdLines: NormalizedThresholdLine[];\n userOption: ChartProps['option'];\n};\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"]}
@@ -0,0 +1 @@
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\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 show?: boolean;\n // TODO v5: remove this prop\n /** @deprecated Does not do anything since the wrapping is now automatic. Will be removed in v 5 */\n wrappingType?: 'wrapping' | 'truncation' | 'overflow';\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 /** Settings for how ECharts should update the chart. */\n settings?: SetOptionOpts;\n /** Whether the chart is in a loading state. */\n isLoading?: boolean;\n /** Callback functions for chart interactions. */\n callbacks?: {\n onZoom?: (params: { startValue: number; endValue: number }) => 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\nexport interface ChartTooltipProps {\n children: React.ReactNode;\n className?: string;\n isOpen?: boolean;\n style?: React.CSSProperties;\n anchorPosition?: {\n x: number;\n y: number;\n };\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 selected?: boolean;\n deSelected?: 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"]}
@@ -0,0 +1 @@
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;AAEO,4EAAgC","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 { Condition } from './chart-types';\n\nconst defaultThresholdLineSeriesOption: {\n condition: Condition;\n} = {\n condition: 'greater',\n};\n\nexport { defaultThresholdLineSeriesOption };\n"]}
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatNumberEnUS = exports.extractValueFromTooltipSeries = exports.useThrottle = exports.capitalizeFirstLetter = void 0;
4
2
  /**
5
3
  *
6
4
  * Copyright (c) "Neo4j"
@@ -21,22 +19,8 @@ exports.formatNumberEnUS = exports.extractValueFromTooltipSeries = exports.useTh
21
19
  * You should have received a copy of the GNU General Public License
22
20
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
21
  */
24
- const react_1 = require("react");
25
- // oxlint-disable-next-line @typescript-eslint/no-explicit-any
26
- const useThrottle = (callback, limit) => {
27
- const lastCallRef = (0, react_1.useRef)(0);
28
- const throttledCallback = (0, react_1.useCallback)(
29
- // oxlint-disable-next-line @typescript-eslint/no-explicit-any
30
- (...args) => {
31
- const now = Date.now();
32
- if (now - lastCallRef.current >= limit) {
33
- lastCallRef.current = now;
34
- callback(...args);
35
- }
36
- }, [callback, limit]);
37
- return throttledCallback;
38
- };
39
- exports.useThrottle = useThrottle;
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.formatNumberEnUS = exports.extractValueFromTooltipSeries = exports.capitalizeFirstLetter = void 0;
40
24
  const capitalizeFirstLetter = (str) => {
41
25
  if (!str) {
42
26
  return str;
@@ -77,4 +61,4 @@ axisDim = 'x') => {
77
61
  return (_b = value[seriesValueIdx]) !== null && _b !== void 0 ? _b : value;
78
62
  };
79
63
  exports.extractValueFromTooltipSeries = extractValueFromTooltipSeries;
80
- //# sourceMappingURL=utils.js.map
64
+ //# sourceMappingURL=format-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-utils.js","sourceRoot":"","sources":["../../../../src/charts/utils/format-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAE,EAAE;IAC5C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC,CAAC;AA8CA,sDAAqB;AA5CvB,MAAM,mBAAmB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AAE3D;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CAAI,KAAQ,EAAc,EAAE;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5E,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAkCA,4CAAgB;AAhClB;;;;GAIG;AACH,MAAM,6BAA6B,GAAG,CACpC,KAA4C,EAC5C,MAGC;AACD,yCAAyC;AACzC,UAAqD,GAAG,EACxD,EAAE;;IACF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,6DAA6D;IAC7D,4FAA4F;IAC5F,MAAM,iBAAiB,GAAG,OAAO,KAAK,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;AAIA,sEAA6B","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\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 * 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 x: number | number[];\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};\n"]}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /**
3
+ *
4
+ * Copyright (c) "Neo4j"
5
+ * Neo4j Sweden AB [http://neo4j.com]
6
+ *
7
+ * This file is part of Neo4j.
8
+ *
9
+ * Neo4j is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.getCollapsedVisibleItemCount = exports.getItemCountThatFitsRow = exports.getComputedElementWidth = exports.COLLAPSED_LEGEND_MAX_HEIGHT = exports.COLLAPSED_LEGEND_ROWS = void 0;
24
+ exports.COLLAPSED_LEGEND_ROWS = 2;
25
+ exports.COLLAPSED_LEGEND_MAX_HEIGHT = 64;
26
+ /**
27
+ * Get the computed element width, including both paddings and margins
28
+ */
29
+ const getComputedElementWidth = (element) => {
30
+ const elementRect = element.getBoundingClientRect();
31
+ const elementComputedStyle = window.getComputedStyle(element);
32
+ const elementMarginLeft = parseFloat(elementComputedStyle.marginLeft);
33
+ const elementMarginRight = parseFloat(elementComputedStyle.marginRight);
34
+ return elementRect.width + elementMarginLeft + elementMarginRight;
35
+ };
36
+ exports.getComputedElementWidth = getComputedElementWidth;
37
+ const getItemCountThatFitsRow = (itemWidths, availableWidth, { keepOversizedFirstItem = true } = {}) => {
38
+ let rowWidth = 0;
39
+ let count = 0;
40
+ for (const itemWidth of itemWidths) {
41
+ if (count === 0 && itemWidth > availableWidth) {
42
+ return keepOversizedFirstItem ? 1 : 0;
43
+ }
44
+ if (rowWidth + itemWidth > availableWidth) {
45
+ return count;
46
+ }
47
+ rowWidth += itemWidth;
48
+ count += 1;
49
+ }
50
+ return count;
51
+ };
52
+ exports.getItemCountThatFitsRow = getItemCountThatFitsRow;
53
+ /**
54
+ * Calculates how many legend items fit in the two-row collapsed layout.
55
+ *
56
+ * The second row reserves space for the "View more" action so that control
57
+ * remains visible at the end of the collapsed legend.
58
+ */
59
+ const getCollapsedVisibleItemCount = (itemWidths, availableRowWidth, viewMoreButtonWidth) => {
60
+ const firstRowItemCount = (0, exports.getItemCountThatFitsRow)(itemWidths, availableRowWidth);
61
+ const secondRowItemCount = (0, exports.getItemCountThatFitsRow)(itemWidths.slice(firstRowItemCount), availableRowWidth - viewMoreButtonWidth, { keepOversizedFirstItem: false });
62
+ return firstRowItemCount + secondRowItemCount;
63
+ };
64
+ exports.getCollapsedVisibleItemCount = getCollapsedVisibleItemCount;
65
+ //# sourceMappingURL=legend-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legend-layout.js","sourceRoot":"","sources":["../../../../src/charts/utils/legend-layout.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEU,QAAA,qBAAqB,GAAG,CAAC,CAAC;AAC1B,QAAA,2BAA2B,GAAG,EAAE,CAAC;AAE9C;;GAEG;AACI,MAAM,uBAAuB,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC1D,MAAM,WAAW,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IACpD,MAAM,oBAAoB,GAAG,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC9D,MAAM,iBAAiB,GAAG,UAAU,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACtE,MAAM,kBAAkB,GAAG,UAAU,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAExE,OAAO,WAAW,CAAC,KAAK,GAAG,iBAAiB,GAAG,kBAAkB,CAAC;AACpE,CAAC,CAAC;AAPW,QAAA,uBAAuB,2BAOlC;AAEK,MAAM,uBAAuB,GAAG,CACrC,UAAoB,EACpB,cAAsB,EACtB,EAAE,sBAAsB,GAAG,IAAI,EAAE,GAAG,EAAE,EACtC,EAAE;IACF,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,KAAK,KAAK,CAAC,IAAI,SAAS,GAAG,cAAc,EAAE,CAAC;YAC9C,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxC,CAAC;QAED,IAAI,QAAQ,GAAG,SAAS,GAAG,cAAc,EAAE,CAAC;YAC1C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,QAAQ,IAAI,SAAS,CAAC;QACtB,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAtBW,QAAA,uBAAuB,2BAsBlC;AAEF;;;;;GAKG;AACI,MAAM,4BAA4B,GAAG,CAC1C,UAAoB,EACpB,iBAAyB,EACzB,mBAA2B,EAC3B,EAAE;IACF,MAAM,iBAAiB,GAAG,IAAA,+BAAuB,EAC/C,UAAU,EACV,iBAAiB,CAClB,CAAC;IACF,MAAM,kBAAkB,GAAG,IAAA,+BAAuB,EAChD,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;AAhBW,QAAA,4BAA4B,gCAgBvC","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"]}
@@ -20,84 +20,8 @@
20
20
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
21
  */
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.highlightOrDownplaySeries = exports.getComputedElementWidth = exports.isThresholdLine = exports.useLegendVisibility = exports.resetAllSeriesHighlight = void 0;
23
+ exports.highlightOrDownplaySeries = exports.resetAllSeriesHighlight = void 0;
24
24
  const echarts_1 = require("echarts");
25
- const react_1 = require("react");
26
- const useLegendVisibility = (chartRef, selectedSeries) => {
27
- const setOnlyVisible = (0, react_1.useCallback)((name) => {
28
- if (chartRef.current === null) {
29
- return;
30
- }
31
- const chart = (0, echarts_1.getInstanceByDom)(chartRef.current);
32
- chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
33
- name: name,
34
- type: 'legendSelect',
35
- });
36
- const otherNames = Object.keys(selectedSeries).filter((n) => n !== name);
37
- otherNames.forEach((name) => {
38
- if (name.startsWith('thresholdLine')) {
39
- return;
40
- }
41
- chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
42
- name: name,
43
- type: 'legendUnSelect',
44
- });
45
- });
46
- }, [chartRef, selectedSeries]);
47
- const setAllVisible = (0, react_1.useCallback)(() => {
48
- if (chartRef.current === null) {
49
- return;
50
- }
51
- const chart = (0, echarts_1.getInstanceByDom)(chartRef.current);
52
- chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
53
- type: 'legendAllSelect',
54
- });
55
- }, [chartRef]);
56
- /**
57
- * Toggle the visibility of a legend series
58
- *
59
- * The toggle logic depends on the current state of the series:
60
- * - If only the legend series that was selected is visible: show all series
61
- * - If all series are visible: hide all except the series that was selected
62
- * - Otherwise: toggle the legend series
63
- *
64
- * The isOnlyVisible and isAllSeriesSelected states can't be calculated in this
65
- * function since different legend types require different logic.
66
- */
67
- const toggleLegendVisibility = (0, react_1.useCallback)((name, isAllSeriesSelected, isOnlyVisible) => {
68
- if (chartRef.current === null || name === undefined) {
69
- return;
70
- }
71
- if (isOnlyVisible) {
72
- setAllVisible();
73
- }
74
- else if (isAllSeriesSelected) {
75
- setOnlyVisible(name);
76
- }
77
- else {
78
- const chart = (0, echarts_1.getInstanceByDom)(chartRef.current);
79
- chart === null || chart === void 0 ? void 0 : chart.dispatchAction({
80
- name: name,
81
- type: 'legendToggleSelect',
82
- });
83
- }
84
- }, [chartRef, setOnlyVisible, setAllVisible]);
85
- return { setAllVisible, setOnlyVisible, toggleLegendVisibility };
86
- };
87
- exports.useLegendVisibility = useLegendVisibility;
88
- const isThresholdLine = (name) => name === null || name === void 0 ? void 0 : name.startsWith('thresholdLine');
89
- exports.isThresholdLine = isThresholdLine;
90
- /**
91
- * Get the computed element width, including both paddings and margins
92
- */
93
- const getComputedElementWidth = (element) => {
94
- const elementRect = element.getBoundingClientRect();
95
- const elementComputedStyle = window.getComputedStyle(element);
96
- const elementMarginLeft = parseFloat(elementComputedStyle.marginLeft);
97
- const elementMarginRight = parseFloat(elementComputedStyle.marginRight);
98
- return elementRect.width + elementMarginLeft + elementMarginRight;
99
- };
100
- exports.getComputedElementWidth = getComputedElementWidth;
101
25
  const resetAllSeriesHighlight = (chart) => {
102
26
  const option = chart.getOption();
103
27
  const seriesList = option.series || [];
@@ -146,7 +70,6 @@ const highlightOrDownplayPieSlices = (chart, currentSeriesToDispatch, action, cu
146
70
  label: {
147
71
  opacity: isDownplay ? 1 : 0.3,
148
72
  },
149
- // ...(seriesItem.blur as Record<string, unknown>),
150
73
  } }))),
151
74
  });
152
75
  // The dataIndex that we want to dispatch can be found in the dataset[0] source array, where the first item is the name of the series
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legend-utils.js","sourceRoot":"","sources":["../../../../src/charts/utils/legend-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAEH,qCAIiB;AAEV,MAAM,uBAAuB,GAAG,CAAC,KAAkB,EAAE,EAAE;IAC5D,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,UAAU,GAAI,MAAM,CAAC,MAAgC,IAAI,EAAE,CAAC;IAElE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,WAAmB,EAAE,EAAE;QAC5C,KAAK,CAAC,cAAc,CAAC;YACnB,WAAW;YACX,IAAI,EAAE,UAAU;SACjB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAVW,QAAA,uBAAuB,2BAUlC;AAEF,MAAM,mCAAmC,GAAG,CAC1C,KAAkB,EAClB,uBAA0D,EAC1D,MAAgC,EAChC,mBAAyD,EACzD,EAAE;;IACF,MAAM,UAAU,GAAG,MAAM,KAAK,UAAU,CAAC;IACzC,MAAM,oBAAoB,GACxB,CAAC,mBAAmB,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B,uBAAnB,mBAAmB,CAAE,MACtB,0CAAG,CAAC,CAAC,0CAAE,IAAI,CAAC;IAEb,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;QACzB,4BAA4B,CAC1B,KAAK,EACL,uBAAuB,EACvB,MAAM,EACN,mBAAmB,CACpB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,mCAAmC,CACjC,KAAK,EACL,uBAAuB,EACvB,MAAM,EACN,mBAAmB,CACpB,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEO,8DAAyB","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport {\n type EChartsOption,\n type EChartsType,\n getInstanceByDom,\n} from 'echarts';\n\nexport const resetAllSeriesHighlight = (chart: EChartsType) => {\n const option = chart.getOption();\n const seriesList = (option.series as unknown[] | undefined) || [];\n\n seriesList.forEach((_, seriesIndex: number) => {\n chart.dispatchAction({\n seriesIndex,\n type: 'downplay',\n });\n });\n};\n\nconst highlightOrDownplayLineAndBarSeries = (\n chart: EChartsType,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n currentChartOptions: ReturnType<EChartsType['getOption']>,\n) => {\n const isDownplay = action === 'downplay';\n const allChartOptionSeries =\n (currentChartOptions?.series as Record<string, unknown>[] | undefined) ||\n [];\n\n // Change emphasis state to add opacity on the non highlighted items\n chart?.setOption({\n series: allChartOptionSeries?.map(\n (seriesItem: Record<string, unknown>) => ({\n ...seriesItem,\n emphasis: {\n ...(seriesItem.emphasis as Record<string, unknown>),\n disabled: isDownplay,\n },\n }),\n ),\n });\n\n const seriesWithSeriesIndex = allChartOptionSeries\n // Since the series index does not exist in the data we extract it from the series index\n ?.map((seriesItem, index) => ({\n ...seriesItem,\n seriesIndex: index,\n }))\n // Select the series that are in the currentSeriesToDispatch array\n ?.filter((seriesItem: Record<string, unknown>) =>\n currentSeriesToDispatch.some((series) => series.name === seriesItem.name),\n );\n\n if (!seriesWithSeriesIndex.length) {\n return;\n }\n\n chart?.dispatchAction({\n seriesIndex: seriesWithSeriesIndex.map((series) => series.seriesIndex),\n type: action,\n });\n};\n\n/**\n * Highlight or downplay pie chart dataset item\n */\nconst highlightOrDownplayPieSlices = (\n chart: EChartsType,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n currentChartOptions: ReturnType<EChartsType['getOption']>,\n) => {\n const isDownplay = action === 'downplay';\n const allChartOptionSeries =\n (currentChartOptions?.series as Record<string, unknown>[] | undefined) ||\n [];\n\n // Change blur state to add opacity on the non highlighted items in the pie chart\n chart?.setOption({\n series: allChartOptionSeries?.map(\n (seriesItem: Record<string, unknown>) => ({\n ...seriesItem,\n blur: {\n itemStyle: {\n opacity: isDownplay ? 1 : 0.3,\n },\n label: {\n opacity: isDownplay ? 1 : 0.3,\n },\n },\n }),\n ),\n });\n\n // The dataIndex that we want to dispatch can be found in the dataset[0] source array, where the first item is the name of the series\n const chartOptionDataset =\n currentChartOptions?.dataset as EChartsOption['dataset'];\n const datasetArray = Array.isArray(chartOptionDataset)\n ? chartOptionDataset\n : [chartOptionDataset];\n const sourceArray = datasetArray?.[0]?.source as unknown[][];\n\n // Find the dataIndexes that we want to dispatch\n const currentDataSeriesIndexes = currentSeriesToDispatch.map((series) => {\n const index = sourceArray?.findIndex((item) => item[0] === series.name) - 1;\n return index;\n });\n\n if (action === 'highlight') {\n // Downplay other data indexes to make sure the other slices are not highlighted\n const otherSeriesIndexes = sourceArray\n .map((_, index) => index)\n .filter((dataIndex) => !currentDataSeriesIndexes.includes(dataIndex));\n\n chart?.dispatchAction({\n seriesIndex: [0], // pie charts only has one series so seriesIndex is always 0\n dataIndex: otherSeriesIndexes,\n type: 'downplay',\n });\n }\n\n chart?.dispatchAction({\n seriesIndex: [0], // pie charts only has one series so otherSeriesIndexes is always 0\n dataIndex: currentDataSeriesIndexes,\n type: action,\n });\n};\n\n/**\n * Highlight or downplay the series in the chart to toggle between emphasized and non-emphasized state\n */\nconst highlightOrDownplaySeries = (\n chartRef: React.RefObject<HTMLDivElement | null>,\n series: { name: string; color: string }[],\n currentSelectedSeries: Record<string, boolean>,\n currentSeriesToDispatch: { name: string; color: string }[],\n action: 'highlight' | 'downplay',\n) => {\n const hasOnlyOneSeries = series.length === 1;\n\n const isOnlyOneSeriesSelected =\n Object.values(currentSelectedSeries).filter(Boolean).length === 1;\n\n if (\n isOnlyOneSeriesSelected ||\n currentSeriesToDispatch.length === 0 ||\n chartRef.current === null ||\n hasOnlyOneSeries\n ) {\n return;\n }\n\n const chart = getInstanceByDom(chartRef.current);\n\n if (!chart) {\n return;\n }\n const currentChartOptions = chart.getOption();\n\n const seriesType = (\n currentChartOptions?.series as Record<string, unknown>[]\n )?.[0]?.type;\n\n if (seriesType === 'pie') {\n highlightOrDownplayPieSlices(\n chart,\n currentSeriesToDispatch,\n action,\n currentChartOptions,\n );\n } else {\n highlightOrDownplayLineAndBarSeries(\n chart,\n currentSeriesToDispatch,\n action,\n currentChartOptions,\n );\n }\n};\n\nexport { highlightOrDownplaySeries };\n"]}
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ /**
3
+ *
4
+ * Copyright (c) "Neo4j"
5
+ * Neo4j Sweden AB [http://neo4j.com]
6
+ *
7
+ * This file is part of Neo4j.
8
+ *
9
+ * Neo4j is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation, either version 3 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * This program is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.getThresholdLineDisplayName = exports.isThresholdLine = void 0;
24
+ exports.normalizeThresholdLines = normalizeThresholdLines;
25
+ exports.evaluateThresholdCondition = evaluateThresholdCondition;
26
+ exports.thresholdConditionToText = thresholdConditionToText;
27
+ const defaults_1 = require("./defaults");
28
+ const isThresholdLine = (name) => name === null || name === void 0 ? void 0 : name.startsWith('thresholdLine');
29
+ exports.isThresholdLine = isThresholdLine;
30
+ const getThresholdLineDisplayName = (name) => name.replace('thresholdLine-', '');
31
+ exports.getThresholdLineDisplayName = getThresholdLineDisplayName;
32
+ /**
33
+ * Extracts threshold-line series and resolves defaults needed by tooltips.
34
+ */
35
+ function normalizeThresholdLines(propsSeries) {
36
+ const seriesArray = Array.isArray(propsSeries) ? propsSeries : [propsSeries];
37
+ const thresholdLineSeries = seriesArray.filter((currentSeries) => {
38
+ return currentSeries.type === 'thresholdLine';
39
+ });
40
+ return thresholdLineSeries.map((currentThresholdLineSeriesOption) => {
41
+ var _a;
42
+ return Object.assign(Object.assign({}, currentThresholdLineSeriesOption), { condition: (_a = currentThresholdLineSeriesOption.condition) !== null && _a !== void 0 ? _a : defaults_1.defaultThresholdLineSeriesOption.condition, value: currentThresholdLineSeriesOption.yAxis });
43
+ });
44
+ }
45
+ /**
46
+ * Evaluates a threshold condition and returns the short label used by
47
+ * chart tooltip notifications.
48
+ */
49
+ function evaluateThresholdCondition(value, condition, threshold) {
50
+ switch (condition) {
51
+ case 'greater':
52
+ return {
53
+ conditionText: 'Above',
54
+ isConditionMet: value > threshold,
55
+ };
56
+ case 'greaterOrEqual':
57
+ return {
58
+ conditionText: value > threshold
59
+ ? 'Above'
60
+ : value === threshold
61
+ ? 'Equal'
62
+ : undefined,
63
+ isConditionMet: value >= threshold,
64
+ };
65
+ case 'less':
66
+ return {
67
+ conditionText: 'Below',
68
+ isConditionMet: value < threshold,
69
+ };
70
+ case 'lessOrEqual':
71
+ return {
72
+ conditionText: value < threshold
73
+ ? 'Below'
74
+ : value === threshold
75
+ ? 'Equal'
76
+ : undefined,
77
+ isConditionMet: value <= threshold,
78
+ };
79
+ case 'equal':
80
+ return {
81
+ conditionText: 'Equal',
82
+ isConditionMet: value === threshold,
83
+ };
84
+ case 'notEqual':
85
+ return {
86
+ conditionText: 'Not equal',
87
+ isConditionMet: value !== threshold,
88
+ };
89
+ default:
90
+ return { conditionText: undefined, isConditionMet: false };
91
+ }
92
+ }
93
+ /**
94
+ * Returns the longer condition phrase used in chart aria descriptions.
95
+ */
96
+ function thresholdConditionToText(condition) {
97
+ switch (condition) {
98
+ case 'greater':
99
+ return 'greater than';
100
+ case 'greaterOrEqual':
101
+ return 'greater than or equal to';
102
+ case 'less':
103
+ return 'less than';
104
+ case 'lessOrEqual':
105
+ return 'less than or equal to';
106
+ case 'equal':
107
+ return 'equal to';
108
+ case 'notEqual':
109
+ return 'not equal to';
110
+ default:
111
+ return 'compared to';
112
+ }
113
+ }
114
+ //# sourceMappingURL=threshold.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threshold.js","sourceRoot":"","sources":["../../../../src/charts/utils/threshold.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAgCH,0DAkBC;AAMD,gEAiDC;AAKD,4DAiBC;AAvHD,yCAA8D;AAevD,MAAM,eAAe,GAAG,CAAC,IAAa,EAAE,EAAE,CAC/C,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,CAAC,eAAe,CAAC,CAAC;AADvB,QAAA,eAAe,mBACQ;AAE7B,MAAM,2BAA2B,GAAG,CAAC,IAAY,EA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gBACL,aAAa,EACX,KAAK,GAAG,SAAS;oBACf,CAAC,CAAC,OAAO;oBACT,CAAC,CAAC,KAAK,KAAK,SAAS;wBACnB,CAAC,CAAC,OAAO;wBACT,CAAC,CAAC,SAAS;gBACjB,cAAc,EAAE,KAAK,IAAI,SAAS;aACnC,CAAC;QACJ,KAAK,OAAO;YACV,OAAO;gBACL,aAAa,EAAE,OAAO;gBACtB,cAAc,EAAE,KAAK,KAAK,SAAS;aACpC,CAAC;QACJ,KAAK,UAAU;YACb,OAAO;gBACL,aAAa,EAAE,WAAW;gBAC1B,cAAc,EAAE,KAAK,KAAK,SAAS;aACpC,CAAC;QACJ;YACE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;IAC/D,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,wBAAwB,CAAC,SAAoB;IAC3D,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,cAAc,CAAC;QACxB,KAAK,gBAAgB;YACnB,OAAO,0BAA0B,CAAC;QACpC,KAAK,MAAM;YACT,OAAO,WAAW,CAAC;QACrB,KAAK,aAAa;YAChB,OAAO,uBAAuB,CAAC;QACjC,KAAK,OAAO;YACV,OAAO,UAAU,CAAC;QACpB,KAAK,UAAU;YACb,OAAO,cAAc,CAAC;QACxB;YACE,OAAO,aAAa,CAAC;IACzB,CAAC;AACH,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport type {\n Condition,\n NeedleSeries,\n NotificationType,\n ThresholdLineSeriesOption,\n} from './chart-types';\nimport { defaultThresholdLineSeriesOption } from './defaults';\n\nexport type NormalizedThresholdLine =\n ThresholdLineSeriesOption<NotificationType> & {\n condition: NonNullable<\n ThresholdLineSeriesOption<NotificationType>['condition']\n >;\n value: number;\n };\n\nexport type ThresholdConditionEvaluation = {\n isConditionMet: boolean;\n conditionText: string | undefined;\n};\n\nexport const isThresholdLine = (name?: string) =>\n name?.startsWith('thresholdLine');\n\nexport const getThresholdLineDisplayName = (name: string) =>\n name.replace('thresholdLine-', '');\n\n/**\n * Extracts threshold-line series and resolves defaults needed by tooltips.\n */\nexport function normalizeThresholdLines(\n propsSeries: NeedleSeries,\n): NormalizedThresholdLine[] {\n const seriesArray = Array.isArray(propsSeries) ? propsSeries : [propsSeries];\n\n const thresholdLineSeries = seriesArray.filter((currentSeries) => {\n return currentSeries.type === 'thresholdLine';\n }) as ThresholdLineSeriesOption<NotificationType>[];\n\n return thresholdLineSeries.map((currentThresholdLineSeriesOption) => {\n return {\n ...currentThresholdLineSeriesOption,\n condition:\n currentThresholdLineSeriesOption.condition ??\n defaultThresholdLineSeriesOption.condition,\n value: currentThresholdLineSeriesOption.yAxis,\n };\n });\n}\n\n/**\n * Evaluates a threshold condition and returns the short label used by\n * chart tooltip notifications.\n */\nexport function evaluateThresholdCondition(\n value: number,\n condition: Condition,\n threshold: number,\n): ThresholdConditionEvaluation {\n switch (condition) {\n case 'greater':\n return {\n conditionText: 'Above',\n isConditionMet: value > threshold,\n };\n case 'greaterOrEqual':\n return {\n conditionText:\n value > threshold\n ? 'Above'\n : value === threshold\n ? 'Equal'\n : undefined,\n isConditionMet: value >= threshold,\n };\n case 'less':\n return {\n conditionText: 'Below',\n isConditionMet: value < threshold,\n };\n case 'lessOrEqual':\n return {\n conditionText:\n value < threshold\n ? 'Below'\n : value === threshold\n ? 'Equal'\n : undefined,\n isConditionMet: value <= threshold,\n };\n case 'equal':\n return {\n conditionText: 'Equal',\n isConditionMet: value === threshold,\n };\n case 'notEqual':\n return {\n conditionText: 'Not equal',\n isConditionMet: value !== threshold,\n };\n default:\n return { conditionText: undefined, isConditionMet: false };\n }\n}\n\n/**\n * Returns the longer condition phrase used in chart aria descriptions.\n */\nexport function thresholdConditionToText(condition: Condition): string {\n switch (condition) {\n case 'greater':\n return 'greater than';\n case 'greaterOrEqual':\n return 'greater than or equal to';\n case 'less':\n return 'less than';\n case 'lessOrEqual':\n return 'less than or equal to';\n case 'equal':\n return 'equal to';\n case 'notEqual':\n return 'not equal to';\n default:\n return 'compared to';\n }\n}\n"]}
@@ -24,9 +24,10 @@ const jsx_runtime_1 = require("react/jsx-runtime");
24
24
  */
25
25
  const base_1 = require("@neo4j-ndl/base");
26
26
  const server_1 = require("react-dom/server");
27
- const ChartTooltip_1 = require("./ChartTooltip");
27
+ const ChartTooltip_1 = require("../ChartTooltip");
28
+ const chart_tooltip_formatter_1 = require("./chart-tooltip-formatter");
28
29
  const defaults_1 = require("./defaults");
29
- const utils_1 = require("./utils");
30
+ const format_utils_1 = require("./format-utils");
30
31
  const defaultColors = Object.values(base_1.tokens.categorical);
31
32
  const mergeSeries = (series, theme = 'light', userOption, palette) => {
32
33
  const colors = palette !== null && palette !== void 0 ? palette : defaultColors;
@@ -54,6 +55,7 @@ const mergeSeries = (series, theme = 'light', userOption, palette) => {
54
55
  return Object.assign(Object.assign({ type: 'line', symbolSize: 9, color, symbol: 'none' }, option), { lineStyle: Object.assign({ width: 2, type: 'solid' }, 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, shadowOffsetX: parseInt(shadowParts[0]), shadowOffsetY: parseInt(shadowParts[1]), shadowBlur: parseInt(shadowParts[2]), shadowColor: shadowParts[4] }, (_b = option.emphasis) === null || _b === void 0 ? void 0 : _b.itemStyle), label: { show: false } }), option.emphasis) });
55
56
  }
56
57
  if (option.type === 'pie') {
58
+ const valueFormatter = (0, chart_tooltip_formatter_1.getTooltipValueFormatter)(userOption);
57
59
  return Object.assign(Object.assign({ animationDuration: 600, animationType: 'scale', selectedMode: 'single' }, option), {
58
60
  // Blur opacity is set to 1 to prevent other slices from
59
61
  // being opacitated when hovering a slice where the emphasis is enabled (used for scale effect)
@@ -65,18 +67,13 @@ const mergeSeries = (series, theme = 'light', userOption, palette) => {
65
67
  var _a, _b;
66
68
  const paramsArray = Array.isArray(params) ? params : [params];
67
69
  const firstParam = paramsArray[0];
68
- let valueFormatter = utils_1.formatNumberEnUS;
69
- if (typeof (userOption === null || userOption === void 0 ? void 0 : userOption.tooltip) === 'object' &&
70
- userOption.tooltip !== null &&
71
- 'valueFormatter' in userOption.tooltip) {
72
- valueFormatter = userOption.tooltip.valueFormatter;
73
- }
74
70
  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: (_a = firstParam === null || firstParam === void 0 ? void 0 : firstParam.value[0]) !== null && _a !== void 0 ? _a : firstParam.seriesName, trailingElement: valueFormatter(Array.isArray(firstParam.value)
75
71
  ? firstParam.value[1]
76
72
  : firstParam.value), indentSquareColor: firstParam.color }, (_b = firstParam === null || firstParam === void 0 ? void 0 : firstParam.value[0]) !== null && _b !== void 0 ? _b : firstParam.seriesName) }))}`;
77
73
  } }, option.tooltip) });
78
74
  }
79
75
  if (option.type === 'bar') {
76
+ const valueFormatter = (0, chart_tooltip_formatter_1.getTooltipValueFormatter)(userOption);
80
77
  return Object.assign(Object.assign({ barMaxWidth: 16 }, option), { blur: Object.assign({ itemStyle: Object.assign({ opacity: 0.3 }, (_e = option.blur) === null || _e === void 0 ? void 0 : _e.itemStyle) }, option.blur), emphasis: Object.assign({ disabled: true, focus: 'series' }, option.emphasis), itemStyle: Object.assign({ color, borderWidth: 20 }, option.itemStyle), markLine: {
81
78
  emphasis: Object.assign({ disabled: true, lineStyle: Object.assign({ width: 20 }, (_g = (_f = option.markLine) === null || _f === void 0 ? void 0 : _f.emphasis) === null || _g === void 0 ? void 0 : _g.lineStyle) }, (_h = option.markLine) === null || _h === void 0 ? void 0 : _h.emphasis),
82
79
  lineStyle: Object.assign({ width: 20 }, (_j = option.markLine) === null || _j === void 0 ? void 0 : _j.lineStyle),
@@ -86,12 +83,6 @@ const mergeSeries = (series, theme = 'light', userOption, palette) => {
86
83
  var _a;
87
84
  const paramsArray = Array.isArray(params) ? params : [params];
88
85
  const firstParam = paramsArray[0];
89
- let valueFormatter = utils_1.formatNumberEnUS;
90
- if (typeof (userOption === null || userOption === void 0 ? void 0 : userOption.tooltip) === 'object' &&
91
- userOption.tooltip !== null &&
92
- 'valueFormatter' in userOption.tooltip) {
93
- valueFormatter = userOption.tooltip.valueFormatter;
94
- }
95
86
  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)
96
87
  ? firstParam.value[1]
97
88
  : firstParam.value), indentSquareColor: firstParam.color }, (_a = firstParam === null || firstParam === void 0 ? void 0 : firstParam.value[0]) !== null && _a !== void 0 ? _a : firstParam.seriesName)] }))}`;
@@ -127,7 +118,7 @@ const mergeXAxis = (xAxis, theme = 'light') => {
127
118
  const xAxisFormatter = xAxis.axisLabel && 'formatter' in xAxis.axisLabel
128
119
  ? xAxis.axisLabel.formatter
129
120
  : undefined;
130
- const valueXAxis = Object.assign(Object.assign({}, baseXAxis), { axisLabel: Object.assign(Object.assign({}, baseXAxis.axisLabel), { formatter: xAxisFormatter !== null && xAxisFormatter !== void 0 ? xAxisFormatter : utils_1.formatNumberEnUS }) });
121
+ 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 }) });
131
122
  return valueXAxis;
132
123
  }
133
124
  if (xAxis.type === 'category') {
@@ -154,7 +145,7 @@ const mergeYAxis = (yAxis, theme = 'light') => {
154
145
  const yAxisFormatter = yAxis.axisLabel && 'formatter' in yAxis.axisLabel
155
146
  ? yAxis.axisLabel.formatter
156
147
  : undefined;
157
- const valueYAxis = Object.assign(Object.assign({}, baseYAxis), { axisLabel: Object.assign(Object.assign({ hideOverlap: true }, baseYAxis.axisLabel), { formatter: yAxisFormatter !== null && yAxisFormatter !== void 0 ? yAxisFormatter : utils_1.formatNumberEnUS }), splitLine: Object.assign({ show: false }, baseYAxis === null || baseYAxis === void 0 ? void 0 : baseYAxis.splitLine) });
148
+ 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) });
158
149
  return valueYAxis;
159
150
  }
160
151
  if (yAxis.type === 'category') {