@fluentui/react-charts 0.0.0-nightly-20251113-0407.1 → 0.0.0-nightly-20251117-0407.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +13 -13
  2. package/dist/index.d.ts +12 -11
  3. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js +2 -16
  4. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -1
  5. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -1
  6. package/lib/components/AreaChart/AreaChart.js +3 -16
  7. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  8. package/lib/components/ChartTable/ChartTable.js +2 -10
  9. package/lib/components/ChartTable/ChartTable.js.map +1 -1
  10. package/lib/components/ChartTable/ChartTable.types.js.map +1 -1
  11. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  12. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +4 -2
  13. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  14. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +4 -2
  15. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  16. package/lib/components/DeclarativeChart/DeclarativeChart.js +48 -25
  17. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  18. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +9 -4
  19. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  20. package/lib/components/DonutChart/DonutChart.js +3 -12
  21. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  22. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  23. package/lib/components/DonutChart/Pie/Pie.js +4 -2
  24. package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
  25. package/lib/components/FunnelChart/FunnelChart.js +2 -9
  26. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  27. package/lib/components/FunnelChart/FunnelChart.types.js.map +1 -1
  28. package/lib/components/GanttChart/GanttChart.js +3 -16
  29. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  30. package/lib/components/GaugeChart/GaugeChart.js +2 -10
  31. package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
  32. package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
  33. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +2 -14
  34. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  35. package/lib/components/HeatMapChart/HeatMapChart.js +3 -16
  36. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  37. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -14
  38. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  39. package/lib/components/Legends/Legends.types.js.map +1 -1
  40. package/lib/components/LineChart/LineChart.js +2 -14
  41. package/lib/components/LineChart/LineChart.js.map +1 -1
  42. package/lib/components/SankeyChart/SankeyChart.js +3 -9
  43. package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
  44. package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -1
  45. package/lib/components/ScatterChart/ScatterChart.js +3 -16
  46. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  47. package/lib/components/VerticalBarChart/VerticalBarChart.js +2 -14
  48. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  49. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +3 -15
  50. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  51. package/lib/types/DataPoint.js.map +1 -1
  52. package/lib/utilities/hooks.js +34 -0
  53. package/lib/utilities/hooks.js.map +1 -0
  54. package/lib/utilities/image-export-utils.js +115 -75
  55. package/lib/utilities/image-export-utils.js.map +1 -1
  56. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js +2 -16
  57. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -1
  58. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -1
  59. package/lib-commonjs/components/AreaChart/AreaChart.js +2 -15
  60. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  61. package/lib-commonjs/components/ChartTable/ChartTable.js +3 -10
  62. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
  63. package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -1
  64. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  65. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +4 -2
  66. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  67. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +4 -2
  68. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  69. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +48 -25
  70. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  71. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +9 -4
  72. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  73. package/lib-commonjs/components/DonutChart/DonutChart.js +2 -11
  74. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  75. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  76. package/lib-commonjs/components/DonutChart/Pie/Pie.js +4 -2
  77. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  78. package/lib-commonjs/components/FunnelChart/FunnelChart.js +2 -9
  79. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  80. package/lib-commonjs/components/FunnelChart/FunnelChart.types.js.map +1 -1
  81. package/lib-commonjs/components/GanttChart/GanttChart.js +2 -15
  82. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  83. package/lib-commonjs/components/GaugeChart/GaugeChart.js +2 -10
  84. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
  85. package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
  86. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +2 -14
  87. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  88. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +2 -15
  89. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  90. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -14
  91. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  92. package/lib-commonjs/components/Legends/Legends.types.js.map +1 -1
  93. package/lib-commonjs/components/LineChart/LineChart.js +2 -14
  94. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  95. package/lib-commonjs/components/SankeyChart/SankeyChart.js +3 -9
  96. package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
  97. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -1
  98. package/lib-commonjs/components/ScatterChart/ScatterChart.js +2 -15
  99. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  100. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +2 -14
  101. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  102. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +3 -15
  103. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  104. package/lib-commonjs/types/DataPoint.js.map +1 -1
  105. package/lib-commonjs/utilities/hooks.js +45 -0
  106. package/lib-commonjs/utilities/hooks.js.map +1 -0
  107. package/lib-commonjs/utilities/image-export-utils.js +116 -76
  108. package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
  109. package/package.json +12 -12
package/CHANGELOG.md CHANGED
@@ -1,26 +1,26 @@
1
1
  # Change Log - @fluentui/react-charts
2
2
 
3
- This log was last generated on Thu, 13 Nov 2025 04:21:57 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 17 Nov 2025 04:21:28 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## [0.0.0-nightly-20251113-0407.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-charts_v0.0.0-nightly-20251113-0407.1)
7
+ ## [0.0.0-nightly-20251117-0407.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-charts_v0.0.0-nightly-20251117-0407.1)
8
8
 
9
- Thu, 13 Nov 2025 04:21:57 GMT
10
- [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-charts_v9.3.6..@fluentui/react-charts_v0.0.0-nightly-20251113-0407.1)
9
+ Mon, 17 Nov 2025 04:21:28 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-charts_v9.3.6..@fluentui/react-charts_v0.0.0-nightly-20251117-0407.1)
11
11
 
12
12
  ### Changes
13
13
 
14
14
  - Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
