@cloudscape-design/chart-components 1.0.97 → 1.0.99

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.
@@ -1 +1 @@
1
- {"version":3,"file":"chart-series-cartesian.js","sourceRoot":"","sources":["../../../src/cartesian-chart/chart-series-cartesian.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAItC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAC;AAGnD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEvD,6GAA6G;AAC7G,0HAA0H;AAC1H,4FAA4F;AAC5F,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,cAA4D,EAC5D,aAAgC,EAChC,EAAE;;IACF,4GAA4G;IAC5G,yGAAyG;IACzG,0CAA0C;IAC1C,MAAM,UAAU,GAAuC,EAAE,CAAC;IAC1D,MAAM,UAAU,GAAuC,EAAE,CAAC;IAC1D,KAAK,MAAM,CAAC,IAAI,cAAc,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,EAAE,GAAG,MAAM,CAAC,iBAAiB,EAAE,KAAK,EAAE,MAAA,CAAC,CAAC,KAAK,mCAAI,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAChG,IAAI,CAAC,CAAC,IAAI,KAAK,aAAa,IAAI,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjE,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,MAAA,CAAC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ACH,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAoD,EAAE,aAAgC;IAClH,MAAM,UAAU,GAKV,EAAE,CAAC;IACT,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU,IAAI,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACxF,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type Highcharts from \"highcharts\";\n\nimport { colorChartsErrorBarMarker } from \"@cloudscape-design/design-tokens\";\n\nimport { PointDataItemType, RangeDataItemOptions } from \"../core/interfaces\";\nimport { createBubbleMetadata, createThresholdMetadata, getOptionsId } from \"../core/utils\";\nimport * as Styles from \"../internal/chart-styles\";\nimport { Writeable } from \"../internal/utils/utils\";\nimport { CartesianChartProps } from \"./interfaces\";\nimport { getMasterSeries, isThreshold } from \"./utils\";\n\n// The utility transforms cartesian chart component's series to Highcharts series. This includes transforming\n// custom x- and y-threshold series types, that are represented as a combination of invisible line series, and plot lines.\n// The plot lines, unlike series, are rendered across the entire chart plot width or height.\nexport const transformCartesianSeries = (\n originalSeries: readonly CartesianChartProps.SeriesOptions[],\n visibleSeries: readonly string[],\n) => {\n // The injected plot lines have IDs matching the IDs of the threshold series. This is used by the core chart\n // to manage visibility and highlight state for them, when the corresponding threshold series are toggled\n // or highlighted in the legend or filter.\n const xPlotLines: Highcharts.XAxisPlotLinesOptions[] = [];\n const yPlotLines: Highcharts.YAxisPlotLinesOptions[] = [];\n for (const s of originalSeries) {\n const seriesId = getOptionsId(s);\n const style = { ...Styles.thresholdPlotLine, color: s.color ?? Styles.thresholdPlotLine.color };\n if (s.type === \"x-threshold\" && visibleSeries.includes(seriesId)) {\n xPlotLines.push({ id: seriesId, value: s.value, ...style, dashStyle: s.dashStyle ?? style.dashStyle });\n }\n if (s.type === \"y-threshold\" && visibleSeries.includes(seriesId)) {\n yPlotLines.push({ id: seriesId, value: s.value, ...style, dashStyle: s.dashStyle ?? style.dashStyle });\n }\n }\n\n // Assign linked series color to its respective master series color or color index.\n const autoColorSeries = originalSeries.filter((s) => !isThreshold(s) && !s.linkedTo && !s.color);\n const getColorProps = (s: CartesianChartProps.SeriesOptions) => {\n const masterSeries = getMasterSeries(originalSeries, s);\n if (!masterSeries) {\n return {};\n }\n return { color: s.color ?? masterSeries.color, colorIndex: autoColorSeries.indexOf(masterSeries) };\n };\n\n // The threshold series require data points to enable keyboard navigation and hover effects.\n const thresholdX = getThresholdX(originalSeries, visibleSeries);\n const thresholdY = getThresholdY(originalSeries, visibleSeries);\n function transformSeriesToHighcharts(s: CartesianChartProps.SeriesOptions): Highcharts.SeriesOptionsType {\n // Highcharts does not properly update data on re-render. When the fake empty series is replaced with the real series,\n // the properties are merged together, so the showInLegend=false is not overridden.\n // That is why we explicitly override this property for all real series.\n const isLinked = !isThreshold(s) && s.linkedTo !== undefined;\n const shared = { showInLegend: !isLinked };\n if (isThreshold(s)) {\n const data =\n s.type === \"x-threshold\"\n ? thresholdY.map((y) => ({ x: s.value, y }))\n : thresholdX.map((x) => ({ x, y: s.value }));\n const { custom } = createThresholdMetadata(s.type, s.value);\n const enableMouseTracking = s.type === \"y-threshold\";\n const style = {\n ...Styles.thresholdSeries,\n color: s.color ?? Styles.thresholdSeries.color,\n dashStyle: s.dashStyle ?? Styles.thresholdSeries.dashStyle,\n };\n const yAxis = s.type === \"y-threshold\" ? s.yAxis : undefined;\n return {\n type: \"line\",\n id: s.id,\n name: s.name,\n yAxis,\n data,\n custom,\n enableMouseTracking,\n ...style,\n ...shared,\n };\n }\n if (s.type === \"errorbar\") {\n const color = s.color ?? colorChartsErrorBarMarker;\n // In Highcharts, the error-bar series graphic color is represented as stem-, and whisker colors.\n // We simplify that, and only expose a single color prop that sets both of those.\n const colors = { stemColor: color, whiskerColor: color };\n return { ...s, data: s.data as Writeable<RangeDataItemOptions[]>, ...colors };\n }\n if (s.type === \"bubble\") {\n const { custom } = createBubbleMetadata(s);\n return { ...s, data: s.data.map((p) => ({ x: p.x, y: p.y, z: p.size })), ...shared, custom, ...getColorProps(s) };\n }\n return { ...s, data: s.data as Writeable<PointDataItemType[]>, ...shared, ...getColorProps(s) };\n }\n const series = originalSeries.map(transformSeriesToHighcharts);\n // We inject a fake empty series so that the empty state still shows axes, if defined.\n if (series.length === 0) {\n series.push({ type: \"line\", data: [], showInLegend: false });\n }\n return { series, xPlotLines, yPlotLines };\n};\n\n// For x-threshold the point-based navigation is disabled as irrelevant. However, we still need at least\n// one data point for core chart to work correctly, so we find the first visible y value from other series.\nfunction getThresholdY(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n for (const s of getVisibleDataSeries(series, visibleSeries)) {\n for (const d of s.data) {\n const y = d === null ? null : typeof d === \"number\" ? d : d.y;\n if (y !== null) {\n return [y];\n }\n }\n }\n return [];\n}\n\n// For y-threshold we find all defined x values from other series and use it those to create an array of\n// data points. As result, the y-threshold series becomes properly navigable.\nfunction getThresholdX(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n const allX = new Set<number>();\n for (const s of getVisibleDataSeries(series, visibleSeries)) {\n for (let i = 0; i < s.data.length; i++) {\n const d = s.data[i];\n const x = (typeof d === \"object\" ? d?.x : i) ?? i;\n allX.add(x);\n }\n }\n return [...allX].sort((a, b) => a - b);\n}\n\nfunction getVisibleDataSeries(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n const dataSeries: Exclude<\n CartesianChartProps.SeriesOptions,\n | CartesianChartProps.XThresholdSeriesOptions\n | CartesianChartProps.YThresholdSeriesOptions\n | CartesianChartProps.ErrorBarSeriesOptions\n >[] = [];\n for (const s of series) {\n if (!isThreshold(s) && s.type !== \"errorbar\" && visibleSeries.includes(getOptionsId(s))) {\n dataSeries.push(s);\n }\n }\n return dataSeries;\n}\n"]}
1
+ {"version":3,"file":"chart-series-cartesian.js","sourceRoot":"","sources":["../../../src/cartesian-chart/chart-series-cartesian.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAItC,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAG7E,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAC;AAGnD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEvD,6GAA6G;AAC7G,0HAA0H;AAC1H,4FAA4F;AAC5F,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,cAA4D,EAC5D,aAAgC,EAChC,EAAE;;IACF,4GAA4G;IAC5G,yGAAyG;IACzG,0CAA0C;IAC1C,MAAM,UAAU,GAAuC,EAAE,CAAC;IAC1D,MAAM,UAAU,GAAuC,EAAE,CAAC;IAC1D,KAAK,MAAM,CAAC,IAAI,cAAc,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,EAAE,GAAG,MAAM,CAAC,iBAAiB,EAAE,KAAK,EAAE,MAAA,CAAC,CAAC,KAAK,mCAAI,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;QAChG,IAAI,CAAC,CAAC,IAAI,KAAK,aAAa,IAAI,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACjE,UAAU,CAAC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CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAI,CAAC,CAAC;YAClD,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAoD,EAAE,aAAgC;IAClH,MAAM,UAAU,GAKV,EAAE,CAAC;IACT,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU,IAAI,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACxF,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type Highcharts from \"highcharts\";\n\nimport { colorChartsErrorBarMarker } from \"@cloudscape-design/design-tokens\";\n\nimport { RangeDataItemOptions } from \"../core/interfaces\";\nimport { createBubbleMetadata, createThresholdMetadata, getOptionsId } from \"../core/utils\";\nimport * as Styles from \"../internal/chart-styles\";\nimport { Writeable } from \"../internal/utils/utils\";\nimport { CartesianChartProps } from \"./interfaces\";\nimport { getMasterSeries, isThreshold } from \"./utils\";\n\n// The utility transforms cartesian chart component's series to Highcharts series. This includes transforming\n// custom x- and y-threshold series types, that are represented as a combination of invisible line series, and plot lines.\n// The plot lines, unlike series, are rendered across the entire chart plot width or height.\nexport const transformCartesianSeries = (\n originalSeries: readonly CartesianChartProps.SeriesOptions[],\n visibleSeries: readonly string[],\n) => {\n // The injected plot lines have IDs matching the IDs of the threshold series. This is used by the core chart\n // to manage visibility and highlight state for them, when the corresponding threshold series are toggled\n // or highlighted in the legend or filter.\n const xPlotLines: Highcharts.XAxisPlotLinesOptions[] = [];\n const yPlotLines: Highcharts.YAxisPlotLinesOptions[] = [];\n for (const s of originalSeries) {\n const seriesId = getOptionsId(s);\n const style = { ...Styles.thresholdPlotLine, color: s.color ?? Styles.thresholdPlotLine.color };\n if (s.type === \"x-threshold\" && visibleSeries.includes(seriesId)) {\n xPlotLines.push({ id: seriesId, value: s.value, ...style, dashStyle: s.dashStyle ?? style.dashStyle });\n }\n if (s.type === \"y-threshold\" && visibleSeries.includes(seriesId)) {\n yPlotLines.push({ id: seriesId, value: s.value, ...style, dashStyle: s.dashStyle ?? style.dashStyle });\n }\n }\n\n // Assign linked series color to its respective master series color or color index.\n const autoColorSeries = originalSeries.filter((s) => !isThreshold(s) && !s.linkedTo && !s.color);\n const getColorProps = (s: CartesianChartProps.SeriesOptions) => {\n const masterSeries = getMasterSeries(originalSeries, s);\n if (!masterSeries) {\n return {};\n }\n return { color: s.color ?? masterSeries.color, colorIndex: autoColorSeries.indexOf(masterSeries) };\n };\n\n // The threshold series require data points to enable keyboard navigation and hover effects.\n const thresholdX = getThresholdX(originalSeries, visibleSeries);\n const thresholdY = getThresholdY(originalSeries, visibleSeries);\n function transformSeriesToHighcharts(s: CartesianChartProps.SeriesOptions): Highcharts.SeriesOptionsType {\n // Highcharts does not properly update data on re-render. When the fake empty series is replaced with the real series,\n // the properties are merged together, so the showInLegend=false is not overridden.\n // That is why we explicitly override this property for all real series.\n const isLinked = !isThreshold(s) && s.linkedTo !== undefined;\n const shared = { showInLegend: !isLinked };\n if (isThreshold(s)) {\n const data =\n s.type === \"x-threshold\"\n ? thresholdY.map((y) => ({ x: s.value, y }))\n : thresholdX.map((x) => ({ x, y: s.value }));\n const { custom } = createThresholdMetadata(s.type, s.value);\n const enableMouseTracking = s.type === \"y-threshold\";\n const style = {\n ...Styles.thresholdSeries,\n color: s.color ?? Styles.thresholdSeries.color,\n dashStyle: s.dashStyle ?? Styles.thresholdSeries.dashStyle,\n };\n const yAxis = s.type === \"y-threshold\" ? s.yAxis : undefined;\n return {\n type: \"line\",\n id: s.id,\n name: s.name,\n yAxis,\n data,\n custom,\n enableMouseTracking,\n ...style,\n ...shared,\n };\n }\n if (s.type === \"errorbar\") {\n const color = s.color ?? colorChartsErrorBarMarker;\n // In Highcharts, the error-bar series graphic color is represented as stem-, and whisker colors.\n // We simplify that, and only expose a single color prop that sets both of those.\n const colors = { stemColor: color, whiskerColor: color };\n return { ...s, data: s.data as Writeable<RangeDataItemOptions[]>, ...colors };\n }\n if (s.type === \"bubble\") {\n const { custom } = createBubbleMetadata(s);\n return { ...s, data: s.data.map((p) => ({ x: p.x, y: p.y, z: p.size })), ...shared, custom, ...getColorProps(s) };\n }\n return { ...s, data: s.data, ...shared, ...getColorProps(s) } as Highcharts.SeriesOptionsType;\n }\n const series = originalSeries.map(transformSeriesToHighcharts);\n // We inject a fake empty series so that the empty state still shows axes, if defined.\n if (series.length === 0) {\n series.push({ type: \"line\", data: [], showInLegend: false });\n }\n return { series, xPlotLines, yPlotLines };\n};\n\n// For x-threshold the point-based navigation is disabled as irrelevant. However, we still need at least\n// one data point for core chart to work correctly, so we find the first visible y value from other series.\nfunction getThresholdY(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n for (const s of getVisibleDataSeries(series, visibleSeries)) {\n for (const d of s.data) {\n const y = d === null ? null : typeof d === \"number\" ? d : d.y;\n if (y !== null) {\n return [y];\n }\n }\n }\n return [];\n}\n\n// For y-threshold we find all defined x values from other series and use it those to create an array of\n// data points. As result, the y-threshold series becomes properly navigable.\nfunction getThresholdX(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n const allX = new Set<number>();\n for (const s of getVisibleDataSeries(series, visibleSeries)) {\n for (let i = 0; i < s.data.length; i++) {\n const d = s.data[i];\n const x = (typeof d === \"object\" ? d?.x : i) ?? i;\n allX.add(x);\n }\n }\n return [...allX].sort((a, b) => a - b);\n}\n\nfunction getVisibleDataSeries(series: readonly CartesianChartProps.SeriesOptions[], visibleSeries: readonly string[]) {\n const dataSeries: Exclude<\n CartesianChartProps.SeriesOptions,\n | CartesianChartProps.XThresholdSeriesOptions\n | CartesianChartProps.YThresholdSeriesOptions\n | CartesianChartProps.ErrorBarSeriesOptions\n >[] = [];\n for (const s of series) {\n if (!isThreshold(s) && s.type !== \"errorbar\" && visibleSeries.includes(getOptionsId(s))) {\n dataSeries.push(s);\n }\n }\n return dataSeries;\n}\n"]}
@@ -85,6 +85,7 @@ function transformLineLikeSeries(s, allSeries) {
85
85
  dashStyle: s.dashStyle,
86
86
  yAxis: s.yAxis,
87
87
  linkedTo: s.linkedTo,
88
+ ...transformZones(s),
88
89
  data,
89
90
  };
