@cloudscape-design/chart-components 1.0.73 → 1.0.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/cartesian-chart/chart-cartesian-internal.js +2 -1
  2. package/cartesian-chart/chart-cartesian-internal.js.map +1 -1
  3. package/cartesian-chart/chart-series-cartesian.js +12 -1
  4. package/cartesian-chart/chart-series-cartesian.js.map +1 -1
  5. package/cartesian-chart/index.js +40 -4
  6. package/cartesian-chart/index.js.map +1 -1
  7. package/cartesian-chart/interfaces.d.ts +9 -1
  8. package/cartesian-chart/interfaces.js.map +1 -1
  9. package/core/chart-core.js +3 -3
  10. package/core/chart-core.js.map +1 -1
  11. package/core/components/core-legend.d.ts +2 -1
  12. package/core/components/core-legend.js +2 -2
  13. package/core/components/core-legend.js.map +1 -1
  14. package/core/interfaces.d.ts +4 -2
  15. package/core/interfaces.js.map +1 -1
  16. package/core/utils.d.ts +4 -0
  17. package/core/utils.js +6 -2
  18. package/core/utils.js.map +1 -1
  19. package/internal/api-docs/components/cartesian-chart.js +12 -66
  20. package/internal/api-docs/test-utils-doc/dom.js +44 -4
  21. package/internal/api-docs/test-utils-doc/selectors.js +44 -4
  22. package/internal/components/chart-legend/index.d.ts +2 -1
  23. package/internal/components/chart-legend/index.js +2 -2
  24. package/internal/components/chart-legend/index.js.map +1 -1
  25. package/internal/environment.js +1 -1
  26. package/internal/environment.json +1 -1
  27. package/internal/generated/styles/tokens.d.ts +6 -0
  28. package/internal/generated/styles/tokens.js +6 -0
  29. package/internal/generated/theming/index.cjs +33 -1
  30. package/internal/generated/theming/index.cjs.d.ts +63 -0
  31. package/internal/generated/theming/index.d.ts +63 -0
  32. package/internal/generated/theming/index.js +33 -1
  33. package/internal/manifest.json +1 -1
  34. package/package.json +1 -1
  35. package/test-utils/dom/internal/base.d.ts +8 -2
  36. package/test-utils/dom/internal/base.js +11 -3
  37. package/test-utils/dom/internal/base.js.map +1 -1
  38. package/test-utils/dom/internal/core.d.ts +3 -2
  39. package/test-utils/dom/internal/core.js +5 -5
  40. package/test-utils/dom/internal/core.js.map +1 -1
  41. package/test-utils/selectors/internal/base.d.ts +8 -2
  42. package/test-utils/selectors/internal/base.js +9 -3
  43. package/test-utils/selectors/internal/base.js.map +1 -1
  44. package/test-utils/selectors/internal/core.d.ts +3 -2
  45. package/test-utils/selectors/internal/core.js +3 -5
  46. package/test-utils/selectors/internal/core.js.map +1 -1
@@ -97,10 +97,11 @@ export const InternalCartesianChart = forwardRef(({ tooltip, ...props }, ref) =>
97
97
  title: { text: xAxisProps.title },
98
98
  plotLines: xPlotLines,
99
99
  })),
100
- yAxis: (_d = castArray(props.yAxis)) === null || _d === void 0 ? void 0 : _d.map((yAxisProps) => ({
100
+ yAxis: (_d = castArray(props.yAxis)) === null || _d === void 0 ? void 0 : _d.map((yAxisProps, index) => ({
101
101
  ...yAxisProps,
102
102
  title: { text: yAxisProps.title },
103
103
  plotLines: yPlotLines,
104
+ ...(index === 1 ? { opposite: true } : {}),
104
105
  })),
105
106
  }, sizeAxis: props.sizeAxis, tooltip: tooltip, getTooltipContent: getTooltipContent, visibleItems: props.visibleSeries, onVisibleItemsChange: onVisibleSeriesChange, className: testClasses.root }));
106
107
  });
