@cloudscape-design/chart-components 1.0.69 → 1.0.71
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.
- package/cartesian-chart/chart-cartesian-internal.js +7 -6
- package/cartesian-chart/chart-cartesian-internal.js.map +1 -1
- package/cartesian-chart/chart-series-cartesian.js +5 -1
- package/cartesian-chart/chart-series-cartesian.js.map +1 -1
- package/cartesian-chart/index.js +23 -1
- package/cartesian-chart/index.js.map +1 -1
- package/cartesian-chart/interfaces.d.ts +18 -1
- package/cartesian-chart/interfaces.js.map +1 -1
- package/core/chart-core.js +1 -1
- package/core/chart-core.js.map +1 -1
- package/core/components/core-tooltip.d.ts +2 -1
- package/core/components/core-tooltip.js +29 -6
- package/core/components/core-tooltip.js.map +1 -1
- package/core/formatters.d.ts +2 -1
- package/core/formatters.js +6 -2
- package/core/formatters.js.map +1 -1
- package/core/interfaces.d.ts +16 -0
- package/core/interfaces.js.map +1 -1
- package/core/utils.d.ts +11 -0
- package/core/utils.js +10 -0
- package/core/utils.js.map +1 -1
- package/internal/api-docs/components/cartesian-chart.js +15 -1
- package/internal/components/series-details/styles.css.js +18 -18
- package/internal/components/series-details/styles.scoped.css +27 -27
- package/internal/components/series-details/styles.selectors.js +18 -18
- package/internal/components/series-marker/render-marker.js +2 -2
- package/internal/components/series-marker/render-marker.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/generated/styles/tokens.d.ts +12 -2
- package/internal/generated/styles/tokens.js +12 -2
- package/internal/generated/theming/index.cjs +152 -10
- package/internal/generated/theming/index.cjs.d.ts +18 -0
- package/internal/generated/theming/index.d.ts +18 -0
- package/internal/generated/theming/index.js +152 -10
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
|
@@ -40,7 +40,7 @@ export const InternalCartesianChart = forwardRef(({ tooltip, ...props }, ref) =>
|
|
|
40
40
|
// to the ones we get from the consumer due to the internal validation/transformation we run on them.
|
|
41
41
|
// See: https://api.highcharts.com/class-reference/Highcharts.Chart#userOptions.
|
|
42
42
|
const transformItem = (item) => {
|
|
43
|
-
var _a, _b, _c;
|
|
43
|
+
var _a, _b, _c, _d;
|
|
44
44
|
const userOptions = item.point.series.userOptions;
|
|
45
45
|
// Restore original threshold type from custom metadata, since transformCartesianSeries
|
|
46
46
|
// replaces "x-threshold" and "y-threshold" with "line" for Highcharts compatibility.
|
|
@@ -51,6 +51,7 @@ export const InternalCartesianChart = forwardRef(({ tooltip, ...props }, ref) =>
|
|
|
51
51
|
return {
|
|
52
52
|
x: item.point.x,
|
|
53
53
|
y: isXThreshold(item.point.series) ? null : ((_c = item.point.y) !== null && _c !== void 0 ? _c : null),
|
|
54
|
+
size: (_d = item.point.options.z) !== null && _d !== void 0 ? _d : undefined,
|
|
54
55
|
series,
|
|
55
56
|
errorRanges: item.errorRanges.map((point) => {
|
|
56
57
|
var _a, _b;
|
|
@@ -70,10 +71,10 @@ export const InternalCartesianChart = forwardRef(({ tooltip, ...props }, ref) =>
|
|
|
70
71
|
items: props.items.map(transformItem),
|
|
71
72
|
});
|
|
72
73
|
return {
|
|
73
|
-
point: tooltip.point ? (
|
|
74
|
-
header: tooltip.header ? (
|
|
75
|
-
body: tooltip.body ? (
|
|
76
|
-
footer: tooltip.footer ? (
|
|
74
|
+
point: tooltip.point ? (coreProps) => tooltip.point(transformSeriesProps(coreProps)) : undefined,
|
|
75
|
+
header: tooltip.header ? (coreProps) => tooltip.header(transformSlotProps(coreProps)) : undefined,
|
|
76
|
+
body: tooltip.body ? (coreProps) => tooltip.body(transformSlotProps(coreProps)) : undefined,
|
|
77
|
+
footer: tooltip.footer ? (coreProps) => tooltip.footer(transformSlotProps(coreProps)) : undefined,
|
|
77
78
|
};
|
|
78
79
|
};
|
|
79
80
|
// Converting x-, and y-threshold series to Highcharts series and plot lines.
|
|
@@ -101,6 +102,6 @@ export const InternalCartesianChart = forwardRef(({ tooltip, ...props }, ref) =>
|
|
|
101
102
|
title: { text: yAxisProps.title },
|
|
102
103
|
plotLines: yPlotLines,
|
|
103
104
|
})),
|
|
104
|
-
}, tooltip: tooltip, getTooltipContent: getTooltipContent, visibleItems: props.visibleSeries, onVisibleItemsChange: onVisibleSeriesChange, className: testClasses.root }));
|
|
105
|
+
}, sizeAxis: props.sizeAxis, tooltip: tooltip, getTooltipContent: getTooltipContent, visibleItems: props.visibleSeries, onVisibleItemsChange: onVisibleSeriesChange, className: testClasses.root }));
|
|
105
106
|
});
|
|
106
107
|
//# sourceMappingURL=chart-cartesian-internal.js.map
|
|
@@ -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;AAC5D,OAAO,EAAE,SAAS,EAAgB,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAGpE,OAAO,WAAW,MAAM,8BAA8B,CAAC;AAOvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAC9C,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAA+B,EAAE,GAAuC,EAAE,EAAE;;IAC9F,MAAM,MAAM,GAAG,MAAM,CAAiC,IAAI,CAAC,CAAC;IAE5D,wHAAwH;IACxH,gFAAgF;IAChF,oBAAoB,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,qBAAqB,EAAE,SAA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AK,EAAE;gBACL,QAAQ,EAAE,KAAK,CAAC,QAAQ;aACzB;YACD,WAAW,EAAE;gBACX,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE;aACrC;YACD,MAAM;YACN,KAAK,EAAE,MAAA,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,0CAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBAClD,GAAG,UAAU;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE;gBACjC,SAAS,EAAE,UAAU;aACtB,CAAC,CAAC;YACH,KAAK,EAAE,MAAA,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,0CAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBAClD,GAAG,UAAU;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE;gBACjC,SAAS,EAAE,UAAU;aACtB,CAAC,CAAC;SACJ,EACD,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 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 return {\n point: tooltip.point ? (props) => tooltip.point!(transformSeriesProps(props)) : undefined,\n header: tooltip.header ? (props) => tooltip.header!(transformSlotProps(props)) : undefined,\n body: tooltip.body ? (props) => tooltip.body!(transformSlotProps(props)) : undefined,\n footer: tooltip.footer ? (props) => tooltip.footer!(transformSlotProps(props)) : 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 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,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAgB,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAGpE,OAAO,WAAW,MAAM,8BAA8B,CAAC;AAOvD,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAC9C,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAA+B,EAAE,GAAuC,EAAE,EAAE;;IAC9F,MAAM,MAAM,GAAG,MAAM,CAAiC,IAAI,CAAC,CAAC;IAE5D,wHAAwH;IACxH,gFAAgF;IAChF,oBAAoB,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,qBAAqB,EAAE,SAAS,EAAE;QAChF,aAAa,EAAE,gBAAgB;QAC/B,YAAY,EAAE,eAAe;QAC7B,iBAAiB,EAAE,u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,EAAE;gBACL,QAAQ,EAAE,KAAK,CAAC,QAAQ;aACzB;YACD,WAAW,EAAE;gBACX,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE;aACrC;YACD,MAAM;YACN,KAAK,EAAE,MAAA,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,0CAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBAClD,GAAG,UAAU;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE;gBACjC,SAAS,EAAE,UAAU;aACtB,CAAC,CAAC;YACH,KAAK,EAAE,MAAA,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,0CAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBAClD,GAAG,UAAU;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE;gBACjC,SAAS,EAAE,UAAU;aACtB,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) => ({\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,7 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { colorChartsErrorBarMarker } from "@cloudscape-design/design-tokens";
|
|
4
|
-
import { createThresholdMetadata, getOptionsId } from "../core/utils";
|
|
4
|
+
import { createBubbleMetadata, createThresholdMetadata, getOptionsId } from "../core/utils";
|
|
5
5
|
import * as Styles from "../internal/chart-styles";
|
|
6
6
|
import { getMasterSeries, isThreshold } from "./utils";
|
|
7
7
|
// The utility transforms cartesian chart component's series to Highcharts series. This includes transforming
|
|
@@ -64,6 +64,10 @@ export const transformCartesianSeries = (originalSeries, visibleSeries) => {
|
|
|
64
64
|
const colors = { stemColor: color, whiskerColor: color };
|
|
65
65
|
return { ...s, data: s.data, ...colors };
|
|
66
66
|
}
|
|
67
|
+
if (s.type === "bubble") {
|
|
68
|
+
const { custom } = createBubbleMetadata(s);
|
|
69
|
+
return { ...s, data: s.data.map((p) => ({ x: p.x, y: p.y, z: p.size })), ...shared, custom, ...getColorProps(s) };
|
|
70
|
+
}
|
|
67
71
|
return { ...s, data: s.data, ...shared, ...getColorProps(s) };
|
|
68
72
|
}
|
|
69
73
|
const series = originalSeries.map(transformSeriesToHighcharts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3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M,CAAC,IAAI,oBAAoB,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC;QAC5D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACpB,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 { 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 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,C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CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACpB,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 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"]}
|
package/cartesian-chart/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { warnOnce } from "@cloudscape-design/component-toolkit/internal";
|
|
|
6
6
|
import { getDataAttributes } from "../internal/base-component/get-data-attributes";
|
|
7
7
|
import useBaseComponent from "../internal/base-component/use-base-component";
|
|
8
8
|
import { applyDisplayName } from "../internal/utils/apply-display-name";
|
|
9
|
+
import { castArray } from "../internal/utils/utils";
|
|
9
10
|
import { InternalCartesianChart } from "./chart-cartesian-internal";
|
|
10
11
|
import { getMasterSeries, isErrorBar, isThreshold } from "./utils";
|
|
11
12
|
const CartesianChart = forwardRef(({ fitHeight = false, inverted = false, stacking = undefined, emphasizeBaseline = true, verticalAxisTitlePlacement = "top", ...props }, ref) => {
|
|
@@ -15,13 +16,14 @@ const CartesianChart = forwardRef(({ fitHeight = false, inverted = false, stacki
|
|
|
15
16
|
const series = transformSeries(props.series, stacking);
|
|
16
17
|
const xAxis = transformXAxisOptions(props.xAxis);
|
|
17
18
|
const yAxis = transformYAxisOptions(props.yAxis);
|
|
19
|
+
const sizeAxis = transformSizeAxisOptions(props.sizeAxis);
|
|
18
20
|
const tooltip = transformTooltip(props.tooltip);
|
|
19
21
|
const legend = transformLegend(props.legend);
|
|
20
22
|
const baseComponentProps = useBaseComponent("CartesianHighcharts", {
|
|
21
23
|
props: { fitHeight, inverted, stacking, emphasizeBaseline, verticalAxisTitlePlacement },
|
|
22
24
|
metadata: {},
|
|
23
25
|
});
|
|
24
|
-
return (_jsx(InternalCartesianChart, { ref: ref, ...props, fitHeight: fitHeight, inverted: inverted, stacking: stacking, emphasizeBaseline: emphasizeBaseline, verticalAxisTitlePlacement: verticalAxisTitlePlacement, series: series, xAxis: xAxis, yAxis: yAxis, tooltip: tooltip, legend: legend, ...getDataAttributes(props), ...baseComponentProps }));
|
|
26
|
+
return (_jsx(InternalCartesianChart, { ref: ref, ...props, fitHeight: fitHeight, inverted: inverted, stacking: stacking, emphasizeBaseline: emphasizeBaseline, verticalAxisTitlePlacement: verticalAxisTitlePlacement, series: series, xAxis: xAxis, yAxis: yAxis, sizeAxis: sizeAxis, tooltip: tooltip, legend: legend, ...getDataAttributes(props), ...baseComponentProps }));
|
|
25
27
|
});
|
|
26
28
|
applyDisplayName(CartesianChart, "CartesianChart");
|
|
27
29
|
export default CartesianChart;
|
|
@@ -38,6 +40,8 @@ function transformSeries(untransformedSeries, stacking) {
|
|
|
38
40
|
return transformColumnSeries(s, untransformedSeries);
|
|
39
41
|
case "scatter":
|
|
40
42
|
return transformScatterSeries(s, untransformedSeries);
|
|
43
|
+
case "bubble":
|
|
44
|
+
return transformBubbleSeries(s, untransformedSeries);
|
|
41
45
|
case "errorbar":
|
|
42
46
|
return transformErrorBarSeries(s, untransformedSeries, stacking);
|
|
43
47
|
case "x-threshold":
|
|
@@ -99,6 +103,13 @@ function transformScatterSeries(s, allSeries) {
|
|
|
99
103
|
const marker = (_a = s.marker) !== null && _a !== void 0 ? _a : {};
|
|
100
104
|
return { type: s.type, id: s.id, name: s.name, color: s.color, linkedTo: s.linkedTo, data, marker };
|
|
101
105
|
}
|
|
106
|
+
function transformBubbleSeries(s, allSeries) {
|
|
107
|
+
if (!validateLinkedTo(s, allSeries)) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
const data = transformBubbleData(s.data);
|
|
111
|
+
return { type: s.type, id: s.id, name: s.name, color: s.color, data, sizeAxis: s.sizeAxis };
|
|
112
|
+
}
|
|
102
113
|
function transformThresholdSeries(s) {
|
|
103
114
|
return {
|
|
104
115
|
type: s.type,
|
|
@@ -126,6 +137,9 @@ function transformErrorBarSeries(series, allSeries, stacking) {
|
|
|
126
137
|
function transformPointData(data) {
|
|
127
138
|
return data.map((d) => (d && typeof d === "object" ? { x: d.x, y: d.y } : d));
|
|
128
139
|
}
|
|
140
|
+
function transformBubbleData(data) {
|
|
141
|
+
return data.map((d) => ({ x: d.x, y: d.y, size: d.size }));
|
|
142
|
+
}
|
|
129
143
|
function transformRangeData(data) {
|
|
130
144
|
return data.map((d) => ({ x: d.x, low: d.low, high: d.high }));
|
|
131
145
|
}
|
|
@@ -135,6 +149,14 @@ function transformXAxisOptions(axis) {
|
|
|
135
149
|
function transformYAxisOptions(axis) {
|
|
136
150
|
return { ...transformAxisOptions(axis), reversedStacks: axis === null || axis === void 0 ? void 0 : axis.reversedStacks };
|
|
137
151
|
}
|
|
152
|
+
function transformSizeAxisOptions(axis) {
|
|
153
|
+
var _a;
|
|
154
|
+
return (_a = castArray(axis)) === null || _a === void 0 ? void 0 : _a.map((a) => ({
|
|
155
|
+
id: a.id,
|
|
156
|
+
title: a.title,
|
|
157
|
+
valueFormatter: a.valueFormatter,
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
138
160
|
function transformAxisOptions(axis) {
|
|
139
161
|
return {
|
|
140
162
|
type: axis === null || axis === void 0 ? void 0 : axis.type,
|
|
@@ -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,i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oB,CAC3B,IAAQ;IAER,OAAO;QACL,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 } 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 { 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 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 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 \"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 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 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 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,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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 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"]}
|
|
@@ -22,6 +22,7 @@ export interface CartesianChartProps extends CoreTypes.BaseChartOptions, CoreTyp
|
|
|
22
22
|
* * [column](https://api.highcharts.com/highcharts/series.column).
|
|
23
23
|
* * [errorbar](https://api.highcharts.com/highcharts/series.errorbar) - requires "highcharts/highcharts-more" module.
|
|
24
24
|
* * [line](https://api.highcharts.com/highcharts/series.line).
|
|
25
|
+
* * [bubble](https://api.highcharts.com/highcharts/series.bubble) - requires "highcharts/highcharts-more" module.
|
|
25
26
|
* * [scatter](https://api.highcharts.com/highcharts/series.scatter).
|
|
26
27
|
* * [spline](https://api.highcharts.com/highcharts/series.spline).
|
|
27
28
|
* * x-threshold - The line-like series to represent x-axis threshold (vertical, when `inverted=false`).
|
|
@@ -80,6 +81,15 @@ export interface CartesianChartProps extends CoreTypes.BaseChartOptions, CoreTyp
|
|
|
80
81
|
* applies to the tooltip points values.
|
|
81
82
|
*/
|
|
82
83
|
yAxis?: CartesianChartProps.YAxisOptions;
|
|
84
|
+
/**
|
|
85
|
+
* One or multiple axes to provide size details formatting for bubble series.
|
|
86
|
+
*
|
|
87
|
+
* Supported options:
|
|
88
|
+
* * `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.
|
|
89
|
+
* * `title` (string) - Axis title, shown in the tooltip details for bubble series.
|
|
90
|
+
* * `valueFormatter` (optional, function) - Value formatter for `size` values of the bubble series data.
|
|
91
|
+
*/
|
|
92
|
+
sizeAxis?: CartesianChartProps.SizeAxisOptions | readonly CartesianChartProps.SizeAxisOptions[];
|
|
83
93
|
/**
|
|
84
94
|
* Specifies which series to show using their IDs. By default, all series are visible and managed by the component.
|
|
85
95
|
* If a series doesn't have an ID, its name is used. When using this property, manage state updates with `onVisibleSeriesChange`.
|
|
@@ -104,9 +114,10 @@ export declare namespace CartesianChartProps {
|
|
|
104
114
|
*/
|
|
105
115
|
showAllSeries(): void;
|
|
106
116
|
}
|
|
107
|
-
export type SeriesOptions = AreaSeriesOptions | AreaSplineSeriesOptions | ColumnSeriesOptions | ErrorBarSeriesOptions | LineSeriesOptions | ScatterSeriesOptions | SplineSeriesOptions | XThresholdSeriesOptions | YThresholdSeriesOptions;
|
|
117
|
+
export type SeriesOptions = AreaSeriesOptions | AreaSplineSeriesOptions | BubbleSeriesOptions | ColumnSeriesOptions | ErrorBarSeriesOptions | LineSeriesOptions | ScatterSeriesOptions | SplineSeriesOptions | XThresholdSeriesOptions | YThresholdSeriesOptions;
|
|
108
118
|
export type AreaSeriesOptions = CoreTypes.AreaSeriesOptions;
|
|
109
119
|
export type AreaSplineSeriesOptions = CoreTypes.AreaSplineSeriesOptions;
|
|
120
|
+
export type BubbleSeriesOptions = CoreTypes.BubbleSeriesOptions;
|
|
110
121
|
export type ColumnSeriesOptions = CoreTypes.ColumnSeriesOptions;
|
|
111
122
|
export type ErrorBarSeriesOptions = CoreTypes.ErrorBarSeriesOptions;
|
|
112
123
|
export type LineSeriesOptions = CoreTypes.LineSeriesOptions;
|
|
@@ -123,6 +134,11 @@ export declare namespace CartesianChartProps {
|
|
|
123
134
|
categories?: string[];
|
|
124
135
|
valueFormatter?: (value: null | number) => string;
|
|
125
136
|
}
|
|
137
|
+
export interface SizeAxisOptions {
|
|
138
|
+
id?: string;
|
|
139
|
+
title: string;
|
|
140
|
+
valueFormatter?: (value: null | number) => string;
|
|
141
|
+
}
|
|
126
142
|
export type XAxisOptions = AxisOptions;
|
|
127
143
|
export interface YAxisOptions extends AxisOptions {
|
|
128
144
|
reversedStacks?: boolean;
|
|
@@ -149,6 +165,7 @@ export declare namespace CartesianChartProps {
|
|
|
149
165
|
export interface TooltipPointItem {
|
|
150
166
|
x: number;
|
|
151
167
|
y: number | null;
|
|
168
|
+
size?: number | null;
|
|
152
169
|
errorRanges: {
|
|
153
170
|
low: number;
|
|
154
171
|
high: number;
|
|
@@ -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 * * [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 [xAxis](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 * 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 | 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 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 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 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 [xAxis](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"]}
|
package/core/chart-core.js
CHANGED
|
@@ -289,7 +289,7 @@ export function InternalCoreChart({ options, ariaLabel, ariaDescription, fitHeig
|
|
|
289
289
|
},
|
|
290
290
|
};
|
|
291
291
|
return (_jsxs(_Fragment, { children: [_jsx(ChartApplication, { api: api, keyboardNavigation: keyboardNavigation, ariaLabel: ariaLabel }), _jsx(HighchartsReact, { highcharts: highcharts, options: highchartsOptions, callback: (chart) => callback === null || callback === void 0 ? void 0 : callback({ chart, highcharts: highcharts, ...api.publicApi }) })] }));
|
|
292
|
-
}, navigator: navigator, primaryLegend: context.legendEnabled && legendProps.primary ? (_jsx(ChartLegend, { ...commonLegendProps, ...legendProps.primary, className: testClasses["legend-primary"] })) : null, secondaryLegend: context.legendEnabled && legendProps.secondary ? (_jsx(ChartLegend, { ...commonLegendProps, ...legendProps.secondary, className: testClasses["legend-secondary"] })) : null, verticalAxisTitle: verticalAxisTitlePlacement === "top" ? _jsx(VerticalAxisTitle, { api: api, inverted: !!inverted }) : null, header: (header === null || header === void 0 ? void 0 : header.content) ? _jsx(ChartHeader, { children: header.content }) : null, footer: (footer === null || footer === void 0 ? void 0 : footer.content) ? _jsx(ChartFooter, { children: footer.content }) : null, filter: (filter === null || filter === void 0 ? void 0 : filter.seriesFilter) || (filter === null || filter === void 0 ? void 0 : filter.additionalFilters) ? (_jsx(ChartFilters, { api: api, seriesFilter: filter === null || filter === void 0 ? void 0 : filter.seriesFilter, additionalFilters: filter === null || filter === void 0 ? void 0 : filter.additionalFilters, i18nStrings: i18nStrings })) : null, noData: context.noDataEnabled && _jsx(ChartNoData, { ...noDataOptions, i18nStrings: i18nStrings, api: api }) }), context.tooltipEnabled && (_jsx(ChartTooltip, { ...tooltipOptions, i18nStrings: i18nStrings, getTooltipContent: rest.getTooltipContent, api: api }))] }));
|
|
292
|
+
}, navigator: navigator, primaryLegend: context.legendEnabled && legendProps.primary ? (_jsx(ChartLegend, { ...commonLegendProps, ...legendProps.primary, className: testClasses["legend-primary"] })) : null, secondaryLegend: context.legendEnabled && legendProps.secondary ? (_jsx(ChartLegend, { ...commonLegendProps, ...legendProps.secondary, className: testClasses["legend-secondary"] })) : null, verticalAxisTitle: verticalAxisTitlePlacement === "top" ? _jsx(VerticalAxisTitle, { api: api, inverted: !!inverted }) : null, header: (header === null || header === void 0 ? void 0 : header.content) ? _jsx(ChartHeader, { children: header.content }) : null, footer: (footer === null || footer === void 0 ? void 0 : footer.content) ? _jsx(ChartFooter, { children: footer.content }) : null, filter: (filter === null || filter === void 0 ? void 0 : filter.seriesFilter) || (filter === null || filter === void 0 ? void 0 : filter.additionalFilters) ? (_jsx(ChartFilters, { api: api, seriesFilter: filter === null || filter === void 0 ? void 0 : filter.seriesFilter, additionalFilters: filter === null || filter === void 0 ? void 0 : filter.additionalFilters, i18nStrings: i18nStrings })) : null, noData: context.noDataEnabled && _jsx(ChartNoData, { ...noDataOptions, i18nStrings: i18nStrings, api: api }) }), context.tooltipEnabled && (_jsx(ChartTooltip, { ...tooltipOptions, i18nStrings: i18nStrings, getTooltipContent: rest.getTooltipContent, sizeAxis: castArray(rest.sizeAxis), api: api }))] }));
|
|
293
293
|
}
|
|
294
294
|
function xAxisClassName(inverted, customClassName) {
|
|
295
295
|
return clsx(testClasses["axis-x"], inverted ? testClasses["axis-vertical"] : testClasses["axis-horizontal"], customClassName);
|