@cloudscape-design/chart-components 1.0.96 → 1.0.98

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "6ab9c2687e3abda3dd61c7f6cb2990607e23ceab"
2
+ "commit": "3b627b10521bd8e8709b32ad9642b32bf1acecee"
3
3
  }
@@ -1,6 +1,7 @@
1
- import type { Chart, Point, Series } from "highcharts";
1
+ import type { Chart, Point, Series, SeriesZonesOptionsObject } from "highcharts";
2
2
  export type SafeChart = Omit<Chart, "series">;
3
3
  export type SafeSeries = Omit<Series, "data">;
4
+ export type SafePoint = Omit<Point, "getZone">;
4
5
  /**
5
6
  * Filters out internal series from chart, e.g., series from navigator, scrollbar, etc.
6
7
  * When calling chart.series, the result includes both the main chart series
@@ -38,3 +39,10 @@ export declare function isPointVisible(point?: Point): boolean;
38
39
  export declare const getSeriesData: (series: SafeSeries, options?: {
39
40
  includeHiddenPoints?: boolean;
40
41
  }) => Array<Point>;
42
+ /**
43
+ * Returns point's zone safely. The Point.getZone() API can crash on series with no zones,
44
+ * see: https://github.com/highcharts/highcharts/issues/24633.
45
+ *
46
+ * It is not clear how to check the presence of zones safely, as zones are not represented in the public Series API.
47
+ */
48
+ export declare function getPointZone(point: SafePoint): null | SeriesZonesOptionsObject;
@@ -54,4 +54,22 @@ export const getSeriesData = (series, options = {}) => {
54
54
  // eslint-disable-next-line no-restricted-syntax -- This is the safe wrapper itself.
55
55
  return series.data.filter((p) => (options.includeHiddenPoints ? isPointValid(p) : isPointVisible(p)));
56
56
  };
57
+ /**
58
+ * Returns point's zone safely. The Point.getZone() API can crash on series with no zones,
59
+ * see: https://github.com/highcharts/highcharts/issues/24633.
60
+ *
61
+ * It is not clear how to check the presence of zones safely, as zones are not represented in the public Series API.
62
+ */
63
+ export function getPointZone(point) {
64
+ try {
65
+ const seriesZones = "zones" in point.series ? point.series.zones : undefined;
66
+ if (seriesZones && Array.isArray(seriesZones) && seriesZones.length > 0) {
67
+ return point.getZone();
68
+ }
69
+ }
70
+ catch {
71
+ // no-op
72
+ }
73
+ return null;
74
+ }
57
75
  //# sourceMappingURL=highcharts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"highcharts.js","sourceRoot":"","sources":["../../../../src/internal/utils/highcharts.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAoBtC;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAgB;;IAC7C,oFAAoF;IACpF,OAAO,MAAA,MAAC,KAAe,CAAC,MAAM,0CAAE,MAAM,CAAC,CAAC,CAAiB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,mCAAI,EAAE,CAAC;AAC7F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAY;;IAC1C,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,MAAM,CAAC,YAAY,mCAAI,KAAK,CAAC,MAAM,CAAC;IAC/D,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAY;IAC1C,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,YAAY,GAAG,CAAC,YAAY,EAAE,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;IAClE,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;AACtE,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAkB,EAAE,UAA6C,EAAE,EAAgB,EAAE;IACjH,oFAAoF;IACpF,OAAQ,MAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpH,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Chart, Point, Series } from \"highcharts\";\n\n// The chart.series array can include internal series, that are unwanted.\n// Use getChartSeries to access chart series instead.\nexport type SafeChart = Omit<Chart, \"series\">;\n\n// The series.data array can include missing or destroyed points.\n// Use getSeriesData to access series data points instead.\nexport type SafeSeries = Omit<Series, \"data\">;\n\n// isInternal is currently not a publicly supported prop\n// https://github.com/highcharts/highcharts/issues/23278\ninterface InternalSeries extends Series {\n options: Series[\"options\"] & {\n isInternal?: boolean;\n };\n}\n\n/**\n * Filters out internal series from chart, e.g., series from navigator, scrollbar, etc.\n * When calling chart.series, the result includes both the main chart series\n * and additional internal series (e.g., navigator series) when using Highstock navigator.\n * We are adding datapoints and doing other calculations and using Highstock version with a\n * navigator is causing duplicated unexpected datapoints and series entries in the chart.\n */\nexport function getChartSeries(chart: SafeChart): SafeSeries[] {\n // eslint-disable-next-line no-restricted-syntax -- This is the safe wrapper itself.\n return (chart as Chart).series?.filter((s: InternalSeries) => !s.options.isInternal) ?? [];\n}\n\n/**\n * Returns point series or series it is linked to.\n */\nexport function getMasterSeries(point: Point): SafeSeries {\n const masterSeries = point.series.linkedParent ?? point.series;\n return masterSeries;\n}\n\n/**\n * Returns point series and all series linked to it.\n */\nexport function getLinkedSeries(point: Point): SafeSeries[] {\n const masterSeries = getMasterSeries(point);\n const linkedSeries = [masterSeries, ...masterSeries.linkedSeries];\n return linkedSeries;\n}\n\n/**\n * This method checks if the point is defined and not destroyed.\n * The point can be undefined when accessing it from series.data array.\n * The point can be destroyed by Highcharts and replaced with { destroyed: true } when\n * the actual point is removed, but a reference to it is still preserved somewhere.\n * See: https://github.com/highcharts/highcharts/issues/23175.\n */\nexport function isPointValid(point?: Point): point is Point {\n return Boolean(point && point.series);\n}\n\n/**\n * This method checks if the point is valid and also visible in the plot.\n */\nexport function isPointVisible(point?: Point) {\n return isPointValid(point) && point.visible && point.series.visible;\n}\n\n/**\n * The series may include undefined points. See: https://api.highcharts.com/class-reference/Highcharts.Series.html#data,\n * and https://github.com/highcharts/highcharts/issues/11116.\n * This can create issues when iterating over the data (using Array.filter() or Array.map() methods is safe, but index access or Array.find()\n * can cause a crash if accessing point's properties without checking).\n */\nexport const getSeriesData = (series: SafeSeries, options: { includeHiddenPoints?: boolean } = {}): Array<Point> => {\n // eslint-disable-next-line no-restricted-syntax -- This is the safe wrapper itself.\n return (series as Series).data.filter((p) => (options.includeHiddenPoints ? isPointValid(p) : isPointVisible(p)));\n};\n"]}