@@ -1 +1 @@
1
- {"version":3,"file":"chart-cartesian-internal.js","sourceRoot":"","sources":["../../../src/cartesian-chart/chart-cartesian-internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC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EACpC,YAAY,EAAE,KAAK,CAAC,aAAa,EACjC,oBAAoB,EAAE,qBAAqB,EAC3C,SAAS,EAAE,WAAW,CAAC,IAAI,GAC3B,CACH,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { forwardRef, useImperativeHandle, useRef, useState } from \"react\";\n\nimport { useControllableState } from \"@cloudscape-design/component-toolkit\";\n\nimport { InternalCoreChart } from \"../core/chart-core\";\nimport { CoreChartProps, ErrorBarSeriesOptions } from \"../core/interfaces\";\nimport { getOptionsId, isXThreshold } from \"../core/utils\";\nimport { InternalBaseComponentProps } from \"../internal/base-component/use-base-component\";\nimport { fireNonCancelableEvent } from \"../internal/events\";\nimport { castArray, SomeRequired } from \"../internal/utils/utils\";\nimport { transformCartesianSeries } from \"./chart-series-cartesian\";\nimport { CartesianChartProps, NonErrorBarSeriesOptions } from \"./interfaces\";\n\nimport testClasses from \"./test-classes/styles.css.js\";\n\ninterface InternalCartesianChartProps extends InternalBaseComponentProps, CartesianChartProps {\n tooltip: SomeRequired<CartesianChartProps.TooltipOptions, \"enabled\" | \"placement\" | \"size\">;\n legend: SomeRequired<CartesianChartProps.LegendOptions, \"enabled\">;\n}\n\nexport const InternalCartesianChart = forwardRef(\n ({ tooltip, ...props }: InternalCartesianChartProps, ref: React.Ref<CartesianChartProps.Ref>) => {\n const apiRef = useRef<null | CoreChartProps.ChartAPI>(null);\n\n // When visibleSeries and onVisibleSeriesChange are provided - the series visibility can be controlled from the outside.\n // Otherwise - the component handles series visibility using its internal state.\n useControllableState(props.visibleSeries, props.onVisibleSeriesChange, undefined, {\n componentName: \"CartesianChart\",\n propertyName: \"visibleSeries\",\n changeHandlerName: \"onVisibleSeriesChange\",\n });\n const allSeriesIds = props.series.map((s) => getOptionsId(s));\n // We keep local visible series state to compute threshold series data, that depends on series visibility.\n const [visibleSeriesLocal, setVisibleSeriesLocal] = useState(props.visibleSeries ?? allSeriesIds);\n const visibleSeriesState = props.visibleSeries ?? visibleSeriesLocal;\n const onVisibleSeriesChange: CoreChartProps[\"onVisibleItemsChange\"] = ({ detail: { items } }) => {\n const visibleSeries = items.filter((i) => i.visible).map((i) => i.id);\n if (props.visibleSeries) {\n fireNonCancelableEvent(props.onVisibleSeriesChange, { visibleSeries });\n } else {\n setVisibleSeriesLocal(visibleSeries);\n }\n };\n\n // We convert cartesian tooltip options to the core chart's getTooltipContent callback,\n // ensuring no internal types are exposed to the consumer-defined render functions.\n const getTooltipContent: CoreChartProps[\"getTooltipContent\"] = () => {\n // We use point.series.userOptions to get the series options that were passed down to Highcharts,\n // assuming Highcharts makes no modifications for those. These options are not referentially equal\n // to the ones we get from the consumer due to the internal validation/transformation we run on them.\n // See: https://api.highcharts.com/class-reference/Highcharts.Chart#userOptions.\n const transformItem = (item: CoreChartProps.TooltipContentItem): CartesianChartProps.TooltipPointItem => {\n const userOptions = item.point.series.userOptions as NonErrorBarSeriesOptions;\n // Restore original threshold type from custom metadata, since transformCartesianSeries\n // replaces \"x-threshold\" and \"y-threshold\" with \"line\" for Highcharts compatibility.\n const originalType = item.point.series.userOptions.custom?.awsui?.type;\n const series = originalType\n ? ({ ...userOptions, type: originalType } as NonErrorBarSeriesOptions)\n : userOptions;\n return {\n x: item.point.x,\n y: isXThreshold(item.point.series) ? null : (item.point.y ?? null),\n size: item.point.options.z ?? undefined,\n series,\n errorRanges: item.errorRanges.map((point) => ({\n low: point.options.low ?? 0,\n high: point.options.high ?? 0,\n series: point.series.userOptions as ErrorBarSeriesOptions,\n })),\n };\n };\n const transformSeriesProps = (\n props: CoreChartProps.TooltipPointProps,\n ): CartesianChartProps.TooltipPointRenderProps => ({\n item: transformItem(props.item),\n });\n const transformSlotProps = (\n props: CoreChartProps.TooltipSlotProps,\n ): CartesianChartProps.TooltipSlotRenderProps => ({\n x: props.x,\n items: props.items.map(transformItem),\n });\n\n return {\n point: tooltip.point ? (coreProps) => tooltip.point!(transformSeriesProps(coreProps)) : undefined,\n header: tooltip.header ? (coreProps) => tooltip.header!(transformSlotProps(coreProps)) : undefined,\n body: tooltip.body ? (coreProps) => tooltip.body!(transformSlotProps(coreProps)) : undefined,\n footer: tooltip.footer ? (coreProps) => tooltip.footer!(transformSlotProps(coreProps)) : undefined,\n };\n };\n\n // Converting x-, and y-threshold series to Highcharts series and plot lines.\n const { series, xPlotLines, yPlotLines } = transformCartesianSeries(props.series, visibleSeriesState);\n\n // Cartesian chart imperative API.\n useImperativeHandle(ref, () => ({\n setVisibleSeries: (visibleSeriesIds) => apiRef.current?.setItemsVisible(visibleSeriesIds),\n showAllSeries: () => apiRef.current?.setItemsVisible(allSeriesIds),\n }));\n\n return (\n <InternalCoreChart\n {...props}\n callback={(api) => (apiRef.current = api)}\n options={{\n chart: {\n inverted: props.inverted,\n },\n plotOptions: {\n series: { stacking: props.stacking },\n },\n series,\n xAxis: castArray(props.xAxis)?.map((xAxisProps) => ({\n ...xAxisProps,\n title: { text: xAxisProps.title },\n plotLines: xPlotLines,\n })),\n yAxis: castArray(props.yAxis)?.map((yAxisProps) => ({\n ...yAxisProps,\n title: { text: yAxisProps.title },\n plotLines: yPlotLines,\n })),\n }}\n sizeAxis={props.sizeAxis}\n tooltip={tooltip}\n getTooltipContent={getTooltipContent}\n visibleItems={props.visibleSeries}\n onVisibleItemsChange={onVisibleSeriesChange}\n className={testClasses.root}\n />\n );\n },\n);\n"]}
1
+ {"version":3,"file":"chart-cartesian-internal.js","sourceRoot":"","sources":["../../../src/cartesian-chart/chart-cartesian-internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAA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;gBACrB,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC3C,CAAC,CAAC;SACJ,EACD,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,OAAO,EAAE,OAAO,EAChB,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,KAAK,CAAC,aAAa,EACjC,oBAAoB,EAAE,qBAAqB,EAC3C,SAAS,EAAE,WAAW,CAAC,IAAI,GAC3B,CACH,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { forwardRef, useImperativeHandle, useRef, useState } from \"react\";\n\nimport { useControllableState } from \"@cloudscape-design/component-toolkit\";\n\nimport { InternalCoreChart } from \"../core/chart-core\";\nimport { CoreChartProps, ErrorBarSeriesOptions } from \"../core/interfaces\";\nimport { getOptionsId, isXThreshold } from \"../core/utils\";\nimport { InternalBaseComponentProps } from \"../internal/base-component/use-base-component\";\nimport { fireNonCancelableEvent } from \"../internal/events\";\nimport { castArray, SomeRequired } from \"../internal/utils/utils\";\nimport { transformCartesianSeries } from \"./chart-series-cartesian\";\nimport { CartesianChartProps, NonErrorBarSeriesOptions } from \"./interfaces\";\n\nimport testClasses from \"./test-classes/styles.css.js\";\n\ninterface InternalCartesianChartProps extends InternalBaseComponentProps, CartesianChartProps {\n tooltip: SomeRequired<CartesianChartProps.TooltipOptions, \"enabled\" | \"placement\" | \"size\">;\n legend: SomeRequired<CartesianChartProps.LegendOptions, \"enabled\">;\n}\n\nexport const InternalCartesianChart = forwardRef(\n ({ tooltip, ...props }: InternalCartesianChartProps, ref: React.Ref<CartesianChartProps.Ref>) => {\n const apiRef = useRef<null | CoreChartProps.ChartAPI>(null);\n\n // When visibleSeries and onVisibleSeriesChange are provided - the series visibility can be controlled from the outside.\n // Otherwise - the component handles series visibility using its internal state.\n useControllableState(props.visibleSeries, props.onVisibleSeriesChange, undefined, {\n componentName: \"CartesianChart\",\n propertyName: \"visibleSeries\",\n changeHandlerName: \"onVisibleSeriesChange\",\n });\n const allSeriesIds = props.series.map((s) => getOptionsId(s));\n // We keep local visible series state to compute threshold series data, that depends on series visibility.\n const [visibleSeriesLocal, setVisibleSeriesLocal] = useState(props.visibleSeries ?? allSeriesIds);\n const visibleSeriesState = props.visibleSeries ?? visibleSeriesLocal;\n const onVisibleSeriesChange: CoreChartProps[\"onVisibleItemsChange\"] = ({ detail: { items } }) => {\n const visibleSeries = items.filter((i) => i.visible).map((i) => i.id);\n if (props.visibleSeries) {\n fireNonCancelableEvent(props.onVisibleSeriesChange, { visibleSeries });\n } else {\n setVisibleSeriesLocal(visibleSeries);\n }\n };\n\n // We convert cartesian tooltip options to the core chart's getTooltipContent callback,\n // ensuring no internal types are exposed to the consumer-defined render functions.\n const getTooltipContent: CoreChartProps[\"getTooltipContent\"] = () => {\n // We use point.series.userOptions to get the series options that were passed down to Highcharts,\n // assuming Highcharts makes no modifications for those. These options are not referentially equal\n // to the ones we get from the consumer due to the internal validation/transformation we run on them.\n // See: https://api.highcharts.com/class-reference/Highcharts.Chart#userOptions.\n const transformItem = (item: CoreChartProps.TooltipContentItem): CartesianChartProps.TooltipPointItem => {\n const userOptions = item.point.series.userOptions as NonErrorBarSeriesOptions;\n // Restore original threshold type from custom metadata, since transformCartesianSeries\n // replaces \"x-threshold\" and \"y-threshold\" with \"line\" for Highcharts compatibility.\n const originalType = item.point.series.userOptions.custom?.awsui?.type;\n const series = originalType\n ? ({ ...userOptions, type: originalType } as NonErrorBarSeriesOptions)\n : userOptions;\n return {\n x: item.point.x,\n y: isXThreshold(item.point.series) ? null : (item.point.y ?? null),\n size: item.point.options.z ?? undefined,\n series,\n errorRanges: item.errorRanges.map((point) => ({\n low: point.options.low ?? 0,\n high: point.options.high ?? 0,\n series: point.series.userOptions as ErrorBarSeriesOptions,\n })),\n };\n };\n const transformSeriesProps = (\n props: CoreChartProps.TooltipPointProps,\n ): CartesianChartProps.TooltipPointRenderProps => ({\n item: transformItem(props.item),\n });\n const transformSlotProps = (\n props: CoreChartProps.TooltipSlotProps,\n ): CartesianChartProps.TooltipSlotRenderProps => ({\n x: props.x,\n items: props.items.map(transformItem),\n });\n\n return {\n point: tooltip.point ? (coreProps) => tooltip.point!(transformSeriesProps(coreProps)) : undefined,\n header: tooltip.header ? (coreProps) => tooltip.header!(transformSlotProps(coreProps)) : undefined,\n body: tooltip.body ? (coreProps) => tooltip.body!(transformSlotProps(coreProps)) : undefined,\n footer: tooltip.footer ? (coreProps) => tooltip.footer!(transformSlotProps(coreProps)) : undefined,\n };\n };\n\n // Converting x-, and y-threshold series to Highcharts series and plot lines.\n const { series, xPlotLines, yPlotLines } = transformCartesianSeries(props.series, visibleSeriesState);\n\n // Cartesian chart imperative API.\n useImperativeHandle(ref, () => ({\n setVisibleSeries: (visibleSeriesIds) => apiRef.current?.setItemsVisible(visibleSeriesIds),\n showAllSeries: () => apiRef.current?.setItemsVisible(allSeriesIds),\n }));\n\n return (\n <InternalCoreChart\n {...props}\n callback={(api) => (apiRef.current = api)}\n options={{\n chart: {\n inverted: props.inverted,\n },\n plotOptions: {\n series: { stacking: props.stacking },\n },\n series,\n xAxis: castArray(props.xAxis)?.map((xAxisProps) => ({\n ...xAxisProps,\n title: { text: xAxisProps.title },\n plotLines: xPlotLines,\n })),\n yAxis: castArray(props.yAxis)?.map((yAxisProps, index) => ({\n ...yAxisProps,\n title: { text: yAxisProps.title },\n plotLines: yPlotLines,\n ...(index === 1 ? { opposite: true } : {}),\n })),\n }}\n sizeAxis={props.sizeAxis}\n tooltip={tooltip}\n getTooltipContent={getTooltipContent}\n visibleItems={props.visibleSeries}\n onVisibleItemsChange={onVisibleSeriesChange}\n className={testClasses.root}\n />\n );\n },\n);\n"]}
@@ -55,7 +55,18 @@ export const transformCartesianSeries = (originalSeries, visibleSeries) => {
55
55
  color: (_a = s.color) !== null && _a !== void 0 ? _a : Styles.thresholdSeries.color,
56
56
  dashStyle: (_b = s.dashStyle) !== null && _b !== void 0 ? _b : Styles.thresholdSeries.dashStyle,
57
57
  };
