@fluentui/react-charts 9.3.5 → 9.3.6
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/CHANGELOG.md +23 -2
- package/dist/index.d.ts +223 -44
- package/lib/AnnotationOnlyChart.js +1 -0
- package/lib/AnnotationOnlyChart.js.map +1 -0
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js +208 -0
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -0
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js +1 -0
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -0
- package/lib/components/AnnotationOnlyChart/index.js +2 -0
- package/lib/components/AnnotationOnlyChart/index.js.map +1 -0
- package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js +31 -0
- package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js.map +1 -0
- package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js +23 -0
- package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js.map +1 -0
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +11 -6
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.js +59 -39
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +5 -5
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +617 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +1 -0
- package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
- package/lib/components/CommonComponents/Annotations/index.js +2 -0
- package/lib/components/CommonComponents/Annotations/index.js.map +1 -0
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +173 -0
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -0
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +126 -0
- package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.js +157 -132
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/index.js +2 -0
- package/lib/components/CommonComponents/index.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +29 -13
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +14 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +2 -6
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js +3 -2
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +39 -19
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +4 -8
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +644 -72
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/useArcStyles.styles.js +23 -8
- package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js +2 -2
- package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.js +2 -2
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.js +3 -3
- package/lib/components/GanttChart/GanttChart.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.types.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js +3 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +3 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +11 -6
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +3 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +3 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +25 -12
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +4 -4
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -2
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +3 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +3 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib/components/Legends/useLegendsStyles.styles.js +97 -37
- package/lib/components/Legends/useLegendsStyles.styles.js.map +1 -1
- package/lib/components/Legends/useLegendsStyles.styles.raw.js +10 -11
- package/lib/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +1 -1
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +15 -10
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js +3 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +13 -10
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +1 -1
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js +13 -8
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +3 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +13 -8
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +11 -6
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/ChartAnnotation.js +1 -0
- package/lib/types/ChartAnnotation.js.map +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/index.js.map +1 -1
- package/lib/utilities/Common.styles.js +1 -2
- package/lib/utilities/Common.styles.js.map +1 -1
- package/lib/utilities/Common.styles.raw.js +1 -2
- package/lib/utilities/Common.styles.raw.js.map +1 -1
- package/lib/utilities/image-export-utils.js +108 -0
- package/lib/utilities/image-export-utils.js.map +1 -1
- package/lib/utilities/utilities.js +16 -13
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/AnnotationOnlyChart.js +6 -0
- package/lib-commonjs/AnnotationOnlyChart.js.map +1 -0
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js +219 -0
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -0
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js +6 -0
- package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -0
- package/lib-commonjs/components/AnnotationOnlyChart/index.js +7 -0
- package/lib-commonjs/components/AnnotationOnlyChart/index.js.map +1 -0
- package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js +56 -0
- package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js.map +1 -0
- package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js +33 -0
- package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js.map +1 -0
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +14 -15
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +74 -102
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +4 -4
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +628 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +4 -0
- package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/Annotations/index.js +7 -0
- package/lib-commonjs/components/CommonComponents/Annotations/index.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +265 -0
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +161 -0
- package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +157 -131
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/index.js +2 -0
- package/lib-commonjs/components/CommonComponents/index.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +32 -21
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +14 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +0 -14
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +38 -18
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +630 -38
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +25 -16
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js +1 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +2 -2
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js +3 -3
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.types.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +3 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +14 -15
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +3 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +47 -34
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +3 -3
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -2
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +3 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.js +144 -86
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -1
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js +9 -10
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +18 -19
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +16 -19
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +16 -17
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +16 -17
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +14 -15
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/ChartAnnotation.js +6 -0
- package/lib-commonjs/types/ChartAnnotation.js.map +1 -0
- package/lib-commonjs/types/index.js +1 -0
- package/lib-commonjs/types/index.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.js +1 -2
- package/lib-commonjs/utilities/Common.styles.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.raw.js +1 -2
- package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -1
- package/lib-commonjs/utilities/image-export-utils.js +108 -0
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +16 -13
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +11 -11
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { mergeClasses } from '@griffel/react';
|
|
4
|
+
import { applyOpacityToColor, DEFAULT_ANNOTATION_BACKGROUND_OPACITY, DEFAULT_CONNECTOR_ARROW, DEFAULT_CONNECTOR_END_PADDING, DEFAULT_CONNECTOR_START_PADDING, DEFAULT_CONNECTOR_STROKE_WIDTH, getDefaultConnectorStrokeColor, useChartAnnotationLayerStyles } from './useChartAnnotationLayer.styles';
|
|
5
|
+
import { useId } from '@fluentui/react-utilities';
|
|
6
|
+
import { tokens } from '@fluentui/react-theme';
|
|
7
|
+
const DEFAULT_HORIZONTAL_ALIGN = 'center';
|
|
8
|
+
const DEFAULT_VERTICAL_ALIGN = 'middle';
|
|
9
|
+
const DEFAULT_FOREIGN_OBJECT_WIDTH = 180;
|
|
10
|
+
const DEFAULT_FOREIGN_OBJECT_HEIGHT = 60;
|
|
11
|
+
const MIN_ARROW_SIZE = 6;
|
|
12
|
+
const MAX_ARROW_SIZE = 24;
|
|
13
|
+
const ARROW_SIZE_SCALE = 0.35;
|
|
14
|
+
const MAX_SIMPLE_MARKUP_DEPTH = 5;
|
|
15
|
+
const CHAR_CODE_LESS_THAN = '<'.codePointAt(0);
|
|
16
|
+
const CHAR_CODE_GREATER_THAN = '>'.codePointAt(0);
|
|
17
|
+
const getAnnotationKey = (annotation, index)=>{
|
|
18
|
+
var _annotation_id, _ref;
|
|
19
|
+
return (_ref = (_annotation_id = annotation.id) !== null && _annotation_id !== void 0 ? _annotation_id : typeof annotation.text === 'string' || typeof annotation.text === 'number' ? String(annotation.text) : undefined) !== null && _ref !== void 0 ? _ref : `annotation-${index}`;
|
|
20
|
+
};
|
|
21
|
+
const decodeSimpleMarkupInput = (input)=>{
|
|
22
|
+
const namedEntities = {
|
|
23
|
+
amp: '&',
|
|
24
|
+
quot: '"',
|
|
25
|
+
apos: "'",
|
|
26
|
+
nbsp: '\u00a0'
|
|
27
|
+
};
|
|
28
|
+
const withBasicEntitiesDecoded = input.replace(/&(#x?[0-9a-f]+|#\d+|[a-z][\w-]*);/gi, (match, entity)=>{
|
|
29
|
+
const lower = entity.toLowerCase();
|
|
30
|
+
if (lower === 'lt' || lower === 'gt') {
|
|
31
|
+
return `&${lower};`;
|
|
32
|
+
}
|
|
33
|
+
if (lower.startsWith('#')) {
|
|
34
|
+
const isHex = lower[1] === 'x';
|
|
35
|
+
const digits = lower.slice(isHex ? 2 : 1);
|
|
36
|
+
const codePoint = Number.parseInt(digits, isHex ? 16 : 10);
|
|
37
|
+
if (Number.isNaN(codePoint)) {
|
|
38
|
+
return match;
|
|
39
|
+
}
|
|
40
|
+
if (codePoint === CHAR_CODE_LESS_THAN) {
|
|
41
|
+
return '<';
|
|
42
|
+
}
|
|
43
|
+
if (codePoint === CHAR_CODE_GREATER_THAN) {
|
|
44
|
+
return '>';
|
|
45
|
+
}
|
|
46
|
+
return String.fromCodePoint(codePoint);
|
|
47
|
+
}
|
|
48
|
+
var _namedEntities_lower;
|
|
49
|
+
return (_namedEntities_lower = namedEntities[lower]) !== null && _namedEntities_lower !== void 0 ? _namedEntities_lower : match;
|
|
50
|
+
});
|
|
51
|
+
return withBasicEntitiesDecoded.replace(/<([^;]+)>/gi, (match, inner)=>{
|
|
52
|
+
const normalized = inner.trim().replace(/\s+/g, ' ');
|
|
53
|
+
const lower = normalized.toLowerCase();
|
|
54
|
+
switch(lower){
|
|
55
|
+
case 'b':
|
|
56
|
+
return '<b>';
|
|
57
|
+
case '/b':
|
|
58
|
+
return '</b>';
|
|
59
|
+
case 'i':
|
|
60
|
+
return '<i>';
|
|
61
|
+
case '/i':
|
|
62
|
+
return '</i>';
|
|
63
|
+
case 'br':
|
|
64
|
+
case 'br/':
|
|
65
|
+
case 'br /':
|
|
66
|
+
return '<br />';
|
|
67
|
+
default:
|
|
68
|
+
return match;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const appendTextNode = (nodes, text)=>{
|
|
73
|
+
if (text.length === 0) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const last = nodes[nodes.length - 1];
|
|
77
|
+
if (last && last.type === 'text') {
|
|
78
|
+
last.content += text;
|
|
79
|
+
} else {
|
|
80
|
+
nodes.push({
|
|
81
|
+
type: 'text',
|
|
82
|
+
content: text
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const serializeSimpleMarkup = (nodes)=>nodes.map((node)=>{
|
|
87
|
+
if (node.type === 'text') {
|
|
88
|
+
return node.content;
|
|
89
|
+
}
|
|
90
|
+
if (node.type === 'br') {
|
|
91
|
+
return '<br />';
|
|
92
|
+
}
|
|
93
|
+
return `<${node.tag}>${serializeSimpleMarkup(node.children)}</${node.tag}>`;
|
|
94
|
+
}).join('');
|
|
95
|
+
const parseSimpleMarkup = (input)=>{
|
|
96
|
+
if (!input) {
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
const decodedInput = decodeSimpleMarkupInput(input);
|
|
100
|
+
const rootChildren = [];
|
|
101
|
+
const stack = [
|
|
102
|
+
{
|
|
103
|
+
node: null
|
|
104
|
+
}
|
|
105
|
+
];
|
|
106
|
+
const currentChildren = ()=>{
|
|
107
|
+
var _stack__node;
|
|
108
|
+
var _stack__node_children;
|
|
109
|
+
return (_stack__node_children = (_stack__node = stack[stack.length - 1].node) === null || _stack__node === void 0 ? void 0 : _stack__node.children) !== null && _stack__node_children !== void 0 ? _stack__node_children : rootChildren;
|
|
110
|
+
};
|
|
111
|
+
const tagRegex = /<\/?([a-z]+)\s*\/?\s*>/gi;
|
|
112
|
+
let lastIndex = 0;
|
|
113
|
+
let match;
|
|
114
|
+
while((match = tagRegex.exec(decodedInput)) !== null){
|
|
115
|
+
const [fullMatch, rawTagName] = match;
|
|
116
|
+
const tagName = rawTagName.toLowerCase();
|
|
117
|
+
const isClosing = fullMatch.startsWith('</');
|
|
118
|
+
const isSelfClosing = /\/\s*>$/.test(fullMatch);
|
|
119
|
+
appendTextNode(currentChildren(), decodedInput.slice(lastIndex, match.index));
|
|
120
|
+
lastIndex = match.index + fullMatch.length;
|
|
121
|
+
if (tagName === 'br' && !isClosing) {
|
|
122
|
+
currentChildren().push({
|
|
123
|
+
type: 'br'
|
|
124
|
+
});
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if ((tagName === 'b' || tagName === 'i') && !isSelfClosing) {
|
|
128
|
+
if (isClosing) {
|
|
129
|
+
const top = stack[stack.length - 1].node;
|
|
130
|
+
if (stack.length > 1 && (top === null || top === void 0 ? void 0 : top.tag) === tagName) {
|
|
131
|
+
stack.pop();
|
|
132
|
+
} else {
|
|
133
|
+
appendTextNode(currentChildren(), fullMatch);
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
if (stack.length - 1 >= MAX_SIMPLE_MARKUP_DEPTH) {
|
|
137
|
+
appendTextNode(currentChildren(), fullMatch);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const elementNode = {
|
|
141
|
+
type: 'element',
|
|
142
|
+
tag: tagName,
|
|
143
|
+
children: []
|
|
144
|
+
};
|
|
145
|
+
currentChildren().push(elementNode);
|
|
146
|
+
stack.push({
|
|
147
|
+
node: elementNode
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
appendTextNode(currentChildren(), fullMatch);
|
|
153
|
+
}
|
|
154
|
+
appendTextNode(currentChildren(), decodedInput.slice(lastIndex));
|
|
155
|
+
while(stack.length > 1){
|
|
156
|
+
var _stack__node;
|
|
157
|
+
const unclosed = stack.pop();
|
|
158
|
+
const elementNode = unclosed.node;
|
|
159
|
+
if (!elementNode) {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
var _stack__node_children;
|
|
163
|
+
const parentChildren = (_stack__node_children = (_stack__node = stack[stack.length - 1].node) === null || _stack__node === void 0 ? void 0 : _stack__node.children) !== null && _stack__node_children !== void 0 ? _stack__node_children : rootChildren;
|
|
164
|
+
const lastChild = parentChildren[parentChildren.length - 1];
|
|
165
|
+
if (lastChild === elementNode) {
|
|
166
|
+
parentChildren.pop();
|
|
167
|
+
} else {
|
|
168
|
+
const nodeIndex = parentChildren.indexOf(elementNode);
|
|
169
|
+
if (nodeIndex !== -1) {
|
|
170
|
+
parentChildren.splice(nodeIndex, 1);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
appendTextNode(parentChildren, `<${elementNode.tag}>${serializeSimpleMarkup(elementNode.children)}</${elementNode.tag}>`);
|
|
174
|
+
}
|
|
175
|
+
return rootChildren;
|
|
176
|
+
};
|
|
177
|
+
const simpleMarkupNodesToPlainText = (nodes)=>nodes.map((node)=>{
|
|
178
|
+
if (node.type === 'text') {
|
|
179
|
+
return node.content;
|
|
180
|
+
}
|
|
181
|
+
if (node.type === 'br') {
|
|
182
|
+
return '\n';
|
|
183
|
+
}
|
|
184
|
+
return simpleMarkupNodesToPlainText(node.children);
|
|
185
|
+
}).join('');
|
|
186
|
+
const renderSimpleMarkupNodeList = (nodes, keyPrefix)=>nodes.map((node, index)=>{
|
|
187
|
+
const key = `${keyPrefix}-${index}`;
|
|
188
|
+
if (node.type === 'text') {
|
|
189
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, {
|
|
190
|
+
key: key
|
|
191
|
+
}, node.content);
|
|
192
|
+
}
|
|
193
|
+
if (node.type === 'br') {
|
|
194
|
+
return /*#__PURE__*/ React.createElement("br", {
|
|
195
|
+
key: key
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
const Tag = node.tag === 'b' ? 'strong' : 'em';
|
|
199
|
+
return /*#__PURE__*/ React.createElement(Tag, {
|
|
200
|
+
key
|
|
201
|
+
}, ...renderSimpleMarkupNodeList(node.children, key));
|
|
202
|
+
});
|
|
203
|
+
const renderSimpleMarkup = (nodes, keyPrefix)=>{
|
|
204
|
+
const rendered = renderSimpleMarkupNodeList(nodes, keyPrefix);
|
|
205
|
+
var _rendered_;
|
|
206
|
+
return rendered.length <= 1 ? (_rendered_ = rendered[0]) !== null && _rendered_ !== void 0 ? _rendered_ : null : rendered;
|
|
207
|
+
};
|
|
208
|
+
const normalizeBandOffset = (scale, value)=>{
|
|
209
|
+
const position = scale === null || scale === void 0 ? void 0 : scale(value);
|
|
210
|
+
if (typeof position !== 'number' || Number.isNaN(position)) {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
if (scale && typeof scale.bandwidth === 'function') {
|
|
214
|
+
return position + scale.bandwidth() / 2;
|
|
215
|
+
}
|
|
216
|
+
return position;
|
|
217
|
+
};
|
|
218
|
+
const clamp = (value, min, max)=>Math.max(min, Math.min(max, value));
|
|
219
|
+
const createMeasurementSignature = (annotationContentSignature, containerStyle, contentStyle, layoutClassName, styleClassName)=>JSON.stringify({
|
|
220
|
+
annotationContentSignature,
|
|
221
|
+
containerStyle,
|
|
222
|
+
contentStyle,
|
|
223
|
+
layoutClassName: layoutClassName !== null && layoutClassName !== void 0 ? layoutClassName : '',
|
|
224
|
+
styleClassName: styleClassName !== null && styleClassName !== void 0 ? styleClassName : ''
|
|
225
|
+
});
|
|
226
|
+
const resolveCoordinates = (annotation, context)=>{
|
|
227
|
+
const { coordinates, layout } = annotation;
|
|
228
|
+
if (!coordinates) {
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
var _layout_offsetX;
|
|
232
|
+
const offsetX = (_layout_offsetX = layout === null || layout === void 0 ? void 0 : layout.offsetX) !== null && _layout_offsetX !== void 0 ? _layout_offsetX : 0;
|
|
233
|
+
var _layout_offsetY;
|
|
234
|
+
const offsetY = (_layout_offsetY = layout === null || layout === void 0 ? void 0 : layout.offsetY) !== null && _layout_offsetY !== void 0 ? _layout_offsetY : 0;
|
|
235
|
+
const anchor = {
|
|
236
|
+
x: 0,
|
|
237
|
+
y: 0
|
|
238
|
+
};
|
|
239
|
+
switch(coordinates.type){
|
|
240
|
+
case 'data':
|
|
241
|
+
{
|
|
242
|
+
const { x, y, yAxis = 'primary' } = coordinates;
|
|
243
|
+
const xScale = context.xScale;
|
|
244
|
+
const yScale = yAxis === 'secondary' ? context.yScaleSecondary : context.yScalePrimary;
|
|
245
|
+
if (!xScale || !yScale) {
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
const xValue = normalizeBandOffset(xScale, x instanceof Date ? x.getTime() : x);
|
|
249
|
+
const yValue = normalizeBandOffset(yScale, y instanceof Date ? y.getTime() : y);
|
|
250
|
+
if (typeof xValue !== 'number' || typeof yValue !== 'number') {
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
anchor.x = xValue;
|
|
254
|
+
anchor.y = yValue;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
case 'relative':
|
|
258
|
+
{
|
|
259
|
+
if (typeof coordinates.x !== 'number' || typeof coordinates.y !== 'number') {
|
|
260
|
+
return undefined;
|
|
261
|
+
}
|
|
262
|
+
anchor.x = context.plotRect.x + context.plotRect.width * coordinates.x;
|
|
263
|
+
anchor.y = context.plotRect.y + context.plotRect.height * coordinates.y;
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
case 'pixel':
|
|
267
|
+
{
|
|
268
|
+
if (typeof coordinates.x !== 'number' || typeof coordinates.y !== 'number') {
|
|
269
|
+
return undefined;
|
|
270
|
+
}
|
|
271
|
+
anchor.x = context.plotRect.x + coordinates.x;
|
|
272
|
+
anchor.y = context.plotRect.y + coordinates.y;
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
default:
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
let left = anchor.x + offsetX;
|
|
279
|
+
let top = anchor.y + offsetY;
|
|
280
|
+
if (layout === null || layout === void 0 ? void 0 : layout.clipToBounds) {
|
|
281
|
+
left = clamp(left, context.plotRect.x, context.plotRect.x + context.plotRect.width);
|
|
282
|
+
top = clamp(top, context.plotRect.y, context.plotRect.y + context.plotRect.height);
|
|
283
|
+
}
|
|
284
|
+
return {
|
|
285
|
+
anchor,
|
|
286
|
+
point: {
|
|
287
|
+
x: left,
|
|
288
|
+
y: top
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
export const ChartAnnotationLayer = /*#__PURE__*/ React.memo((props)=>{
|
|
293
|
+
const { annotations: annotationsProp, context } = props;
|
|
294
|
+
const classes = useChartAnnotationLayerStyles(props);
|
|
295
|
+
const idPrefix = useId('chart-annotation');
|
|
296
|
+
const [measurements, setMeasurements] = React.useState({});
|
|
297
|
+
const resolvedAnnotations = React.useMemo(()=>(annotationsProp !== null && annotationsProp !== void 0 ? annotationsProp : []).map((annotation, index)=>({
|
|
298
|
+
annotation,
|
|
299
|
+
key: getAnnotationKey(annotation, index)
|
|
300
|
+
})), [
|
|
301
|
+
annotationsProp
|
|
302
|
+
]);
|
|
303
|
+
React.useEffect(()=>{
|
|
304
|
+
setMeasurements((prev)=>{
|
|
305
|
+
if (resolvedAnnotations.length === 0) {
|
|
306
|
+
if (Object.keys(prev).length === 0) {
|
|
307
|
+
return prev;
|
|
308
|
+
}
|
|
309
|
+
return {};
|
|
310
|
+
}
|
|
311
|
+
const next = {};
|
|
312
|
+
resolvedAnnotations.forEach(({ key })=>{
|
|
313
|
+
if (prev[key]) {
|
|
314
|
+
next[key] = prev[key];
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
if (Object.keys(next).length === Object.keys(prev).length) {
|
|
318
|
+
let identical = true;
|
|
319
|
+
for (const key of Object.keys(next)){
|
|
320
|
+
if (next[key] !== prev[key]) {
|
|
321
|
+
identical = false;
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
if (identical) {
|
|
326
|
+
return prev;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return next;
|
|
330
|
+
});
|
|
331
|
+
}, [
|
|
332
|
+
resolvedAnnotations
|
|
333
|
+
]);
|
|
334
|
+
const updateMeasurement = React.useCallback((key, width, height, signature)=>{
|
|
335
|
+
setMeasurements((prev)=>{
|
|
336
|
+
const prevEntry = prev[key];
|
|
337
|
+
if (prevEntry && prevEntry.signature === signature && Math.abs(prevEntry.width - width) < 0.5 && Math.abs(prevEntry.height - height) < 0.5) {
|
|
338
|
+
return prev;
|
|
339
|
+
}
|
|
340
|
+
if (width === 0 && height === 0) {
|
|
341
|
+
return prev;
|
|
342
|
+
}
|
|
343
|
+
return {
|
|
344
|
+
...prev,
|
|
345
|
+
[key]: {
|
|
346
|
+
width,
|
|
347
|
+
height,
|
|
348
|
+
signature
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
});
|
|
352
|
+
}, []);
|
|
353
|
+
const annotationForeignObjects = [];
|
|
354
|
+
const measurementElements = [];
|
|
355
|
+
const connectors = [];
|
|
356
|
+
resolvedAnnotations.forEach(({ annotation, key })=>{
|
|
357
|
+
var _annotation_style, _annotation_style1, _annotation_style2, _annotation_style3, _annotation_style4, _annotation_style5, _annotation_style6, _annotation_style7, _annotation_style8, _annotation_style9, _annotation_style10, _annotation_style11, _annotation_style12, _annotation_style13, _annotation_style14, _annotation_style15, _annotation_style16, _annotation_style17, _annotation_accessibility, _annotation_accessibility1, _annotation_accessibility2;
|
|
358
|
+
const resolved = resolveCoordinates(annotation, context);
|
|
359
|
+
if (!resolved) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const rawAnnotationText = annotation.text === undefined || annotation.text === null ? '' : String(annotation.text);
|
|
363
|
+
const annotationMarkupNodes = parseSimpleMarkup(rawAnnotationText);
|
|
364
|
+
const annotationMarkupSignature = JSON.stringify(annotationMarkupNodes);
|
|
365
|
+
const annotationPlainText = simpleMarkupNodesToPlainText(annotationMarkupNodes);
|
|
366
|
+
const layout = annotation.layout;
|
|
367
|
+
var _layout_align;
|
|
368
|
+
const horizontalAlign = (_layout_align = layout === null || layout === void 0 ? void 0 : layout.align) !== null && _layout_align !== void 0 ? _layout_align : DEFAULT_HORIZONTAL_ALIGN;
|
|
369
|
+
var _layout_verticalAlign;
|
|
370
|
+
const verticalAlign = (_layout_verticalAlign = layout === null || layout === void 0 ? void 0 : layout.verticalAlign) !== null && _layout_verticalAlign !== void 0 ? _layout_verticalAlign : DEFAULT_VERTICAL_ALIGN;
|
|
371
|
+
var _annotation_style_opacity;
|
|
372
|
+
const backgroundOpacity = (_annotation_style_opacity = (_annotation_style = annotation.style) === null || _annotation_style === void 0 ? void 0 : _annotation_style.opacity) !== null && _annotation_style_opacity !== void 0 ? _annotation_style_opacity : DEFAULT_ANNOTATION_BACKGROUND_OPACITY;
|
|
373
|
+
const baseBackgroundColor = (_annotation_style1 = annotation.style) === null || _annotation_style1 === void 0 ? void 0 : _annotation_style1.backgroundColor;
|
|
374
|
+
const hasCustomBackground = ((_annotation_style2 = annotation.style) === null || _annotation_style2 === void 0 ? void 0 : _annotation_style2.backgroundColor) !== undefined || ((_annotation_style3 = annotation.style) === null || _annotation_style3 === void 0 ? void 0 : _annotation_style3.opacity) !== undefined;
|
|
375
|
+
var _annotation_style_borderStyle;
|
|
376
|
+
const containerStyle = {
|
|
377
|
+
maxWidth: layout === null || layout === void 0 ? void 0 : layout.maxWidth,
|
|
378
|
+
...hasCustomBackground ? {
|
|
379
|
+
backgroundColor: applyOpacityToColor(baseBackgroundColor, backgroundOpacity)
|
|
380
|
+
} : {
|
|
381
|
+
backgroundColor: applyOpacityToColor(tokens.colorNeutralBackground1, DEFAULT_ANNOTATION_BACKGROUND_OPACITY)
|
|
382
|
+
},
|
|
383
|
+
borderColor: (_annotation_style4 = annotation.style) === null || _annotation_style4 === void 0 ? void 0 : _annotation_style4.borderColor,
|
|
384
|
+
borderWidth: (_annotation_style5 = annotation.style) === null || _annotation_style5 === void 0 ? void 0 : _annotation_style5.borderWidth,
|
|
385
|
+
borderStyle: (_annotation_style_borderStyle = (_annotation_style6 = annotation.style) === null || _annotation_style6 === void 0 ? void 0 : _annotation_style6.borderStyle) !== null && _annotation_style_borderStyle !== void 0 ? _annotation_style_borderStyle : ((_annotation_style7 = annotation.style) === null || _annotation_style7 === void 0 ? void 0 : _annotation_style7.borderColor) ? 'solid' : undefined,
|
|
386
|
+
borderRadius: (_annotation_style8 = annotation.style) === null || _annotation_style8 === void 0 ? void 0 : _annotation_style8.borderRadius,
|
|
387
|
+
padding: (_annotation_style9 = annotation.style) === null || _annotation_style9 === void 0 ? void 0 : _annotation_style9.padding,
|
|
388
|
+
boxShadow: (_annotation_style10 = annotation.style) === null || _annotation_style10 === void 0 ? void 0 : _annotation_style10.boxShadow
|
|
389
|
+
};
|
|
390
|
+
const contentStyle = {
|
|
391
|
+
color: (_annotation_style11 = annotation.style) === null || _annotation_style11 === void 0 ? void 0 : _annotation_style11.textColor,
|
|
392
|
+
fontSize: (_annotation_style12 = annotation.style) === null || _annotation_style12 === void 0 ? void 0 : _annotation_style12.fontSize,
|
|
393
|
+
fontWeight: (_annotation_style13 = annotation.style) === null || _annotation_style13 === void 0 ? void 0 : _annotation_style13.fontWeight,
|
|
394
|
+
opacity: 1
|
|
395
|
+
};
|
|
396
|
+
if (typeof ((_annotation_style14 = annotation.style) === null || _annotation_style14 === void 0 ? void 0 : _annotation_style14.rotation) === 'number' && !Number.isNaN(annotation.style.rotation)) {
|
|
397
|
+
containerStyle.transform = `rotate(${annotation.style.rotation}deg)`;
|
|
398
|
+
containerStyle.transformOrigin = '50% 50%';
|
|
399
|
+
}
|
|
400
|
+
const measurementSignature = createMeasurementSignature(annotationMarkupSignature, containerStyle, contentStyle, layout === null || layout === void 0 ? void 0 : layout.className, (_annotation_style15 = annotation.style) === null || _annotation_style15 === void 0 ? void 0 : _annotation_style15.className);
|
|
401
|
+
const measurementEntry = measurements[key];
|
|
402
|
+
const isMeasurementValid = (measurementEntry === null || measurementEntry === void 0 ? void 0 : measurementEntry.signature) === measurementSignature;
|
|
403
|
+
const measuredSize = isMeasurementValid ? measurementEntry : undefined;
|
|
404
|
+
var _measuredSize_width, _ref;
|
|
405
|
+
const width = Math.max((_ref = (_measuredSize_width = measuredSize === null || measuredSize === void 0 ? void 0 : measuredSize.width) !== null && _measuredSize_width !== void 0 ? _measuredSize_width : layout === null || layout === void 0 ? void 0 : layout.maxWidth) !== null && _ref !== void 0 ? _ref : DEFAULT_FOREIGN_OBJECT_WIDTH, 1);
|
|
406
|
+
var _measuredSize_height;
|
|
407
|
+
const height = Math.max((_measuredSize_height = measuredSize === null || measuredSize === void 0 ? void 0 : measuredSize.height) !== null && _measuredSize_height !== void 0 ? _measuredSize_height : DEFAULT_FOREIGN_OBJECT_HEIGHT, 1);
|
|
408
|
+
const offsetX = horizontalAlign === 'center' ? -width / 2 : horizontalAlign === 'end' ? -width : 0;
|
|
409
|
+
const offsetY = verticalAlign === 'middle' ? -height / 2 : verticalAlign === 'bottom' ? -height : 0;
|
|
410
|
+
const baseTopLeftX = resolved.point.x + offsetX;
|
|
411
|
+
const baseTopLeftY = resolved.point.y + offsetY;
|
|
412
|
+
const usePlotBounds = (layout === null || layout === void 0 ? void 0 : layout.clipToBounds) !== false;
|
|
413
|
+
const viewportX = usePlotBounds ? context.plotRect.x : 0;
|
|
414
|
+
const viewportY = usePlotBounds ? context.plotRect.y : 0;
|
|
415
|
+
var _context_svgRect_width;
|
|
416
|
+
const viewportWidth = usePlotBounds ? context.plotRect.width : (_context_svgRect_width = context.svgRect.width) !== null && _context_svgRect_width !== void 0 ? _context_svgRect_width : 0;
|
|
417
|
+
var _context_svgRect_height;
|
|
418
|
+
const viewportHeight = usePlotBounds ? context.plotRect.height : (_context_svgRect_height = context.svgRect.height) !== null && _context_svgRect_height !== void 0 ? _context_svgRect_height : 0;
|
|
419
|
+
const maxTopLeftX = viewportWidth > 0 ? viewportX + viewportWidth - width : baseTopLeftX;
|
|
420
|
+
const maxTopLeftY = viewportHeight > 0 ? viewportY + viewportHeight - height : baseTopLeftY;
|
|
421
|
+
let topLeftX = viewportWidth > 0 ? clamp(baseTopLeftX, viewportX, Math.max(viewportX, maxTopLeftX)) : baseTopLeftX;
|
|
422
|
+
let topLeftY = viewportHeight > 0 ? clamp(baseTopLeftY, viewportY, Math.max(viewportY, maxTopLeftY)) : baseTopLeftY;
|
|
423
|
+
let displayPoint = {
|
|
424
|
+
x: topLeftX - offsetX,
|
|
425
|
+
y: topLeftY - offsetY
|
|
426
|
+
};
|
|
427
|
+
if (annotation.connector) {
|
|
428
|
+
var _annotation_connector_startPadding;
|
|
429
|
+
const startPadding = (_annotation_connector_startPadding = annotation.connector.startPadding) !== null && _annotation_connector_startPadding !== void 0 ? _annotation_connector_startPadding : 12;
|
|
430
|
+
var _annotation_connector_endPadding;
|
|
431
|
+
const endPadding = (_annotation_connector_endPadding = annotation.connector.endPadding) !== null && _annotation_connector_endPadding !== void 0 ? _annotation_connector_endPadding : 0;
|
|
432
|
+
const minArrowClearance = 6;
|
|
433
|
+
const minDistance = Math.max(startPadding + endPadding + minArrowClearance, startPadding);
|
|
434
|
+
const dx = displayPoint.x - resolved.anchor.x;
|
|
435
|
+
const dy = displayPoint.y - resolved.anchor.y;
|
|
436
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
437
|
+
if (distance < minDistance) {
|
|
438
|
+
const fallbackDirection = {
|
|
439
|
+
x: 0,
|
|
440
|
+
y: -1
|
|
441
|
+
};
|
|
442
|
+
const ux = distance === 0 ? fallbackDirection.x : dx / distance;
|
|
443
|
+
const uy = distance === 0 ? fallbackDirection.y : dy / distance;
|
|
444
|
+
const desiredDisplayX = resolved.anchor.x + ux * minDistance;
|
|
445
|
+
const desiredDisplayY = resolved.anchor.y + uy * minDistance;
|
|
446
|
+
let desiredTopLeftX = desiredDisplayX + offsetX;
|
|
447
|
+
let desiredTopLeftY = desiredDisplayY + offsetY;
|
|
448
|
+
desiredTopLeftX = viewportWidth > 0 ? clamp(desiredTopLeftX, viewportX, Math.max(viewportX, maxTopLeftX)) : desiredTopLeftX;
|
|
449
|
+
desiredTopLeftY = viewportHeight > 0 ? clamp(desiredTopLeftY, viewportY, Math.max(viewportY, maxTopLeftY)) : desiredTopLeftY;
|
|
450
|
+
topLeftX = desiredTopLeftX;
|
|
451
|
+
topLeftY = desiredTopLeftY;
|
|
452
|
+
displayPoint = {
|
|
453
|
+
x: topLeftX - offsetX,
|
|
454
|
+
y: topLeftY - offsetY
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
const measurementStyle = {
|
|
459
|
+
position: 'absolute',
|
|
460
|
+
left: topLeftX,
|
|
461
|
+
top: topLeftY,
|
|
462
|
+
pointerEvents: 'none',
|
|
463
|
+
visibility: 'hidden',
|
|
464
|
+
...containerStyle
|
|
465
|
+
};
|
|
466
|
+
if (!isMeasurementValid) {
|
|
467
|
+
var _annotation_style18, _annotation_style19;
|
|
468
|
+
measurementElements.push(/*#__PURE__*/ React.createElement("div", {
|
|
469
|
+
key: `${key}-measurement`,
|
|
470
|
+
ref: (node)=>{
|
|
471
|
+
if (node) {
|
|
472
|
+
const rect = node.getBoundingClientRect();
|
|
473
|
+
if (rect.width !== 0 || rect.height !== 0) {
|
|
474
|
+
updateMeasurement(key, rect.width, rect.height, measurementSignature);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
className: mergeClasses(classes.annotation, classes.measurement, layout === null || layout === void 0 ? void 0 : layout.className, (_annotation_style18 = annotation.style) === null || _annotation_style18 === void 0 ? void 0 : _annotation_style18.className),
|
|
479
|
+
style: measurementStyle,
|
|
480
|
+
"aria-hidden": true,
|
|
481
|
+
"data-annotation-key": key,
|
|
482
|
+
"data-chart-annotation-measurement": "true"
|
|
483
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
484
|
+
className: mergeClasses(classes.annotationContent, layout === null || layout === void 0 ? void 0 : layout.className, (_annotation_style19 = annotation.style) === null || _annotation_style19 === void 0 ? void 0 : _annotation_style19.className),
|
|
485
|
+
style: contentStyle
|
|
486
|
+
}, renderSimpleMarkup(annotationMarkupNodes, `${key}-measurement`))));
|
|
487
|
+
}
|
|
488
|
+
var _annotation_accessibility_role, _annotation_accessibility_ariaLabel;
|
|
489
|
+
annotationForeignObjects.push(/*#__PURE__*/ React.createElement("foreignObject", {
|
|
490
|
+
key: `${key}-annotation`,
|
|
491
|
+
x: topLeftX,
|
|
492
|
+
y: topLeftY,
|
|
493
|
+
width: width,
|
|
494
|
+
height: height,
|
|
495
|
+
className: mergeClasses(classes.annotationForeignObject),
|
|
496
|
+
"data-annotation-key": key
|
|
497
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
498
|
+
className: mergeClasses(classes.annotation, layout === null || layout === void 0 ? void 0 : layout.className, (_annotation_style16 = annotation.style) === null || _annotation_style16 === void 0 ? void 0 : _annotation_style16.className),
|
|
499
|
+
style: containerStyle,
|
|
500
|
+
"data-annotation-key": key
|
|
501
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
502
|
+
className: mergeClasses(classes.annotationContent, (_annotation_style17 = annotation.style) === null || _annotation_style17 === void 0 ? void 0 : _annotation_style17.className),
|
|
503
|
+
style: contentStyle,
|
|
504
|
+
role: (_annotation_accessibility_role = (_annotation_accessibility = annotation.accessibility) === null || _annotation_accessibility === void 0 ? void 0 : _annotation_accessibility.role) !== null && _annotation_accessibility_role !== void 0 ? _annotation_accessibility_role : 'note',
|
|
505
|
+
"aria-label": (_annotation_accessibility_ariaLabel = (_annotation_accessibility1 = annotation.accessibility) === null || _annotation_accessibility1 === void 0 ? void 0 : _annotation_accessibility1.ariaLabel) !== null && _annotation_accessibility_ariaLabel !== void 0 ? _annotation_accessibility_ariaLabel : annotationPlainText ? annotationPlainText : undefined,
|
|
506
|
+
"aria-describedby": (_annotation_accessibility2 = annotation.accessibility) === null || _annotation_accessibility2 === void 0 ? void 0 : _annotation_accessibility2.ariaDescribedBy,
|
|
507
|
+
"data-chart-annotation": "true",
|
|
508
|
+
"data-annotation-key": key
|
|
509
|
+
}, renderSimpleMarkup(annotationMarkupNodes, `${key}-content`)))));
|
|
510
|
+
if (annotation.connector) {
|
|
511
|
+
const { startPadding = DEFAULT_CONNECTOR_START_PADDING, endPadding = DEFAULT_CONNECTOR_END_PADDING, strokeColor = getDefaultConnectorStrokeColor(), strokeWidth = DEFAULT_CONNECTOR_STROKE_WIDTH, dashArray, arrow = DEFAULT_CONNECTOR_ARROW } = annotation.connector;
|
|
512
|
+
const dx = resolved.anchor.x - displayPoint.x;
|
|
513
|
+
const dy = resolved.anchor.y - displayPoint.y;
|
|
514
|
+
const distance = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
515
|
+
const ux = dx / distance;
|
|
516
|
+
const uy = dy / distance;
|
|
517
|
+
const sizeBasis = Math.max(1, Math.min(width, height));
|
|
518
|
+
const proportionalSize = sizeBasis * ARROW_SIZE_SCALE;
|
|
519
|
+
const maxByPadding = startPadding > 0 ? startPadding * 1.25 : MAX_ARROW_SIZE;
|
|
520
|
+
const maxByDistance = distance * 0.6;
|
|
521
|
+
const markerSize = clamp(proportionalSize, MIN_ARROW_SIZE, Math.min(MAX_ARROW_SIZE, maxByPadding, maxByDistance));
|
|
522
|
+
const markerStrokeWidth = clamp(strokeWidth, 1, markerSize / 2);
|
|
523
|
+
const start = {
|
|
524
|
+
x: displayPoint.x + ux * startPadding,
|
|
525
|
+
y: displayPoint.y + uy * startPadding
|
|
526
|
+
};
|
|
527
|
+
const end = {
|
|
528
|
+
x: resolved.anchor.x - ux * endPadding,
|
|
529
|
+
y: resolved.anchor.y - uy * endPadding
|
|
530
|
+
};
|
|
531
|
+
connectors.push({
|
|
532
|
+
key: `${key}-connector`,
|
|
533
|
+
start,
|
|
534
|
+
end,
|
|
535
|
+
strokeColor,
|
|
536
|
+
strokeWidth,
|
|
537
|
+
dashArray,
|
|
538
|
+
arrow,
|
|
539
|
+
markerSize,
|
|
540
|
+
markerStrokeWidth
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
if (annotationForeignObjects.length === 0 && connectors.length === 0) {
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
547
|
+
const viewBoxWidth = context.svgRect.width || 1;
|
|
548
|
+
const viewBoxHeight = context.svgRect.height || 1;
|
|
549
|
+
const markerDefs = [];
|
|
550
|
+
const createMarkerId = (color, position, size, markerStrokeWidth)=>{
|
|
551
|
+
const id = `${idPrefix}-${position}-${markerDefs.length}`;
|
|
552
|
+
const refY = size / 2;
|
|
553
|
+
const refX = position === 'end' ? size : 0;
|
|
554
|
+
const pathEnd = `M0 0 L ${size} ${refY} L0 ${size} Z`;
|
|
555
|
+
const pathStart = `M ${size} 0 L0 ${refY} L ${size} ${size} Z`;
|
|
556
|
+
const path = position === 'end' ? pathEnd : pathStart;
|
|
557
|
+
markerDefs.push(/*#__PURE__*/ React.createElement("marker", {
|
|
558
|
+
key: id,
|
|
559
|
+
id: id,
|
|
560
|
+
markerWidth: size,
|
|
561
|
+
markerHeight: size,
|
|
562
|
+
viewBox: `0 0 ${size} ${size}`,
|
|
563
|
+
refX: refX,
|
|
564
|
+
refY: refY,
|
|
565
|
+
orient: "auto",
|
|
566
|
+
markerUnits: "userSpaceOnUse"
|
|
567
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
568
|
+
d: path,
|
|
569
|
+
fill: color,
|
|
570
|
+
stroke: color,
|
|
571
|
+
strokeWidth: markerStrokeWidth,
|
|
572
|
+
strokeLinecap: "round",
|
|
573
|
+
strokeLinejoin: "round"
|
|
574
|
+
})));
|
|
575
|
+
return id;
|
|
576
|
+
};
|
|
577
|
+
const connectorElements = connectors.map((connector)=>{
|
|
578
|
+
let markerStart;
|
|
579
|
+
let markerEnd;
|
|
580
|
+
if (connector.arrow === 'start' || connector.arrow === 'both') {
|
|
581
|
+
markerStart = createMarkerId(connector.strokeColor, 'start', connector.markerSize, connector.markerStrokeWidth);
|
|
582
|
+
}
|
|
583
|
+
if (connector.arrow === 'end' || connector.arrow === 'both') {
|
|
584
|
+
markerEnd = createMarkerId(connector.strokeColor, 'end', connector.markerSize, connector.markerStrokeWidth);
|
|
585
|
+
}
|
|
586
|
+
return /*#__PURE__*/ React.createElement("line", {
|
|
587
|
+
key: connector.key,
|
|
588
|
+
x1: connector.start.x,
|
|
589
|
+
y1: connector.start.y,
|
|
590
|
+
x2: connector.end.x,
|
|
591
|
+
y2: connector.end.y,
|
|
592
|
+
stroke: connector.strokeColor,
|
|
593
|
+
strokeWidth: connector.strokeWidth,
|
|
594
|
+
strokeDasharray: connector.dashArray,
|
|
595
|
+
strokeLinecap: "round",
|
|
596
|
+
markerStart: markerStart ? `url(#${markerStart})` : undefined,
|
|
597
|
+
markerEnd: markerEnd ? `url(#${markerEnd})` : undefined
|
|
598
|
+
});
|
|
599
|
+
});
|
|
600
|
+
const shouldRenderSvg = connectors.length > 0 || annotationForeignObjects.length > 0;
|
|
601
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
602
|
+
className: classes.root,
|
|
603
|
+
role: "presentation",
|
|
604
|
+
"data-chart-annotation-layer": "true"
|
|
605
|
+
}, shouldRenderSvg && /*#__PURE__*/ React.createElement("svg", {
|
|
606
|
+
className: classes.connectorLayer,
|
|
607
|
+
width: "100%",
|
|
608
|
+
height: "100%",
|
|
609
|
+
viewBox: `0 0 ${viewBoxWidth} ${viewBoxHeight}`,
|
|
610
|
+
preserveAspectRatio: "none",
|
|
611
|
+
"data-chart-annotation-svg": "true"
|
|
612
|
+
}, markerDefs.length > 0 && /*#__PURE__*/ React.createElement("defs", null, markerDefs), connectorElements.length > 0 && /*#__PURE__*/ React.createElement("g", {
|
|
613
|
+
"aria-hidden": "true",
|
|
614
|
+
className: classes.connectorGroup
|
|
615
|
+
}, connectorElements), annotationForeignObjects), measurementElements);
|
|
616
|
+
});
|
|
617
|
+
ChartAnnotationLayer.displayName = 'ChartAnnotationLayer';
|