1
+ {"version":3,"file":"highcharts.js","sourceRoot":"","sources":["../../../../src/internal/utils/highcharts.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAwBtC;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAgB;;IAC7C,oFAAoF;IACpF,OAAO,MAAA,MAAC,KAAe,CAAC,MAAM,0CAAE,MAAM,CAAC,CAAC,CAAiB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,mCAAI,EAAE,CAAC;AAC7F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAY;;IAC1C,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,MAAM,CAAC,YAAY,mCAAI,KAAK,CAAC,MAAM,CAAC;IAC/D,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAY;IAC1C,MAAM,YA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,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Chart, Point, Series, SeriesZonesOptionsObject } from \"highcharts\";\n\n// The chart.series array can include internal series, that are unwanted.\n// Use getChartSeries to access chart series instead.\nexport type SafeChart = Omit<Chart, \"series\">;\n\n// The series.data array can include missing or destroyed points.\n// Use getSeriesData to access series data points instead.\nexport type SafeSeries = Omit<Series, \"data\">;\n\n// This point object without getZone API.\n// Use getPointZone to get point's zone instead.\nexport type SafePoint = Omit<Point, \"getZone\">;\n\n// isInternal is currently not a publicly supported prop\n// https://github.com/highcharts/highcharts/issues/23278\ninterface InternalSeries extends Series {\n options: Series[\"options\"] & {\n isInternal?: boolean;\n };\n}\n\n/**\n * Filters out internal series from chart, e.g., series from navigator, scrollbar, etc.\n * When calling chart.series, the result includes both the main chart series\n * and additional internal series (e.g., navigator series) when using Highstock navigator.\n * We are adding datapoints and doing other calculations and using Highstock version with a\n * navigator is causing duplicated unexpected datapoints and series entries in the chart.\n */\nexport function getChartSeries(chart: SafeChart): SafeSeries[] {\n // eslint-disable-next-line no-restricted-syntax -- This is the safe wrapper itself.\n return (chart as Chart).series?.filter((s: InternalSeries) => !s.options.isInternal) ?? [];\n}\n\n/**\n * Returns point series or series it is linked to.\n */\nexport function getMasterSeries(point: Point): SafeSeries {\n const masterSeries = point.series.linkedParent ?? point.series;\n return masterSeries;\n}\n\n/**\n * Returns point series and all series linked to it.\n */\nexport function getLinkedSeries(point: Point): SafeSeries[] {\n const masterSeries = getMasterSeries(point);\n const linkedSeries = [masterSeries, ...masterSeries.linkedSeries];\n return linkedSeries;\n}\n\n/**\n * This method checks if the point is defined and not destroyed.\n * The point can be undefined when accessing it from series.data array.\n * The point can be destroyed by Highcharts and replaced with { destroyed: true } when\n * the actual point is removed, but a reference to it is still preserved somewhere.\n * See: https://github.com/highcharts/highcharts/issues/23175.\n */\nexport function isPointValid(point?: Point): point is Point {\n return Boolean(point && point.series);\n}\n\n/**\n * This method checks if the point is valid and also visible in the plot.\n */\nexport function isPointVisible(point?: Point) {\n return isPointValid(point) && point.visible && point.series.visible;\n}\n\n/**\n * The series may include undefined points. See: https://api.highcharts.com/class-reference/Highcharts.Series.html#data,\n * and https://github.com/highcharts/highcharts/issues/11116.\n * This can create issues when iterating over the data (using Array.filter() or Array.map() methods is safe, but index access or Array.find()\n * can cause a crash if accessing point's properties without checking).\n */\nexport const getSeriesData = (series: SafeSeries, options: { includeHiddenPoints?: boolean } = {}): Array<Point> => {\n // eslint-disable-next-line no-restricted-syntax -- This is the safe wrapper itself.\n return (series as Series).data.filter((p) => (options.includeHiddenPoints ? isPointValid(p) : isPointVisible(p)));\n};\n\n/**\n * Returns point's zone safely. The Point.getZone() API can crash on series with no zones,\n * see: https://github.com/highcharts/highcharts/issues/24633.\n *\n * It is not clear how to check the presence of zones safely, as zones are not represented in the public Series API.\n */\nexport function getPointZone(point: SafePoint): null | SeriesZonesOptionsObject {\n try {\n const seriesZones = \"zones\" in point.series ? point.series.zones : undefined;\n if (seriesZones && Array.isArray(seriesZones) && seriesZones.length > 0) {\n return (point as Point).getZone();\n }\n } catch {\n // no-op\n }\n return null;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudscape-design/chart-components",
3
- "version": "1.0.96",
3
+ "version": "1.0.98",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cloudscape-design/chart-components.git"