58
- return { type: "line", id: s.id, name: s.name, data, custom, enableMouseTracking, ...style, ...shared };
58
+ const yAxis = s.type === "y-threshold" ? s.yAxis : undefined;
59
+ return {
60
+ type: "line",
61
+ id: s.id,
62
+ name: s.name,
63
+ yAxis,
64
+ data,
65
+ custom,
66
+ enableMouseTracking,
67
+ ...style,
68
+ ...shared,
69
+ };
59
70
  }
60
71
  if (s.type === "errorbar") {
61
72
  const color = (_c = s.color) !== null && _c !== void 0 ? _c : colorChartsErrorBarMarker;
@@ -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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QAAQ,CAAC,CAAC,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,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 { 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 return { type: \"line\", id: s.id, name: s.name, data, custom, enableMouseTracking, ...style, ...shared };\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,IAA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,MAAM,CAAC,GAAG,MAAA,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,aAAD,CAAC,uBAAD,CAAC,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 { 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"]}
@@ -83,6 +83,7 @@ function transformLineLikeSeries(s, allSeries) {
83
83
  name: s.name,
84
84
  color: s.color,
85
85
  dashStyle: s.dashStyle,
86
+ yAxis: s.yAxis,
86
87
  linkedTo: s.linkedTo,
87
88
  data,
88
89
  };
@@ -92,7 +93,7 @@ function transformColumnSeries(s, allSeries) {
92
93
  return null;
93
94
  }
94
95
  const data = transformPointData(s.data);
95
- return { type: s.type, id: s.id, name: s.name, color: s.color, linkedTo: s.linkedTo, data };
96
+ return { type: s.type, id: s.id, name: s.name, color: s.color, yAxis: s.yAxis, linkedTo: s.linkedTo, data };
96
97
  }