90
91
  }
@@ -93,7 +94,16 @@ function transformColumnSeries(s, allSeries) {
93
94
  return null;
94
95
  }
95
96
  const data = transformPointData(s.data);
96
- return { type: s.type, id: s.id, name: s.name, color: s.color, yAxis: s.yAxis, linkedTo: s.linkedTo, data };
97
+ return {
98
+ type: s.type,
99
+ id: s.id,
100
+ name: s.name,
101
+ color: s.color,
102
+ yAxis: s.yAxis,
103
+ linkedTo: s.linkedTo,
104
+ ...transformZones(s),
105
+ data,
106
+ };
97
107
  }
98
108
  function transformScatterSeries(s, allSeries) {
99
109
  var _a;
@@ -172,6 +182,12 @@ function transformBubbleData(data) {
172
182
  function transformRangeData(data) {
173
183
  return data.map((d) => ({ x: d.x, low: d.low, high: d.high }));
174
184
  }
185
+ function transformZones(series) {
186
+ var _a;
187
+ const zoneAxis = series.zoneAxis === "x" || series.zoneAxis === "y" ? series.zoneAxis : undefined;
188
+ const zones = (_a = series.zones) === null || _a === void 0 ? void 0 : _a.map(({ value, color, dashStyle }) => ({ value, color, dashStyle }));
189
+ return { zoneAxis, zones };
190
+ }
175
191
  function transformXAxisOptions(axis) {
176
192
  return transformAxisOptions(axis);
177
193
  }
@@ -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AAY;QAChC,UAAU,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU;QAC5B,cAAc,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,cAAc;KAChC,CAAC;AACT,CAAC;AAED,SAAS,gBAAgB,CACvB,OAA4C;;IAE5C,OAAO;QACL,GAAG,OAAO;QACV,OAAO,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,mCAAI,IAAI;QACjC,SAAS,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,mCAAI,QAAQ;QACzC,IAAI,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,mCAAI,QAAQ;KAChC,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CACtB,MAA0C;;IAE1C,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,mCAAI,IAAI,EAAE,CAAC;AACzD,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { forwardRef } from \"react\";\n\nimport { warnOnce } from \"@cloudscape-design/component-toolkit/internal\";\n\nimport { PointDataItemType, RangeDataItemOptions, SizePointDataItemOptions } from \"../core/interfaces\";\nimport { getDataAttributes } from \"../internal/base-component/get-data-attributes\";\nimport useBaseComponent from \"../internal/base-component/use-base-component\";\nimport { applyDisplayName } from \"../internal/utils/apply-display-name\";\nimport { castArray, SomeRequired } from \"../internal/utils/utils\";\nimport { InternalCartesianChart } from \"./chart-cartesian-internal\";\nimport { CartesianChartProps } from \"./interfaces\";\nimport { getMasterSeries, isErrorBar, isThreshold } from \"./utils\";\n\nexport type { CartesianChartProps };\n\nconst CartesianChart = forwardRef(\n (\n {\n fitHeight = false,\n inverted = false,\n stacking = undefined,\n emphasizeBaseline = true,\n verticalAxisTitlePlacement = \"top\",\n ...props\n }: CartesianChartProps,\n ref: React.Ref<CartesianChartProps.Ref>,\n ) => {\n // We transform options before propagating them to the internal chart to ensure only those\n // defined in the component's contract can be propagated down to the underlying Highcharts.\n // Additionally, we assign all default options, including the nested ones.\n const series = transformSeries(props.series, stacking);\n const xAxis = transformXAxisOptions(props.xAxis);\n const yAxis = transformYAxisOptions(props.yAxis);\n const sizeAxis = transformSizeAxisOptions(props.sizeAxis);\n const tooltip = transformTooltip(props.tooltip);\n const legend = transformLegend(props.legend);\n\n const baseComponentProps = useBaseComponent(\"CartesianHighcharts\", {\n props: { fitHeight, inverted, stacking, emphasizeBaseline, verticalAxisTitlePlacement },\n metadata: {},\n });\n\n return (\n <InternalCartesianChart\n ref={ref}\n {...props}\n fitHeight={fitHeight}\n inverted={inverted}\n stacking={stacking}\n emphasizeBaseline={emphasizeBaseline}\n verticalAxisTitlePlacement={verticalAxisTitlePlacement}\n series={series}\n xAxis={xAxis}\n yAxis={yAxis}\n sizeAxis={sizeAxis}\n tooltip={tooltip}\n legend={legend}\n {...getDataAttributes(props)}\n {...baseComponentProps}\n />\n );\n },\n);\n\napplyDisplayName(CartesianChart, \"CartesianChart\");\n\nexport default CartesianChart;\n\nfunction transformSeries(\n untransformedSeries: readonly CartesianChartProps.SeriesOptions[],\n stacking?: \"normal\",\n): CartesianChartProps.SeriesOptions[] {\n const transformedSeries: CartesianChartProps.SeriesOptions[] = [];\n function transformSingleSeries(s: CartesianChartProps.SeriesOptions): null | CartesianChartProps.SeriesOptions {\n switch (s.type) {\n case \"area\":\n case \"areaspline\":\n case \"line\":\n case \"spline\":\n return transformLineLikeSeries(s, untransformedSeries);\n case \"column\":\n return transformColumnSeries(s, untransformedSeries);\n case \"scatter\":\n return transformScatterSeries(s, untransformedSeries);\n case \"bubble\":\n return transformBubbleSeries(s, untransformedSeries);\n case \"errorbar\":\n return transformErrorBarSeries(s, untransformedSeries, stacking);\n case \"x-threshold\":\n case \"y-threshold\":\n return transformThresholdSeries(s);\n default:\n return null;\n }\n }\n for (const series of untransformedSeries) {\n const transformed = transformSingleSeries(series);\n if (transformed) {\n transformedSeries.push(transformed);\n }\n }\n return transformedSeries;\n}\n\nfunction validateLinkedTo(\n series: CartesianChartProps.SeriesOptions,\n allSeries: readonly CartesianChartProps.SeriesOptions[],\n): boolean {\n if (isThreshold(series) || series.linkedTo === undefined) {\n return true;\n }\n // The incorrectly linked series will not appear in our custom legend and tooltip, so we remove them\n // from the series array. We also do not support linking series to errorbar or threshold series.\n const masterSeries = getMasterSeries(allSeries, series);\n if (!masterSeries || isErrorBar(masterSeries) || isThreshold(masterSeries)) {\n warnOnce(\"CartesianChart\", \"The `linkedTo` property points to a missing or unsupported series.\");\n return false;\n }\n return true;\n}\n\nfunction transformLineLikeSeries<\n S extends\n | CartesianChartProps.AreaSeriesOptions\n | CartesianChartProps.AreaSplineSeriesOptions\n | CartesianChartProps.LineSeriesOptions\n | CartesianChartProps.SplineSeriesOptions,\n>(s: S, allSeries: readonly CartesianChartProps.SeriesOptions[]): null | S {\n if (!validateLinkedTo(s, allSeries)) {\n return null;\n }\n const data = transformPointData(s.data);\n return {\n type: s.type,\n id: s.id,\n name: s.name,\n color: s.color,\n dashStyle: s.dashStyle,\n yAxis: s.yAxis,\n linkedTo: s.linkedTo,\n data,\n } as S;\n}\n\nfunction transformColumnSeries<S extends CartesianChartProps.ColumnSeriesOptions>(\n s: S,\n allSeries: readonly CartesianChartProps.SeriesOptions[],\n): null | S {\n if (!validateLinkedTo(s, allSeries)) {\n return null;\n }\n const data = transformPointData(s.data);\n return { type: s.type, id: s.id, name: s.name, color: s.color, yAxis: s.yAxis, linkedTo: s.linkedTo, data } as S;\n}\n\nfunction transformScatterSeries<S extends CartesianChartProps.ScatterSeriesOptions>(\n s: S,\n allSeries: readonly CartesianChartProps.SeriesOptions[],\n): null | S {\n if (!validateLinkedTo(s, allSeries)) {\n return null;\n }\n const data = transformPointData(s.data);\n const marker = s.marker ?? {};\n return {\n type: s.type,\n id: s.id,\n name: s.name,\n color: s.color,\n yAxis: s.yAxis,\n linkedTo: s.linkedTo,\n data,\n marker,\n } as S;\n}\n\nfunction transformBubbleSeries<S extends CartesianChartProps.BubbleSeriesOptions>(\n s: S,\n allSeries: readonly CartesianChartProps.SeriesOptions[],\n): null | S {\n if (!validateLinkedTo(s, allSeries)) {\n return null;\n }\n const data = transformBubbleData(s.data);\n return {\n type: s.type,\n id: s.id,\n name: s.name,\n color: s.color,\n data,\n yAxis: s.yAxis,\n sizeAxis: s.sizeAxis,\n linkedTo: s.linkedTo,\n } as S;\n}\n\nfunction transformThresholdSeries<\n S extends CartesianChartProps.XThresholdSeriesOptions | CartesianChartProps.YThresholdSeriesOptions,\n>(s: S): null | S {\n const yAxis = s.type === \"y-threshold\" ? s.yAxis : undefined;\n return {\n type: s.type,\n id: s.id,\n name: s.name,\n color: s.color,\n yAxis,\n value: s.value,\n dashStyle: s.dashStyle,\n } as S;\n}\n\nfunction transformErrorBarSeries(\n series: CartesianChartProps.ErrorBarSeriesOptions,\n allSeries: readonly CartesianChartProps.SeriesOptions[],\n stacking?: \"normal\",\n): null | CartesianChartProps.ErrorBarSeriesOptions {\n // Highcharts only supports error bars for non-stacked series.\n // See: https://github.com/highcharts/highcharts/issues/23080.\n if (stacking) {\n warnOnce(\"CartesianChart\", \"Error bars are not supported for stacked series.\");\n return null;\n }\n // We only support error bars that are linked to some other series.\n if (!validateLinkedTo(series, allSeries)) {\n return null;\n }\n const data = transformRangeData(series.data);\n return {\n type: series.type,\n id: series.id,\n name: series.name,\n color: series.color,\n yAxis: series.yAxis,\n linkedTo: series.linkedTo,\n data,\n };\n}\n\nfunction transformPointData(data: readonly PointDataItemType[]): readonly PointDataItemType[] {\n return data.map((d) => (d && typeof d === \"object\" ? { x: d.x, y: d.y } : d));\n}\n\nfunction transformBubbleData(data: readonly SizePointDataItemOptions[]): readonly SizePointDataItemOptions[] {\n return data.map((d) => ({ x: d.x, y: d.y, size: d.size }));\n}\n\nfunction transformRangeData(data: readonly RangeDataItemOptions[]): readonly RangeDataItemOptions[] {\n return data.map((d) => ({ x: d.x, low: d.low, high: d.high }));\n}\n\nfunction transformXAxisOptions(axis?: CartesianChartProps.XAxisOptions): CartesianChartProps.XAxisOptions {\n return transformAxisOptions(axis);\n}\n\nfunction transformYAxisOptions(\n axis?: CartesianChartProps.YAxisOptions | [CartesianChartProps.YAxisWithId, CartesianChartProps.YAxisWithId],\n): CartesianChartProps.YAxisOptions | [CartesianChartProps.YAxisWithId, CartesianChartProps.YAxisWithId] {\n if (Array.isArray(axis)) {\n return [transformSingleYAxisOptions(axis[0]), transformSingleYAxisOptions(axis[1])];\n }\n return transformSingleYAxisOptions(axis);\n}\n\nfunction transformSingleYAxisOptions<T extends CartesianChartProps.YAxisOptions>(axis?: T): T {\n return { ...transformAxisOptions(axis), reversedStacks: axis?.reversedStacks } as T;\n}\n\nfunction transformSizeAxisOptions(\n axis?: CartesianChartProps.SizeAxisOptions | readonly CartesianChartProps.SizeAxisOptions[],\n): undefined | CartesianChartProps.SizeAxisOptions[] {\n return castArray(axis as CartesianChartProps.SizeAxisOptions[])?.map((a) => ({\n id: a.id,\n title: a.title,\n valueFormatter: a.valueFormatter,\n }));\n}\n\nfunction transformAxisOptions<O extends CartesianChartProps.XAxisOptions | CartesianChartProps.YAxisOptions>(\n axis?: O,\n): O {\n return {\n id: axis?.id,\n type: axis?.type,\n title: axis?.title,\n min: axis?.min,\n max: axis?.max,\n tickInterval: axis?.tickInterval,\n categories: axis?.categories,\n valueFormatter: axis?.valueFormatter,\n } as O;\n}\n\nfunction transformTooltip(\n tooltip?: CartesianChartProps.TooltipOptions,\n): SomeRequired<CartesianChartProps.TooltipOptions, \"enabled\" | \"placement\" | \"size\"> {\n return {\n ...tooltip,\n enabled: tooltip?.enabled ?? true,\n placement: tooltip?.placement ?? \"middle\",\n size: tooltip?.size ?? \"medium\",\n };\n}\n\nfunction transformLegend(\n legend?: CartesianChartProps.LegendOptions,\n): SomeRequired<CartesianChartProps.LegendOptions, \"enabled\"> {\n return { ...legend, enabled: legend?.enabled ?? true };\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cartesian-chart/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAGzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,gBAAgB,MAAM,+CAA+C,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAgB,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAInE,MAAM,cAAc,GAAG,UAAU,CAC/B,CACE,EACE,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,QAAQ,GAAG,SAAS,EACpB,iBAAiB,GAAG,IAAI,EACxB,0BAA0B,GAAG,KAAK,EAClC,GAAG,KAAK,EACY,EACtB,GAAuC,EACvC,EAAE;IACF,0FAA0F;IAC1F,2FAA2F;IAC3F,0EAA0E;IAC1E,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,wBAAwB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,MAAM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esContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { forwardRef } from \"react\";\n\nimport { warnOnce } from \"@cloudscape-design/component-toolkit/internal\";\n\nimport { PointDataItemType, RangeDataItemOptions, SizePointDataItemOptions, WithZones } from \"../core/interfaces\";\nimport { getDataAttributes } from \"../internal/base-component/get-data-attributes\";\nimport useBaseComponent from \"../internal/base-component/use-base-component\";\nimport { applyDisplayName } from \"../internal/utils/apply-display-name\";\nimport { castArray, SomeRequired } from \"../internal/utils/utils\";\nimport { InternalCartesianChart } from \"./chart-cartesian-internal\";\nimport { CartesianChartProps } from \"./interfaces\";\nimport { getMasterSeries, isErrorBar, isThreshold } from \"./utils\";\n\nexport type { CartesianChartProps };\n\nconst CartesianChart = forwardRef(\n (\n {\n fitHeight = false,\n inverted = false,\n stacking = undefined,\n emphasizeBaseline = true,\n verticalAxisTitlePlacement = \"top\",\n ...props\n }: CartesianChartProps,\n ref: React.Ref<CartesianChartProps.Ref>,\n ) => {\n // We transform options before propagating them to the internal chart to ensure only those\n // defined in the component's contract can be propagated down to the underlying Highcharts.\n // Additionally, we assign all default options, including the nested ones.\n const series = transformSeries(props.series, stacking);\n const xAxis = transformXAxisOptions(props.xAxis);\n const yAxis = transformYAxisOptions(props.yAxis);\n const sizeAxis = transformSizeAxisOptions(props.sizeAxis);\n const tooltip = transformTooltip(props.tooltip);\n const legend = transformLegend(props.legend);\n\n const baseComponentProps = useBaseComponent(\"CartesianHighcharts\", {\n props: { fitHeight, inverted, stacking, emphasizeBaseline, verticalAxisTitlePlacement },\n metadata: {},\n });\n\n return (\n <InternalCartesianChart\n ref={ref}\n {...props}\n fitHeight={fitHeight}\n inverted={inverted}\n stacking={stacking}\n emphasizeBaseline={emphasizeBaseline}\n verticalAxisTitlePlacement={verticalAxisTitlePlacement}\n series={series}\n xAxis={xAxis}\n yAxis={yAxis}\n sizeAxis={sizeAxis}\n tooltip={tooltip}\n legend={legend}\n {...getDataAttributes(props)}\n {...baseComponentProps}\n />\n );\n },\n);\n\napplyDisplayName(CartesianChart, \"CartesianChart\");\n\nexport default CartesianChart;\n\nfunction transformSeries(\n untransformedSeries: readonly CartesianChartProps.SeriesOptions[],\n stacking?: \"normal\",\n): CartesianChartProps.SeriesOptions[] {\n const transformedSeries: CartesianChartProps.SeriesOptions[] = [];\n function transformSingleSeries(s: CartesianChartProps.SeriesOptions): null | CartesianChartProps.SeriesOptions {\n switch (s.type) {\n case \"area\":\n case \"areaspline\":\n case \"line\":\n case \"spline\":\n return transformLineLikeSeries(s, untransformedSeries);\n case \"column\":\n return transformColumnSeries(s, untransformedSeries);\n case \"scatter\":\n return transformScatterSeries(s, untransformedSeries);\n case \"bubble\":\n return transformBubbleSeries(s, untransformedSeries);\n case \"errorbar\":\n return transformErrorBarSeries(s, untransformedSeries, stacking);\n case \"x-threshold\":\n case \"y-threshold\":\n return transformThresholdSeries(s);\n default:\n return null;\n }\n }\n for (const series of untransformedSeries) {\n const transformed = transformSingleSeries(series);\n if (transformed) {\n transformedSeries.push(transformed);\n }\n }\n return transformedSeries;\n}\n\nfunction validateLinkedTo(\n series: CartesianChartProps.SeriesOptions,\n allSeries: readonly CartesianChartProps.SeriesOptions[],\n): boolean {\n if (isThreshold(series) || series.linkedTo === undefined) {\n return true;\n }\n // The incorrectly linked series will not appear in our custom legend and tooltip, so we remove them\n // from the series array. We also do not support linking series to errorbar or threshold series.\n const masterSeries = getMasterSeries(allSeries, series);\n if (!masterSeries || isErrorBar(masterSeries) || isThreshold(masterSeries)) {\n warnOnce(\"CartesianChart\", \"The `linkedTo` property points to a missing or unsupported series.\");\n return false;\n }\n return true;\n}\n\nfunction transformLineLikeSeries<\n S extends\n | CartesianChartProps.AreaSeriesOptions\n | CartesianChartProps.AreaSplineSeriesOptions\n | CartesianChartProps.LineSeriesOptions\n | CartesianChartProps.SplineSeriesOptions,\n>(s: S, allSeries: readonly CartesianChartProps.SeriesOptions[]): null | S {\n if (!validateLinkedTo(s, allSeries)) {\n return null;\n }\n const data = transformPointData(s.data);\n return {\n type: s.type,\n id: s.id,\n name: s.name,\n color: s.color,\n dashStyle: s.dashStyle,\n yAxis: s.yAxis,\n linkedTo: s.linkedTo,\n ...transformZones(s),\n data,\n } as S;\n}\n\nfunction transformColumnSeries<S extends CartesianChartProps.ColumnSeriesOptions>(\n s: S,\n allSeries: readonly CartesianChartProps.SeriesOptions[],\n): null | S {\n if (!validateLinkedTo(s, allSeries)) {\n return null;\n }\n const data = transformPointData(s.data);\n return {\n type: s.type,\n id: s.id,\n name: s.name,\n color: s.color,\n yAxis: s.yAxis,\n linkedTo: s.linkedTo,\n ...transformZones(s),\n data,\n } as S;\n}\n\nfunction transformScatterSeries<S extends CartesianChartProps.ScatterSeriesOptions>(\n s: S,\n allSeries: readonly CartesianChartProps.SeriesOptions[],\n): null | S {\n if (!validateLinkedTo(s, allSeries)) {\n return null;\n }\n const data = transformPointData(s.data);\n const marker = s.marker ?? {};\n return {\n type: s.type,\n id: s.id,\n name: s.name,\n color: s.color,\n yAxis: s.yAxis,\n linkedTo: s.linkedTo,\n data,\n marker,\n } as S;\n}\n\nfunction transformBubbleSeries<S extends CartesianChartProps.BubbleSeriesOptions>(\n s: S,\n allSeries: readonly CartesianChartProps.SeriesOptions[],\n): null | S {\n if (!validateLinkedTo(s, allSeries)) {\n return null;\n }\n const data = transformBubbleData(s.data);\n return {\n type: s.type,\n id: s.id,\n name: s.name,\n color: s.color,\n data,\n yAxis: s.yAxis,\n sizeAxis: s.sizeAxis,\n linkedTo: s.linkedTo,\n } as S;\n}\n\nfunction transformThresholdSeries<\n S extends CartesianChartProps.XThresholdSeriesOptions | CartesianChartProps.YThresholdSeriesOptions,\n>(s: S): null | S {\n const yAxis = s.type === \"y-threshold\" ? s.yAxis : undefined;\n return {\n type: s.type,\n id: s.id,\n name: s.name,\n color: s.color,\n yAxis,\n value: s.value,\n dashStyle: s.dashStyle,\n } as S;\n}\n\nfunction transformErrorBarSeries(\n series: CartesianChartProps.ErrorBarSeriesOptions,\n allSeries: readonly CartesianChartProps.SeriesOptions[],\n stacking?: \"normal\",\n): null | CartesianChartProps.ErrorBarSeriesOptions {\n // Highcharts only supports error bars for non-stacked series.\n // See: https://github.com/highcharts/highcharts/issues/23080.\n if (stacking) {\n warnOnce(\"CartesianChart\", \"Error bars are not supported for stacked series.\");\n return null;\n }\n // We only support error bars that are linked to some other series.\n if (!validateLinkedTo(series, allSeries)) {\n return null;\n }\n const data = transformRangeData(series.data);\n return {\n type: series.type,\n id: series.id,\n name: series.name,\n color: series.color,\n yAxis: series.yAxis,\n linkedTo: series.linkedTo,\n data,\n };\n}\n\nfunction transformPointData(data: readonly PointDataItemType[]): readonly PointDataItemType[] {\n return data.map((d) => (d && typeof d === \"object\" ? { x: d.x, y: d.y } : d));\n}\n\nfunction transformBubbleData(data: readonly SizePointDataItemOptions[]): readonly SizePointDataItemOptions[] {\n return data.map((d) => ({ x: d.x, y: d.y, size: d.size }));\n}\n\nfunction transformRangeData(data: readonly RangeDataItemOptions[]): readonly RangeDataItemOptions[] {\n return data.map((d) => ({ x: d.x, low: d.low, high: d.high }));\n}\n\nfunction transformZones(series: WithZones) {\n const zoneAxis = series.zoneAxis === \"x\" || series.zoneAxis === \"y\" ? series.zoneAxis : undefined;\n const zones = series.zones?.map(({ value, color, dashStyle }) => ({ value, color, dashStyle }));\n return { zoneAxis, zones };\n}\n\nfunction transformXAxisOptions(axis?: CartesianChartProps.XAxisOptions): CartesianChartProps.XAxisOptions {\n return transformAxisOptions(axis);\n}\n\nfunction transformYAxisOptions(\n axis?: CartesianChartProps.YAxisOptions | [CartesianChartProps.YAxisWithId, CartesianChartProps.YAxisWithId],\n): CartesianChartProps.YAxisOptions | [CartesianChartProps.YAxisWithId, CartesianChartProps.YAxisWithId] {\n if (Array.isArray(axis)) {\n return [transformSingleYAxisOptions(axis[0]), transformSingleYAxisOptions(axis[1])];\n }\n return transformSingleYAxisOptions(axis);\n}\n\nfunction transformSingleYAxisOptions<T extends CartesianChartProps.YAxisOptions>(axis?: T): T {\n return { ...transformAxisOptions(axis), reversedStacks: axis?.reversedStacks } as T;\n}\n\nfunction transformSizeAxisOptions(\n axis?: CartesianChartProps.SizeAxisOptions | readonly CartesianChartProps.SizeAxisOptions[],\n): undefined | CartesianChartProps.SizeAxisOptions[] {\n return castArray(axis as CartesianChartProps.SizeAxisOptions[])?.map((a) => ({\n id: a.id,\n title: a.title,\n valueFormatter: a.valueFormatter,\n }));\n}\n\nfunction transformAxisOptions<O extends CartesianChartProps.XAxisOptions | CartesianChartProps.YAxisOptions>(\n axis?: O,\n): O {\n return {\n id: axis?.id,\n type: axis?.type,\n title: axis?.title,\n min: axis?.min,\n max: axis?.max,\n tickInterval: axis?.tickInterval,\n categories: axis?.categories,\n valueFormatter: axis?.valueFormatter,\n } as O;\n}\n\nfunction transformTooltip(\n tooltip?: CartesianChartProps.TooltipOptions,\n): SomeRequired<CartesianChartProps.TooltipOptions, \"enabled\" | \"placement\" | \"size\"> {\n return {\n ...tooltip,\n enabled: tooltip?.enabled ?? true,\n placement: tooltip?.placement ?? \"middle\",\n size: tooltip?.size ?? \"medium\",\n };\n}\n\nfunction transformLegend(\n legend?: CartesianChartProps.LegendOptions,\n): SomeRequired<CartesianChartProps.LegendOptions, \"enabled\"> {\n return { ...legend, enabled: legend?.enabled ?? true };\n}\n"]}
@@ -182,6 +182,7 @@ export declare namespace CartesianChartProps {
182
182
  series: NonErrorBarSeriesOptions;
183
183
  }
