@neo4j-ndl/react-charts 1.0.50 → 1.0.52

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.
@@ -23,6 +23,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
23
23
  * You should have received a copy of the GNU General Public License
24
24
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
25
  */
26
+ const base_1 = require("@neo4j-ndl/base");
26
27
  const react_1 = require("@neo4j-ndl/react");
27
28
  const echarts_1 = require("echarts");
28
29
  const react_2 = require("react");
@@ -347,10 +348,21 @@ function Chart({ dataset, option: userOption, xAxis: propXAxis, yAxis: propYAxis
347
348
  return;
348
349
  }
349
350
  const chart = (0, echarts_1.getInstanceByDom)(chartEchartRef === null || chartEchartRef === void 0 ? void 0 : chartEchartRef.current);
350
- isLoading || isWaitingForFirstResize
351
- ? chart === null || chart === void 0 ? void 0 : chart.showLoading()
352
- : chart === null || chart === void 0 ? void 0 : chart.hideLoading();
353
- }, [isLoading, isWaitingForFirstResize]);
351
+ if (isLoading === true || isWaitingForFirstResize) {
352
+ chart === null || chart === void 0 ? void 0 : chart.showLoading({
353
+ color: base_1.tokens.theme[theme].color.primary.bg.status,
354
+ fontFamily: base_1.tokens.typography['label'].fontFamily,
355
+ fontSize: base_1.tokens.typography['label'].fontSize,
356
+ fontWeight: base_1.tokens.typography['label'].fontWeight,
357
+ maskColor: `rgb( from ${base_1.tokens.theme[theme].color.neutral.text.inverse} r g b / 0.8)`,
358
+ text: 'Loading',
359
+ textColor: base_1.tokens.theme[theme].color.neutral.text.default,
360
+ });
361
+ }
362
+ else {
363
+ chart === null || chart === void 0 ? void 0 : chart.hideLoading();
364
+ }
365
+ }, [isLoading, isWaitingForFirstResize, theme]);
354
366
  const legendSeries = (0, react_2.useMemo)(() => {
355
367
  var _a;
356
368
  if (chartEchartRef.current === null || isWaitingForFirstResize) {
@@ -1 +1 @@
1
- {"version":3,"file":"Chart.js","sourceRoot":"","sources":["../../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esContent":["/**\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 { useNeedleTheme } from '@neo4j-ndl/react';\nimport {\n type DataZoomComponentOption,\n type ECharts,\n type EChartsOption,\n getInstanceByDom,\n init,\n type LineSeriesOption,\n type RegisteredSeriesOption,\n registerTheme,\n type SetOptionOpts,\n} from 'echarts';\nimport {\n type CSSProperties,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { renderToString } from 'react-dom/server';\n\nimport { ChartTooltip, type NotificationType } from './ChartTooltip';\nimport { Legend, type LegendProps } from './Legend';\nimport { ndlEchartsTheme } from './themes/ndl-echarts-theme';\nimport {\n mergeDataZoom,\n mergeSeries,\n mergeToolbox,\n mergeXAxis,\n mergeYAxis,\n} from './user-option-utils';\nimport { capitalizeFirstLetter, extractValueFromTooltipSeries } from './utils';\n\ntype Condition =\n | 'greater'\n | 'greaterOrEqual'\n | 'less'\n | 'lessOrEqual'\n | 'equal'\n | 'notEqual';\n\ntype CustomCondition = (\n lineValue: unknown,\n thresholdLineValue: unknown,\n) => boolean;\n\n// This returns a boolean if the condition is met\n// and also what to display in the tooltip.\nfunction checkCondition(\n value: number,\n condition: Condition,\n threshold: number,\n): {\n isConditionMet: boolean;\n conditionText: string | undefined;\n} {\n switch (condition) {\n case 'greater':\n return {\n isConditionMet: value > threshold,\n conditionText: 'Above',\n };\n case 'greaterOrEqual':\n return {\n isConditionMet: value >= threshold,\n conditionText:\n value > threshold\n ? 'Above'\n : value === threshold\n ? 'Equal'\n : undefined,\n };\n case 'less':\n return {\n isConditionMet: value < threshold,\n conditionText: 'Below',\n };\n case 'lessOrEqual':\n return {\n isConditionMet: value <= threshold,\n conditionText:\n value < threshold\n ? 'Below'\n : value === threshold\n ? 'Equal'\n : undefined,\n };\n case 'equal':\n return {\n isConditionMet: value === threshold,\n conditionText: 'Equal',\n };\n case 'notEqual':\n return {\n isConditionMet: value !== threshold,\n conditionText: 'Not equal',\n };\n default:\n return { isConditionMet: false, conditionText: undefined };\n }\n}\n\nexport interface ThresholdLineSeriesOption<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\nexport const defaultThresholdLineSeriesOption: {\n condition: Condition;\n} = {\n condition: 'greater',\n};\n\nexport type Values<T> = T[keyof T];\nexport type SeriesOption = Values<RegisteredSeriesOption>;\n\nexport type EchartsSeries = SeriesOption | SeriesOption[];\n\n/*\nKeep this, if we want more than one type of the same threshold line\nthis will be useful to use.\n\nexport interface NewRegisteredSeriesOption extends RegisteredSeriesOption {\nthresholdLine: ThresholdLineSeriesOption;\n}\nexport type SeriesOption = Values<NewRegisteredSeriesOption>;\nexport type Series = SeriesOption | SeriesOption[];\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\ninterface 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 wrappingType?: LegendProps['wrappingType'];\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?: 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}\n\nexport function Chart({\n dataset,\n option: userOption,\n xAxis: propXAxis,\n yAxis: propYAxis,\n series: propsSeries,\n style,\n settings = {\n notMerge: true,\n lazyUpdate: false,\n silent: false,\n },\n isLoading,\n isChartZoomDisabled = false,\n legend,\n callbacks,\n}: ChartProps): React.JSX.Element {\n const chartRef = useRef<HTMLDivElement>(null);\n const chartEchartRef = useRef<HTMLDivElement>(null);\n const chartLegendRef = useRef<HTMLDivElement>(null);\n const [isWaitingForFirstResize, setIsWaitingForFirstResize] = useState(true);\n\n const dataZoomOptions = (userOption as EChartsOption)?.dataZoom;\n const toolboxOptions = (userOption as EChartsOption)?.toolbox;\n\n const hasSliderZoom = Array.isArray(dataZoomOptions)\n ? dataZoomOptions.some((dataZoomOption: DataZoomComponentOption) => {\n return dataZoomOption?.type === 'slider';\n })\n : dataZoomOptions?.type === 'slider';\n\n const { theme } = useNeedleTheme();\n const thresholdLines = useMemo(() => {\n const seriesArray = Array.isArray(propsSeries)\n ? propsSeries\n : [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 }, [propsSeries]);\n\n const dataZoom = useMemo(() => {\n return mergeDataZoom(dataZoomOptions);\n }, [dataZoomOptions]);\n\n const series = mergeSeries(propsSeries, theme);\n const xAxis = mergeXAxis(propXAxis, theme);\n const yAxis = mergeYAxis(propYAxis, theme);\n\n const hasCategoryXAxis = Array.isArray(xAxis)\n ? xAxis.some((x) => x.type === 'category')\n : xAxis?.type === 'category';\n\n // The initial option used, the charts option is not necessarily\n // the same as this due to mutation via dispatch and setOption.\n // use getOption to get the current option of the chart.\n const initialOption = useMemo(() => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const option = {\n dataset,\n xAxis,\n yAxis,\n ...userOption,\n aria: {\n decal: {\n show: false,\n },\n enabled: true,\n ...(userOption?.aria as EChartsOption['aria']),\n },\n grid: {\n left: hasCategoryXAxis ? '15px' : '10px',\n right: hasCategoryXAxis ? '15px' : '10px',\n top: '10px',\n bottom: hasSliderZoom ? '60px' : '10px',\n type: 'solid',\n containLabel: true,\n ...(userOption?.grid as EChartsOption['grid']),\n },\n legend: {\n // Removes in-built echarts legend\n show: false,\n },\n series,\n tooltip: {\n trigger: 'axis',\n confine: true,\n // Reset the default tooltip css styling\n padding: 0,\n borderRadius: 0,\n borderWidth: 0,\n extraCssText: 'box-shadow: none; background-color: transparent;',\n formatter: function (params: unknown) {\n const paramsArray = Array.isArray(params) ? params : [params];\n const firstParam = paramsArray[0];\n\n let valueFormatter = (value: unknown) => `${value}`;\n if (\n typeof userOption?.tooltip === 'object' &&\n userOption.tooltip !== null &&\n 'valueFormatter' in userOption.tooltip\n ) {\n valueFormatter = userOption.tooltip.valueFormatter as (\n value: unknown,\n ) => string;\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: seriesValueUnknown } = series;\n\n const seriesValue = Array.isArray(seriesValueUnknown)\n ? seriesValueUnknown[1]\n : seriesValueUnknown;\n\n const isThresholdLine =\n series.seriesName.startsWith('thresholdLine');\n\n const notifications = thresholdLines\n .filter((threshold) => {\n const {\n value: thresholdValue,\n condition,\n customCondition,\n } = threshold;\n\n const isConditionMet = customCondition\n ? customCondition(seriesValue, thresholdValue)\n : checkCondition(seriesValue, condition, thresholdValue)\n .isConditionMet;\n\n return !isThresholdLine && isConditionMet;\n })\n .map((threshold) => {\n const {\n notificationType,\n value: thresholdValue,\n condition,\n customConditionText,\n customCondition,\n } = threshold;\n\n return {\n id: `threshold-${notificationType}`,\n notificationType,\n leadingElement: customCondition\n ? customConditionText\n : `${\n checkCondition(\n seriesValue,\n condition,\n thresholdValue,\n ).conditionText\n } threshold`,\n trailingElement: thresholdValue,\n };\n });\n\n const value = extractValueFromTooltipSeries(\n series.value,\n series.encode,\n series.axisDim,\n );\n\n return (\n <ChartTooltip.Content\n key={series.seriesName}\n leadingElement={\n isThresholdLine\n ? `${capitalizeFirstLetter(\n series.seriesName.replace('thresholdLine-', ''),\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 dataZoom,\n toolbox: mergeToolbox(toolboxOptions),\n };\n\n // Update chart with initial option\n const chart = getInstanceByDom(chartEchartRef.current);\n chart?.setOption(option, settings);\n // Get option returns the current option of the chart.\n // This is slightly different than the option we gave as an argument.\n // Because we use useMemo in other areas we want to get this set first,\n // this is why we are setting then getting then returning. If we did this in\n // a useEffect it would run after the other useMemos which is not what we want.\n // This is purely for order of operations.\n const chartOption = chart?.getOption();\n\n return chartOption;\n }, [\n dataset,\n xAxis,\n yAxis,\n userOption,\n hasCategoryXAxis,\n hasSliderZoom,\n series,\n dataZoom,\n toolboxOptions,\n thresholdLines,\n settings,\n ]);\n\n useEffect(() => {\n // Initialize chart\n let chart: ECharts | undefined;\n if (chartEchartRef.current !== null) {\n registerTheme('ndl-light', ndlEchartsTheme('light'));\n registerTheme('ndl-dark', ndlEchartsTheme('dark'));\n\n const currentChart = getInstanceByDom(chartEchartRef.current);\n if (currentChart) {\n chart = currentChart;\n } else {\n const echartsTheme = theme === 'light' ? 'ndl-light' : 'ndl-dark';\n chart = init(chartEchartRef.current, echartsTheme, {\n renderer: 'svg',\n });\n }\n }\n\n if (callbacks?.onZoom) {\n chart?.on('datazoom', () => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const currentChart = getInstanceByDom(chartEchartRef.current);\n if (!currentChart) {\n return;\n }\n\n const option = currentChart.getOption();\n if (!option || !option.dataZoom) {\n return;\n }\n\n const dataZoom = Array.isArray(option.dataZoom)\n ? option.dataZoom[0]\n : option.dataZoom;\n const { startValue, endValue } = dataZoom as {\n startValue: number;\n endValue: number;\n };\n\n callbacks?.onZoom?.({ startValue, endValue });\n });\n }\n\n // Add chart resize listener\n // ResizeObserver is leading to a bit janky UX\n function resizeChart() {\n // TODO: We need to revisit this. Right now using grid containLabel seems to work.\n // We still need to visit this for overflowing of the x-axis labels.\n // const calculateGridLeft = () => {\n // const textElements = chartEchartRef.current?.querySelectorAll('text');\n // const filteredTextElements = Array.from(textElements || []).filter(\n // (element) => element.getAttribute('text-anchor') === 'end',\n // );\n // let maxWidth = 0;\n // filteredTextElements.forEach((element) => {\n // const bbox = element.getBBox();\n // maxWidth = Math.max(maxWidth, bbox.width);\n // });\n // const tickLength = 5;\n // const tickPadding = 3;\n // return maxWidth + tickLength + tickPadding;\n // };\n //\n // // Example of dynamically setting the grid's left\n // const gridLeft = calculateGridLeft();\n // chart?.setOption({\n // grid: {\n // left: gridLeft,\n // },\n // });\n\n // We want to fit the chart to the charts container.\n const chartContainerHeight = chartRef.current?.clientHeight;\n const chartContainerWidth = chartRef.current?.clientWidth;\n // Need to take legends height into consideration, otherwise it will overflow the parent.\n const chartLegendHeight = chartLegendRef?.current?.clientHeight || 0;\n const height = chartContainerHeight\n ? chartContainerHeight - chartLegendHeight\n : undefined;\n chart?.resize({\n width: chartContainerWidth,\n height,\n });\n }\n window.addEventListener('resize', resizeChart);\n requestAnimationFrame(() => {\n resizeChart();\n setIsWaitingForFirstResize(false);\n });\n\n // Add chart zoom listeners\n const handleMouseMove = () => {\n // I do not like this at all: https://github.com/apache/echarts/issues/19819\n // echarts updates the svgs on every mouse movement so we need to do this.\n chart?.getZr().setCursorStyle('default');\n };\n // We cannot use chart.getZr().on('mousemove', handleMouseMove)\n // This is because it doesn't respect our callbacks. It will\n // always run echarts code last instead of our callback.\n const chartChild = chartEchartRef.current?.children[0] as HTMLElement;\n if (!isChartZoomDisabled) {\n chartChild.addEventListener('mousemove', handleMouseMove);\n }\n\n const handleMouseDown = (params: { event: MouseEvent }) => {\n const event = params.event;\n const amountOfMouseClicks = event.detail;\n const isDoubleClick = amountOfMouseClicks === 2;\n if (isDoubleClick) {\n // Reset zooming.\n if (chart === undefined) {\n return;\n }\n chart?.dispatchAction({\n type: 'dataZoom',\n start: 0,\n end: 100,\n });\n if (callbacks?.onZoom) {\n callbacks?.onZoom?.({ startValue: 0, endValue: 100 });\n }\n }\n };\n if (!isChartZoomDisabled) {\n chart?.getZr().on('mousedown', handleMouseDown);\n }\n\n // Return cleanup function\n const chartRefCurrentElement = chartEchartRef.current;\n const element = chartRefCurrentElement?.children[0];\n return () => {\n window.removeEventListener('resize', resizeChart);\n\n element?.removeEventListener('mousemove', handleMouseMove);\n\n // Remove chart zoom handlers\n if (chartRefCurrentElement) {\n const chart = getInstanceByDom(chartRefCurrentElement);\n chart?.getZr().off('mousedown', handleMouseDown);\n }\n };\n });\n\n useEffect(() => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef?.current);\n\n isLoading || isWaitingForFirstResize\n ? chart?.showLoading()\n : chart?.hideLoading();\n }, [isLoading, isWaitingForFirstResize]);\n\n const legendSeries = useMemo(() => {\n if (chartEchartRef.current === null || isWaitingForFirstResize) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef?.current);\n const optionSeries = (initialOption?.series as NeedleSeries) ?? [];\n const optionDataset = initialOption?.dataset;\n\n const legendSeries: {\n name: string;\n color: string;\n }[] = [];\n if (Array.isArray(optionSeries)) {\n optionSeries.forEach((currentSeries, index) => {\n if (currentSeries === null) {\n return;\n } else if (\n currentSeries.type === 'line' &&\n typeof currentSeries.name === 'string' &&\n currentSeries.name?.includes('thresholdLine')\n ) {\n return;\n } else if (currentSeries.type === 'pie') {\n const encodedItemName = currentSeries.encode?.itemName;\n let currentDataset = Array.isArray(optionDataset)\n ? optionDataset[0]\n : optionDataset;\n if (currentSeries.datasetId && Array.isArray(optionDataset)) {\n currentDataset = optionDataset.find(\n (ds) => ds.id === currentSeries.datasetId,\n );\n } else if (currentSeries.datasetIndex !== undefined) {\n currentDataset = Array.isArray(optionDataset)\n ? optionDataset[currentSeries.datasetIndex]\n : optionDataset;\n }\n const firstDatasetRow = Array.isArray(currentDataset?.source)\n ? currentDataset?.source[0]\n : undefined;\n if (!firstDatasetRow) {\n return;\n }\n\n if (Array.isArray(firstDatasetRow)) {\n const firstDatasetRowIndex = firstDatasetRow.findIndex(\n (item) => item === encodedItemName,\n );\n\n if (firstDatasetRowIndex === -1) {\n return;\n }\n\n const source = currentDataset?.source;\n if (!source) {\n return;\n }\n\n const sourceLength = Array.isArray(source) ? source.length : 0;\n for (let rowIndex = 1; rowIndex < sourceLength; rowIndex++) {\n const row = source[rowIndex] as (string | number)[];\n const color = chart?.getVisual(\n { dataIndexInside: rowIndex - 1, seriesIndex: index },\n 'color',\n );\n legendSeries.push({\n name: String(row[firstDatasetRowIndex]),\n color: typeof color === 'string' ? color : '#000000',\n });\n }\n } else {\n // TODO: handle dictionary\n }\n\n return;\n } else {\n const name = Array.isArray(optionSeries)\n ? optionSeries[index]?.name\n : undefined;\n\n if (name === undefined) {\n return null;\n }\n\n const color = chart?.getVisual({ seriesIndex: index }, 'color');\n legendSeries.push({\n name: String(name),\n color: typeof color === 'string' ? color : '#000000',\n });\n }\n });\n }\n return legendSeries.filter((currentSeries) => currentSeries !== null);\n }, [isWaitingForFirstResize, initialOption]);\n\n if (chartEchartRef.current !== null && !isChartZoomDisabled) {\n const chart = getInstanceByDom(chartEchartRef.current);\n if (chart) {\n // Needs to be re-set on every re-render.\n // Sets the selectable zoom area over the chart (not the slider).\n chart.dispatchAction({\n type: 'takeGlobalCursor',\n key: 'dataZoomSelect',\n dataZoomSelectActive: true,\n });\n }\n }\n\n return (\n <div ref={chartRef} className=\"ndl-chart\" style={style}>\n <div ref={chartEchartRef} />\n {legend?.show && !isWaitingForFirstResize && (\n <Legend\n ref={chartLegendRef}\n wrappingType={legend.wrappingType}\n series={legendSeries ?? []}\n chartRef={chartEchartRef}\n />\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"Chart.js","sourceRoot":"","sources":["../../../src/charts/Chart.tsx"],"names":[],"mappings":";;;AA4MA,sBAwgBC;;AAptBD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,0CAAyC;AACzC,4CAAkD;AAClD,qCAUiB;AACjB,iCAMe;AACf,6CAAkD;AAElD,iDAAqE;AACrE,qCAAoD;AACpD,kEAA6D;AAC7D,2DAM6B;AAC7B,mCAA+E;AAe/E,iDAAiD;AACjD,2CAA2C;AAC3C,SAAS,cAAc,CACrB,KAAa,EACb,SAAoB,EACpB,SAAiB;IAKjB,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO;gBACL,cAAc,EAAE,KAAK,GAAG,SAAS;gBACjC,aAAa,EAAE,OAAO;aACvB,CAAC;QACJ,KAAK,gBAAgB;YACnB,OAAO;gBACL,cAAc,EAAE,KAAK,IAAI,SAAS;gBAClC,aAAa,EACX,KAAK,GAAG,SAAS;oBACf,CAAC,CAAC,OAAO;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AE,cAAc,GACxB,CACH,IACG,CACP,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 { tokens } from '@neo4j-ndl/base';\nimport { useNeedleTheme } from '@neo4j-ndl/react';\nimport {\n type DataZoomComponentOption,\n type ECharts,\n type EChartsOption,\n getInstanceByDom,\n init,\n type LineSeriesOption,\n type RegisteredSeriesOption,\n registerTheme,\n type SetOptionOpts,\n} from 'echarts';\nimport {\n type CSSProperties,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { renderToString } from 'react-dom/server';\n\nimport { ChartTooltip, type NotificationType } from './ChartTooltip';\nimport { Legend, type LegendProps } from './Legend';\nimport { ndlEchartsTheme } from './themes/ndl-echarts-theme';\nimport {\n mergeDataZoom,\n mergeSeries,\n mergeToolbox,\n mergeXAxis,\n mergeYAxis,\n} from './user-option-utils';\nimport { capitalizeFirstLetter, extractValueFromTooltipSeries } from './utils';\n\ntype Condition =\n | 'greater'\n | 'greaterOrEqual'\n | 'less'\n | 'lessOrEqual'\n | 'equal'\n | 'notEqual';\n\ntype CustomCondition = (\n lineValue: unknown,\n thresholdLineValue: unknown,\n) => boolean;\n\n// This returns a boolean if the condition is met\n// and also what to display in the tooltip.\nfunction checkCondition(\n value: number,\n condition: Condition,\n threshold: number,\n): {\n isConditionMet: boolean;\n conditionText: string | undefined;\n} {\n switch (condition) {\n case 'greater':\n return {\n isConditionMet: value > threshold,\n conditionText: 'Above',\n };\n case 'greaterOrEqual':\n return {\n isConditionMet: value >= threshold,\n conditionText:\n value > threshold\n ? 'Above'\n : value === threshold\n ? 'Equal'\n : undefined,\n };\n case 'less':\n return {\n isConditionMet: value < threshold,\n conditionText: 'Below',\n };\n case 'lessOrEqual':\n return {\n isConditionMet: value <= threshold,\n conditionText:\n value < threshold\n ? 'Below'\n : value === threshold\n ? 'Equal'\n : undefined,\n };\n case 'equal':\n return {\n isConditionMet: value === threshold,\n conditionText: 'Equal',\n };\n case 'notEqual':\n return {\n isConditionMet: value !== threshold,\n conditionText: 'Not equal',\n };\n default:\n return { isConditionMet: false, conditionText: undefined };\n }\n}\n\nexport interface ThresholdLineSeriesOption<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\nexport const defaultThresholdLineSeriesOption: {\n condition: Condition;\n} = {\n condition: 'greater',\n};\n\nexport type Values<T> = T[keyof T];\nexport type SeriesOption = Values<RegisteredSeriesOption>;\n\nexport type EchartsSeries = SeriesOption | SeriesOption[];\n\n/*\nKeep this, if we want more than one type of the same threshold line\nthis will be useful to use.\n\nexport interface NewRegisteredSeriesOption extends RegisteredSeriesOption {\nthresholdLine: ThresholdLineSeriesOption;\n}\nexport type SeriesOption = Values<NewRegisteredSeriesOption>;\nexport type Series = SeriesOption | SeriesOption[];\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\ninterface 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 wrappingType?: LegendProps['wrappingType'];\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?: 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}\n\nexport function Chart({\n dataset,\n option: userOption,\n xAxis: propXAxis,\n yAxis: propYAxis,\n series: propsSeries,\n style,\n settings = {\n notMerge: true,\n lazyUpdate: false,\n silent: false,\n },\n isLoading,\n isChartZoomDisabled = false,\n legend,\n callbacks,\n}: ChartProps): React.JSX.Element {\n const chartRef = useRef<HTMLDivElement>(null);\n const chartEchartRef = useRef<HTMLDivElement>(null);\n const chartLegendRef = useRef<HTMLDivElement>(null);\n const [isWaitingForFirstResize, setIsWaitingForFirstResize] = useState(true);\n\n const dataZoomOptions = (userOption as EChartsOption)?.dataZoom;\n const toolboxOptions = (userOption as EChartsOption)?.toolbox;\n\n const hasSliderZoom = Array.isArray(dataZoomOptions)\n ? dataZoomOptions.some((dataZoomOption: DataZoomComponentOption) => {\n return dataZoomOption?.type === 'slider';\n })\n : dataZoomOptions?.type === 'slider';\n\n const { theme } = useNeedleTheme();\n const thresholdLines = useMemo(() => {\n const seriesArray = Array.isArray(propsSeries)\n ? propsSeries\n : [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 }, [propsSeries]);\n\n const dataZoom = useMemo(() => {\n return mergeDataZoom(dataZoomOptions);\n }, [dataZoomOptions]);\n\n const series = mergeSeries(propsSeries, theme);\n const xAxis = mergeXAxis(propXAxis, theme);\n const yAxis = mergeYAxis(propYAxis, theme);\n\n const hasCategoryXAxis = Array.isArray(xAxis)\n ? xAxis.some((x) => x.type === 'category')\n : xAxis?.type === 'category';\n\n // The initial option used, the charts option is not necessarily\n // the same as this due to mutation via dispatch and setOption.\n // use getOption to get the current option of the chart.\n const initialOption = useMemo(() => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const option = {\n dataset,\n xAxis,\n yAxis,\n ...userOption,\n aria: {\n decal: {\n show: false,\n },\n enabled: true,\n ...(userOption?.aria as EChartsOption['aria']),\n },\n grid: {\n left: hasCategoryXAxis ? '15px' : '10px',\n right: hasCategoryXAxis ? '15px' : '10px',\n top: '10px',\n bottom: hasSliderZoom ? '60px' : '10px',\n type: 'solid',\n containLabel: true,\n ...(userOption?.grid as EChartsOption['grid']),\n },\n legend: {\n // Removes in-built echarts legend\n show: false,\n },\n series,\n tooltip: {\n trigger: 'axis',\n confine: true,\n // Reset the default tooltip css styling\n padding: 0,\n borderRadius: 0,\n borderWidth: 0,\n extraCssText: 'box-shadow: none; background-color: transparent;',\n formatter: function (params: unknown) {\n const paramsArray = Array.isArray(params) ? params : [params];\n const firstParam = paramsArray[0];\n\n let valueFormatter = (value: unknown) => `${value}`;\n if (\n typeof userOption?.tooltip === 'object' &&\n userOption.tooltip !== null &&\n 'valueFormatter' in userOption.tooltip\n ) {\n valueFormatter = userOption.tooltip.valueFormatter as (\n value: unknown,\n ) => string;\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: seriesValueUnknown } = series;\n\n const seriesValue = Array.isArray(seriesValueUnknown)\n ? seriesValueUnknown[1]\n : seriesValueUnknown;\n\n const isThresholdLine =\n series.seriesName.startsWith('thresholdLine');\n\n const notifications = thresholdLines\n .filter((threshold) => {\n const {\n value: thresholdValue,\n condition,\n customCondition,\n } = threshold;\n\n const isConditionMet = customCondition\n ? customCondition(seriesValue, thresholdValue)\n : checkCondition(seriesValue, condition, thresholdValue)\n .isConditionMet;\n\n return !isThresholdLine && isConditionMet;\n })\n .map((threshold) => {\n const {\n notificationType,\n value: thresholdValue,\n condition,\n customConditionText,\n customCondition,\n } = threshold;\n\n return {\n id: `threshold-${notificationType}`,\n notificationType,\n leadingElement: customCondition\n ? customConditionText\n : `${\n checkCondition(\n seriesValue,\n condition,\n thresholdValue,\n ).conditionText\n } threshold`,\n trailingElement: thresholdValue,\n };\n });\n\n const value = extractValueFromTooltipSeries(\n series.value,\n series.encode,\n series.axisDim,\n );\n\n return (\n <ChartTooltip.Content\n key={series.seriesName}\n leadingElement={\n isThresholdLine\n ? `${capitalizeFirstLetter(\n series.seriesName.replace('thresholdLine-', ''),\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 dataZoom,\n toolbox: mergeToolbox(toolboxOptions),\n };\n\n // Update chart with initial option\n const chart = getInstanceByDom(chartEchartRef.current);\n chart?.setOption(option, settings);\n // Get option returns the current option of the chart.\n // This is slightly different than the option we gave as an argument.\n // Because we use useMemo in other areas we want to get this set first,\n // this is why we are setting then getting then returning. If we did this in\n // a useEffect it would run after the other useMemos which is not what we want.\n // This is purely for order of operations.\n const chartOption = chart?.getOption();\n\n return chartOption;\n }, [\n dataset,\n xAxis,\n yAxis,\n userOption,\n hasCategoryXAxis,\n hasSliderZoom,\n series,\n dataZoom,\n toolboxOptions,\n thresholdLines,\n settings,\n ]);\n\n useEffect(() => {\n // Initialize chart\n let chart: ECharts | undefined;\n if (chartEchartRef.current !== null) {\n registerTheme('ndl-light', ndlEchartsTheme('light'));\n registerTheme('ndl-dark', ndlEchartsTheme('dark'));\n\n const currentChart = getInstanceByDom(chartEchartRef.current);\n if (currentChart) {\n chart = currentChart;\n } else {\n const echartsTheme = theme === 'light' ? 'ndl-light' : 'ndl-dark';\n chart = init(chartEchartRef.current, echartsTheme, {\n renderer: 'svg',\n });\n }\n }\n\n if (callbacks?.onZoom) {\n chart?.on('datazoom', () => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const currentChart = getInstanceByDom(chartEchartRef.current);\n if (!currentChart) {\n return;\n }\n\n const option = currentChart.getOption();\n if (!option || !option.dataZoom) {\n return;\n }\n\n const dataZoom = Array.isArray(option.dataZoom)\n ? option.dataZoom[0]\n : option.dataZoom;\n const { startValue, endValue } = dataZoom as {\n startValue: number;\n endValue: number;\n };\n\n callbacks?.onZoom?.({ startValue, endValue });\n });\n }\n\n // Add chart resize listener\n // ResizeObserver is leading to a bit janky UX\n function resizeChart() {\n // TODO: We need to revisit this. Right now using grid containLabel seems to work.\n // We still need to visit this for overflowing of the x-axis labels.\n // const calculateGridLeft = () => {\n // const textElements = chartEchartRef.current?.querySelectorAll('text');\n // const filteredTextElements = Array.from(textElements || []).filter(\n // (element) => element.getAttribute('text-anchor') === 'end',\n // );\n // let maxWidth = 0;\n // filteredTextElements.forEach((element) => {\n // const bbox = element.getBBox();\n // maxWidth = Math.max(maxWidth, bbox.width);\n // });\n // const tickLength = 5;\n // const tickPadding = 3;\n // return maxWidth + tickLength + tickPadding;\n // };\n //\n // // Example of dynamically setting the grid's left\n // const gridLeft = calculateGridLeft();\n // chart?.setOption({\n // grid: {\n // left: gridLeft,\n // },\n // });\n\n // We want to fit the chart to the charts container.\n const chartContainerHeight = chartRef.current?.clientHeight;\n const chartContainerWidth = chartRef.current?.clientWidth;\n // Need to take legends height into consideration, otherwise it will overflow the parent.\n const chartLegendHeight = chartLegendRef?.current?.clientHeight || 0;\n const height = chartContainerHeight\n ? chartContainerHeight - chartLegendHeight\n : undefined;\n chart?.resize({\n width: chartContainerWidth,\n height,\n });\n }\n window.addEventListener('resize', resizeChart);\n requestAnimationFrame(() => {\n resizeChart();\n setIsWaitingForFirstResize(false);\n });\n\n // Add chart zoom listeners\n const handleMouseMove = () => {\n // I do not like this at all: https://github.com/apache/echarts/issues/19819\n // echarts updates the svgs on every mouse movement so we need to do this.\n chart?.getZr().setCursorStyle('default');\n };\n // We cannot use chart.getZr().on('mousemove', handleMouseMove)\n // This is because it doesn't respect our callbacks. It will\n // always run echarts code last instead of our callback.\n const chartChild = chartEchartRef.current?.children[0] as HTMLElement;\n if (!isChartZoomDisabled) {\n chartChild.addEventListener('mousemove', handleMouseMove);\n }\n\n const handleMouseDown = (params: { event: MouseEvent }) => {\n const event = params.event;\n const amountOfMouseClicks = event.detail;\n const isDoubleClick = amountOfMouseClicks === 2;\n if (isDoubleClick) {\n // Reset zooming.\n if (chart === undefined) {\n return;\n }\n chart?.dispatchAction({\n type: 'dataZoom',\n start: 0,\n end: 100,\n });\n if (callbacks?.onZoom) {\n callbacks?.onZoom?.({ startValue: 0, endValue: 100 });\n }\n }\n };\n if (!isChartZoomDisabled) {\n chart?.getZr().on('mousedown', handleMouseDown);\n }\n\n // Return cleanup function\n const chartRefCurrentElement = chartEchartRef.current;\n const element = chartRefCurrentElement?.children[0];\n return () => {\n window.removeEventListener('resize', resizeChart);\n\n element?.removeEventListener('mousemove', handleMouseMove);\n\n // Remove chart zoom handlers\n if (chartRefCurrentElement) {\n const chart = getInstanceByDom(chartRefCurrentElement);\n chart?.getZr().off('mousedown', handleMouseDown);\n }\n };\n });\n\n useEffect(() => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef?.current);\n\n if (isLoading === true || isWaitingForFirstResize) {\n chart?.showLoading({\n color: tokens.theme[theme].color.primary.bg.status,\n fontFamily: tokens.typography['label'].fontFamily,\n fontSize: tokens.typography['label'].fontSize,\n fontWeight: tokens.typography['label'].fontWeight,\n maskColor: `rgb( from ${tokens.theme[theme].color.neutral.text.inverse} r g b / 0.8)`,\n text: 'Loading',\n textColor: tokens.theme[theme].color.neutral.text.default,\n });\n } else {\n chart?.hideLoading();\n }\n }, [isLoading, isWaitingForFirstResize, theme]);\n\n const legendSeries = useMemo(() => {\n if (chartEchartRef.current === null || isWaitingForFirstResize) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef?.current);\n const optionSeries = (initialOption?.series as NeedleSeries) ?? [];\n const optionDataset = initialOption?.dataset;\n\n const legendSeries: {\n name: string;\n color: string;\n }[] = [];\n if (Array.isArray(optionSeries)) {\n optionSeries.forEach((currentSeries, index) => {\n if (currentSeries === null) {\n return;\n } else if (\n currentSeries.type === 'line' &&\n typeof currentSeries.name === 'string' &&\n currentSeries.name?.includes('thresholdLine')\n ) {\n return;\n } else if (currentSeries.type === 'pie') {\n const encodedItemName = currentSeries.encode?.itemName;\n let currentDataset = Array.isArray(optionDataset)\n ? optionDataset[0]\n : optionDataset;\n if (currentSeries.datasetId && Array.isArray(optionDataset)) {\n currentDataset = optionDataset.find(\n (ds) => ds.id === currentSeries.datasetId,\n );\n } else if (currentSeries.datasetIndex !== undefined) {\n currentDataset = Array.isArray(optionDataset)\n ? optionDataset[currentSeries.datasetIndex]\n : optionDataset;\n }\n const firstDatasetRow = Array.isArray(currentDataset?.source)\n ? currentDataset?.source[0]\n : undefined;\n if (!firstDatasetRow) {\n return;\n }\n\n if (Array.isArray(firstDatasetRow)) {\n const firstDatasetRowIndex = firstDatasetRow.findIndex(\n (item) => item === encodedItemName,\n );\n\n if (firstDatasetRowIndex === -1) {\n return;\n }\n\n const source = currentDataset?.source;\n if (!source) {\n return;\n }\n\n const sourceLength = Array.isArray(source) ? source.length : 0;\n for (let rowIndex = 1; rowIndex < sourceLength; rowIndex++) {\n const row = source[rowIndex] as (string | number)[];\n const color = chart?.getVisual(\n { dataIndexInside: rowIndex - 1, seriesIndex: index },\n 'color',\n );\n legendSeries.push({\n name: String(row[firstDatasetRowIndex]),\n color: typeof color === 'string' ? color : '#000000',\n });\n }\n } else {\n // TODO: handle dictionary\n }\n\n return;\n } else {\n const name = Array.isArray(optionSeries)\n ? optionSeries[index]?.name\n : undefined;\n\n if (name === undefined) {\n return null;\n }\n\n const color = chart?.getVisual({ seriesIndex: index }, 'color');\n legendSeries.push({\n name: String(name),\n color: typeof color === 'string' ? color : '#000000',\n });\n }\n });\n }\n return legendSeries.filter((currentSeries) => currentSeries !== null);\n }, [isWaitingForFirstResize, initialOption]);\n\n if (chartEchartRef.current !== null && !isChartZoomDisabled) {\n const chart = getInstanceByDom(chartEchartRef.current);\n if (chart) {\n // Needs to be re-set on every re-render.\n // Sets the selectable zoom area over the chart (not the slider).\n chart.dispatchAction({\n type: 'takeGlobalCursor',\n key: 'dataZoomSelect',\n dataZoomSelectActive: true,\n });\n }\n }\n\n return (\n <div ref={chartRef} className=\"ndl-chart\" style={style}>\n <div ref={chartEchartRef} />\n {legend?.show && !isWaitingForFirstResize && (\n <Legend\n ref={chartLegendRef}\n wrappingType={legend.wrappingType}\n series={legendSeries ?? []}\n chartRef={chartEchartRef}\n />\n )}\n </div>\n );\n}\n"]}
@@ -19,6 +19,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
19
  * You should have received a copy of the GNU General Public License
20
20
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
21
  */
22
+ import { tokens } from '@neo4j-ndl/base';
22
23
  import { useNeedleTheme } from '@neo4j-ndl/react';
23
24
  import { getInstanceByDom, init, registerTheme, } from 'echarts';
24
25
  import { useEffect, useMemo, useRef, useState, } from 'react';
@@ -343,10 +344,21 @@ export function Chart({ dataset, option: userOption, xAxis: propXAxis, yAxis: pr
343
344
  return;
344
345
  }
345
346
  const chart = getInstanceByDom(chartEchartRef === null || chartEchartRef === void 0 ? void 0 : chartEchartRef.current);
346
- isLoading || isWaitingForFirstResize
347
- ? chart === null || chart === void 0 ? void 0 : chart.showLoading()
348
- : chart === null || chart === void 0 ? void 0 : chart.hideLoading();
349
- }, [isLoading, isWaitingForFirstResize]);
347
+ if (isLoading === true || isWaitingForFirstResize) {
348
+ chart === null || chart === void 0 ? void 0 : chart.showLoading({
349
+ color: tokens.theme[theme].color.primary.bg.status,
350
+ fontFamily: tokens.typography['label'].fontFamily,
351
+ fontSize: tokens.typography['label'].fontSize,
352
+ fontWeight: tokens.typography['label'].fontWeight,
353
+ maskColor: `rgb( from ${tokens.theme[theme].color.neutral.text.inverse} r g b / 0.8)`,
354
+ text: 'Loading',
355
+ textColor: tokens.theme[theme].color.neutral.text.default,
356
+ });
357
+ }
358
+ else {
359
+ chart === null || chart === void 0 ? void 0 : chart.hideLoading();
360
+ }
361
+ }, [isLoading, isWaitingForFirstResize, theme]);
350
362
  const legendSeries = useMemo(() => {
351
363
  var _a;
352
364
  if (chartEchartRef.current === null || isWaitingForFirstResize) {
@@ -1 +1 @@
1
- {"version":3,"file":"Chart.js","sourceRoot":"","sources":["../../../src/charts/Chart.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAIL,gBAAgB,EAChB,IAAI,EAGJ,aAAa,GAEd,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAyB,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAoB,MAAM,UAAU,CAAC;AACpD,O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,CAAC,CAAC,CAAC,SAAS;qBACrD,CAAC,CAAC;gBACL,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,KAAK,IAAI,CAAC,CAAC;IACxE,CAAC,EAAE,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC,CAAC;IAE7C,IAAI,cAAc,CAAC,OAAO,KAAK,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC5D,MAAM,KAAK,GAAG,gBAAgB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACvD,IAAI,KAAK,EAAE,CAAC;YACV,yCAAyC;YACzC,iEAAiE;YACjE,KAAK,CAAC,cAAc,CAAC;gBACnB,IAAI,EAAE,kBAAkB;gBACxB,GAAG,EAAE,gBAAgB;gBACrB,oBAAoB,EAAE,IAAI;aAC3B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,CACL,eAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,WAAW,EAAC,KAAK,EAAE,KAAK,aACpD,cAAK,GAAG,EAAE,cAAc,GAAI,EAC3B,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,KAAI,CAAC,uBAAuB,IAAI,CAC3C,KAAC,MAAM,IACL,GAAG,EAAE,cAAc,EACnB,YAAY,EAAE,MAAM,CAAC,YAAY,EACjC,MAAM,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,EAC1B,QAAQ,EAAE,cAAc,GACxB,CACH,IACG,CACP,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 { useNeedleTheme } from '@neo4j-ndl/react';\nimport {\n type DataZoomComponentOption,\n type ECharts,\n type EChartsOption,\n getInstanceByDom,\n init,\n type LineSeriesOption,\n type RegisteredSeriesOption,\n registerTheme,\n type SetOptionOpts,\n} from 'echarts';\nimport {\n type CSSProperties,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { renderToString } from 'react-dom/server';\n\nimport { ChartTooltip, type NotificationType } from './ChartTooltip';\nimport { Legend, type LegendProps } from './Legend';\nimport { ndlEchartsTheme } from './themes/ndl-echarts-theme';\nimport {\n mergeDataZoom,\n mergeSeries,\n mergeToolbox,\n mergeXAxis,\n mergeYAxis,\n} from './user-option-utils';\nimport { capitalizeFirstLetter, extractValueFromTooltipSeries } from './utils';\n\ntype Condition =\n | 'greater'\n | 'greaterOrEqual'\n | 'less'\n | 'lessOrEqual'\n | 'equal'\n | 'notEqual';\n\ntype CustomCondition = (\n lineValue: unknown,\n thresholdLineValue: unknown,\n) => boolean;\n\n// This returns a boolean if the condition is met\n// and also what to display in the tooltip.\nfunction checkCondition(\n value: number,\n condition: Condition,\n threshold: number,\n): {\n isConditionMet: boolean;\n conditionText: string | undefined;\n} {\n switch (condition) {\n case 'greater':\n return {\n isConditionMet: value > threshold,\n conditionText: 'Above',\n };\n case 'greaterOrEqual':\n return {\n isConditionMet: value >= threshold,\n conditionText:\n value > threshold\n ? 'Above'\n : value === threshold\n ? 'Equal'\n : undefined,\n };\n case 'less':\n return {\n isConditionMet: value < threshold,\n conditionText: 'Below',\n };\n case 'lessOrEqual':\n return {\n isConditionMet: value <= threshold,\n conditionText:\n value < threshold\n ? 'Below'\n : value === threshold\n ? 'Equal'\n : undefined,\n };\n case 'equal':\n return {\n isConditionMet: value === threshold,\n conditionText: 'Equal',\n };\n case 'notEqual':\n return {\n isConditionMet: value !== threshold,\n conditionText: 'Not equal',\n };\n default:\n return { isConditionMet: false, conditionText: undefined };\n }\n}\n\nexport interface ThresholdLineSeriesOption<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\nexport const defaultThresholdLineSeriesOption: {\n condition: Condition;\n} = {\n condition: 'greater',\n};\n\nexport type Values<T> = T[keyof T];\nexport type SeriesOption = Values<RegisteredSeriesOption>;\n\nexport type EchartsSeries = SeriesOption | SeriesOption[];\n\n/*\nKeep this, if we want more than one type of the same threshold line\nthis will be useful to use.\n\nexport interface NewRegisteredSeriesOption extends RegisteredSeriesOption {\nthresholdLine: ThresholdLineSeriesOption;\n}\nexport type SeriesOption = Values<NewRegisteredSeriesOption>;\nexport type Series = SeriesOption | SeriesOption[];\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\ninterface 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 wrappingType?: LegendProps['wrappingType'];\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?: 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}\n\nexport function Chart({\n dataset,\n option: userOption,\n xAxis: propXAxis,\n yAxis: propYAxis,\n series: propsSeries,\n style,\n settings = {\n notMerge: true,\n lazyUpdate: false,\n silent: false,\n },\n isLoading,\n isChartZoomDisabled = false,\n legend,\n callbacks,\n}: ChartProps): React.JSX.Element {\n const chartRef = useRef<HTMLDivElement>(null);\n const chartEchartRef = useRef<HTMLDivElement>(null);\n const chartLegendRef = useRef<HTMLDivElement>(null);\n const [isWaitingForFirstResize, setIsWaitingForFirstResize] = useState(true);\n\n const dataZoomOptions = (userOption as EChartsOption)?.dataZoom;\n const toolboxOptions = (userOption as EChartsOption)?.toolbox;\n\n const hasSliderZoom = Array.isArray(dataZoomOptions)\n ? dataZoomOptions.some((dataZoomOption: DataZoomComponentOption) => {\n return dataZoomOption?.type === 'slider';\n })\n : dataZoomOptions?.type === 'slider';\n\n const { theme } = useNeedleTheme();\n const thresholdLines = useMemo(() => {\n const seriesArray = Array.isArray(propsSeries)\n ? propsSeries\n : [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 }, [propsSeries]);\n\n const dataZoom = useMemo(() => {\n return mergeDataZoom(dataZoomOptions);\n }, [dataZoomOptions]);\n\n const series = mergeSeries(propsSeries, theme);\n const xAxis = mergeXAxis(propXAxis, theme);\n const yAxis = mergeYAxis(propYAxis, theme);\n\n const hasCategoryXAxis = Array.isArray(xAxis)\n ? xAxis.some((x) => x.type === 'category')\n : xAxis?.type === 'category';\n\n // The initial option used, the charts option is not necessarily\n // the same as this due to mutation via dispatch and setOption.\n // use getOption to get the current option of the chart.\n const initialOption = useMemo(() => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const option = {\n dataset,\n xAxis,\n yAxis,\n ...userOption,\n aria: {\n decal: {\n show: false,\n },\n enabled: true,\n ...(userOption?.aria as EChartsOption['aria']),\n },\n grid: {\n left: hasCategoryXAxis ? '15px' : '10px',\n right: hasCategoryXAxis ? '15px' : '10px',\n top: '10px',\n bottom: hasSliderZoom ? '60px' : '10px',\n type: 'solid',\n containLabel: true,\n ...(userOption?.grid as EChartsOption['grid']),\n },\n legend: {\n // Removes in-built echarts legend\n show: false,\n },\n series,\n tooltip: {\n trigger: 'axis',\n confine: true,\n // Reset the default tooltip css styling\n padding: 0,\n borderRadius: 0,\n borderWidth: 0,\n extraCssText: 'box-shadow: none; background-color: transparent;',\n formatter: function (params: unknown) {\n const paramsArray = Array.isArray(params) ? params : [params];\n const firstParam = paramsArray[0];\n\n let valueFormatter = (value: unknown) => `${value}`;\n if (\n typeof userOption?.tooltip === 'object' &&\n userOption.tooltip !== null &&\n 'valueFormatter' in userOption.tooltip\n ) {\n valueFormatter = userOption.tooltip.valueFormatter as (\n value: unknown,\n ) => string;\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: seriesValueUnknown } = series;\n\n const seriesValue = Array.isArray(seriesValueUnknown)\n ? seriesValueUnknown[1]\n : seriesValueUnknown;\n\n const isThresholdLine =\n series.seriesName.startsWith('thresholdLine');\n\n const notifications = thresholdLines\n .filter((threshold) => {\n const {\n value: thresholdValue,\n condition,\n customCondition,\n } = threshold;\n\n const isConditionMet = customCondition\n ? customCondition(seriesValue, thresholdValue)\n : checkCondition(seriesValue, condition, thresholdValue)\n .isConditionMet;\n\n return !isThresholdLine && isConditionMet;\n })\n .map((threshold) => {\n const {\n notificationType,\n value: thresholdValue,\n condition,\n customConditionText,\n customCondition,\n } = threshold;\n\n return {\n id: `threshold-${notificationType}`,\n notificationType,\n leadingElement: customCondition\n ? customConditionText\n : `${\n checkCondition(\n seriesValue,\n condition,\n thresholdValue,\n ).conditionText\n } threshold`,\n trailingElement: thresholdValue,\n };\n });\n\n const value = extractValueFromTooltipSeries(\n series.value,\n series.encode,\n series.axisDim,\n );\n\n return (\n <ChartTooltip.Content\n key={series.seriesName}\n leadingElement={\n isThresholdLine\n ? `${capitalizeFirstLetter(\n series.seriesName.replace('thresholdLine-', ''),\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 dataZoom,\n toolbox: mergeToolbox(toolboxOptions),\n };\n\n // Update chart with initial option\n const chart = getInstanceByDom(chartEchartRef.current);\n chart?.setOption(option, settings);\n // Get option returns the current option of the chart.\n // This is slightly different than the option we gave as an argument.\n // Because we use useMemo in other areas we want to get this set first,\n // this is why we are setting then getting then returning. If we did this in\n // a useEffect it would run after the other useMemos which is not what we want.\n // This is purely for order of operations.\n const chartOption = chart?.getOption();\n\n return chartOption;\n }, [\n dataset,\n xAxis,\n yAxis,\n userOption,\n hasCategoryXAxis,\n hasSliderZoom,\n series,\n dataZoom,\n toolboxOptions,\n thresholdLines,\n settings,\n ]);\n\n useEffect(() => {\n // Initialize chart\n let chart: ECharts | undefined;\n if (chartEchartRef.current !== null) {\n registerTheme('ndl-light', ndlEchartsTheme('light'));\n registerTheme('ndl-dark', ndlEchartsTheme('dark'));\n\n const currentChart = getInstanceByDom(chartEchartRef.current);\n if (currentChart) {\n chart = currentChart;\n } else {\n const echartsTheme = theme === 'light' ? 'ndl-light' : 'ndl-dark';\n chart = init(chartEchartRef.current, echartsTheme, {\n renderer: 'svg',\n });\n }\n }\n\n if (callbacks?.onZoom) {\n chart?.on('datazoom', () => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const currentChart = getInstanceByDom(chartEchartRef.current);\n if (!currentChart) {\n return;\n }\n\n const option = currentChart.getOption();\n if (!option || !option.dataZoom) {\n return;\n }\n\n const dataZoom = Array.isArray(option.dataZoom)\n ? option.dataZoom[0]\n : option.dataZoom;\n const { startValue, endValue } = dataZoom as {\n startValue: number;\n endValue: number;\n };\n\n callbacks?.onZoom?.({ startValue, endValue });\n });\n }\n\n // Add chart resize listener\n // ResizeObserver is leading to a bit janky UX\n function resizeChart() {\n // TODO: We need to revisit this. Right now using grid containLabel seems to work.\n // We still need to visit this for overflowing of the x-axis labels.\n // const calculateGridLeft = () => {\n // const textElements = chartEchartRef.current?.querySelectorAll('text');\n // const filteredTextElements = Array.from(textElements || []).filter(\n // (element) => element.getAttribute('text-anchor') === 'end',\n // );\n // let maxWidth = 0;\n // filteredTextElements.forEach((element) => {\n // const bbox = element.getBBox();\n // maxWidth = Math.max(maxWidth, bbox.width);\n // });\n // const tickLength = 5;\n // const tickPadding = 3;\n // return maxWidth + tickLength + tickPadding;\n // };\n //\n // // Example of dynamically setting the grid's left\n // const gridLeft = calculateGridLeft();\n // chart?.setOption({\n // grid: {\n // left: gridLeft,\n // },\n // });\n\n // We want to fit the chart to the charts container.\n const chartContainerHeight = chartRef.current?.clientHeight;\n const chartContainerWidth = chartRef.current?.clientWidth;\n // Need to take legends height into consideration, otherwise it will overflow the parent.\n const chartLegendHeight = chartLegendRef?.current?.clientHeight || 0;\n const height = chartContainerHeight\n ? chartContainerHeight - chartLegendHeight\n : undefined;\n chart?.resize({\n width: chartContainerWidth,\n height,\n });\n }\n window.addEventListener('resize', resizeChart);\n requestAnimationFrame(() => {\n resizeChart();\n setIsWaitingForFirstResize(false);\n });\n\n // Add chart zoom listeners\n const handleMouseMove = () => {\n // I do not like this at all: https://github.com/apache/echarts/issues/19819\n // echarts updates the svgs on every mouse movement so we need to do this.\n chart?.getZr().setCursorStyle('default');\n };\n // We cannot use chart.getZr().on('mousemove', handleMouseMove)\n // This is because it doesn't respect our callbacks. It will\n // always run echarts code last instead of our callback.\n const chartChild = chartEchartRef.current?.children[0] as HTMLElement;\n if (!isChartZoomDisabled) {\n chartChild.addEventListener('mousemove', handleMouseMove);\n }\n\n const handleMouseDown = (params: { event: MouseEvent }) => {\n const event = params.event;\n const amountOfMouseClicks = event.detail;\n const isDoubleClick = amountOfMouseClicks === 2;\n if (isDoubleClick) {\n // Reset zooming.\n if (chart === undefined) {\n return;\n }\n chart?.dispatchAction({\n type: 'dataZoom',\n start: 0,\n end: 100,\n });\n if (callbacks?.onZoom) {\n callbacks?.onZoom?.({ startValue: 0, endValue: 100 });\n }\n }\n };\n if (!isChartZoomDisabled) {\n chart?.getZr().on('mousedown', handleMouseDown);\n }\n\n // Return cleanup function\n const chartRefCurrentElement = chartEchartRef.current;\n const element = chartRefCurrentElement?.children[0];\n return () => {\n window.removeEventListener('resize', resizeChart);\n\n element?.removeEventListener('mousemove', handleMouseMove);\n\n // Remove chart zoom handlers\n if (chartRefCurrentElement) {\n const chart = getInstanceByDom(chartRefCurrentElement);\n chart?.getZr().off('mousedown', handleMouseDown);\n }\n };\n });\n\n useEffect(() => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef?.current);\n\n isLoading || isWaitingForFirstResize\n ? chart?.showLoading()\n : chart?.hideLoading();\n }, [isLoading, isWaitingForFirstResize]);\n\n const legendSeries = useMemo(() => {\n if (chartEchartRef.current === null || isWaitingForFirstResize) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef?.current);\n const optionSeries = (initialOption?.series as NeedleSeries) ?? [];\n const optionDataset = initialOption?.dataset;\n\n const legendSeries: {\n name: string;\n color: string;\n }[] = [];\n if (Array.isArray(optionSeries)) {\n optionSeries.forEach((currentSeries, index) => {\n if (currentSeries === null) {\n return;\n } else if (\n currentSeries.type === 'line' &&\n typeof currentSeries.name === 'string' &&\n currentSeries.name?.includes('thresholdLine')\n ) {\n return;\n } else if (currentSeries.type === 'pie') {\n const encodedItemName = currentSeries.encode?.itemName;\n let currentDataset = Array.isArray(optionDataset)\n ? optionDataset[0]\n : optionDataset;\n if (currentSeries.datasetId && Array.isArray(optionDataset)) {\n currentDataset = optionDataset.find(\n (ds) => ds.id === currentSeries.datasetId,\n );\n } else if (currentSeries.datasetIndex !== undefined) {\n currentDataset = Array.isArray(optionDataset)\n ? optionDataset[currentSeries.datasetIndex]\n : optionDataset;\n }\n const firstDatasetRow = Array.isArray(currentDataset?.source)\n ? currentDataset?.source[0]\n : undefined;\n if (!firstDatasetRow) {\n return;\n }\n\n if (Array.isArray(firstDatasetRow)) {\n const firstDatasetRowIndex = firstDatasetRow.findIndex(\n (item) => item === encodedItemName,\n );\n\n if (firstDatasetRowIndex === -1) {\n return;\n }\n\n const source = currentDataset?.source;\n if (!source) {\n return;\n }\n\n const sourceLength = Array.isArray(source) ? source.length : 0;\n for (let rowIndex = 1; rowIndex < sourceLength; rowIndex++) {\n const row = source[rowIndex] as (string | number)[];\n const color = chart?.getVisual(\n { dataIndexInside: rowIndex - 1, seriesIndex: index },\n 'color',\n );\n legendSeries.push({\n name: String(row[firstDatasetRowIndex]),\n color: typeof color === 'string' ? color : '#000000',\n });\n }\n } else {\n // TODO: handle dictionary\n }\n\n return;\n } else {\n const name = Array.isArray(optionSeries)\n ? optionSeries[index]?.name\n : undefined;\n\n if (name === undefined) {\n return null;\n }\n\n const color = chart?.getVisual({ seriesIndex: index }, 'color');\n legendSeries.push({\n name: String(name),\n color: typeof color === 'string' ? color : '#000000',\n });\n }\n });\n }\n return legendSeries.filter((currentSeries) => currentSeries !== null);\n }, [isWaitingForFirstResize, initialOption]);\n\n if (chartEchartRef.current !== null && !isChartZoomDisabled) {\n const chart = getInstanceByDom(chartEchartRef.current);\n if (chart) {\n // Needs to be re-set on every re-render.\n // Sets the selectable zoom area over the chart (not the slider).\n chart.dispatchAction({\n type: 'takeGlobalCursor',\n key: 'dataZoomSelect',\n dataZoomSelectActive: true,\n });\n }\n }\n\n return (\n <div ref={chartRef} className=\"ndl-chart\" style={style}>\n <div ref={chartEchartRef} />\n {legend?.show && !isWaitingForFirstResize && (\n <Legend\n ref={chartLegendRef}\n wrappingType={legend.wrappingType}\n series={legendSeries ?? []}\n chartRef={chartEchartRef}\n />\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"Chart.js","sourceRoot":"","sources":["../../../src/charts/Chart.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAIL,gBAAgB,EAChB,IAAI,EAGJ,aAAa,GAEd,MAAM,SAAS,CAAC;AACjB,OAAO,EAEL,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAyB,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAoB,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,WAAW,EACX,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAe/E,iDAAiD;AACjD,2CAA2C;AAC3C,SAAS,cAAc,CACrB,KAAa,EACb,SAAoB,EACpB,SAAiB;IAKjB,QAAQ,SAAS,E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YAAY,cAAZ,YAAY,GAAI,EAAE,EAC1B,QAAQ,EAAE,cAAc,GACxB,CACH,IACG,CACP,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 { tokens } from '@neo4j-ndl/base';\nimport { useNeedleTheme } from '@neo4j-ndl/react';\nimport {\n type DataZoomComponentOption,\n type ECharts,\n type EChartsOption,\n getInstanceByDom,\n init,\n type LineSeriesOption,\n type RegisteredSeriesOption,\n registerTheme,\n type SetOptionOpts,\n} from 'echarts';\nimport {\n type CSSProperties,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { renderToString } from 'react-dom/server';\n\nimport { ChartTooltip, type NotificationType } from './ChartTooltip';\nimport { Legend, type LegendProps } from './Legend';\nimport { ndlEchartsTheme } from './themes/ndl-echarts-theme';\nimport {\n mergeDataZoom,\n mergeSeries,\n mergeToolbox,\n mergeXAxis,\n mergeYAxis,\n} from './user-option-utils';\nimport { capitalizeFirstLetter, extractValueFromTooltipSeries } from './utils';\n\ntype Condition =\n | 'greater'\n | 'greaterOrEqual'\n | 'less'\n | 'lessOrEqual'\n | 'equal'\n | 'notEqual';\n\ntype CustomCondition = (\n lineValue: unknown,\n thresholdLineValue: unknown,\n) => boolean;\n\n// This returns a boolean if the condition is met\n// and also what to display in the tooltip.\nfunction checkCondition(\n value: number,\n condition: Condition,\n threshold: number,\n): {\n isConditionMet: boolean;\n conditionText: string | undefined;\n} {\n switch (condition) {\n case 'greater':\n return {\n isConditionMet: value > threshold,\n conditionText: 'Above',\n };\n case 'greaterOrEqual':\n return {\n isConditionMet: value >= threshold,\n conditionText:\n value > threshold\n ? 'Above'\n : value === threshold\n ? 'Equal'\n : undefined,\n };\n case 'less':\n return {\n isConditionMet: value < threshold,\n conditionText: 'Below',\n };\n case 'lessOrEqual':\n return {\n isConditionMet: value <= threshold,\n conditionText:\n value < threshold\n ? 'Below'\n : value === threshold\n ? 'Equal'\n : undefined,\n };\n case 'equal':\n return {\n isConditionMet: value === threshold,\n conditionText: 'Equal',\n };\n case 'notEqual':\n return {\n isConditionMet: value !== threshold,\n conditionText: 'Not equal',\n };\n default:\n return { isConditionMet: false, conditionText: undefined };\n }\n}\n\nexport interface ThresholdLineSeriesOption<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\nexport const defaultThresholdLineSeriesOption: {\n condition: Condition;\n} = {\n condition: 'greater',\n};\n\nexport type Values<T> = T[keyof T];\nexport type SeriesOption = Values<RegisteredSeriesOption>;\n\nexport type EchartsSeries = SeriesOption | SeriesOption[];\n\n/*\nKeep this, if we want more than one type of the same threshold line\nthis will be useful to use.\n\nexport interface NewRegisteredSeriesOption extends RegisteredSeriesOption {\nthresholdLine: ThresholdLineSeriesOption;\n}\nexport type SeriesOption = Values<NewRegisteredSeriesOption>;\nexport type Series = SeriesOption | SeriesOption[];\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\ninterface 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 wrappingType?: LegendProps['wrappingType'];\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?: 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}\n\nexport function Chart({\n dataset,\n option: userOption,\n xAxis: propXAxis,\n yAxis: propYAxis,\n series: propsSeries,\n style,\n settings = {\n notMerge: true,\n lazyUpdate: false,\n silent: false,\n },\n isLoading,\n isChartZoomDisabled = false,\n legend,\n callbacks,\n}: ChartProps): React.JSX.Element {\n const chartRef = useRef<HTMLDivElement>(null);\n const chartEchartRef = useRef<HTMLDivElement>(null);\n const chartLegendRef = useRef<HTMLDivElement>(null);\n const [isWaitingForFirstResize, setIsWaitingForFirstResize] = useState(true);\n\n const dataZoomOptions = (userOption as EChartsOption)?.dataZoom;\n const toolboxOptions = (userOption as EChartsOption)?.toolbox;\n\n const hasSliderZoom = Array.isArray(dataZoomOptions)\n ? dataZoomOptions.some((dataZoomOption: DataZoomComponentOption) => {\n return dataZoomOption?.type === 'slider';\n })\n : dataZoomOptions?.type === 'slider';\n\n const { theme } = useNeedleTheme();\n const thresholdLines = useMemo(() => {\n const seriesArray = Array.isArray(propsSeries)\n ? propsSeries\n : [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 }, [propsSeries]);\n\n const dataZoom = useMemo(() => {\n return mergeDataZoom(dataZoomOptions);\n }, [dataZoomOptions]);\n\n const series = mergeSeries(propsSeries, theme);\n const xAxis = mergeXAxis(propXAxis, theme);\n const yAxis = mergeYAxis(propYAxis, theme);\n\n const hasCategoryXAxis = Array.isArray(xAxis)\n ? xAxis.some((x) => x.type === 'category')\n : xAxis?.type === 'category';\n\n // The initial option used, the charts option is not necessarily\n // the same as this due to mutation via dispatch and setOption.\n // use getOption to get the current option of the chart.\n const initialOption = useMemo(() => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const option = {\n dataset,\n xAxis,\n yAxis,\n ...userOption,\n aria: {\n decal: {\n show: false,\n },\n enabled: true,\n ...(userOption?.aria as EChartsOption['aria']),\n },\n grid: {\n left: hasCategoryXAxis ? '15px' : '10px',\n right: hasCategoryXAxis ? '15px' : '10px',\n top: '10px',\n bottom: hasSliderZoom ? '60px' : '10px',\n type: 'solid',\n containLabel: true,\n ...(userOption?.grid as EChartsOption['grid']),\n },\n legend: {\n // Removes in-built echarts legend\n show: false,\n },\n series,\n tooltip: {\n trigger: 'axis',\n confine: true,\n // Reset the default tooltip css styling\n padding: 0,\n borderRadius: 0,\n borderWidth: 0,\n extraCssText: 'box-shadow: none; background-color: transparent;',\n formatter: function (params: unknown) {\n const paramsArray = Array.isArray(params) ? params : [params];\n const firstParam = paramsArray[0];\n\n let valueFormatter = (value: unknown) => `${value}`;\n if (\n typeof userOption?.tooltip === 'object' &&\n userOption.tooltip !== null &&\n 'valueFormatter' in userOption.tooltip\n ) {\n valueFormatter = userOption.tooltip.valueFormatter as (\n value: unknown,\n ) => string;\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: seriesValueUnknown } = series;\n\n const seriesValue = Array.isArray(seriesValueUnknown)\n ? seriesValueUnknown[1]\n : seriesValueUnknown;\n\n const isThresholdLine =\n series.seriesName.startsWith('thresholdLine');\n\n const notifications = thresholdLines\n .filter((threshold) => {\n const {\n value: thresholdValue,\n condition,\n customCondition,\n } = threshold;\n\n const isConditionMet = customCondition\n ? customCondition(seriesValue, thresholdValue)\n : checkCondition(seriesValue, condition, thresholdValue)\n .isConditionMet;\n\n return !isThresholdLine && isConditionMet;\n })\n .map((threshold) => {\n const {\n notificationType,\n value: thresholdValue,\n condition,\n customConditionText,\n customCondition,\n } = threshold;\n\n return {\n id: `threshold-${notificationType}`,\n notificationType,\n leadingElement: customCondition\n ? customConditionText\n : `${\n checkCondition(\n seriesValue,\n condition,\n thresholdValue,\n ).conditionText\n } threshold`,\n trailingElement: thresholdValue,\n };\n });\n\n const value = extractValueFromTooltipSeries(\n series.value,\n series.encode,\n series.axisDim,\n );\n\n return (\n <ChartTooltip.Content\n key={series.seriesName}\n leadingElement={\n isThresholdLine\n ? `${capitalizeFirstLetter(\n series.seriesName.replace('thresholdLine-', ''),\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 dataZoom,\n toolbox: mergeToolbox(toolboxOptions),\n };\n\n // Update chart with initial option\n const chart = getInstanceByDom(chartEchartRef.current);\n chart?.setOption(option, settings);\n // Get option returns the current option of the chart.\n // This is slightly different than the option we gave as an argument.\n // Because we use useMemo in other areas we want to get this set first,\n // this is why we are setting then getting then returning. If we did this in\n // a useEffect it would run after the other useMemos which is not what we want.\n // This is purely for order of operations.\n const chartOption = chart?.getOption();\n\n return chartOption;\n }, [\n dataset,\n xAxis,\n yAxis,\n userOption,\n hasCategoryXAxis,\n hasSliderZoom,\n series,\n dataZoom,\n toolboxOptions,\n thresholdLines,\n settings,\n ]);\n\n useEffect(() => {\n // Initialize chart\n let chart: ECharts | undefined;\n if (chartEchartRef.current !== null) {\n registerTheme('ndl-light', ndlEchartsTheme('light'));\n registerTheme('ndl-dark', ndlEchartsTheme('dark'));\n\n const currentChart = getInstanceByDom(chartEchartRef.current);\n if (currentChart) {\n chart = currentChart;\n } else {\n const echartsTheme = theme === 'light' ? 'ndl-light' : 'ndl-dark';\n chart = init(chartEchartRef.current, echartsTheme, {\n renderer: 'svg',\n });\n }\n }\n\n if (callbacks?.onZoom) {\n chart?.on('datazoom', () => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const currentChart = getInstanceByDom(chartEchartRef.current);\n if (!currentChart) {\n return;\n }\n\n const option = currentChart.getOption();\n if (!option || !option.dataZoom) {\n return;\n }\n\n const dataZoom = Array.isArray(option.dataZoom)\n ? option.dataZoom[0]\n : option.dataZoom;\n const { startValue, endValue } = dataZoom as {\n startValue: number;\n endValue: number;\n };\n\n callbacks?.onZoom?.({ startValue, endValue });\n });\n }\n\n // Add chart resize listener\n // ResizeObserver is leading to a bit janky UX\n function resizeChart() {\n // TODO: We need to revisit this. Right now using grid containLabel seems to work.\n // We still need to visit this for overflowing of the x-axis labels.\n // const calculateGridLeft = () => {\n // const textElements = chartEchartRef.current?.querySelectorAll('text');\n // const filteredTextElements = Array.from(textElements || []).filter(\n // (element) => element.getAttribute('text-anchor') === 'end',\n // );\n // let maxWidth = 0;\n // filteredTextElements.forEach((element) => {\n // const bbox = element.getBBox();\n // maxWidth = Math.max(maxWidth, bbox.width);\n // });\n // const tickLength = 5;\n // const tickPadding = 3;\n // return maxWidth + tickLength + tickPadding;\n // };\n //\n // // Example of dynamically setting the grid's left\n // const gridLeft = calculateGridLeft();\n // chart?.setOption({\n // grid: {\n // left: gridLeft,\n // },\n // });\n\n // We want to fit the chart to the charts container.\n const chartContainerHeight = chartRef.current?.clientHeight;\n const chartContainerWidth = chartRef.current?.clientWidth;\n // Need to take legends height into consideration, otherwise it will overflow the parent.\n const chartLegendHeight = chartLegendRef?.current?.clientHeight || 0;\n const height = chartContainerHeight\n ? chartContainerHeight - chartLegendHeight\n : undefined;\n chart?.resize({\n width: chartContainerWidth,\n height,\n });\n }\n window.addEventListener('resize', resizeChart);\n requestAnimationFrame(() => {\n resizeChart();\n setIsWaitingForFirstResize(false);\n });\n\n // Add chart zoom listeners\n const handleMouseMove = () => {\n // I do not like this at all: https://github.com/apache/echarts/issues/19819\n // echarts updates the svgs on every mouse movement so we need to do this.\n chart?.getZr().setCursorStyle('default');\n };\n // We cannot use chart.getZr().on('mousemove', handleMouseMove)\n // This is because it doesn't respect our callbacks. It will\n // always run echarts code last instead of our callback.\n const chartChild = chartEchartRef.current?.children[0] as HTMLElement;\n if (!isChartZoomDisabled) {\n chartChild.addEventListener('mousemove', handleMouseMove);\n }\n\n const handleMouseDown = (params: { event: MouseEvent }) => {\n const event = params.event;\n const amountOfMouseClicks = event.detail;\n const isDoubleClick = amountOfMouseClicks === 2;\n if (isDoubleClick) {\n // Reset zooming.\n if (chart === undefined) {\n return;\n }\n chart?.dispatchAction({\n type: 'dataZoom',\n start: 0,\n end: 100,\n });\n if (callbacks?.onZoom) {\n callbacks?.onZoom?.({ startValue: 0, endValue: 100 });\n }\n }\n };\n if (!isChartZoomDisabled) {\n chart?.getZr().on('mousedown', handleMouseDown);\n }\n\n // Return cleanup function\n const chartRefCurrentElement = chartEchartRef.current;\n const element = chartRefCurrentElement?.children[0];\n return () => {\n window.removeEventListener('resize', resizeChart);\n\n element?.removeEventListener('mousemove', handleMouseMove);\n\n // Remove chart zoom handlers\n if (chartRefCurrentElement) {\n const chart = getInstanceByDom(chartRefCurrentElement);\n chart?.getZr().off('mousedown', handleMouseDown);\n }\n };\n });\n\n useEffect(() => {\n if (chartEchartRef.current === null) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef?.current);\n\n if (isLoading === true || isWaitingForFirstResize) {\n chart?.showLoading({\n color: tokens.theme[theme].color.primary.bg.status,\n fontFamily: tokens.typography['label'].fontFamily,\n fontSize: tokens.typography['label'].fontSize,\n fontWeight: tokens.typography['label'].fontWeight,\n maskColor: `rgb( from ${tokens.theme[theme].color.neutral.text.inverse} r g b / 0.8)`,\n text: 'Loading',\n textColor: tokens.theme[theme].color.neutral.text.default,\n });\n } else {\n chart?.hideLoading();\n }\n }, [isLoading, isWaitingForFirstResize, theme]);\n\n const legendSeries = useMemo(() => {\n if (chartEchartRef.current === null || isWaitingForFirstResize) {\n return;\n }\n\n const chart = getInstanceByDom(chartEchartRef?.current);\n const optionSeries = (initialOption?.series as NeedleSeries) ?? [];\n const optionDataset = initialOption?.dataset;\n\n const legendSeries: {\n name: string;\n color: string;\n }[] = [];\n if (Array.isArray(optionSeries)) {\n optionSeries.forEach((currentSeries, index) => {\n if (currentSeries === null) {\n return;\n } else if (\n currentSeries.type === 'line' &&\n typeof currentSeries.name === 'string' &&\n currentSeries.name?.includes('thresholdLine')\n ) {\n return;\n } else if (currentSeries.type === 'pie') {\n const encodedItemName = currentSeries.encode?.itemName;\n let currentDataset = Array.isArray(optionDataset)\n ? optionDataset[0]\n : optionDataset;\n if (currentSeries.datasetId && Array.isArray(optionDataset)) {\n currentDataset = optionDataset.find(\n (ds) => ds.id === currentSeries.datasetId,\n );\n } else if (currentSeries.datasetIndex !== undefined) {\n currentDataset = Array.isArray(optionDataset)\n ? optionDataset[currentSeries.datasetIndex]\n : optionDataset;\n }\n const firstDatasetRow = Array.isArray(currentDataset?.source)\n ? currentDataset?.source[0]\n : undefined;\n if (!firstDatasetRow) {\n return;\n }\n\n if (Array.isArray(firstDatasetRow)) {\n const firstDatasetRowIndex = firstDatasetRow.findIndex(\n (item) => item === encodedItemName,\n );\n\n if (firstDatasetRowIndex === -1) {\n return;\n }\n\n const source = currentDataset?.source;\n if (!source) {\n return;\n }\n\n const sourceLength = Array.isArray(source) ? source.length : 0;\n for (let rowIndex = 1; rowIndex < sourceLength; rowIndex++) {\n const row = source[rowIndex] as (string | number)[];\n const color = chart?.getVisual(\n { dataIndexInside: rowIndex - 1, seriesIndex: index },\n 'color',\n );\n legendSeries.push({\n name: String(row[firstDatasetRowIndex]),\n color: typeof color === 'string' ? color : '#000000',\n });\n }\n } else {\n // TODO: handle dictionary\n }\n\n return;\n } else {\n const name = Array.isArray(optionSeries)\n ? optionSeries[index]?.name\n : undefined;\n\n if (name === undefined) {\n return null;\n }\n\n const color = chart?.getVisual({ seriesIndex: index }, 'color');\n legendSeries.push({\n name: String(name),\n color: typeof color === 'string' ? color : '#000000',\n });\n }\n });\n }\n return legendSeries.filter((currentSeries) => currentSeries !== null);\n }, [isWaitingForFirstResize, initialOption]);\n\n if (chartEchartRef.current !== null && !isChartZoomDisabled) {\n const chart = getInstanceByDom(chartEchartRef.current);\n if (chart) {\n // Needs to be re-set on every re-render.\n // Sets the selectable zoom area over the chart (not the slider).\n chart.dispatchAction({\n type: 'takeGlobalCursor',\n key: 'dataZoomSelect',\n dataZoomSelectActive: true,\n });\n }\n }\n\n return (\n <div ref={chartRef} className=\"ndl-chart\" style={style}>\n <div ref={chartEchartRef} />\n {legend?.show && !isWaitingForFirstResize && (\n <Legend\n ref={chartLegendRef}\n wrappingType={legend.wrappingType}\n series={legendSeries ?? []}\n chartRef={chartEchartRef}\n />\n )}\n </div>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../../src/charts/Chart.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAGL,KAAK,aAAa,EAGlB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,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,EAAE,MAAM,CAAA;SAAE,KAAK,IAAI,CAAC;KACrE,CAAC;IACF,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IACrC,gDAAgD;IAChD,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,wBAAgB,KAAK,CAAC,EACpB,OAAO,EACP,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,WAAW,EACnB,KAAK,EACL,QAIC,EACD,SAAS,EACT,mBAA2B,EAC3B,MAAM,EACN,SAAS,GACV,EAAE,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAwfhC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-ndl/react-charts",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "sideEffects": false,
5
5
  "description": "React implementation of charts from Neo4j Design System",
6
6
  "keywords": [
@@ -54,7 +54,7 @@
54
54
  "react": ">=19.0.0",
55
55
  "react-dom": ">=19.0.0",
56
56
  "@neo4j-ndl/base": "^4.3.3",
57
- "@neo4j-ndl/react": "^4.3.4"
57
+ "@neo4j-ndl/react": "^4.3.5"
58
58
  },
59
59
  "dependencies": {
60
60
  "classnames": "2.5.1",