97
98
  function transformScatterSeries(s, allSeries) {
98
99
  var _a;
@@ -101,21 +102,41 @@ function transformScatterSeries(s, allSeries) {
101
102
  }
102
103
  const data = transformPointData(s.data);
103
104
  const marker = (_a = s.marker) !== null && _a !== void 0 ? _a : {};
104
- return { type: s.type, id: s.id, name: s.name, color: s.color, linkedTo: s.linkedTo, data, marker };
105
+ return {
106
+ type: s.type,
107
+ id: s.id,
108
+ name: s.name,
109
+ color: s.color,
110
+ yAxis: s.yAxis,
111
+ linkedTo: s.linkedTo,
112
+ data,
113
+ marker,
114
+ };
105
115
  }
106
116
  function transformBubbleSeries(s, allSeries) {
107
117
  if (!validateLinkedTo(s, allSeries)) {
108
118
  return null;
109
119
  }
110
120
  const data = transformBubbleData(s.data);
111
- return { type: s.type, id: s.id, name: s.name, color: s.color, data, sizeAxis: s.sizeAxis };
121
+ return {
122
+ type: s.type,
123
+ id: s.id,
124
+ name: s.name,
125
+ color: s.color,
126
+ data,
127
+ yAxis: s.yAxis,
128
+ sizeAxis: s.sizeAxis,
129
+ linkedTo: s.linkedTo,
130
+ };
112
131
  }