184
184
  export type TooltipPointFormatted = CoreTypes.BaseTooltipPointFormatted;
185
+ export type SeriesZone = CoreTypes.SeriesZone;
185
186
  export type LegendOptions = CoreTypes.BaseLegendOptions;
186
187
  export type FilterOptions = CoreTypes.BaseFilterOptions;
187
188
  export type NoDataOptions = CoreTypes.BaseNoDataOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/cartesian-chart/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport * as CoreTypes from \"../core/interfaces\";\nimport { NonCancelableEventHandler } from \"../internal/events\";\n\n// CartesianChartProps is the type for CartesianChart React component properties. Unlike in Highcharts API,\n// we pass options directly to the component, instead of grouping them all into a single \"options\" property.\n// We do still organize related options in groups, e.g.: \"SeriesOptions\", \"TooltipOptions\".\nexport interface CartesianChartProps\n extends CoreTypes.BaseChartOptions, CoreTypes.CoreCartesianOptions, CoreTypes.WithCartesianI18nStrings {\n /**\n * Inverts X and Y axes. Use it to show horizontal columns (bars).\n * This property corresponds to [chart.inverted](https://api.highcharts.com/highcharts/chart.inverted).\n */\n inverted?: boolean;\n\n /**\n * Enables series stacking behavior. Use it for column- or area- series.\n * This property corresponds to \"normal\" stacking type in Highcharts ([plotOptions.series.stacking](https://api.highcharts.com/highcharts/plotOptions.series.stacking)).\n */\n stacking?: \"normal\";\n\n /**\n * Defines series options of the chart.\n * This property corresponds to [series](https://api.highcharts.com/highcharts/series), and extends it\n * with two additional series types: \"x-threshold\", and \"y-threshold\".\n *\n * Supported types:\n * * [area](https://api.highcharts.com/highcharts/series.area).\n * * [areaspline](https://api.highcharts.com/highcharts/series.areaspline).\n * * [column](https://api.highcharts.com/highcharts/series.column).\n * * [errorbar](https://api.highcharts.com/highcharts/series.errorbar) - requires \"highcharts/highcharts-more\" module.\n * * [line](https://api.highcharts.com/highcharts/series.line).\n * * [bubble](https://api.highcharts.com/highcharts/series.bubble) - requires \"highcharts/highcharts-more\" module.\n * * [scatter](https://api.highcharts.com/highcharts/series.scatter).\n * * [spline](https://api.highcharts.com/highcharts/series.spline).\n * * x-threshold - The line-like series to represent x-axis threshold (vertical, when `inverted=false`).\n * * y-threshold - The line-like series to represent y-axis threshold (horizontal, when `inverted=false`).\n */\n series: readonly CartesianChartProps.SeriesOptions[];\n\n /**\n * Defines tooltip options of the chart, including:\n * * `enabled` - (optional, boolean) - Hides the tooltip when set to false.\n * * `size` - (optional, \"small\" | \"medium\" | \"large\") - Specifies max tooltip size.\n * * `placement` - (optional, \"middle\" | \"outside\") - Specifies preferred tooltip placement.\n * * `point` - (optional, function) - Customizes tooltip series point rendering.\n * * `header` - (optional, function) - Renders a custom tooltip header.\n * * `body` - (optional, function) - Renders a custom tooltip body.\n * * `footer` - (optional, function) - Renders a custom tooltip footer.\n */\n tooltip?: CartesianChartProps.TooltipOptions;\n\n /**\n * Defines options of the chart's x axis.\n * This property corresponds to [xAxis](https://api.highcharts.com/highcharts/xAxis), and extends it\n * with a custom value formatter.\n *\n * Supported options:\n * * `title` (optional, string) - Axis title.\n * * `type` (optional, \"linear\" | \"datetime\" | \"category\" | \"logarithmic\") - Axis type.\n * * * \"linear\" - Uses continuous proportional values scale.\n * * * \"datetime\" - Similar to linear, but takes epoch time as values.\n * * * \"category\" - Uses discrete scale, requires `categories` to be set.\n * * * \"logarithmic\" - Uses continuous logarithmic values scale.\n * * `min` (optional, number) - Axis min value boundary.\n * * `max` (optional, number) - Axis max value boundary.\n * * `tickInterval` (optional, number) - Distance between axis ticks.\n * * `categories` (optional, Array<string>) - Predefined list of values, used for categorical axis type.\n * * `valueFormatter` (optional, function) - Takes axis tick as input and returns a formatted string. This formatter also\n * applies to the tooltip header.\n */\n xAxis?: CartesianChartProps.XAxisOptions;\n\n /**\n * Defines options of the chart's y axis.\n * This property corresponds to [yAxis](https://api.highcharts.com/highcharts/yAxis), and extends it\n * with a custom value formatter.\n *\n * Use a single object for a single y axis, or a tuple of two objects for a dual-axis chart.\n * When using a tuple, both axes must have an `id`. The second axis is automatically rendered on the opposite (inline-end) side.\n * Series reference their axis by setting `yAxis` to the axis `id`.\n *\n * Supported options:\n * * `title` (optional, string) - Axis title.\n * * `type` (optional, \"linear\" | \"datetime\" | \"category\" | \"logarithmic\") - Axis type.\n * * * \"linear\" - Uses continuous proportional values scale.\n * * * \"datetime\" - Similar to linear, but takes epoch time as values.\n * * * \"category\" - Uses discrete scale, requires `categories` to be set.\n * * * \"logarithmic\" - Uses continuous logarithmic values scale.\n * * `min` (optional, number) - Axis min value boundary.\n * * `max` (optional, number) - Axis max value boundary.\n * * `tickInterval` (optional, number) - Distance between axis ticks.\n * * `categories` (optional, Array<string>) - Predefined list of values, used for categorical axis type.\n * * `reversedStacks` (optional, boolean) - Reverts series order in stacked series.\n * * `valueFormatter` (optional, function) - Takes axis tick as input and returns a formatted string. This formatter also\n * applies to the tooltip points values.\n */\n yAxis?: CartesianChartProps.YAxisOptions | [CartesianChartProps.YAxisWithId, CartesianChartProps.YAxisWithId];\n\n /**\n * One or multiple axes to provide size details formatting for bubble series.\n *\n * Supported options:\n * * `id` (optional, string) - Use it to connect axes with respective series when multiple size axes are present. The axis id must correspond `sizeAxis` property of the bubble series.\n * * `title` (string) - Axis title, shown in the tooltip details for bubble series.\n * * `valueFormatter` (optional, function) - Value formatter for `size` values of the bubble series data.\n */\n sizeAxis?: CartesianChartProps.SizeAxisOptions | readonly CartesianChartProps.SizeAxisOptions[];\n\n /**\n * Specifies which series to show using their IDs. By default, all series are visible and managed by the component.\n * If a series doesn't have an ID, its name is used. When using this property, manage state updates with `onVisibleSeriesChange`.\n */\n visibleSeries?: readonly string[];\n\n /**\n * A callback function, triggered when series visibility changes as a result of user interaction with the legend or filter.\n */\n onVisibleSeriesChange?: NonCancelableEventHandler<{ visibleSeries: string[] }>;\n}\n\nexport namespace CartesianChartProps {\n export interface Ref {\n /**\n * Controls series visibility and works with both controlled and uncontrolled visibility modes.\n */\n setVisibleSeries(visibleSeries: readonly string[]): void;\n /**\n * Functions similarly to `setVisibleSeries`, but applies to all series and doesn't require series IDs as input.\n * Use this when implementing clear-filter actions in no-match states.\n */\n showAllSeries(): void;\n }\n\n export type SeriesOptions =\n | AreaSeriesOptions\n | AreaSplineSeriesOptions\n | BubbleSeriesOptions\n | ColumnSeriesOptions\n | ErrorBarSeriesOptions\n | LineSeriesOptions\n | ScatterSeriesOptions\n | SplineSeriesOptions\n | XThresholdSeriesOptions\n | YThresholdSeriesOptions;\n\n export type AreaSeriesOptions = CoreTypes.AreaSeriesOptions;\n export type AreaSplineSeriesOptions = CoreTypes.AreaSplineSeriesOptions;\n export type BubbleSeriesOptions = CoreTypes.BubbleSeriesOptions;\n export type ColumnSeriesOptions = CoreTypes.ColumnSeriesOptions;\n export type ErrorBarSeriesOptions = CoreTypes.ErrorBarSeriesOptions;\n export type LineSeriesOptions = CoreTypes.LineSeriesOptions;\n export type ScatterSeriesOptions = CoreTypes.ScatterSeriesOptions;\n export type SplineSeriesOptions = CoreTypes.SplineSeriesOptions;\n export type XThresholdSeriesOptions = CoreTypes.XThresholdSeriesOptions;\n export type YThresholdSeriesOptions = CoreTypes.YThresholdSeriesOptions;\n\n interface AxisOptions {\n id?: string;\n title?: string;\n type?: \"linear\" | \"datetime\" | \"category\" | \"logarithmic\";\n min?: number;\n max?: number;\n tickInterval?: number;\n categories?: string[];\n valueFormatter?: (value: null | number) => string;\n }\n\n export interface SizeAxisOptions {\n id?: string;\n title: string;\n valueFormatter?: (value: null | number) => string;\n }\n\n export type XAxisOptions = AxisOptions;\n\n export interface YAxisOptions extends AxisOptions {\n reversedStacks?: boolean;\n }\n\n export interface YAxisWithId extends YAxisOptions {\n id: string;\n }\n\n export interface TooltipOptions {\n enabled?: boolean;\n placement?: \"middle\" | \"outside\";\n size?: \"small\" | \"medium\" | \"large\";\n point?: (props: TooltipPointRenderProps) => TooltipPointFormatted;\n header?: (props: TooltipHeaderRenderProps) => React.ReactNode;\n body?: (props: TooltipBodyRenderProps) => React.ReactNode;\n footer?: (props: TooltipFooterRenderProps) => React.ReactNode;\n }\n export type TooltipHeaderRenderProps = TooltipSlotRenderProps;\n export type TooltipBodyRenderProps = TooltipSlotRenderProps;\n export type TooltipFooterRenderProps = TooltipSlotRenderProps;\n export interface TooltipSlotRenderProps {\n x: number;\n items: TooltipPointItem[];\n }\n export interface TooltipPointRenderProps {\n item: TooltipPointItem;\n }\n export interface TooltipPointItem {\n x: number;\n y: number | null;\n size?: number | null;\n errorRanges: { low: number; high: number; series: CartesianChartProps.ErrorBarSeriesOptions }[];\n series: NonErrorBarSeriesOptions;\n }\n export type TooltipPointFormatted = CoreTypes.BaseTooltipPointFormatted;\n\n export type LegendOptions = CoreTypes.BaseLegendOptions;\n\n export type FilterOptions = CoreTypes.BaseFilterOptions;\n\n export type NoDataOptions = CoreTypes.BaseNoDataOptions;\n}\n\n// Internal types\n\nexport type NonErrorBarSeriesOptions = Exclude<\n CartesianChartProps.SeriesOptions,\n CartesianChartProps.ErrorBarSeriesOptions\n>;\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/cartesian-chart/interfaces.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport * as CoreTypes from \"../core/interfaces\";\nimport { NonCancelableEventHandler } from \"../internal/events\";\n\n// CartesianChartProps is the type for CartesianChart React component properties. Unlike in Highcharts API,\n// we pass options directly to the component, instead of grouping them all into a single \"options\" property.\n// We do still organize related options in groups, e.g.: \"SeriesOptions\", \"TooltipOptions\".\nexport interface CartesianChartProps\n extends CoreTypes.BaseChartOptions, CoreTypes.CoreCartesianOptions, CoreTypes.WithCartesianI18nStrings {\n /**\n * Inverts X and Y axes. Use it to show horizontal columns (bars).\n * This property corresponds to [chart.inverted](https://api.highcharts.com/highcharts/chart.inverted).\n */\n inverted?: boolean;\n\n /**\n * Enables series stacking behavior. Use it for column- or area- series.\n * This property corresponds to \"normal\" stacking type in Highcharts ([plotOptions.series.stacking](https://api.highcharts.com/highcharts/plotOptions.series.stacking)).\n */\n stacking?: \"normal\";\n\n /**\n * Defines series options of the chart.\n * This property corresponds to [series](https://api.highcharts.com/highcharts/series), and extends it\n * with two additional series types: \"x-threshold\", and \"y-threshold\".\n *\n * Supported types:\n * * [area](https://api.highcharts.com/highcharts/series.area).\n * * [areaspline](https://api.highcharts.com/highcharts/series.areaspline).\n * * [column](https://api.highcharts.com/highcharts/series.column).\n * * [errorbar](https://api.highcharts.com/highcharts/series.errorbar) - requires \"highcharts/highcharts-more\" module.\n * * [line](https://api.highcharts.com/highcharts/series.line).\n * * [bubble](https://api.highcharts.com/highcharts/series.bubble) - requires \"highcharts/highcharts-more\" module.\n * * [scatter](https://api.highcharts.com/highcharts/series.scatter).\n * * [spline](https://api.highcharts.com/highcharts/series.spline).\n * * x-threshold - The line-like series to represent x-axis threshold (vertical, when `inverted=false`).\n * * y-threshold - The line-like series to represent y-axis threshold (horizontal, when `inverted=false`).\n */\n series: readonly CartesianChartProps.SeriesOptions[];\n\n /**\n * Defines tooltip options of the chart, including:\n * * `enabled` - (optional, boolean) - Hides the tooltip when set to false.\n * * `size` - (optional, \"small\" | \"medium\" | \"large\") - Specifies max tooltip size.\n * * `placement` - (optional, \"middle\" | \"outside\") - Specifies preferred tooltip placement.\n * * `point` - (optional, function) - Customizes tooltip series point rendering.\n * * `header` - (optional, function) - Renders a custom tooltip header.\n * * `body` - (optional, function) - Renders a custom tooltip body.\n * * `footer` - (optional, function) - Renders a custom tooltip footer.\n */\n tooltip?: CartesianChartProps.TooltipOptions;\n\n /**\n * Defines options of the chart's x axis.\n * This property corresponds to [xAxis](https://api.highcharts.com/highcharts/xAxis), and extends it\n * with a custom value formatter.\n *\n * Supported options:\n * * `title` (optional, string) - Axis title.\n * * `type` (optional, \"linear\" | \"datetime\" | \"category\" | \"logarithmic\") - Axis type.\n * * * \"linear\" - Uses continuous proportional values scale.\n * * * \"datetime\" - Similar to linear, but takes epoch time as values.\n * * * \"category\" - Uses discrete scale, requires `categories` to be set.\n * * * \"logarithmic\" - Uses continuous logarithmic values scale.\n * * `min` (optional, number) - Axis min value boundary.\n * * `max` (optional, number) - Axis max value boundary.\n * * `tickInterval` (optional, number) - Distance between axis ticks.\n * * `categories` (optional, Array<string>) - Predefined list of values, used for categorical axis type.\n * * `valueFormatter` (optional, function) - Takes axis tick as input and returns a formatted string. This formatter also\n * applies to the tooltip header.\n */\n xAxis?: CartesianChartProps.XAxisOptions;\n\n /**\n * Defines options of the chart's y axis.\n * This property corresponds to [yAxis](https://api.highcharts.com/highcharts/yAxis), and extends it\n * with a custom value formatter.\n *\n * Use a single object for a single y axis, or a tuple of two objects for a dual-axis chart.\n * When using a tuple, both axes must have an `id`. The second axis is automatically rendered on the opposite (inline-end) side.\n * Series reference their axis by setting `yAxis` to the axis `id`.\n *\n * Supported options:\n * * `title` (optional, string) - Axis title.\n * * `type` (optional, \"linear\" | \"datetime\" | \"category\" | \"logarithmic\") - Axis type.\n * * * \"linear\" - Uses continuous proportional values scale.\n * * * \"datetime\" - Similar to linear, but takes epoch time as values.\n * * * \"category\" - Uses discrete scale, requires `categories` to be set.\n * * * \"logarithmic\" - Uses continuous logarithmic values scale.\n * * `min` (optional, number) - Axis min value boundary.\n * * `max` (optional, number) - Axis max value boundary.\n * * `tickInterval` (optional, number) - Distance between axis ticks.\n * * `categories` (optional, Array<string>) - Predefined list of values, used for categorical axis type.\n * * `reversedStacks` (optional, boolean) - Reverts series order in stacked series.\n * * `valueFormatter` (optional, function) - Takes axis tick as input and returns a formatted string. This formatter also\n * applies to the tooltip points values.\n */\n yAxis?: CartesianChartProps.YAxisOptions | [CartesianChartProps.YAxisWithId, CartesianChartProps.YAxisWithId];\n\n /**\n * One or multiple axes to provide size details formatting for bubble series.\n *\n * Supported options:\n * * `id` (optional, string) - Use it to connect axes with respective series when multiple size axes are present. The axis id must correspond `sizeAxis` property of the bubble series.\n * * `title` (string) - Axis title, shown in the tooltip details for bubble series.\n * * `valueFormatter` (optional, function) - Value formatter for `size` values of the bubble series data.\n */\n sizeAxis?: CartesianChartProps.SizeAxisOptions | readonly CartesianChartProps.SizeAxisOptions[];\n\n /**\n * Specifies which series to show using their IDs. By default, all series are visible and managed by the component.\n * If a series doesn't have an ID, its name is used. When using this property, manage state updates with `onVisibleSeriesChange`.\n */\n visibleSeries?: readonly string[];\n\n /**\n * A callback function, triggered when series visibility changes as a result of user interaction with the legend or filter.\n */\n onVisibleSeriesChange?: NonCancelableEventHandler<{ visibleSeries: string[] }>;\n}\n\nexport namespace CartesianChartProps {\n export interface Ref {\n /**\n * Controls series visibility and works with both controlled and uncontrolled visibility modes.\n */\n setVisibleSeries(visibleSeries: readonly string[]): void;\n /**\n * Functions similarly to `setVisibleSeries`, but applies to all series and doesn't require series IDs as input.\n * Use this when implementing clear-filter actions in no-match states.\n */\n showAllSeries(): void;\n }\n\n export type SeriesOptions =\n | AreaSeriesOptions\n | AreaSplineSeriesOptions\n | BubbleSeriesOptions\n | ColumnSeriesOptions\n | ErrorBarSeriesOptions\n | LineSeriesOptions\n | ScatterSeriesOptions\n | SplineSeriesOptions\n | XThresholdSeriesOptions\n | YThresholdSeriesOptions;\n\n export type AreaSeriesOptions = CoreTypes.AreaSeriesOptions;\n export type AreaSplineSeriesOptions = CoreTypes.AreaSplineSeriesOptions;\n export type BubbleSeriesOptions = CoreTypes.BubbleSeriesOptions;\n export type ColumnSeriesOptions = CoreTypes.ColumnSeriesOptions;\n export type ErrorBarSeriesOptions = CoreTypes.ErrorBarSeriesOptions;\n export type LineSeriesOptions = CoreTypes.LineSeriesOptions;\n export type ScatterSeriesOptions = CoreTypes.ScatterSeriesOptions;\n export type SplineSeriesOptions = CoreTypes.SplineSeriesOptions;\n export type XThresholdSeriesOptions = CoreTypes.XThresholdSeriesOptions;\n export type YThresholdSeriesOptions = CoreTypes.YThresholdSeriesOptions;\n\n interface AxisOptions {\n id?: string;\n title?: string;\n type?: \"linear\" | \"datetime\" | \"category\" | \"logarithmic\";\n min?: number;\n max?: number;\n tickInterval?: number;\n categories?: string[];\n valueFormatter?: (value: null | number) => string;\n }\n\n export interface SizeAxisOptions {\n id?: string;\n title: string;\n valueFormatter?: (value: null | number) => string;\n }\n\n export type XAxisOptions = AxisOptions;\n\n export interface YAxisOptions extends AxisOptions {\n reversedStacks?: boolean;\n }\n\n export interface YAxisWithId extends YAxisOptions {\n id: string;\n }\n\n export interface TooltipOptions {\n enabled?: boolean;\n placement?: \"middle\" | \"outside\";\n size?: \"small\" | \"medium\" | \"large\";\n point?: (props: TooltipPointRenderProps) => TooltipPointFormatted;\n header?: (props: TooltipHeaderRenderProps) => React.ReactNode;\n body?: (props: TooltipBodyRenderProps) => React.ReactNode;\n footer?: (props: TooltipFooterRenderProps) => React.ReactNode;\n }\n export type TooltipHeaderRenderProps = TooltipSlotRenderProps;\n export type TooltipBodyRenderProps = TooltipSlotRenderProps;\n export type TooltipFooterRenderProps = TooltipSlotRenderProps;\n export interface TooltipSlotRenderProps {\n x: number;\n items: TooltipPointItem[];\n }\n export interface TooltipPointRenderProps {\n item: TooltipPointItem;\n }\n export interface TooltipPointItem {\n x: number;\n y: number | null;\n size?: number | null;\n errorRanges: { low: number; high: number; series: CartesianChartProps.ErrorBarSeriesOptions }[];\n series: NonErrorBarSeriesOptions;\n }\n export type TooltipPointFormatted = CoreTypes.BaseTooltipPointFormatted;\n\n export type SeriesZone = CoreTypes.SeriesZone;\n\n export type LegendOptions = CoreTypes.BaseLegendOptions;\n\n export type FilterOptions = CoreTypes.BaseFilterOptions;\n\n export type NoDataOptions = CoreTypes.BaseNoDataOptions;\n}\n\n// Internal types\n\nexport type NonErrorBarSeriesOptions = Exclude<\n CartesianChartProps.SeriesOptions,\n CartesianChartProps.ErrorBarSeriesOptions\n>;\n"]}