15
- - Bump @fluentui/react-button to v0.0.0-nightly-20251113-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/54423918e468eada12192309088e7472d0126d7c) by beachball)
16
- - Bump @fluentui/react-jsx-runtime to v0.0.0-nightly-20251113-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/54423918e468eada12192309088e7472d0126d7c) by beachball)
17
- - Bump @fluentui/react-overflow to v0.0.0-nightly-20251113-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/54423918e468eada12192309088e7472d0126d7c) by beachball)
18
- - Bump @fluentui/react-popover to v0.0.0-nightly-20251113-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/54423918e468eada12192309088e7472d0126d7c) by beachball)
19
- - Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20251113-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/54423918e468eada12192309088e7472d0126d7c) by beachball)
20
- - Bump @fluentui/react-tabster to v0.0.0-nightly-20251113-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/54423918e468eada12192309088e7472d0126d7c) by beachball)
21
- - Bump @fluentui/react-theme to v0.0.0-nightly-20251113-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/54423918e468eada12192309088e7472d0126d7c) by beachball)
22
- - Bump @fluentui/react-tooltip to v0.0.0-nightly-20251113-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/54423918e468eada12192309088e7472d0126d7c) by beachball)
23
- - Bump @fluentui/react-utilities to v0.0.0-nightly-20251113-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/54423918e468eada12192309088e7472d0126d7c) by beachball)
15
+ - Bump @fluentui/react-button to v0.0.0-nightly-20251117-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/c2de371a638c76f995cafc282428c3d6eaffd8db) by beachball)
16
+ - Bump @fluentui/react-jsx-runtime to v0.0.0-nightly-20251117-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/c2de371a638c76f995cafc282428c3d6eaffd8db) by beachball)
17
+ - Bump @fluentui/react-overflow to v0.0.0-nightly-20251117-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/c2de371a638c76f995cafc282428c3d6eaffd8db) by beachball)
18
+ - Bump @fluentui/react-popover to v0.0.0-nightly-20251117-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/c2de371a638c76f995cafc282428c3d6eaffd8db) by beachball)
19
+ - Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20251117-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/c2de371a638c76f995cafc282428c3d6eaffd8db) by beachball)
20
+ - Bump @fluentui/react-tabster to v0.0.0-nightly-20251117-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/c2de371a638c76f995cafc282428c3d6eaffd8db) by beachball)
21
+ - Bump @fluentui/react-theme to v0.0.0-nightly-20251117-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/c2de371a638c76f995cafc282428c3d6eaffd8db) by beachball)
22
+ - Bump @fluentui/react-tooltip to v0.0.0-nightly-20251117-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/c2de371a638c76f995cafc282428c3d6eaffd8db) by beachball)
23
+ - Bump @fluentui/react-utilities to v0.0.0-nightly-20251117-0407.1 ([commit](https://github.com/microsoft/fluentui/commit/c2de371a638c76f995cafc282428c3d6eaffd8db) by beachball)
24
24
 
25
25
  ## [9.3.6](https://github.com/microsoft/fluentui/tree/@fluentui/react-charts_v9.3.6)
26
26
 
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { JSXElement } from '@fluentui/react-utilities';
3
3
  import type { Margin } from '@fluentui/chart-utilities';
4
4
  import { PositioningShorthand } from '@fluentui/react-positioning';
5
5
  import * as React_2 from 'react';
6
- import { RefObject } from 'react';
6
+ import { Ref } from 'react';
7
7
  import { SankeyGraph } from 'd3-sankey';
8
8
  import { SankeyLayout } from 'd3-sankey';
9
9
  import { SankeyLink } from 'd3-sankey';
@@ -67,7 +67,7 @@ export declare interface AnnotationOnlyChartProps {
67
67
  /** Layout margin converted to padding for the outer wrapper. */
68
68
  margin?: Partial<Margin>;
69
69
  /** Component ref propagated by the DeclarativeChart surface. */
70
- componentRef?: React_2.RefObject<Chart>;
70
+ componentRef?: React_2.Ref<Chart>;
71
71
  }
72
72
 
73
73
  export declare interface AnnotationPlotRect {
@@ -546,7 +546,7 @@ export declare interface CartesianChartProps {
546
546
  * Optional callback to access the Chart interface. Use this instead of ref for accessing
547
547
  * the public methods and properties of the component.
548
548
  */
549
- componentRef?: React_2.RefObject<Chart | null>;
549
+ componentRef?: React_2.Ref<Chart>;
550
550
  /**
551
551
  * Prop to set the x axis annotation. Used to display additional information on the x-axis.
552
552
  * This is shown on the top of the chart.
@@ -1048,7 +1048,7 @@ export declare interface ChartTableProps {
1048
1048
  * Optional callback to access the Chart interface. Use this instead of ref for accessing
1049
1049
  * the public methods and properties of the component.
1050
1050
  */
1051
- componentRef?: React_2.RefObject<Chart>;
1051
+ componentRef?: React_2.Ref<Chart>;
1052
1052
  }
1053
1053
 
1054
1054
  /**
@@ -1313,7 +1313,7 @@ export declare interface DeclarativeChartProps extends React_2.RefAttributes<HTM
1313
1313
  * Optional callback to access the IDeclarativeChart interface. Use this instead of ref for accessing
1314
1314
  * the public methods and properties of the component.
1315
1315
  */
1316
- componentRef?: React_2.RefObject<IDeclarativeChart | null>;
1316
+ componentRef?: React_2.Ref<IDeclarativeChart>;
1317
1317
  /**
1318
1318
  * Optional prop to specify the colorway type of the chart.
1319
1319
  * - 'default': Use Fluent UI color palette aligning with plotly colorway.
@@ -1416,7 +1416,7 @@ export declare interface DonutChartProps extends CartesianChartProps {
1416
1416
  * Optional callback to access the Chart interface. Use this instead of ref for accessing
1417
1417
  * the public methods and properties of the component.
1418
1418
  */
1419
- componentRef?: React_2.RefObject<Chart>;
1419
+ componentRef?: React_2.Ref<Chart>;
1420
1420
  /**
1421
1421
  * Prop to enable the round corners in the chart
1422
1422
  * @default false
@@ -1572,7 +1572,7 @@ export declare interface FunnelChartProps {
1572
1572
  /**
1573
1573
  * Reference to the chart component
1574
1574
  */
1575
- componentRef?: React_2.RefObject<any>;
1575
+ componentRef?: React_2.Ref<Chart>;
1576
1576
  /**
1577
1577
  * Additional CSS class(es) to apply to the chart
1578
1578
  */
@@ -1833,7 +1833,7 @@ export declare interface GaugeChartProps {
1833
1833
  * Optional callback to access the Chart interface. Use this instead of ref for accessing
1834
1834
  * the public methods and properties of the component.
1835
1835
  */
1836
- componentRef?: React.RefObject<Chart>;
1836
+ componentRef?: React.Ref<Chart>;
1837
1837
  }
1838
1838
 
1839
1839
  /**
@@ -2789,7 +2789,7 @@ export declare interface Legend {
2789
2789
  */
2790
2790
  export declare interface LegendContainer {
2791
2791
  toSVG: (svgWidth: number, isRTL?: boolean) => {
2792
- node: SVGGElement | null;
2792
+ node: SVGSVGElement | null;
2793
2793
  width: number;
2794
2794
  height: number;
2795
2795
  };
@@ -2922,7 +2922,7 @@ export declare interface LegendsProps {
2922
2922
  /**
2923
2923
  * Callback to access the public methods and properties of the component.
2924
2924
  */
2925
- legendRef?: React_2.RefObject<LegendContainer | null>;
2925
+ legendRef?: React_2.Ref<LegendContainer>;
2926
2926
  }
2927
2927
 
2928
2928
  /**
@@ -3681,7 +3681,7 @@ export declare interface SankeyChartProps {
3681
3681
  * Optional callback to access the Chart interface. Use this instead of ref for accessing
3682
3682
  * the public methods and properties of the component.
3683
3683
  */
3684
- componentRef?: RefObject<Chart>;
3684
+ componentRef?: Ref<Chart>;
3685
3685
  /**
3686
3686
  * props for the callout in the chart
3687
3687
  */
@@ -3906,6 +3906,7 @@ declare interface SLinkExtra {
3906
3906
  */
3907
3907
  value: number;
3908
3908
  unnormalizedValue?: number;
3909
+ color?: string;
3909
3910
  }
3910
3911
 
3911
3912
  export declare type SNode = SankeyNode<SNodeExtra, SLinkExtra>;
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
  import * as React from 'react';
3
3
  import { ChartAnnotationLayer } from '../CommonComponents/Annotations/ChartAnnotationLayer';
4
- import { toImage as exportToImage } from '../../utilities/image-export-utils';
5
4
  import { useRtl } from '../../utilities';
6
5
  import { useAnnotationOnlyChartStyles } from './useAnnotationOnlyChartStyles.styles';
6
+ import { useImageExport } from '../../utilities/hooks';
7
7
  const DEFAULT_HEIGHT = 650;
8
8
  const FALLBACK_WIDTH = 400;
9
9
  const buildPadding = (margin)=>{
@@ -27,7 +27,7 @@ export const AnnotationOnlyChart = (props)=>{
27
27
  const { annotations, chartTitle, description, width, height, paperBackgroundColor, plotBackgroundColor, fontColor, fontFamily, margin, componentRef } = props;
28
28
  const isRtl = useRtl();
29
29
  const classes = useAnnotationOnlyChartStyles();
30
- const containerRef = React.useRef(null);
30
+ const { chartContainerRef: containerRef } = useImageExport(componentRef, true, false);
31
31
  const contentRef = React.useRef(null);
32
32
  const [measuredWidth, setMeasuredWidth] = React.useState(width !== null && width !== void 0 ? width : 0);
33
33
  const [contentHeight, setContentHeight] = React.useState(height !== null && height !== void 0 ? height : DEFAULT_HEIGHT);
@@ -154,20 +154,6 @@ export const AnnotationOnlyChart = (props)=>{
154
154
  const resolvedAnnotations = annotations !== null && annotations !== void 0 ? annotations : [];
155
155
  const hasAnnotations = resolvedAnnotations.length > 0;
156
156
  const ariaLabel = hasAnnotations ? description !== null && description !== void 0 ? description : chartTitle : undefined;
157
- React.useImperativeHandle(componentRef, ()=>{
158
- const chartHandle = {
159
- chartContainer: containerRef.current,
160
- toImage: (opts)=>{
161
- if (!containerRef.current) {
162
- return Promise.reject(new Error('Chart container is not defined'));
163
- }
164
- return exportToImage(containerRef.current, undefined, isRtl, opts);
165
- }
166
- };
167
- return chartHandle;
168
- }, [
169
- isRtl
170
- ]);
171
157
  return /*#__PURE__*/ React.createElement("div", {
172
158
  ref: containerRef,
173
159
  "data-chart-annotation-container": "true"
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/AnnotationOnlyChart/AnnotationOnlyChart.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChartAnnotationLayer } from '../CommonComponents/Annotations/ChartAnnotationLayer';\nimport { toImage as exportToImage } from '../../utilities/image-export-utils';\nimport { useRtl } from '../../utilities';\nimport { useAnnotationOnlyChartStyles } from './useAnnotationOnlyChartStyles.styles';\nimport type { AnnotationOnlyChartProps } from './AnnotationOnlyChart.types';\nimport type { Chart, ImageExportOptions } from '../../types/index';\nimport type { ChartAnnotationContext } from '../CommonComponents/Annotations/ChartAnnotationLayer.types';\n\nconst DEFAULT_HEIGHT = 650;\nconst FALLBACK_WIDTH = 400;\n\nconst buildPadding = (margin: AnnotationOnlyChartProps['margin']): string | undefined => {\n if (!margin) {\n return undefined;\n }\n\n const top = margin.t ?? 0;\n const right = margin.r ?? 0;\n const bottom = margin.b ?? 0;\n const left = margin.l ?? 0;\n\n if (top === 0 && right === 0 && bottom === 0 && left === 0) {\n return undefined;\n }\n\n return `${top}px ${right}px ${bottom}px ${left}px`;\n};\n\nexport const AnnotationOnlyChart: React.FC<AnnotationOnlyChartProps> = props => {\n const {\n annotations,\n chartTitle,\n description,\n width,\n height,\n paperBackgroundColor,\n plotBackgroundColor,\n fontColor,\n fontFamily,\n margin,\n componentRef,\n } = props;\n\n const isRtl = useRtl();\n const classes = useAnnotationOnlyChartStyles();\n const containerRef = React.useRef<HTMLDivElement | null>(null);\n const contentRef = React.useRef<HTMLDivElement | null>(null);\n const [measuredWidth, setMeasuredWidth] = React.useState<number>(width ?? 0);\n const [contentHeight, setContentHeight] = React.useState<number>(height ?? DEFAULT_HEIGHT);\n\n React.useEffect(() => {\n if (typeof width === 'number' && width > 0) {\n setMeasuredWidth(width);\n return;\n }\n\n const node = containerRef.current;\n if (!node || typeof ResizeObserver === 'undefined') {\n const rect = node?.getBoundingClientRect();\n if (rect && rect.width > 0) {\n setMeasuredWidth(rect.width);\n } else {\n setMeasuredWidth(prev => (prev > 0 ? prev : FALLBACK_WIDTH));\n }\n return;\n }\n\n const observer = new ResizeObserver(entries => {\n const entry = entries[0];\n if (!entry) {\n return;\n }\n const newWidth = entry.contentRect.width;\n if (newWidth > 0 && Math.abs(newWidth - measuredWidth) > 0.5) {\n setMeasuredWidth(newWidth);\n }\n });\n\n const rect = node.getBoundingClientRect();\n if (rect.width > 0) {\n setMeasuredWidth(rect.width);\n }\n\n observer.observe(node);\n return () => observer.disconnect();\n }, [width, measuredWidth]);\n\n const resolvedWidth = Math.max(measuredWidth || FALLBACK_WIDTH, 1);\n const resolvedHeight = Math.max(height ?? DEFAULT_HEIGHT, 1);\n\n React.useEffect(() => {\n const node = contentRef.current;\n if (!node) {\n setContentHeight(prev => (prev > 0 ? prev : resolvedHeight));\n return;\n }\n\n if (typeof ResizeObserver === 'undefined') {\n const rect = node.getBoundingClientRect();\n setContentHeight(prev => (rect.height > 0 ? rect.height : prev > 0 ? prev : resolvedHeight));\n return;\n }\n\n const observer = new ResizeObserver(entries => {\n const entry = entries[0];\n if (!entry) {\n return;\n }\n\n const newHeight = entry.contentRect.height;\n if (newHeight > 0) {\n setContentHeight(prev => (Math.abs(prev - newHeight) > 0.5 ? newHeight : prev));\n }\n });\n\n const rect = node.getBoundingClientRect();\n setContentHeight(prev => (rect.height > 0 ? rect.height : prev > 0 ? prev : resolvedHeight));\n\n observer.observe(node);\n return () => observer.disconnect();\n }, [\n resolvedHeight,\n resolvedWidth,\n annotations,\n chartTitle,\n description,\n margin,\n plotBackgroundColor,\n paperBackgroundColor,\n fontColor,\n fontFamily,\n ]);\n\n const svgHeight = Math.max(Math.ceil(contentHeight || 0), resolvedHeight);\n\n const context: ChartAnnotationContext = {\n plotRect: { x: 0, y: 0, width: resolvedWidth, height: resolvedHeight },\n svgRect: { width: resolvedWidth, height: resolvedHeight },\n isRtl,\n };\n\n const padding = buildPadding(margin);\n\n // Inline styles for dynamic values that can't be in makeStyles\n const rootStyle: React.CSSProperties = React.useMemo(\n () => ({\n width: width ? `${width}px` : '100%',\n minHeight: resolvedHeight,\n ...(paperBackgroundColor && { backgroundColor: paperBackgroundColor }),\n ...(fontColor && { color: fontColor }),\n ...(fontFamily && { fontFamily }),\n ...(padding && { padding }),\n }),\n [fontColor, fontFamily, paperBackgroundColor, padding, resolvedHeight, width],\n );\n\n const contentStyle: React.CSSProperties = React.useMemo(\n () => ({\n ...(plotBackgroundColor && { backgroundColor: plotBackgroundColor }),\n }),\n [plotBackgroundColor],\n );\n\n const resolvedAnnotations = annotations ?? [];\n const hasAnnotations = resolvedAnnotations.length > 0;\n const ariaLabel = hasAnnotations ? description ?? chartTitle : undefined;\n\n React.useImperativeHandle(\n componentRef,\n () => {\n const chartHandle: Chart = {\n chartContainer: containerRef.current,\n toImage: (opts?: ImageExportOptions) => {\n if (!containerRef.current) {\n return Promise.reject(new Error('Chart container is not defined'));\n }\n\n return exportToImage(containerRef.current, undefined, isRtl, opts);\n },\n };\n\n return chartHandle;\n },\n [isRtl],\n );\n\n return (\n <div ref={containerRef} data-chart-annotation-container=\"true\">\n <svg\n width={resolvedWidth}\n height={svgHeight}\n viewBox={`0 0 ${resolvedWidth} ${svgHeight}`}\n style={{ width: width ? `${width}px` : '100%', height: `${svgHeight}px`, display: 'block' }}\n role={ariaLabel ? 'img' : undefined}\n aria-label={ariaLabel}\n >\n <foreignObject x={0} y={0} width={resolvedWidth} height={svgHeight}>\n <div\n ref={contentRef}\n className={classes.root}\n style={rootStyle}\n data-chart-annotation-only=\"true\"\n aria-label={ariaLabel}\n >\n {chartTitle && (\n <span className={classes.title} aria-hidden=\"true\">\n {chartTitle}\n </span>\n )}\n <div className={classes.content} style={contentStyle} role=\"presentation\">\n {hasAnnotations ? <ChartAnnotationLayer annotations={resolvedAnnotations} context={context} /> : null}\n </div>\n </div>\n </foreignObject>\n </svg>\n </div>\n );\n};\n\nAnnotationOnlyChart.displayName = 'AnnotationOnlyChart';\n"],"names":["React","ChartAnnotationLayer","toImage","exportToImage","useRtl","useAnnotationOnlyChartStyles","DEFAULT_HEIGHT","FALLBACK_WIDTH","buildPadding","margin","undefined","top","t","right","r","bottom","b","left","l","AnnotationOnlyChart","props","annotations","chartTitle","description","width","height","paperBackgroundColor","plotBackgroundColor","fontColor","fontFamily","componentRef","isRtl","classes","containerRef","useRef","contentRef","measuredWidth","setMeasuredWidth","useState","contentHeight","setContentHeight","useEffect","node","current","ResizeObserver","rect","getBoundingClientRect","prev","observer","entries","entry","newWidth","contentRect","Math","abs","observe","disconnect","resolvedWidth","max","resolvedHeight","newHeight","svgHeight","ceil","context","plotRect","x","y","svgRect","padding","rootStyle","useMemo","minHeight","backgroundColor","color","contentStyle","resolvedAnnotations","hasAnnotations","length","ariaLabel","useImperativeHandle","chartHandle","chartContainer","opts","Promise","reject","Error","div","ref","data-chart-annotation-container","svg","viewBox","style","display","role","aria-label","foreignObject","className","root","data-chart-annotation-only","span","title","aria-hidden","content","displayName"],"mappings":"AAAA;AAEA,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;QACL6D,WAAWhE,QAAQiE,IAAI;QACvBN,OAAOtB;QACP6B,8BAA2B;QAC3BJ,cAAYhB;OAEXxD,4BACC,oBAAC6E;QAAKH,WAAWhE,QAAQoE,KAAK;QAAEC,eAAY;OACzC/E,2BAGL,oBAACgE;QAAIU,WAAWhE,QAAQsE,OAAO;QAAEX,OAAOjB;QAAcmB,MAAK;OACxDjB,+BAAiB,oBAAC3E;QAAqBoB,aAAasD;QAAqBZ,SAASA;SAAc;AAO/G,EAAE;AAEF5C,oBAAoBoF,WAAW,GAAG"}
1
+ {"version":3,"sources":["../src/components/AnnotationOnlyChart/AnnotationOnlyChart.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChartAnnotationLayer } from '../CommonComponents/Annotations/ChartAnnotationLayer';\nimport { useRtl } from '../../utilities';\nimport { useAnnotationOnlyChartStyles } from './useAnnotationOnlyChartStyles.styles';\nimport type { AnnotationOnlyChartProps } from './AnnotationOnlyChart.types';\nimport type { ChartAnnotationContext } from '../CommonComponents/Annotations/ChartAnnotationLayer.types';\nimport { useImageExport } from '../../utilities/hooks';\n\nconst DEFAULT_HEIGHT = 650;\nconst FALLBACK_WIDTH = 400;\n\nconst buildPadding = (margin: AnnotationOnlyChartProps['margin']): string | undefined => {\n if (!margin) {\n return undefined;\n }\n\n const top = margin.t ?? 0;\n const right = margin.r ?? 0;\n const bottom = margin.b ?? 0;\n const left = margin.l ?? 0;\n\n if (top === 0 && right === 0 && bottom === 0 && left === 0) {\n return undefined;\n }\n\n return `${top}px ${right}px ${bottom}px ${left}px`;\n};\n\nexport const AnnotationOnlyChart: React.FC<AnnotationOnlyChartProps> = props => {\n const {\n annotations,\n chartTitle,\n description,\n width,\n height,\n paperBackgroundColor,\n plotBackgroundColor,\n fontColor,\n fontFamily,\n margin,\n componentRef,\n } = props;\n\n const isRtl = useRtl();\n const classes = useAnnotationOnlyChartStyles();\n const { chartContainerRef: containerRef } = useImageExport(componentRef, true, false);\n const contentRef = React.useRef<HTMLDivElement | null>(null);\n const [measuredWidth, setMeasuredWidth] = React.useState<number>(width ?? 0);\n const [contentHeight, setContentHeight] = React.useState<number>(height ?? DEFAULT_HEIGHT);\n\n React.useEffect(() => {\n if (typeof width === 'number' && width > 0) {\n setMeasuredWidth(width);\n return;\n }\n\n const node = containerRef.current;\n if (!node || typeof ResizeObserver === 'undefined') {\n const rect = node?.getBoundingClientRect();\n if (rect && rect.width > 0) {\n setMeasuredWidth(rect.width);\n } else {\n setMeasuredWidth(prev => (prev > 0 ? prev : FALLBACK_WIDTH));\n }\n return;\n }\n\n const observer = new ResizeObserver(entries => {\n const entry = entries[0];\n if (!entry) {\n return;\n }\n const newWidth = entry.contentRect.width;\n if (newWidth > 0 && Math.abs(newWidth - measuredWidth) > 0.5) {\n setMeasuredWidth(newWidth);\n }\n });\n\n const rect = node.getBoundingClientRect();\n if (rect.width > 0) {\n setMeasuredWidth(rect.width);\n }\n\n observer.observe(node);\n return () => observer.disconnect();\n }, [width, measuredWidth]);\n\n const resolvedWidth = Math.max(measuredWidth || FALLBACK_WIDTH, 1);\n const resolvedHeight = Math.max(height ?? DEFAULT_HEIGHT, 1);\n\n React.useEffect(() => {\n const node = contentRef.current;\n if (!node) {\n setContentHeight(prev => (prev > 0 ? prev : resolvedHeight));\n return;\n }\n\n if (typeof ResizeObserver === 'undefined') {\n const rect = node.getBoundingClientRect();\n setContentHeight(prev => (rect.height > 0 ? rect.height : prev > 0 ? prev : resolvedHeight));\n return;\n }\n\n const observer = new ResizeObserver(entries => {\n const entry = entries[0];\n if (!entry) {\n return;\n }\n\n const newHeight = entry.contentRect.height;\n if (newHeight > 0) {\n setContentHeight(prev => (Math.abs(prev - newHeight) > 0.5 ? newHeight : prev));\n }\n });\n\n const rect = node.getBoundingClientRect();\n setContentHeight(prev => (rect.height > 0 ? rect.height : prev > 0 ? prev : resolvedHeight));\n\n observer.observe(node);\n return () => observer.disconnect();\n }, [\n resolvedHeight,\n resolvedWidth,\n annotations,\n chartTitle,\n description,\n margin,\n plotBackgroundColor,\n paperBackgroundColor,\n fontColor,\n fontFamily,\n ]);\n\n const svgHeight = Math.max(Math.ceil(contentHeight || 0), resolvedHeight);\n\n const context: ChartAnnotationContext = {\n plotRect: { x: 0, y: 0, width: resolvedWidth, height: resolvedHeight },\n svgRect: { width: resolvedWidth, height: resolvedHeight },\n isRtl,\n };\n\n const padding = buildPadding(margin);\n\n // Inline styles for dynamic values that can't be in makeStyles\n const rootStyle: React.CSSProperties = React.useMemo(\n () => ({\n width: width ? `${width}px` : '100%',\n minHeight: resolvedHeight,\n ...(paperBackgroundColor && { backgroundColor: paperBackgroundColor }),\n ...(fontColor && { color: fontColor }),\n ...(fontFamily && { fontFamily }),\n ...(padding && { padding }),\n }),\n [fontColor, fontFamily, paperBackgroundColor, padding, resolvedHeight, width],\n );\n\n const contentStyle: React.CSSProperties = React.useMemo(\n () => ({\n ...(plotBackgroundColor && { backgroundColor: plotBackgroundColor }),\n }),\n [plotBackgroundColor],\n );\n\n const resolvedAnnotations = annotations ?? [];\n const hasAnnotations = resolvedAnnotations.length > 0;\n const ariaLabel = hasAnnotations ? description ?? chartTitle : undefined;\n\n return (\n <div ref={containerRef} data-chart-annotation-container=\"true\">\n <svg\n width={resolvedWidth}\n height={svgHeight}\n viewBox={`0 0 ${resolvedWidth} ${svgHeight}`}\n style={{ width: width ? `${width}px` : '100%', height: `${svgHeight}px`, display: 'block' }}\n role={ariaLabel ? 'img' : undefined}\n aria-label={ariaLabel}\n >\n <foreignObject x={0} y={0} width={resolvedWidth} height={svgHeight}>\n <div\n ref={contentRef}\n className={classes.root}\n style={rootStyle}\n data-chart-annotation-only=\"true\"\n aria-label={ariaLabel}\n >\n {chartTitle && (\n <span className={classes.title} aria-hidden=\"true\">\n {chartTitle}\n </span>\n )}\n <div className={classes.content} style={contentStyle} role=\"presentation\">\n {hasAnnotations ? <ChartAnnotationLayer annotations={resolvedAnnotations} context={context} /> : null}\n </div>\n </div>\n </foreignObject>\n </svg>\n </div>\n );\n};\n\nAnnotationOnlyChart.displayName = 'AnnotationOnlyChart';\n"],"names":["React","ChartAnnotationLayer","useRtl","useAnnotationOnlyChartStyles","useImageExport","DEFAULT_HEIGHT","FALLBACK_WIDTH","buildPadding","margin","undefined","top","t","right","r","bottom","b","left","l","AnnotationOnlyChart","props","annotations","chartTitle","description","width","height","paperBackgroundColor","plotBackgroundColor","fontColor","fontFamily","componentRef","isRtl","classes","chartContainerRef","containerRef","contentRef","useRef","measuredWidth","setMeasuredWidth","useState","contentHeight","setContentHeight","useEffect","node","current","ResizeObserver","rect","getBoundingClientRect","prev","observer","entries","entry","newWidth","contentRect","Math","abs","observe","disconnect","resolvedWidth","max","resolvedHeight","newHeight","svgHeight","ceil","context","plotRect","x","y","svgRect","padding","rootStyle","useMemo","minHeight","backgroundColor","color","contentStyle","resolvedAnnotations","hasAnnotations","length","ariaLabel","div","ref","data-chart-annotation-container","svg","viewBox","style","display","role","aria-label","foreignObject","className","root","data-chart-annotation-only","span","title","aria-hidden","content","displayName"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,oBAAoB,QAAQ,uDAAuD;AAC5F,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,4BAA4B,QAAQ,wCAAwC;AAGrF,SAASC,cAAc,QAAQ,wBAAwB;AAEvD,MAAMC,iBAAiB;AACvB,MAAMC,iBAAiB;AAEvB,MAAMC,eAAe,CAACC;IACpB,IAAI,CAACA,QAAQ;QACX,OAAOC;IACT;QAEYD;IAAZ,MAAME,MAAMF,CAAAA,YAAAA,OAAOG,CAAC,cAARH,uBAAAA,YAAY;QACVA;IAAd,MAAMI,QAAQJ,CAAAA,YAAAA,OAAOK,CAAC,cAARL,uBAAAA,YAAY;QACXA;IAAf,MAAMM,SAASN,CAAAA,YAAAA,OAAOO,CAAC,cAARP,uBAAAA,YAAY;QACdA;IAAb,MAAMQ,OAAOR,CAAAA,YAAAA,OAAOS,CAAC,cAART,uBAAAA,YAAY;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C;QACPjC,QAAQqC;QACRsB,SAAS,CAAC,IAAI,EAAE1B,cAAc,CAAC,EAAEI,WAAW;QAC5CuB,OAAO;YAAE7D,OAAOA,QAAQ,GAAGA,MAAM,EAAE,CAAC,GAAG;YAAQC,QAAQ,GAAGqC,UAAU,EAAE,CAAC;YAAEwB,SAAS;QAAQ;QAC1FC,MAAMR,YAAY,QAAQrE;QAC1B8E,cAAYT;qBAEZ,oBAACU;QAAcvB,GAAG;QAAGC,GAAG;QAAG3C,OAAOkC;QAAejC,QAAQqC;qBACvD,oBAACkB;QACCC,KAAK9C;QACLuD,WAAW1D,QAAQ2D,IAAI;QACvBN,OAAOf;QACPsB,8BAA2B;QAC3BJ,cAAYT;OAEXzD,4BACC,oBAACuE;QAAKH,WAAW1D,QAAQ8D,KAAK;QAAEC,eAAY;OACzCzE,2BAGL,oBAAC0D;QAAIU,WAAW1D,QAAQgE,OAAO;QAAEX,OAAOV;QAAcY,MAAK;OACxDV,+BAAiB,oBAAC3E;QAAqBmB,aAAauD;QAAqBZ,SAASA;SAAc;AAO/G,EAAE;AAEF7C,oBAAoB8E,WAAW,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/AnnotationOnlyChart/AnnotationOnlyChart.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ChartAnnotation } from '../../types/ChartAnnotation';\nimport type { Chart } from '../../types/index';\nimport type { Margin } from '@fluentui/chart-utilities';\n\n/**\n * Props for the annotation-only chart renderer.\n */\nexport interface AnnotationOnlyChartProps {\n /**\n * Collection of annotations to render.\n */\n annotations: ChartAnnotation[];\n /** Optional layout title extracted from the Plotly schema. */\n chartTitle?: string;\n /** Optional descriptive text for accessibility. */\n description?: string;\n /** Desired width in pixels (if absent the chart will grow to fit the container). */\n width?: number;\n /** Desired height in pixels. */\n height?: number;\n /** Paper/background colour specified in the Plotly layout. */\n paperBackgroundColor?: string;\n /** Plot area background colour specified in the Plotly layout. */\n plotBackgroundColor?: string;\n /** Global layout font colour. */\n fontColor?: string;\n /** Global layout font family. */\n fontFamily?: string;\n /** Layout margin converted to padding for the outer wrapper. */\n margin?: Partial<Margin>;\n /** Component ref propagated by the DeclarativeChart surface. */\n componentRef?: React.RefObject<Chart>;\n}\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
1
+ {"version":3,"sources":["../src/components/AnnotationOnlyChart/AnnotationOnlyChart.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ChartAnnotation } from '../../types/ChartAnnotation';\nimport type { Chart } from '../../types/index';\nimport type { Margin } from '@fluentui/chart-utilities';\n\n/**\n * Props for the annotation-only chart renderer.\n */\nexport interface AnnotationOnlyChartProps {\n /**\n * Collection of annotations to render.\n */\n annotations: ChartAnnotation[];\n /** Optional layout title extracted from the Plotly schema. */\n chartTitle?: string;\n /** Optional descriptive text for accessibility. */\n description?: string;\n /** Desired width in pixels (if absent the chart will grow to fit the container). */\n width?: number;\n /** Desired height in pixels. */\n height?: number;\n /** Paper/background colour specified in the Plotly layout. */\n paperBackgroundColor?: string;\n /** Plot area background colour specified in the Plotly layout. */\n plotBackgroundColor?: string;\n /** Global layout font colour. */\n fontColor?: string;\n /** Global layout font family. */\n fontFamily?: string;\n /** Layout margin converted to padding for the outer wrapper. */\n margin?: Partial<Margin>;\n /** Component ref propagated by the DeclarativeChart surface. */\n componentRef?: React.Ref<Chart>;\n}\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
@@ -7,11 +7,11 @@ import { select as d3Select } from 'd3-selection';
7
7
  import { tokens } from '@fluentui/react-theme';
8
8
  import { area as d3Area, stack as d3Stack, curveMonotoneX as d3CurveBasis, line as d3Line } from 'd3-shape';
9
9
  import { CartesianChart } from '../../index';
10
- import { calloutData, getXAxisType, ChartTypes, XAxisTypes, getTypeOfAxis, tooltipOfAxislabels, getNextColor, getColorFromToken, getSecureProps, areArraysEqual, getCurveFactory, findNumericMinMaxOfY, createNumericYAxis, domainRangeOfNumericForAreaLineScatterCharts, domainRangeOfDateForAreaLineScatterVerticalBarCharts, createStringYAxis, useRtl, findCalloutPoints } from '../../utilities/index';
10
+ import { calloutData, getXAxisType, ChartTypes, XAxisTypes, getTypeOfAxis, tooltipOfAxislabels, getNextColor, getColorFromToken, getSecureProps, areArraysEqual, getCurveFactory, findNumericMinMaxOfY, createNumericYAxis, domainRangeOfNumericForAreaLineScatterCharts, domainRangeOfDateForAreaLineScatterVerticalBarCharts, createStringYAxis, findCalloutPoints } from '../../utilities/index';
11
11
  import { useId } from '@fluentui/react-utilities';
12
12
  import { Legends } from '../Legends/index';
13
- import { toImage } from '../../utilities/image-export-utils';
14
13
  import { formatDateToLocaleString } from '@fluentui/chart-utilities';
14
+ import { useImageExport } from '../../utilities/hooks';
15
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
16
  const bisect = bisector((d)=>d.x).left;
17
17
  var InterceptVisibility = /*#__PURE__*/ function(InterceptVisibility) {
@@ -48,9 +48,7 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
48
48
  let _xAxisRectScale;
49
49
  // determines if the given area chart has multiple stacked bar charts
50
50
  let _isMultiStackChart;
51
- const cartesianChartRef = React.useRef(null);
52
- const _legendsRef = React.useRef(null);
53
- const _isRTL = useRtl();
51
+ const { cartesianChartRef, legendsRef: _legendsRef } = useImageExport(props.componentRef, props.hideLegend);
54
52
  const [selectedLegends, setSelectedLegends] = React.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
55
53
  const [activeLegend, setActiveLegend] = React.useState(undefined);
56
54
  const [hoverXValue, setHoverXValue] = React.useState('');
@@ -83,17 +81,6 @@ export const AreaChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
83
81
  }, [
84
82
  props
85
83
  ]);
86
- React.useImperativeHandle(props.componentRef, ()=>{
87
- var _cartesianChartRef_current;
88
- var _cartesianChartRef_current_chartContainer;
89
- return {
90
- chartContainer: (_cartesianChartRef_current_chartContainer = (_cartesianChartRef_current = cartesianChartRef.current) === null || _cartesianChartRef_current === void 0 ? void 0 : _cartesianChartRef_current.chartContainer) !== null && _cartesianChartRef_current_chartContainer !== void 0 ? _cartesianChartRef_current_chartContainer : null,
91
- toImage: (opts)=>{
92
- var _cartesianChartRef_current, _legendsRef_current;
93
- return toImage((_cartesianChartRef_current = cartesianChartRef.current) === null || _cartesianChartRef_current === void 0 ? void 0 : _cartesianChartRef_current.chartContainer, (_legendsRef_current = _legendsRef.current) === null || _legendsRef_current === void 0 ? void 0 : _legendsRef_current.toSVG, _isRTL, opts);
94
- }
95
- };
96
- }, []);
97
84
  const classes = useAreaChartStyles(props);
98
85
  function _getMinMaxOfYAxis(points, yAxisType, useSecondaryYScale) {
99
86
  return findNumericMinMaxOfY(points, yAxisType, useSecondaryYScale);