113
132
  function transformThresholdSeries(s) {
133
+ const yAxis = s.type === "y-threshold" ? s.yAxis : undefined;
114
134
  return {
115
135
  type: s.type,
116
136
  id: s.id,
117
137
  name: s.name,
118
138
  color: s.color,
139
+ yAxis,
119
140
  value: s.value,
120
141
  dashStyle: s.dashStyle,
121
142
  };
@@ -132,7 +153,15 @@ function transformErrorBarSeries(series, allSeries, stacking) {
132
153
  return null;
133
154
  }
134
155
  const data = transformRangeData(series.data);
135
- return { type: series.type, id: series.id, name: series.name, color: series.color, linkedTo: series.linkedTo, data };
156
+ return {
157
+ type: series.type,
158
+ id: series.id,
159
+ name: series.name,
160
+ color: series.color,
161
+ yAxis: series.yAxis,
162
+ linkedTo: series.linkedTo,
163
+ data,
164
+ };
136
165
  }
137
166
  function transformPointData(data) {
138
167
  return data.map((d) => (d && typeof d === "object" ? { x: d.x, y: d.y } : d));
@@ -147,6 +176,12 @@ function transformXAxisOptions(axis) {
147
176
  return transformAxisOptions(axis);
148
177
  }
149
178
  function transformYAxisOptions(axis) {
179
+ if (Array.isArray(axis)) {
180
+ return [transformSingleYAxisOptions(axis[0]), transformSingleYAxisOptions(axis[1])];
181
+ }
182
+ return transformSingleYAxisOptions(axis);
183
+ }
184
+ function transformSingleYAxisOptions(axis) {
150
185
  return { ...transformAxisOptions(axis), reversedStacks: axis === null || axis === void 0 ? void 0 : axis.reversedStacks };
151
186
  }
152
187
  function transformSizeAxisOptions(axis) {
@@ -159,6 +194,7 @@ function transformSizeAxisOptions(axis) {
159
194
  }
160
195
  function transformAxisOptions(axis) {
161
196
  return {
197
+ id: axis === null || axis === void 0 ? void 0 : axis.id,
162
198
  type: axis === null || axis === void 0 ? void 0 : axis.type,
163
199
  title: axis === null || axis === void 0 ? void 0 : axis.title,
164
200
  min: axis === null || axis === void 0 ? void 0 : axis.min,
@@ -1 +1 @@
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,QA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AED,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 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, 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 { type: s.type, id: s.id, name: s.name, color: s.color, linkedTo: s.linkedTo, data, marker } 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 { type: s.type, id: s.id, name: s.name, color: s.color, data, sizeAxis: s.sizeAxis } as S;\n}\n\nfunction transformThresholdSeries<\n S extends CartesianChartProps.XThresholdSeriesOptions | CartesianChartProps.YThresholdSeriesOptions,\n>(s: S): null | S {\n return {\n type: s.type,\n id: s.id,\n name: s.name,\n color: s.color,\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 { type: series.type, id: series.id, name: series.name, color: series.color, linkedTo: series.linkedTo, data };\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(axis?: CartesianChartProps.YAxisOptions): CartesianChartProps.YAxisOptions {\n return { ...transformAxisOptions(axis), reversedStacks: axis?.reversedStacks };\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 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,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,CAAE,EAAE;QACZ,IAAI,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI;QAChB,KAAK,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK;QAClB,GAAG,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG;QACd,GAAG,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG;QACd,YAAY,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY;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"]}
@@ -65,6 +65,10 @@ export interface CartesianChartProps extends CoreTypes.BaseChartOptions, CoreTyp
65
65
  * This property corresponds to [yAxis](https://api.highcharts.com/highcharts/yAxis), and extends it
66
66
  * with a custom value formatter.
67
67
  *
68
+ * Use a single object for a single y axis, or a tuple of two objects for a dual-axis chart.
69
+ * When using a tuple, both axes must have an `id`. The second axis is automatically rendered on the opposite (inline-end) side.
70
+ * Series reference their axis by setting `yAxis` to the axis `id`.
71
+ *
68
72
  * Supported options:
69
73
  * * `title` (optional, string) - Axis title.
70
74
  * * `type` (optional, "linear" | "datetime" | "category" | "logarithmic") - Axis type.
@@ -80,7 +84,7 @@ export interface CartesianChartProps extends CoreTypes.BaseChartOptions, CoreTyp
80
84
  * * `valueFormatter` (optional, function) - Takes axis tick as input and returns a formatted string. This formatter also
81
85
  * applies to the tooltip points values.
82
86
  */
83
- yAxis?: CartesianChartProps.YAxisOptions;
87
+ yAxis?: CartesianChartProps.YAxisOptions | [CartesianChartProps.YAxisWithId, CartesianChartProps.YAxisWithId];
84
88
  /**
85
89
  * One or multiple axes to provide size details formatting for bubble series.
86
90
  *
@@ -126,6 +130,7 @@ export declare namespace CartesianChartProps {
126
130
  export type XThresholdSeriesOptions = CoreTypes.XThresholdSeriesOptions;
127
131
  export type YThresholdSeriesOptions = CoreTypes.YThresholdSeriesOptions;
128
132
  interface AxisOptions {
133
+ id?: string;
129
134
  title?: string;
130
135
  type?: "linear" | "datetime" | "category" | "logarithmic";
131
136
  min?: number;
@@ -143,6 +148,9 @@ export declare namespace CartesianChartProps {
143
148
  export interface YAxisOptions extends AxisOptions {
144
149
  reversedStacks?: boolean;
145
150
  }
151
+ export interface YAxisWithId extends YAxisOptions {
152
+ id: string;
153
+ }
146
154
  export interface TooltipOptions {
147
155
  enabled?: boolean;
148
156
  placement?: "middle" | "outside";
@@ -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 * 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;\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 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 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 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"]}
@@ -179,7 +179,7 @@ export function InternalCoreChart({ options, ariaLabel, ariaDescription, fitHeig
179
179
  // Depending on the chart.inverted the y-axis can be rendered as vertical, and needs to respect page direction.
180
180
  reversed: inverted && isRtl ? !yAxisOptions.reversed : yAxisOptions.reversed,
181
181
  opposite: !inverted && isRtl ? !yAxisOptions.opposite : yAxisOptions.opposite,
182
- className: yAxisClassName(inverted, yAxisOptions.className),
182
+ className: yAxisClassName(inverted, yAxisOptions.className, yAxisOptions.id),
183
183
  title: axisTitle((_a = yAxisOptions.title) !== null && _a !== void 0 ? _a : {}, inverted || verticalAxisTitlePlacement === "side"),
184
184
  labels: axisLabels((_b = yAxisOptions.labels) !== null && _b !== void 0 ? _b : {}),
185
185
  plotLines: yAxisPlotLines(yAxisOptions.plotLines, emphasizeBaseline),
@@ -294,8 +294,8 @@ export function InternalCoreChart({ options, ariaLabel, ariaDescription, fitHeig
294
294
  function xAxisClassName(inverted, customClassName) {
295
295
  return clsx(testClasses["axis-x"], inverted ? testClasses["axis-vertical"] : testClasses["axis-horizontal"], customClassName);
296
296
  }
297
- function yAxisClassName(inverted, customClassName) {
298
- return clsx(testClasses["axis-y"], inverted ? testClasses["axis-horizontal"] : testClasses["axis-vertical"], customClassName);
297
+ function yAxisClassName(inverted, customClassName, axisId) {
298
+ return clsx(testClasses["axis-y"], inverted ? testClasses["axis-horizontal"] : testClasses["axis-vertical"], customClassName, axisId && `awsui-axis-${axisId}`);
299
299
  }
300
300
  // When placing vertical axis title in the chart's top, the actual axis title rendered by Highcharts
301
301
  // needs to be visually hidden (it is still accessible by screen-readers). We then set title's