@@ -66,30 +66,18 @@ function computeDerivedState(chart) {
66
66
  sortPoints(points);
67
67
  }
68
68
  const allX = Array.from(allXSet).sort(compareX);
69
- // For each series, compute the ordered list of points to navigate through. For a linked family
70
- // (primary + its linked children), all members share the same flat list: points sorted by X,
71
- // with family members interleaved in series order within the same X value.
72
69
  const seriesPointsMap = new WeakMap();
73
70
  for (const s of getChartSeries(chart)) {
74
- if (seriesPointsMap.has(s)) {
75
- continue; // Already computed as part of a family.
76
- }
77
- const master = (_a = s.linkedParent) !== null && _a !== void 0 ? _a : s;
78
- const family = [master, ...master.linkedSeries];
79
- const allFamilyPoints = family
80
- .flatMap((m) => { var _a; return (_a = allPointsInSeries.get(m)) !== null && _a !== void 0 ? _a : []; })
81
- .sort(({ x: x1 }, { x: x2 }) => compareX(x1, x2));
71
+ const allSeriesPoints = ((_a = allPointsInSeries.get(s)) !== null && _a !== void 0 ? _a : []).sort(({ x: x1 }, { x: x2 }) => compareX(x1, x2));
82
72
  const usedXSet = new Set();
83
- const familyPoints = new Array();
84
- for (const point of allFamilyPoints) {
73
+ const navigableSeriesPoints = new Array();
74
+ for (const point of allSeriesPoints) {
85
75
  if (!usedXSet.has(point.x)) {
86
- familyPoints.push(point);
76
+ navigableSeriesPoints.push(point);
87
77
  usedXSet.add(point.x); // We ignore points that share X coordinate.
88
78
  }
89
79
  }
90
- for (const member of family) {
91
- seriesPointsMap.set(member, familyPoints);
92
- }
80
+ seriesPointsMap.set(s, navigableSeriesPoints);
93
81
  }
94
82
  return {
95
83
  allX,
@@ -1 +1 @@
1
- {"version":3,"file":"chart-extra-context.js","sourceRoot":"","sources":["../../../../src/core/chart-api/chart-extra-context.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAKtC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAyB,MAAM,iCAAiC,CAAC;AAGvG,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA6CzD,kFAAkF;AAClF,gGAAgG;AAChG,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,QAAQ,EAAE;YACR,OAAO,EAAE,EAAE;YACX,aAAa,EAAE,KAAK;YACpB,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,KAAK;YACrB,yBAAyB,EAAE,KAAK;YAChC,MAAM,EAAE,EAAE;SACX;QACD,QAAQ,EAAE,EAAE;QACZ,KAAK,EAAE,EAAE;QACT,KAAK,EAAE,GAAG,EAAE;YACV,yGAAyG;YACzG,2GAA2G;YAC3G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pB,IAAI,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;SAClC,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED,+FAA+F;AAC/F,iGAAiG;AACjG,oCAAoC;AACpC,SAAS,UAAU,CAAC,KAAyB;;IAC3C,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAA,MAAA,MAAA,KAAK,CAAC,CAAC,CAAC,0CAAE,MAAM,CAAC,KAAK,0CAAE,QAAQ,CAAA,CAAC;IACpD,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAClB,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC7G,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC7G,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type Highcharts from \"highcharts\";\n\nimport { NonCancelableEventHandler } from \"../../internal/events\";\nimport { getChartSeries, getSeriesData, SafeChart, SafeSeries } from \"../../internal/utils/highcharts\";\nimport { ChartLabels } from \"../i18n-utils\";\nimport { CoreChartProps, Rect } from \"../interfaces\";\nimport { getGroupRect, isSeriesStacked } from \"../utils\";\n\n// Chart API context is used for dependency injection for chart utilities.\n// It is initialized on chart render, and includes the chart instance, consumer\n// settings and state, and derived state, which is computed from the chart instance\n// on each render, and reused across utilities to avoid duplicate work.\n\nexport interface ChartExtraContext {\n settings: ChartExtraContext.Settings;\n handlers: ChartExtraContext.Handlers;\n state: ChartExtraContext.State;\n derived: ChartExtraContext.DerivedState;\n chartOrNull: null | SafeChart;\n chart: () => SafeChart;\n}\n\nexport namespace ChartExtraContext {\n export interface Settings {\n chartId: string;\n noDataEnabled: boolean;\n legendEnabled: boolean;\n tooltipEnabled: boolean;\n keyboardNavigationEnabled: boolean;\n labels: ChartLabels;\n getItemOptions?: CoreChartProps.GetItemOptions;\n }\n\n export interface Handlers {\n onHighlight?: NonCancelableEventHandler<CoreChartProps.HighlightChangeDetail>;\n onClearHighlight?: NonCancelableEventHandler<CoreChartProps.HighlightClearDetail>;\n onVisibleItemsChange?: NonCancelableEventHandler<CoreChartProps.VisibleItemsChangeDetail>;\n }\n\n export interface State {\n visibleItems?: readonly string[];\n }\n\n export interface DerivedState {\n allX: number[];\n getPointsByX: (x: number) => Highcharts.Point[];\n getSeriesPoints: (series: SafeSeries) => Highcharts.Point[];\n groupRects: { group: Highcharts.Point[]; rect: Rect }[];\n }\n}\n\n// The context is created when the chart component is rendered for the first time.\n// On every subsequent render the settings and state are updated directly in the context object.\nexport function createChartContext(): ChartExtraContext {\n return {\n settings: {\n chartId: \"\",\n noDataEnabled: false,\n legendEnabled: false,\n tooltipEnabled: false,\n keyboardNavigationEnabled: false,\n labels: {},\n },\n handlers: {},\n state: {},\n chart: () => {\n // Before the first chart render there is no chart instance, which is required for most of the utilities.\n // Instead of doing null checks in each utility, an attempt to access the chart instance before it is ready\n // will cause an exception, indicating an logical error in the code.\n throw new Error(\"Invariant violation: using chart API before initialization.\");\n },\n chartOrNull: null,\n derived: { allX: [], getPointsByX: () => [], getSeriesPoints: () => [], groupRects: [] },\n };\n}\n\n// The update method is called on every chart render, before any other initialization code.\n// This ensures the context state is up to date and can be used for subsequent computations.\nexport function updateChartContext(context: ChartExtraContext, chart: SafeChart) {\n context.chart = () => chart;\n context.chartOrNull = chart;\n context.derived = computeDerivedState(chart);\n}\n\nfunction computeDerivedState(chart: SafeChart): ChartExtraContext.DerivedState {\n const allXSet = new Set<number>();\n const allPointsInSeries = new WeakMap<SafeSeries, Highcharts.Point[]>();\n const pointsByX = new Map<number, Highcharts.Point[]>();\n const getXPoints = (x: number) => pointsByX.get(x) ?? [];\n const addPoint = (point: Highcharts.Point) => {\n const xPoints = getXPoints(point.x);\n xPoints.push(point);\n pointsByX.set(point.x, xPoints);\n };\n const compareX = (a: number, b: number) => a - b;\n\n for (const s of getChartSeries(chart)) {\n const seriesPoints = new Array<Highcharts.Point>();\n if (s.visible) {\n for (const d of getSeriesData(s)) {\n // Points with y=null represent the absence of value, there is no need to include them and those\n // should have no impact on computed rects or navigation.\n\n // Although \"d\" can't be undefined according to Highcharts API, it does become undefined for chart containing more datapoints\n // than the cropThreshold for that series (specific cases of re-rendering the chart with updated options listening to setExteme updates)\n if (d.visible && d.y !== null) {\n seriesPoints.push(d);\n allXSet.add(d.x);\n addPoint(d);\n }\n }\n }\n allPointsInSeries.set(s, seriesPoints);\n }\n for (const [, points] of pointsByX) {\n sortPoints(points);\n }\n const allX = Array.from(allXSet).sort(compareX);\n\n // For each series, compute the ordered list of points to navigate through. For a linked family\n // (primary + its linked children), all members share the same flat list: points sorted by X,\n // with family members interleaved in series order within the same X value.\n const seriesPointsMap = new WeakMap<SafeSeries, Highcharts.Point[]>();\n for (const s of getChartSeries(chart)) {\n if (seriesPointsMap.has(s)) {\n continue; // Already computed as part of a family.\n }\n const master = s.linkedParent ?? s;\n const family = [master, ...master.linkedSeries];\n const allFamilyPoints = family\n .flatMap((m) => allPointsInSeries.get(m) ?? [])\n .sort(({ x: x1 }, { x: x2 }) => compareX(x1, x2));\n const usedXSet = new Set<number>();\n const familyPoints = new Array<Highcharts.Point>();\n for (const point of allFamilyPoints) {\n if (!usedXSet.has(point.x)) {\n familyPoints.push(point);\n usedXSet.add(point.x); // We ignore points that share X coordinate.\n }\n }\n for (const member of family) {\n seriesPointsMap.set(member, familyPoints);\n }\n }\n return {\n allX,\n getPointsByX: (x) => pointsByX.get(x) ?? [],\n getSeriesPoints: (s) => seriesPointsMap.get(s) ?? [],\n // Group rects are computed for every available x coordinate, each including at least one point with matching x value.\n // They enclose all matching points of the group and are used to match hover position and place the tooltip or focus outline.\n groupRects: allX.map((x) => ({\n group: getXPoints(x),\n rect: getGroupRect(getXPoints(x)),\n })),\n };\n}\n\n// The points are sorted to ensure consistent navigation, including inverted chart orientation.\n// The order of series in grouped column charts is kept, while stacked series are sorted by their\n// respective positions in the plot.\nfunction sortPoints(group: Highcharts.Point[]) {\n const reversed = !!group[0]?.series.yAxis?.reversed;\n group.sort((a, b) => {\n const ay = a.plotY === undefined || (a.series.type === \"column\" && !isSeriesStacked(a.series)) ? 0 : a.plotY;\n const by = b.plotY === undefined || (b.series.type === \"column\" && !isSeriesStacked(b.series)) ? 0 : b.plotY;\n return !reversed ? ay - by : by - ay;\n });\n}\n"]}
1
+ {"version":3,"file":"chart-extra-context.js","sourceRoot":"","sources":["../../../../src/core/chart-api/chart-extra-context.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAKtC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAyB,MAAM,iCAAiC,CAAC;AAGvG,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA6CzD,kFAAkF;AAClF,gGAAgG;AAChG,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,QAAQ,EAAE;YACR,OAAO,EAAE,EAAE;YACX,aAAa,EAAE,KAAK;YACpB,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,KAAK;YACrB,yBAAyB,EAAE,KAAK;YAChC,MAAM,EAAE,EAAE;SACX;QACD,QAAQ,EAAE,EAAE;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,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAClB,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC7G,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC7G,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type Highcharts from \"highcharts\";\n\nimport { NonCancelableEventHandler } from \"../../internal/events\";\nimport { getChartSeries, getSeriesData, SafeChart, SafeSeries } from \"../../internal/utils/highcharts\";\nimport { ChartLabels } from \"../i18n-utils\";\nimport { CoreChartProps, Rect } from \"../interfaces\";\nimport { getGroupRect, isSeriesStacked } from \"../utils\";\n\n// Chart API context is used for dependency injection for chart utilities.\n// It is initialized on chart render, and includes the chart instance, consumer\n// settings and state, and derived state, which is computed from the chart instance\n// on each render, and reused across utilities to avoid duplicate work.\n\nexport interface ChartExtraContext {\n settings: ChartExtraContext.Settings;\n handlers: ChartExtraContext.Handlers;\n state: ChartExtraContext.State;\n derived: ChartExtraContext.DerivedState;\n chartOrNull: null | SafeChart;\n chart: () => SafeChart;\n}\n\nexport namespace ChartExtraContext {\n export interface Settings {\n chartId: string;\n noDataEnabled: boolean;\n legendEnabled: boolean;\n tooltipEnabled: boolean;\n keyboardNavigationEnabled: boolean;\n labels: ChartLabels;\n getItemOptions?: CoreChartProps.GetItemOptions;\n }\n\n export interface Handlers {\n onHighlight?: NonCancelableEventHandler<CoreChartProps.HighlightChangeDetail>;\n onClearHighlight?: NonCancelableEventHandler<CoreChartProps.HighlightClearDetail>;\n onVisibleItemsChange?: NonCancelableEventHandler<CoreChartProps.VisibleItemsChangeDetail>;\n }\n\n export interface State {\n visibleItems?: readonly string[];\n }\n\n export interface DerivedState {\n allX: number[];\n getPointsByX: (x: number) => Highcharts.Point[];\n getSeriesPoints: (series: SafeSeries) => Highcharts.Point[];\n groupRects: { group: Highcharts.Point[]; rect: Rect }[];\n }\n}\n\n// The context is created when the chart component is rendered for the first time.\n// On every subsequent render the settings and state are updated directly in the context object.\nexport function createChartContext(): ChartExtraContext {\n return {\n settings: {\n chartId: \"\",\n noDataEnabled: false,\n legendEnabled: false,\n tooltipEnabled: false,\n keyboardNavigationEnabled: false,\n labels: {},\n },\n handlers: {},\n state: {},\n chart: () => {\n // Before the first chart render there is no chart instance, which is required for most of the utilities.\n // Instead of doing null checks in each utility, an attempt to access the chart instance before it is ready\n // will cause an exception, indicating an logical error in the code.\n throw new Error(\"Invariant violation: using chart API before initialization.\");\n },\n chartOrNull: null,\n derived: { allX: [], getPointsByX: () => [], getSeriesPoints: () => [], groupRects: [] },\n };\n}\n\n// The update method is called on every chart render, before any other initialization code.\n// This ensures the context state is up to date and can be used for subsequent computations.\nexport function updateChartContext(context: ChartExtraContext, chart: SafeChart) {\n context.chart = () => chart;\n context.chartOrNull = chart;\n context.derived = computeDerivedState(chart);\n}\n\nfunction computeDerivedState(chart: SafeChart): ChartExtraContext.DerivedState {\n const allXSet = new Set<number>();\n const allPointsInSeries = new WeakMap<SafeSeries, Highcharts.Point[]>();\n const pointsByX = new Map<number, Highcharts.Point[]>();\n const getXPoints = (x: number) => pointsByX.get(x) ?? [];\n const addPoint = (point: Highcharts.Point) => {\n const xPoints = getXPoints(point.x);\n xPoints.push(point);\n pointsByX.set(point.x, xPoints);\n };\n const compareX = (a: number, b: number) => a - b;\n\n for (const s of getChartSeries(chart)) {\n const seriesPoints = new Array<Highcharts.Point>();\n if (s.visible) {\n for (const d of getSeriesData(s)) {\n // Points with y=null represent the absence of value, there is no need to include them and those\n // should have no impact on computed rects or navigation.\n\n // Although \"d\" can't be undefined according to Highcharts API, it does become undefined for chart containing more datapoints\n // than the cropThreshold for that series (specific cases of re-rendering the chart with updated options listening to setExteme updates)\n if (d.visible && d.y !== null) {\n seriesPoints.push(d);\n allXSet.add(d.x);\n addPoint(d);\n }\n }\n }\n allPointsInSeries.set(s, seriesPoints);\n }\n for (const [, points] of pointsByX) {\n sortPoints(points);\n }\n const allX = Array.from(allXSet).sort(compareX);\n\n const seriesPointsMap = new WeakMap<SafeSeries, Highcharts.Point[]>();\n for (const s of getChartSeries(chart)) {\n const allSeriesPoints = (allPointsInSeries.get(s) ?? []).sort(({ x: x1 }, { x: x2 }) => compareX(x1, x2));\n const usedXSet = new Set<number>();\n const navigableSeriesPoints = new Array<Highcharts.Point>();\n for (const point of allSeriesPoints) {\n if (!usedXSet.has(point.x)) {\n navigableSeriesPoints.push(point);\n usedXSet.add(point.x); // We ignore points that share X coordinate.\n }\n }\n seriesPointsMap.set(s, navigableSeriesPoints);\n }\n return {\n allX,\n getPointsByX: (x) => pointsByX.get(x) ?? [],\n getSeriesPoints: (s) => seriesPointsMap.get(s) ?? [],\n // Group rects are computed for every available x coordinate, each including at least one point with matching x value.\n // They enclose all matching points of the group and are used to match hover position and place the tooltip or focus outline.\n groupRects: allX.map((x) => ({\n group: getXPoints(x),\n rect: getGroupRect(getXPoints(x)),\n })),\n };\n}\n\n// The points are sorted to ensure consistent navigation, including inverted chart orientation.\n// The order of series in grouped column charts is kept, while stacked series are sorted by their\n// respective positions in the plot.\nfunction sortPoints(group: Highcharts.Point[]) {\n const reversed = !!group[0]?.series.yAxis?.reversed;\n group.sort((a, b) => {\n const ay = a.plotY === undefined || (a.series.type === \"column\" && !isSeriesStacked(a.series)) ? 0 : a.plotY;\n const by = b.plotY === undefined || (b.series.type === \"column\" && !isSeriesStacked(b.series)) ? 0 : b.plotY;\n return !reversed ? ay - by : by - ay;\n });\n}\n"]}
@@ -11,7 +11,7 @@ import { useSelector } from "../../internal/utils/async-store";
11
11
  import { getChartSeries, getSeriesData, isPointVisible } from "../../internal/utils/highcharts";
12
12
  import { useDebouncedValue } from "../../internal/utils/use-debounced-value";
13
13
  import { getFormatter } from "../formatters";
14
- import { getPointColor, getPointId, getSeriesColor, getSeriesId, getSeriesMarkerType, isXThreshold, matchSizeAxis, } from "../utils";
14
+ import { getPointColor, getPointId, getPointMarkerType, getSeriesId, getSeriesMarkerType, isXThreshold, matchSizeAxis, } from "../utils";
15
15
  import styles from "../styles.css.js";
16
16
  const MIN_VISIBLE_BLOCK_SIZE = 200;
17
17
  const DEFAULT_DEBOUNCE = 200;
@@ -81,12 +81,12 @@ function getTooltipContentCartesian(api, { point, group, expandedSeries, rendere
81
81
  // By design, every point of the group has the same x value.
82
82
  const x = group[0].x;
83
83
  const chart = group[0].series.chart;
84
- const getSeriesMarker = (series) => {
84
+ const getPointMarker = (point) => {
85
85
  var _a, _b, _c, _d;
86
- const itemOptions = (_b = (_a = api.context.settings).getItemOptions) === null || _b === void 0 ? void 0 : _b.call(_a, getSeriesId(series));
86
+ const itemOptions = (_b = (_a = api.context.settings).getItemOptions) === null || _b === void 0 ? void 0 : _b.call(_a, getSeriesId(point.series));
87
87
  return api.renderMarker({
88
- type: getSeriesMarkerType(series),
89
- color: getSeriesColor(series),
88
+ type: getPointMarkerType(point),
89
+ color: getPointColor(point),
90
90
  visible: true,
91
91
  status: itemOptions === null || itemOptions === void 0 ? void 0 : itemOptions.status,
92
92
  ariaLabel: (_d = (_c = api.context.settings.labels).itemMarkerLabel) === null || _d === void 0 ? void 0 : _d.call(_c, itemOptions === null || itemOptions === void 0 ? void 0 : itemOptions.status),
@@ -108,7 +108,7 @@ function getTooltipContentCartesian(api, { point, group, expandedSeries, rendere
108
108
  return {
109
109
  key: (_b = customContent === null || customContent === void 0 ? void 0 : customContent.key) !== null && _b !== void 0 ? _b : item.point.series.name,
110
110
  value: (_c = customContent === null || customContent === void 0 ? void 0 : customContent.value) !== null && _c !== void 0 ? _c : defaultValue,
111
- marker: getSeriesMarker(item.point.series),
111
+ marker: getPointMarker(item.point),
112
112
  subItems: (_d = customContent === null || customContent === void 0 ? void 0 : customContent.subItems) !== null && _d !== void 0 ? _d : bubbleSubItems,
113
113
  expandableId: (customContent === null || customContent === void 0 ? void 0 : customContent.expandable) ? item.point.series.name : undefined,
114
114
  highlighted: item.point.x === (point === null || point === void 0 ? void 0 : point.x) && item.point.y === (point === null || point === void 0 ? void 0 : point.y),
@@ -1 +1 @@
1
- {"version":3,"file":"core-tooltip.js","sourceRoot":"","sources":["../../../../src/core/components/core-tooltip.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,GAAG,MAAM,mCAAmC,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iEAAiE,CAAC;AACvG,OAAO,UAAU,MAAM,2CAA2C,CAAC;AAEnE,OAAO,kBAA6C,MAAM,0CAA0C,CAAC;AACrG,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAc,MAAM,iCAAiC,CAAC;AAC5G,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE7E,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,WAAW,EACX,mBAAmB,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AAI,CAAC,MAAA,EAAE,CAAC,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,MAAA,EAAE,CAAC,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC;QACF,8FAA8F;SAC7F,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;;QACZ,MAAM,WAAW,GAAG,MAAA,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,mCAAI,EAAE,CAAC;QAC3E,MAAM,iBAAiB,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9G,OAAO,EAAE,GAAG,IAAI,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACrD,CAAC,CAAC,CACL,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useState } from \"react\";\n\nimport { warnOnce } from \"@cloudscape-design/component-toolkit/internal\";\nimport Box from \"@cloudscape-design/components/box\";\nimport { InternalChartTooltip } from \"@cloudscape-design/components/internal/do-not-use/chart-tooltip\";\nimport LiveRegion from \"@cloudscape-design/components/live-region\";\n\nimport ChartSeriesDetails, { ChartSeriesDetailItem } from \"../../internal/components/series-details\";\nimport { useSelector } from \"../../internal/utils/async-store\";\nimport { getChartSeries, getSeriesData, isPointVisible, SafeSeries } from \"../../internal/utils/highcharts\";\nimport { useDebouncedValue } from \"../../internal/utils/use-debounced-value\";\nimport { ChartAPI } from \"../chart-api\";\nimport { getFormatter } from \"../formatters\";\nimport { BaseI18nStrings, CoreChartProps } from \"../interfaces\";\nimport {\n getPointColor,\n getPointId,\n getSeriesColor,\n getSeriesId,\n getSeriesMarkerType,\n isXThreshold,\n matchSizeAxis,\n} from \"../utils\";\n\nimport styles from \"../styles.css.js\";\n\nconst MIN_VISIBLE_BLOCK_SIZE = 200;\nconst DEFAULT_DEBOUNCE = 200;\n\ntype ExpandedSeriesState = Record<string, Set<string>>;\n\ninterface ExpandedSeriesStateProps {\n expandedSeries: ExpandedSeriesState;\n setExpandedSeries: (cb: (state: ExpandedSeriesState) => ExpandedSeriesState) => void;\n}\n\ninterface RenderedTooltipContent {\n header: React.ReactNode;\n body: React.ReactNode;\n footer: React.ReactNode;\n}\n\ninterface MatchedItem {\n point: Highcharts.Point;\n errorRanges: Highcharts.Point[];\n}\n\nexport function ChartTooltip({\n placement = \"target\",\n size,\n getTooltipContent: getTooltipContentOverrides,\n api,\n i18nStrings,\n debounce = false,\n seriesSorting = \"as-added\",\n sizeAxis,\n}: CoreChartProps.TooltipOptions & {\n i18nStrings?: BaseI18nStrings;\n getTooltipContent?: CoreChartProps.GetTooltipContent;\n sizeAxis?: readonly CoreChartProps.SizeAxisOptions[];\n api: ChartAPI;\n}) {\n const [expandedSeries, setExpandedSeries] = useState<ExpandedSeriesState>({});\n const tooltip = useSelector(api.tooltipStore, (s) => s);\n const debouncedTooltip = useDebouncedValue(tooltip, debounce === true ? DEFAULT_DEBOUNCE : debounce || 0);\n\n if (\n !debouncedTooltip ||\n !debouncedTooltip.visible ||\n debouncedTooltip.group.length === 0 ||\n debouncedTooltip.group[0].series === undefined\n ) {\n return null;\n }\n\n const chart = debouncedTooltip.group[0]?.series.chart;\n const renderers = getTooltipContentOverrides?.({ point: debouncedTooltip.point, group: debouncedTooltip.group });\n const getTrack = placement === \"target\" ? api.getTargetTrack : api.getGroupTrack;\n const position = (() => {\n if (placement === \"target\" || placement === \"middle\") {\n return !chart.inverted ? \"right\" : \"bottom\";\n } else {\n return !chart.inverted ? \"bottom\" : \"right\";\n }\n })();\n const content = getTooltipContent(api, {\n renderers,\n point: debouncedTooltip.point,\n group: debouncedTooltip.group,\n expandedSeries,\n setExpandedSeries,\n seriesSorting,\n sizeAxis,\n hideTooltip: () => {\n api.hideTooltip();\n },\n });\n if (!content) {\n return null;\n }\n return (\n <InternalChartTooltip\n getTrack={getTrack}\n trackKey={getTrackKey(debouncedTooltip.point, debouncedTooltip.group)}\n container={null}\n dismissButton={debouncedTooltip.pinned}\n dismissAriaLabel={i18nStrings?.detailPopoverDismissAriaLabel}\n onDismiss={api.onDismissTooltip}\n onMouseEnter={api.onMouseEnterTooltip}\n onMouseLeave={api.onMouseLeaveTooltip}\n title={content.header}\n footer={\n content.footer ? (\n <>\n <hr aria-hidden={true} />\n {content.footer}\n </>\n ) : null\n }\n size={size}\n position={position}\n minVisibleBlockSize={MIN_VISIBLE_BLOCK_SIZE}\n >\n <LiveRegion>{content.body}</LiveRegion>\n </InternalChartTooltip>\n );\n}\n\nfunction getTrackKey(point: null | Highcharts.Point, group: readonly Highcharts.Point[]) {\n const pointId = point && (point.options.id || point.options.name);\n if (point && pointId) {\n return `p-${pointId}-${point.x}-${point.y}`;\n }\n if (point) {\n return `p-${point.x}-${point.y}`;\n }\n return `g_${group.length}_${group[0].x}`;\n}\n\nfunction getTooltipContent(\n api: ChartAPI,\n props: CoreChartProps.GetTooltipContentProps & {\n renderers?: CoreChartProps.TooltipContentRenderer;\n hideTooltip: () => void;\n seriesSorting: NonNullable<CoreChartProps.TooltipOptions[\"seriesSorting\"]>;\n sizeAxis?: readonly CoreChartProps.SizeAxisOptions[];\n } & ExpandedSeriesStateProps,\n): null | RenderedTooltipContent {\n if (props.point && props.point.series.type === \"pie\") {\n return getTooltipContentPie(api, { ...props, point: props.point });\n } else if (props.group.length > 0 && props.group[0].series.type !== \"pie\") {\n return getTooltipContentCartesian(api, props);\n } else {\n return null;\n }\n}\n\nfunction getTooltipContentCartesian(\n api: ChartAPI,\n {\n point,\n group,\n expandedSeries,\n renderers = {},\n setExpandedSeries,\n hideTooltip,\n seriesSorting,\n sizeAxis,\n }: CoreChartProps.GetTooltipContentProps & {\n renderers?: CoreChartProps.TooltipContentRenderer;\n hideTooltip: () => void;\n seriesSorting: NonNullable<CoreChartProps.TooltipOptions[\"seriesSorting\"]>;\n sizeAxis?: readonly CoreChartProps.SizeAxisOptions[];\n } & ExpandedSeriesStateProps,\n): RenderedTooltipContent {\n // The cartesian tooltip might or might not have a selected point, but it always has a non-empty group.\n // By design, every point of the group has the same x value.\n const x = group[0].x;\n const chart = group[0].series.chart;\n const getSeriesMarker = (series: SafeSeries) => {\n const itemOptions = api.context.settings.getItemOptions?.(getSeriesId(series));\n return api.renderMarker({\n type: getSeriesMarkerType(series),\n color: getSeriesColor(series),\n visible: true,\n status: itemOptions?.status,\n ariaLabel: api.context.settings.labels.itemMarkerLabel?.(itemOptions?.status),\n });\n };\n const matchedItems = findTooltipSeriesItems(getChartSeries(chart), group, seriesSorting);\n const detailItems: ChartSeriesDetailItem[] = matchedItems.map((item) => {\n const valueFormatter = getFormatter(item.point.series.yAxis);\n const itemY = isXThreshold(item.point.series) ? null : (item.point.y ?? null);\n const bubbleSubItems = item.point.series.type === \"bubble\" ? getBubblePointDetails(item, sizeAxis) : undefined;\n const customContent = renderers.point\n ? renderers.point({\n item,\n hideTooltip,\n })\n : undefined;\n const defaultValue = bubbleSubItems ? null : valueFormatter(itemY);\n return {\n key: customContent?.key ?? item.point.series.name,\n value: customContent?.value ?? defaultValue,\n marker: getSeriesMarker(item.point.series),\n subItems: customContent?.subItems ?? bubbleSubItems,\n expandableId: customContent?.expandable ? item.point.series.name : undefined,\n highlighted: item.point.x === point?.x && item.point.y === point?.y,\n description:\n customContent?.description === undefined && item.errorRanges.length ? (\n <>\n {item.errorRanges.map((errorBarPoint, index) => (\n <div key={index} className={styles[\"error-range\"]}>\n <span>{errorBarPoint.series.userOptions.name ? errorBarPoint.series.userOptions.name : \"\"}</span>\n <span>\n {valueFormatter(errorBarPoint.options.low ?? 0)} - {valueFormatter(errorBarPoint.options.high ?? 0)}\n </span>\n </div>\n ))}\n </>\n ) : (\n customContent?.description\n ),\n };\n });\n // We only support cartesian charts with a single x axis.\n const titleFormatter = getFormatter(chart.xAxis[0]);\n const slotRenderProps: CoreChartProps.TooltipSlotProps = {\n x,\n items: matchedItems,\n hideTooltip: hideTooltip,\n };\n return {\n header: renderers.header?.(slotRenderProps) ?? titleFormatter(x),\n body: renderers.body?.(slotRenderProps) ?? (\n <ChartSeriesDetails\n details={detailItems}\n expandedSeries={expandedSeries[x]}\n setExpandedState={(id, isExpanded) => {\n setExpandedSeries((oldState) => {\n const expandedSeriesInCurrentCoordinate = new Set(oldState[x]);\n if (isExpanded) {\n expandedSeriesInCurrentCoordinate.add(id);\n } else {\n expandedSeriesInCurrentCoordinate.delete(id);\n }\n return { ...oldState, [x]: expandedSeriesInCurrentCoordinate };\n });\n }}\n />\n ),\n footer: renderers.footer?.(slotRenderProps),\n };\n}\n\nfunction getTooltipContentPie(\n api: ChartAPI,\n {\n point,\n renderers = {},\n hideTooltip,\n }: { point: Highcharts.Point } & { renderers?: CoreChartProps.TooltipContentRenderer; hideTooltip: () => void },\n): RenderedTooltipContent {\n const tooltipDetails: CoreChartProps.TooltipSlotProps = {\n x: point.x,\n items: [{ point, errorRanges: [] }],\n hideTooltip,\n };\n\n const itemOptions = api.context.settings.getItemOptions?.(getPointId(point));\n const markerAriaLabel = api.context.settings.labels.itemMarkerLabel?.(itemOptions?.status);\n\n return {\n header: renderers.header?.(tooltipDetails) ?? (\n <div className={styles[\"tooltip-default-header\"]}>\n {api.renderMarker({\n type: getSeriesMarkerType(point.series),\n color: getPointColor(point),\n visible: true,\n status: itemOptions?.status,\n ariaLabel: markerAriaLabel,\n })}\n <Box variant=\"span\" fontWeight=\"bold\">\n {point.name}\n </Box>\n </div>\n ),\n body:\n renderers.body?.(tooltipDetails) ??\n (renderers.details ? (\n <ChartSeriesDetails\n details={renderers.details({\n point,\n hideTooltip,\n })}\n compactList={true}\n />\n ) : (\n // We expect all pie chart segments to have defined y values. We use y=0 as fallback\n // because the property is optional in Highcharts types.\n <ChartSeriesDetails details={[{ key: point.series.name, value: point.y ?? 0 }]} />\n )),\n footer: renderers.footer?.(tooltipDetails),\n };\n}\n\nfunction getBubblePointDetails(item: MatchedItem, sizeAxis: readonly CoreChartProps.SizeAxisOptions[] = []) {\n const subItems: { key: React.ReactNode; value: React.ReactNode }[] = [];\n\n const y = item.point.y;\n const yAxisTitle = item.point.series.yAxis?.options?.title?.text;\n const yFormatter = item.point.series.yAxis ? getFormatter(item.point.series.yAxis) : (v: unknown) => String(v);\n subItems.push({ key: yAxisTitle, value: yFormatter(y) });\n\n // Size axis is a custom abstraction built to support bubble series title and formatter for z (size) values.\n // We match size axes by ID if provided, or take the first defined axis instead.\n const matchedSizeAxis = matchSizeAxis(sizeAxis, item.point.series);\n if (matchedSizeAxis) {\n // Highcharts bubble size is represented by point.z value, which is however not present in the internal point type -\n // so we take it from point's options instead.\n const size = item.point.options.z ?? null;\n const sizeAxisTitle = matchedSizeAxis.title;\n const sizeFormatter = getFormatter(matchedSizeAxis);\n subItems.push({ key: sizeAxisTitle, value: sizeFormatter(size) });\n }\n\n return subItems;\n}\n\nfunction findTooltipSeriesItems(\n series: readonly SafeSeries[],\n group: readonly Highcharts.Point[],\n seriesSorting: NonNullable<CoreChartProps.TooltipOptions[\"seriesSorting\"]>,\n): MatchedItem[] {\n const seriesOrder = series.reduce((d, s, i) => d.set(s, i), new Map<SafeSeries, number>());\n const getSeriesIndex = (s: SafeSeries) => seriesOrder.get(s) ?? -1;\n const seriesErrors = new Map<string, Highcharts.Point[]>();\n const matchedSeries = new Set<SafeSeries>();\n const matchedItems: MatchedItem[] = [];\n for (const point of group) {\n if (!isPointVisible(point)) {\n continue;\n }\n // We only support errorbar series that are linked to other series. In tooltip content we add\n // linked error bars to series detail slot.\n if (point.series.type === \"errorbar\") {\n if (point.series.linkedParent) {\n addError(getSeriesId(point.series.linkedParent), point);\n } else {\n warnOnce(\n \"chart-components\",\n 'The `linkedTo` property of \"errorbar\" series is missing, or points to a series that does not exist.',\n );\n }\n } else {\n addMatchedPoints(point);\n }\n }\n function addError(seriesId: string, errorPoint: Highcharts.Point) {\n if (errorPoint.options.low !== undefined && errorPoint.options.high !== undefined) {\n const errorRanges = seriesErrors.get(seriesId) ?? [];\n errorRanges.push(errorPoint);\n seriesErrors.set(seriesId, errorRanges);\n }\n }\n function addMatchedPoints(point: Highcharts.Point) {\n if (!matchedSeries.has(point.series)) {\n matchedSeries.add(point.series);\n if (isXThreshold(point.series)) {\n matchedItems.push({ point, errorRanges: [] });\n } else {\n getSeriesData(point.series)\n .filter((d) => d.x === point.x)\n .sort((a, b) => (a.y ?? 0) - (b.y ?? 0))\n .forEach((point) => matchedItems.push({ point, errorRanges: [] }));\n }\n }\n }\n return (\n matchedItems\n .sort((i1, i2) => {\n if (seriesSorting === \"by-value-desc\") {\n return (i2.point.y ?? 0) - (i1.point.y ?? 0);\n }\n // We sort matched items by series order. If there are multiple items that belong to the same series, we sort them by value.\n const s1 = getSeriesIndex(i1.point.series) - getSeriesIndex(i2.point.series);\n return s1 || (i1.point.y ?? 0) - (i2.point.y ?? 0);\n })\n // For each series item we add linked error ranges, sorted by their respective series indices.\n .map((item) => {\n const errorRanges = seriesErrors.get(getSeriesId(item.point.series)) ?? [];\n const sortedErrorRanges = errorRanges.sort((i1, i2) => getSeriesIndex(i1.series) - getSeriesIndex(i2.series));\n return { ...item, errorRanges: sortedErrorRanges };\n })\n );\n}\n"]}
1
+ {"version":3,"file":"core-tooltip.js","sourceRoot":"","sources":["../../../../src/core/components/core-tooltip.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AACzE,OAAO,GAAG,MAAM,mCAAmC,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iEAAiE,CAAC;AACvG,OAAO,UAAU,MAAM,2CAA2C,CAAC;AAEnE,OAAO,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C;YACtC,OAAO,CAAC,MAAA,EAAE,CAAC,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,MAAA,EAAE,CAAC,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC,CAAC;QAC/C,CAAC;QACD,4HAA4H;QAC5H,MAAM,EAAE,GAAG,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7E,OAAO,EAAE,IAAI,CAAC,MAAA,EAAE,CAAC,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,MAAA,EAAE,CAAC,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC;QACF,8FAA8F;SAC7F,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;;QACZ,MAAM,WAAW,GAAG,MAAA,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,mCAAI,EAAE,CAAC;QAC3E,MAAM,iBAAiB,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAC9G,OAAO,EAAE,GAAG,IAAI,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACrD,CAAC,CAAC,CACL,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useState } from \"react\";\n\nimport { warnOnce } from \"@cloudscape-design/component-toolkit/internal\";\nimport Box from \"@cloudscape-design/components/box\";\nimport { InternalChartTooltip } from \"@cloudscape-design/components/internal/do-not-use/chart-tooltip\";\nimport LiveRegion from \"@cloudscape-design/components/live-region\";\n\nimport ChartSeriesDetails, { ChartSeriesDetailItem } from \"../../internal/components/series-details\";\nimport { useSelector } from \"../../internal/utils/async-store\";\nimport { getChartSeries, getSeriesData, isPointVisible, SafeSeries } from \"../../internal/utils/highcharts\";\nimport { useDebouncedValue } from \"../../internal/utils/use-debounced-value\";\nimport { ChartAPI } from \"../chart-api\";\nimport { getFormatter } from \"../formatters\";\nimport { BaseI18nStrings, CoreChartProps } from \"../interfaces\";\nimport {\n getPointColor,\n getPointId,\n getPointMarkerType,\n getSeriesId,\n getSeriesMarkerType,\n isXThreshold,\n matchSizeAxis,\n} from \"../utils\";\n\nimport styles from \"../styles.css.js\";\n\nconst MIN_VISIBLE_BLOCK_SIZE = 200;\nconst DEFAULT_DEBOUNCE = 200;\n\ntype ExpandedSeriesState = Record<string, Set<string>>;\n\ninterface ExpandedSeriesStateProps {\n expandedSeries: ExpandedSeriesState;\n setExpandedSeries: (cb: (state: ExpandedSeriesState) => ExpandedSeriesState) => void;\n}\n\ninterface RenderedTooltipContent {\n header: React.ReactNode;\n body: React.ReactNode;\n footer: React.ReactNode;\n}\n\ninterface MatchedItem {\n point: Highcharts.Point;\n errorRanges: Highcharts.Point[];\n}\n\nexport function ChartTooltip({\n placement = \"target\",\n size,\n getTooltipContent: getTooltipContentOverrides,\n api,\n i18nStrings,\n debounce = false,\n seriesSorting = \"as-added\",\n sizeAxis,\n}: CoreChartProps.TooltipOptions & {\n i18nStrings?: BaseI18nStrings;\n getTooltipContent?: CoreChartProps.GetTooltipContent;\n sizeAxis?: readonly CoreChartProps.SizeAxisOptions[];\n api: ChartAPI;\n}) {\n const [expandedSeries, setExpandedSeries] = useState<ExpandedSeriesState>({});\n const tooltip = useSelector(api.tooltipStore, (s) => s);\n const debouncedTooltip = useDebouncedValue(tooltip, debounce === true ? DEFAULT_DEBOUNCE : debounce || 0);\n\n if (\n !debouncedTooltip ||\n !debouncedTooltip.visible ||\n debouncedTooltip.group.length === 0 ||\n debouncedTooltip.group[0].series === undefined\n ) {\n return null;\n }\n\n const chart = debouncedTooltip.group[0]?.series.chart;\n const renderers = getTooltipContentOverrides?.({ point: debouncedTooltip.point, group: debouncedTooltip.group });\n const getTrack = placement === \"target\" ? api.getTargetTrack : api.getGroupTrack;\n const position = (() => {\n if (placement === \"target\" || placement === \"middle\") {\n return !chart.inverted ? \"right\" : \"bottom\";\n } else {\n return !chart.inverted ? \"bottom\" : \"right\";\n }\n })();\n const content = getTooltipContent(api, {\n renderers,\n point: debouncedTooltip.point,\n group: debouncedTooltip.group,\n expandedSeries,\n setExpandedSeries,\n seriesSorting,\n sizeAxis,\n hideTooltip: () => {\n api.hideTooltip();\n },\n });\n if (!content) {\n return null;\n }\n return (\n <InternalChartTooltip\n getTrack={getTrack}\n trackKey={getTrackKey(debouncedTooltip.point, debouncedTooltip.group)}\n container={null}\n dismissButton={debouncedTooltip.pinned}\n dismissAriaLabel={i18nStrings?.detailPopoverDismissAriaLabel}\n onDismiss={api.onDismissTooltip}\n onMouseEnter={api.onMouseEnterTooltip}\n onMouseLeave={api.onMouseLeaveTooltip}\n title={content.header}\n footer={\n content.footer ? (\n <>\n <hr aria-hidden={true} />\n {content.footer}\n </>\n ) : null\n }\n size={size}\n position={position}\n minVisibleBlockSize={MIN_VISIBLE_BLOCK_SIZE}\n >\n <LiveRegion>{content.body}</LiveRegion>\n </InternalChartTooltip>\n );\n}\n\nfunction getTrackKey(point: null | Highcharts.Point, group: readonly Highcharts.Point[]) {\n const pointId = point && (point.options.id || point.options.name);\n if (point && pointId) {\n return `p-${pointId}-${point.x}-${point.y}`;\n }\n if (point) {\n return `p-${point.x}-${point.y}`;\n }\n return `g_${group.length}_${group[0].x}`;\n}\n\nfunction getTooltipContent(\n api: ChartAPI,\n props: CoreChartProps.GetTooltipContentProps & {\n renderers?: CoreChartProps.TooltipContentRenderer;\n hideTooltip: () => void;\n seriesSorting: NonNullable<CoreChartProps.TooltipOptions[\"seriesSorting\"]>;\n sizeAxis?: readonly CoreChartProps.SizeAxisOptions[];\n } & ExpandedSeriesStateProps,\n): null | RenderedTooltipContent {\n if (props.point && props.point.series.type === \"pie\") {\n return getTooltipContentPie(api, { ...props, point: props.point });\n } else if (props.group.length > 0 && props.group[0].series.type !== \"pie\") {\n return getTooltipContentCartesian(api, props);\n } else {\n return null;\n }\n}\n\nfunction getTooltipContentCartesian(\n api: ChartAPI,\n {\n point,\n group,\n expandedSeries,\n renderers = {},\n setExpandedSeries,\n hideTooltip,\n seriesSorting,\n sizeAxis,\n }: CoreChartProps.GetTooltipContentProps & {\n renderers?: CoreChartProps.TooltipContentRenderer;\n hideTooltip: () => void;\n seriesSorting: NonNullable<CoreChartProps.TooltipOptions[\"seriesSorting\"]>;\n sizeAxis?: readonly CoreChartProps.SizeAxisOptions[];\n } & ExpandedSeriesStateProps,\n): RenderedTooltipContent {\n // The cartesian tooltip might or might not have a selected point, but it always has a non-empty group.\n // By design, every point of the group has the same x value.\n const x = group[0].x;\n const chart = group[0].series.chart;\n const getPointMarker = (point: Highcharts.Point) => {\n const itemOptions = api.context.settings.getItemOptions?.(getSeriesId(point.series));\n return api.renderMarker({\n type: getPointMarkerType(point),\n color: getPointColor(point),\n visible: true,\n status: itemOptions?.status,\n ariaLabel: api.context.settings.labels.itemMarkerLabel?.(itemOptions?.status),\n });\n };\n const matchedItems = findTooltipSeriesItems(getChartSeries(chart), group, seriesSorting);\n const detailItems: ChartSeriesDetailItem[] = matchedItems.map((item) => {\n const valueFormatter = getFormatter(item.point.series.yAxis);\n const itemY = isXThreshold(item.point.series) ? null : (item.point.y ?? null);\n const bubbleSubItems = item.point.series.type === \"bubble\" ? getBubblePointDetails(item, sizeAxis) : undefined;\n const customContent = renderers.point\n ? renderers.point({\n item,\n hideTooltip,\n })\n : undefined;\n const defaultValue = bubbleSubItems ? null : valueFormatter(itemY);\n return {\n key: customContent?.key ?? item.point.series.name,\n value: customContent?.value ?? defaultValue,\n marker: getPointMarker(item.point),\n subItems: customContent?.subItems ?? bubbleSubItems,\n expandableId: customContent?.expandable ? item.point.series.name : undefined,\n highlighted: item.point.x === point?.x && item.point.y === point?.y,\n description:\n customContent?.description === undefined && item.errorRanges.length ? (\n <>\n {item.errorRanges.map((errorBarPoint, index) => (\n <div key={index} className={styles[\"error-range\"]}>\n <span>{errorBarPoint.series.userOptions.name ? errorBarPoint.series.userOptions.name : \"\"}</span>\n <span>\n {valueFormatter(errorBarPoint.options.low ?? 0)} - {valueFormatter(errorBarPoint.options.high ?? 0)}\n </span>\n </div>\n ))}\n </>\n ) : (\n customContent?.description\n ),\n };\n });\n // We only support cartesian charts with a single x axis.\n const titleFormatter = getFormatter(chart.xAxis[0]);\n const slotRenderProps: CoreChartProps.TooltipSlotProps = {\n x,\n items: matchedItems,\n hideTooltip: hideTooltip,\n };\n return {\n header: renderers.header?.(slotRenderProps) ?? titleFormatter(x),\n body: renderers.body?.(slotRenderProps) ?? (\n <ChartSeriesDetails\n details={detailItems}\n expandedSeries={expandedSeries[x]}\n setExpandedState={(id, isExpanded) => {\n setExpandedSeries((oldState) => {\n const expandedSeriesInCurrentCoordinate = new Set(oldState[x]);\n if (isExpanded) {\n expandedSeriesInCurrentCoordinate.add(id);\n } else {\n expandedSeriesInCurrentCoordinate.delete(id);\n }\n return { ...oldState, [x]: expandedSeriesInCurrentCoordinate };\n });\n }}\n />\n ),\n footer: renderers.footer?.(slotRenderProps),\n };\n}\n\nfunction getTooltipContentPie(\n api: ChartAPI,\n {\n point,\n renderers = {},\n hideTooltip,\n }: { point: Highcharts.Point } & { renderers?: CoreChartProps.TooltipContentRenderer; hideTooltip: () => void },\n): RenderedTooltipContent {\n const tooltipDetails: CoreChartProps.TooltipSlotProps = {\n x: point.x,\n items: [{ point, errorRanges: [] }],\n hideTooltip,\n };\n\n const itemOptions = api.context.settings.getItemOptions?.(getPointId(point));\n const markerAriaLabel = api.context.settings.labels.itemMarkerLabel?.(itemOptions?.status);\n\n return {\n header: renderers.header?.(tooltipDetails) ?? (\n <div className={styles[\"tooltip-default-header\"]}>\n {api.renderMarker({\n type: getSeriesMarkerType(point.series),\n color: getPointColor(point),\n visible: true,\n status: itemOptions?.status,\n ariaLabel: markerAriaLabel,\n })}\n <Box variant=\"span\" fontWeight=\"bold\">\n {point.name}\n </Box>\n </div>\n ),\n body:\n renderers.body?.(tooltipDetails) ??\n (renderers.details ? (\n <ChartSeriesDetails\n details={renderers.details({\n point,\n hideTooltip,\n })}\n compactList={true}\n />\n ) : (\n // We expect all pie chart segments to have defined y values. We use y=0 as fallback\n // because the property is optional in Highcharts types.\n <ChartSeriesDetails details={[{ key: point.series.name, value: point.y ?? 0 }]} />\n )),\n footer: renderers.footer?.(tooltipDetails),\n };\n}\n\nfunction getBubblePointDetails(item: MatchedItem, sizeAxis: readonly CoreChartProps.SizeAxisOptions[] = []) {\n const subItems: { key: React.ReactNode; value: React.ReactNode }[] = [];\n\n const y = item.point.y;\n const yAxisTitle = item.point.series.yAxis?.options?.title?.text;\n const yFormatter = item.point.series.yAxis ? getFormatter(item.point.series.yAxis) : (v: unknown) => String(v);\n subItems.push({ key: yAxisTitle, value: yFormatter(y) });\n\n // Size axis is a custom abstraction built to support bubble series title and formatter for z (size) values.\n // We match size axes by ID if provided, or take the first defined axis instead.\n const matchedSizeAxis = matchSizeAxis(sizeAxis, item.point.series);\n if (matchedSizeAxis) {\n // Highcharts bubble size is represented by point.z value, which is however not present in the internal point type -\n // so we take it from point's options instead.\n const size = item.point.options.z ?? null;\n const sizeAxisTitle = matchedSizeAxis.title;\n const sizeFormatter = getFormatter(matchedSizeAxis);\n subItems.push({ key: sizeAxisTitle, value: sizeFormatter(size) });\n }\n\n return subItems;\n}\n\nfunction findTooltipSeriesItems(\n series: readonly SafeSeries[],\n group: readonly Highcharts.Point[],\n seriesSorting: NonNullable<CoreChartProps.TooltipOptions[\"seriesSorting\"]>,\n): MatchedItem[] {\n const seriesOrder = series.reduce((d, s, i) => d.set(s, i), new Map<SafeSeries, number>());\n const getSeriesIndex = (s: SafeSeries) => seriesOrder.get(s) ?? -1;\n const seriesErrors = new Map<string, Highcharts.Point[]>();\n const matchedSeries = new Set<SafeSeries>();\n const matchedItems: MatchedItem[] = [];\n for (const point of group) {\n if (!isPointVisible(point)) {\n continue;\n }\n // We only support errorbar series that are linked to other series. In tooltip content we add\n // linked error bars to series detail slot.\n if (point.series.type === \"errorbar\") {\n if (point.series.linkedParent) {\n addError(getSeriesId(point.series.linkedParent), point);\n } else {\n warnOnce(\n \"chart-components\",\n 'The `linkedTo` property of \"errorbar\" series is missing, or points to a series that does not exist.',\n );\n }\n } else {\n addMatchedPoints(point);\n }\n }\n function addError(seriesId: string, errorPoint: Highcharts.Point) {\n if (errorPoint.options.low !== undefined && errorPoint.options.high !== undefined) {\n const errorRanges = seriesErrors.get(seriesId) ?? [];\n errorRanges.push(errorPoint);\n seriesErrors.set(seriesId, errorRanges);\n }\n }\n function addMatchedPoints(point: Highcharts.Point) {\n if (!matchedSeries.has(point.series)) {\n matchedSeries.add(point.series);\n if (isXThreshold(point.series)) {\n matchedItems.push({ point, errorRanges: [] });\n } else {\n getSeriesData(point.series)\n .filter((d) => d.x === point.x)\n .sort((a, b) => (a.y ?? 0) - (b.y ?? 0))\n .forEach((point) => matchedItems.push({ point, errorRanges: [] }));\n }\n }\n }\n return (\n matchedItems\n .sort((i1, i2) => {\n if (seriesSorting === \"by-value-desc\") {\n return (i2.point.y ?? 0) - (i1.point.y ?? 0);\n }\n // We sort matched items by series order. If there are multiple items that belong to the same series, we sort them by value.\n const s1 = getSeriesIndex(i1.point.series) - getSeriesIndex(i2.point.series);\n return s1 || (i1.point.y ?? 0) - (i2.point.y ?? 0);\n })\n // For each series item we add linked error ranges, sorted by their respective series indices.\n .map((item) => {\n const errorRanges = seriesErrors.get(getSeriesId(item.point.series)) ?? [];\n const sortedErrorRanges = errorRanges.sort((i1, i2) => getSeriesIndex(i1.series) - getSeriesIndex(i2.series));\n return { ...item, errorRanges: sortedErrorRanges };\n })\n );\n}\n"]}
@@ -177,23 +177,23 @@ export interface BaseTooltipPointFormatted {
177
177
  value: React.ReactNode;
178
178
  }>;
179
179
  }
180
- export interface AreaSeriesOptions extends BaseCartesianLineLikeOptions, LinkableSeries {
180
+ export interface AreaSeriesOptions extends BaseCartesianLineLikeOptions, LinkableSeries, WithZones {
181
181
  type: "area";
182
182
  data: readonly PointDataItemType[];
183
183
  }
184
- export interface AreaSplineSeriesOptions extends BaseCartesianLineLikeOptions, LinkableSeries {
184
+ export interface AreaSplineSeriesOptions extends BaseCartesianLineLikeOptions, LinkableSeries, WithZones {
185
185
  type: "areaspline";
186
186
  data: readonly PointDataItemType[];
187
187
  }
188
- export interface ColumnSeriesOptions extends BaseCartesianSeriesOptions, LinkableSeries {
188
+ export interface ColumnSeriesOptions extends BaseCartesianSeriesOptions, LinkableSeries, WithZones {
189
189
  type: "column";
190
190
  data: readonly PointDataItemType[];
191
191
  }
192
- export interface LineSeriesOptions extends BaseCartesianLineLikeOptions, LinkableSeries {
192
+ export interface LineSeriesOptions extends BaseCartesianLineLikeOptions, LinkableSeries, WithZones {
193
193
  type: "line";
194
194
  data: readonly PointDataItemType[];
195
195
  }
196
- export interface SplineSeriesOptions extends BaseCartesianLineLikeOptions, LinkableSeries {
196
+ export interface SplineSeriesOptions extends BaseCartesianLineLikeOptions, LinkableSeries, WithZones {
197
197
  type: "spline";
198
198
  data: readonly PointDataItemType[];
199
199
  }
@@ -268,6 +268,15 @@ export interface LinkableSeries {
268
268
  */
269
269
  linkedTo?: string;
270
270
  }
271
+ export interface WithZones {
272
+ zoneAxis?: "x" | "y";
273
+ zones?: readonly SeriesZone[];
274
+ }
275
+ export interface SeriesZone {
276
+ value?: number;
277
+ color?: string;
278
+ dashStyle?: Highcharts.DashStyleValue;
279
+ }
271
280
  interface BaseCartesianLineLikeOptions extends BaseCartesianSeriesOptions {
272
281
  dashStyle?: Highcharts.DashStyleValue;
273
282
  }