@fluentui/react-charts 9.3.5 → 9.3.7
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 +42 -2
- package/dist/index.d.ts +239 -55
- package/lib/AnnotationOnlyChart.js +1 -0
- package/lib/AnnotationOnlyChart.js.map +1 -0
- package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js +194 -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/AreaChart.js +3 -16
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- 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/ChartTable.js +2 -10
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.types.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 +159 -132
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.js +1 -2
- package/lib/components/CommonComponents/ChartPopover.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 +32 -14
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +17 -2
- 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 +1 -2
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +83 -40
- 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 +692 -94
- 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/DonutChart.js +3 -12
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/Pie/Pie.js +4 -2
- package/lib/components/DonutChart/Pie/Pie.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/FunnelChart/FunnelChart.js +2 -10
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.types.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.js +6 -19
- 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/GaugeChart/GaugeChart.js +2 -10
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +8 -20
- 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 +4 -17
- 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 +5 -23
- 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/Legends.types.js.map +1 -1
- package/lib/components/Legends/OverflowMenu.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 +11 -20
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.js +1 -1
- package/lib/components/LineChart/LineChart.types.js.map +1 -1
- package/lib/components/LineChart/eventAnnotation/EventAnnotation.js +3 -4
- package/lib/components/LineChart/eventAnnotation/EventAnnotation.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/SankeyChart.js +3 -9
- package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.types.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 +24 -24
- 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/Sparkline/Sparkline.js +11 -7
- package/lib/components/Sparkline/Sparkline.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +3 -15
- 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 +8 -18
- 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/DataPoint.js.map +1 -1
- 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/FocusableTooltipText.js +1 -1
- package/lib/utilities/FocusableTooltipText.js.map +1 -1
- package/lib/utilities/getWindow.js +0 -1
- package/lib/utilities/getWindow.js.map +1 -1
- package/lib/utilities/hooks.js +34 -0
- package/lib/utilities/hooks.js.map +1 -0
- package/lib/utilities/image-export-utils.js +221 -73
- package/lib/utilities/image-export-utils.js.map +1 -1
- package/lib/utilities/utilities.js +39 -37
- 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 +205 -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/AreaChart.js +2 -15
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- 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/ChartTable.js +3 -10
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.types.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 +159 -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/ChartPopover.js +1 -2
- package/lib-commonjs/components/CommonComponents/ChartPopover.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 +35 -22
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +17 -2
- 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 +0 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +82 -39
- 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 +678 -60
- 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/DonutChart.js +2 -11
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/Pie.js +4 -2
- package/lib-commonjs/components/DonutChart/Pie/Pie.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/FunnelChart/FunnelChart.js +2 -10
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.types.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js +5 -18
- 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/GaugeChart/GaugeChart.js +2 -10
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +8 -20
- 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 +3 -16
- 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 +4 -21
- 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/Legends.types.js.map +1 -1
- package/lib-commonjs/components/Legends/OverflowMenu.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 +11 -20
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.js +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js +2 -2
- package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.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/SankeyChart.js +3 -9
- package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.types.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 +22 -22
- 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/Sparkline/Sparkline.js +11 -7
- package/lib-commonjs/components/Sparkline/Sparkline.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +3 -15
- 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 +7 -17
- 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/DataPoint.js.map +1 -1
- 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/FocusableTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/getWindow.js +0 -1
- package/lib-commonjs/utilities/getWindow.js.map +1 -1
- package/lib-commonjs/utilities/hooks.js +45 -0
- package/lib-commonjs/utilities/hooks.js.map +1 -0
- package/lib-commonjs/utilities/image-export-utils.js +222 -74
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +37 -33
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +11 -11
|
@@ -1,36 +1,54 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { create as d3Create, select as d3Select } from 'd3-selection';
|
|
3
|
-
import {
|
|
3
|
+
import { isHTMLElement } from '@fluentui/react-utilities';
|
|
4
|
+
import { copyStyle, createMeasurementSpan } from './index';
|
|
4
5
|
import { LEGEND_CONTAINER_MARGIN_TOP, LEGEND_CONTAINER_MARGIN_START, LEGEND_PADDING, LEGEND_HEIGHT, LEGEND_SHAPE_BORDER, LEGEND_SHAPE_SIZE, LEGEND_SHAPE_MARGIN_END, INACTIVE_LEGEND_TEXT_OPACITY } from '../components/Legends/useLegendsStyles.styles';
|
|
5
|
-
export function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
scale: opts.scale
|
|
27
|
-
}).then(resolve).catch(reject);
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
svgDataUrl = null;
|
|
30
|
-
} catch (err) {
|
|
31
|
-
return reject(err);
|
|
6
|
+
export async function exportChartsAsImage(charts, legendsToSvg, isRTL = false, opts = {}) {
|
|
7
|
+
if (charts.length === 0 && !legendsToSvg) {
|
|
8
|
+
throw new Error('No charts or legends to export');
|
|
9
|
+
}
|
|
10
|
+
const chartImages = await Promise.all(charts.map((chart)=>{
|
|
11
|
+
return new Promise((resolve)=>{
|
|
12
|
+
const svg = cloneStyledSVG(chart.container, isRTL);
|
|
13
|
+
const svgDataUrl = svgToBase64(svg.node);
|
|
14
|
+
resolve({
|
|
15
|
+
dataUrl: svgDataUrl,
|
|
16
|
+
width: svg.width,
|
|
17
|
+
height: svg.height
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}));
|
|
21
|
+
const grid = []; // Sparse 2D array
|
|
22
|
+
charts.forEach((chart, i)=>{
|
|
23
|
+
const row = chart.row || 0;
|
|
24
|
+
const col = chart.col || 0;
|
|
25
|
+
if (!grid[row]) {
|
|
26
|
+
grid[row] = [];
|
|
32
27
|
}
|
|
28
|
+
grid[row][col] = chartImages[i];
|
|
33
29
|
});
|
|
30
|
+
if (legendsToSvg) {
|
|
31
|
+
let totalWidth = 0;
|
|
32
|
+
grid.forEach((row)=>{
|
|
33
|
+
let rowWidth = 0;
|
|
34
|
+
row.forEach((item)=>{
|
|
35
|
+
rowWidth += item.width;
|
|
36
|
+
});
|
|
37
|
+
totalWidth = Math.max(totalWidth, rowWidth);
|
|
38
|
+
});
|
|
39
|
+
const svg = legendsToSvg(totalWidth, isRTL);
|
|
40
|
+
if (svg.node) {
|
|
41
|
+
const svgDataUrl = svgToBase64(svg.node);
|
|
42
|
+
grid.push([
|
|
43
|
+
{
|
|
44
|
+
dataUrl: svgDataUrl,
|
|
45
|
+
width: svg.width,
|
|
46
|
+
height: svg.height
|
|
47
|
+
}
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return svgToPng(grid, opts);
|
|
34
52
|
}
|
|
35
53
|
const SVG_STYLE_PROPERTIES = [
|
|
36
54
|
'display',
|
|
@@ -53,7 +71,59 @@ const SVG_TEXT_STYLE_PROPERTIES = [
|
|
|
53
71
|
'text-align',
|
|
54
72
|
'border'
|
|
55
73
|
];
|
|
56
|
-
|
|
74
|
+
const ANNOTATION_HTML_STYLE_PROPERTIES = [
|
|
75
|
+
'align-items',
|
|
76
|
+
'background',
|
|
77
|
+
'background-color',
|
|
78
|
+
'border',
|
|
79
|
+
'border-radius',
|
|
80
|
+
'box-shadow',
|
|
81
|
+
'box-sizing',
|
|
82
|
+
'color',
|
|
83
|
+
'column-gap',
|
|
84
|
+
'display',
|
|
85
|
+
'flex',
|
|
86
|
+
'flex-direction',
|
|
87
|
+
'font-family',
|
|
88
|
+
'font-size',
|
|
89
|
+
'font-style',
|
|
90
|
+
'font-weight',
|
|
91
|
+
'gap',
|
|
92
|
+
'height',
|
|
93
|
+
'justify-content',
|
|
94
|
+
'letter-spacing',
|
|
95
|
+
'line-height',
|
|
96
|
+
'margin',
|
|
97
|
+
'max-height',
|
|
98
|
+
'max-width',
|
|
99
|
+
'min-height',
|
|
100
|
+
'min-width',
|
|
101
|
+
'opacity',
|
|
102
|
+
'overflow',
|
|
103
|
+
'padding',
|
|
104
|
+
'pointer-events',
|
|
105
|
+
'position',
|
|
106
|
+
'row-gap',
|
|
107
|
+
'text-align',
|
|
108
|
+
'text-decoration',
|
|
109
|
+
'text-transform',
|
|
110
|
+
'top',
|
|
111
|
+
'right',
|
|
112
|
+
'bottom',
|
|
113
|
+
'left',
|
|
114
|
+
'visibility',
|
|
115
|
+
'white-space',
|
|
116
|
+
'width',
|
|
117
|
+
'z-index'
|
|
118
|
+
];
|
|
119
|
+
const ANNOTATION_FOREIGN_OBJECT_STYLE_PROPERTIES = [
|
|
120
|
+
'overflow',
|
|
121
|
+
'pointer-events'
|
|
122
|
+
];
|
|
123
|
+
function cloneStyledSVG(chartContainer, isRTL) {
|
|
124
|
+
if (!chartContainer) {
|
|
125
|
+
throw new Error('Chart container is not defined');
|
|
126
|
+
}
|
|
57
127
|
const svg = chartContainer.querySelector('svg');
|
|
58
128
|
if (!svg) {
|
|
59
129
|
throw new Error('SVG not found');
|
|
@@ -87,24 +157,70 @@ function toSVG(chartContainer, legendsToSvgCallback, isRTL, background) {
|
|
|
87
157
|
svgElements = null;
|
|
88
158
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
159
|
clonedSvgElements = null;
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
160
|
+
const originalForeignObjects = svg.querySelectorAll('foreignObject');
|
|
161
|
+
const clonedForeignObjects = clonedSvg.node().querySelectorAll('foreignObject');
|
|
162
|
+
originalForeignObjects.forEach((originalFo, index)=>{
|
|
163
|
+
const clonedFo = clonedForeignObjects[index];
|
|
164
|
+
if (!clonedFo) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const originalRoot = originalFo.firstElementChild;
|
|
168
|
+
const clonedRoot = clonedFo.firstElementChild;
|
|
169
|
+
if (originalRoot && clonedRoot) {
|
|
170
|
+
copyStyle(ANNOTATION_HTML_STYLE_PROPERTIES, originalRoot, clonedRoot);
|
|
171
|
+
}
|
|
172
|
+
const originalHtmlElements = originalFo.querySelectorAll('*');
|
|
173
|
+
const clonedHtmlElements = clonedFo.querySelectorAll('*');
|
|
174
|
+
originalHtmlElements.forEach((originalEl, elementIndex)=>{
|
|
175
|
+
const clonedEl = clonedHtmlElements[elementIndex];
|
|
176
|
+
if (clonedEl) {
|
|
177
|
+
copyStyle(ANNOTATION_HTML_STYLE_PROPERTIES, originalEl, clonedEl);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
const annotationSvg = chartContainer.querySelector('[data-chart-annotation-svg="true"]');
|
|
182
|
+
let annotationClone = null;
|
|
183
|
+
if (annotationSvg) {
|
|
184
|
+
annotationClone = annotationSvg.cloneNode(true);
|
|
185
|
+
copyStyle(SVG_STYLE_PROPERTIES, annotationSvg, annotationClone);
|
|
186
|
+
const annotationElements = annotationSvg.getElementsByTagName('*');
|
|
187
|
+
const clonedAnnotationElements = annotationClone.getElementsByTagName('*');
|
|
188
|
+
for(let i = 0; i < annotationElements.length; i++){
|
|
189
|
+
const original = annotationElements[i];
|
|
190
|
+
const cloned = clonedAnnotationElements[i];
|
|
191
|
+
const tag = original.tagName.toLowerCase();
|
|
192
|
+
const isSvgElement = original instanceof SVGElement;
|
|
193
|
+
const isTextElement = tag === 'text';
|
|
194
|
+
const isHtmlElement = isHTMLElement(original);
|
|
195
|
+
if (isSvgElement) {
|
|
196
|
+
if (isTextElement) {
|
|
197
|
+
copyStyle([
|
|
198
|
+
...SVG_STYLE_PROPERTIES,
|
|
199
|
+
...SVG_TEXT_STYLE_PROPERTIES
|
|
200
|
+
], original, cloned);
|
|
201
|
+
} else {
|
|
202
|
+
copyStyle(SVG_STYLE_PROPERTIES, original, cloned);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (isHtmlElement) {
|
|
206
|
+
copyStyle(ANNOTATION_HTML_STYLE_PROPERTIES, original, cloned);
|
|
207
|
+
}
|
|
208
|
+
if (tag === 'foreignobject') {
|
|
209
|
+
copyStyle(ANNOTATION_FOREIGN_OBJECT_STYLE_PROPERTIES, original, cloned);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const { width, height } = svg.getBoundingClientRect();
|
|
214
|
+
clonedSvg.attr('width', width).attr('height', height).attr('viewBox', `0 0 ${width} ${height}`).attr('direction', isRTL ? 'rtl' : 'ltr');
|
|
215
|
+
if (annotationClone) {
|
|
216
|
+
clonedSvg.selectAll('[data-chart-annotation-layer="true"]').remove();
|
|
217
|
+
d3Select(annotationClone).attr('x', 0).attr('y', 0).attr('width', width).attr('height', height);
|
|
218
|
+
clonedSvg.append(()=>annotationClone);
|
|
101
219
|
}
|
|
102
|
-
clonedSvg.insert('rect', ':first-child').attr('x', 0).attr('y', 0).attr('width', w1).attr('height', h1).attr('fill', background);
|
|
103
|
-
clonedSvg.attr('width', w1).attr('height', h1).attr('viewBox', `0 0 ${w1} ${h1}`).attr('direction', isRTL ? 'rtl' : 'ltr');
|
|
104
220
|
const result = {
|
|
105
221
|
node: clonedSvg.node(),
|
|
106
|
-
width
|
|
107
|
-
height
|
|
222
|
+
width,
|
|
223
|
+
height
|
|
108
224
|
};
|
|
109
225
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
226
|
clonedSvg = null;
|
|
@@ -187,38 +303,70 @@ export function cloneLegendsToSVG(legends, svgWidth, config, legendContainer) {
|
|
|
187
303
|
});
|
|
188
304
|
});
|
|
189
305
|
}
|
|
306
|
+
const w1 = Math.max(svgWidth, ...legendLineWidths);
|
|
307
|
+
const h1 = legendY;
|
|
308
|
+
const svg = d3Create('svg').attr('width', w1).attr('height', h1).attr('viewBox', `0 0 ${w1} ${h1}`);
|
|
309
|
+
svg.append(()=>legendGroup.node());
|
|
190
310
|
return {
|
|
191
|
-
node:
|
|
192
|
-
width:
|
|
193
|
-
height:
|
|
311
|
+
node: svg.node(),
|
|
312
|
+
width: w1,
|
|
313
|
+
height: h1
|
|
194
314
|
};
|
|
195
315
|
}
|
|
196
|
-
function svgToPng(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
316
|
+
async function svgToPng(grid, opts = {}) {
|
|
317
|
+
let totalWidth = 0;
|
|
318
|
+
let totalHeight = 0;
|
|
319
|
+
const positionedImages = grid.map((row)=>{
|
|
320
|
+
let rowWidth = 0;
|
|
321
|
+
let rowHeight = 0;
|
|
322
|
+
const items = row.map((item)=>{
|
|
323
|
+
const positioned = {
|
|
324
|
+
...item,
|
|
325
|
+
x: rowWidth,
|
|
326
|
+
y: totalHeight
|
|
327
|
+
};
|
|
328
|
+
rowWidth += item.width;
|
|
329
|
+
rowHeight = Math.max(rowHeight, item.height);
|
|
330
|
+
return positioned;
|
|
331
|
+
});
|
|
332
|
+
totalWidth = Math.max(totalWidth, rowWidth);
|
|
333
|
+
totalHeight += rowHeight;
|
|
334
|
+
return items;
|
|
335
|
+
}).flat();
|
|
336
|
+
const scale = opts.scale || 1;
|
|
337
|
+
const w0 = opts.width || totalWidth;
|
|
338
|
+
const h0 = opts.height || totalHeight;
|
|
339
|
+
const scaleX = scale * w0 / totalWidth;
|
|
340
|
+
const scaleY = scale * h0 / totalHeight;
|
|
341
|
+
totalWidth = scaleX * totalWidth;
|
|
342
|
+
totalHeight = scaleY * totalHeight;
|
|
343
|
+
const canvas = document.createElement('canvas');
|
|
344
|
+
canvas.width = totalWidth;
|
|
345
|
+
canvas.height = totalHeight;
|
|
346
|
+
const ctx = canvas.getContext('2d');
|
|
347
|
+
if (!ctx) {
|
|
348
|
+
throw new Error('Canvas context is null');
|
|
349
|
+
}
|
|
350
|
+
ctx.fillStyle = opts.background || 'transparent';
|
|
351
|
+
ctx.fillRect(0, 0, totalWidth, totalHeight);
|
|
352
|
+
await Promise.all(positionedImages.map((item)=>new Promise((resolve, reject)=>{
|
|
353
|
+
const img = new Image();
|
|
354
|
+
img.onload = ()=>{
|
|
355
|
+
ctx.drawImage(img, scaleX * item.x, scaleY * item.y, scaleX * item.width, scaleY * item.height);
|
|
356
|
+
resolve();
|
|
357
|
+
};
|
|
358
|
+
img.onerror = reject;
|
|
359
|
+
img.src = item.dataUrl;
|
|
360
|
+
})));
|
|
361
|
+
return canvas.toDataURL('image/png');
|
|
362
|
+
}
|
|
363
|
+
function svgToBase64(svgNode) {
|
|
364
|
+
if (!svgNode) {
|
|
365
|
+
throw new Error('SVG node is null');
|
|
366
|
+
}
|
|
367
|
+
const svgData = new XMLSerializer().serializeToString(svgNode);
|
|
368
|
+
const svgDataUrl = 'data:image/svg+xml;base64,' + btoa(unescapePonyfill(encodeURIComponent(svgData)));
|
|
369
|
+
return svgDataUrl;
|
|
222
370
|
}
|
|
223
371
|
const hex2 = /^[\da-f]{2}$/i;
|
|
224
372
|
const hex4 = /^[\da-f]{4}$/i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utilities/image-export-utils.ts"],"sourcesContent":["'use client';\n\nimport { create as d3Create, select as d3Select, Selection } from 'd3-selection';\nimport { copyStyle, createMeasurementSpan, resolveCSSVariables } from './index';\nimport { ImageExportOptions } from '../types/index';\nimport { Legend, LegendContainer } from '../Legends';\nimport {\n LEGEND_CONTAINER_MARGIN_TOP,\n LEGEND_CONTAINER_MARGIN_START,\n LEGEND_PADDING,\n LEGEND_HEIGHT,\n LEGEND_SHAPE_BORDER,\n LEGEND_SHAPE_SIZE,\n LEGEND_SHAPE_MARGIN_END,\n INACTIVE_LEGEND_TEXT_OPACITY,\n} from '../components/Legends/useLegendsStyles.styles';\n\nexport function toImage(\n chartContainer: HTMLElement | null | undefined,\n legendsToSvgCallback?: LegendContainer['toSVG'],\n isRTL: boolean = false,\n opts: ImageExportOptions = {},\n): Promise<string> {\n return new Promise((resolve, reject) => {\n if (!chartContainer) {\n return reject(new Error('Chart container is not defined'));\n }\n\n try {\n const background =\n typeof opts.background === 'string' ? resolveCSSVariables(chartContainer, opts.background) : 'transparent';\n\n const svg = toSVG(chartContainer, legendsToSvgCallback, isRTL, background);\n if (!svg.node) {\n return reject(new Error('SVG node is null'));\n }\n\n let svgData = new XMLSerializer().serializeToString(svg.node);\n // This node is already detached from the DOM, so there's no need to call remove() on it.\n // Just clear the reference.\n svg.node = null;\n\n let svgDataUrl = 'data:image/svg+xml;base64,' + btoa(unescapePonyfill(encodeURIComponent(svgData)));\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n svgData = null as any;\n\n svgToPng(svgDataUrl, {\n width: opts.width || svg.width,\n height: opts.height || svg.height,\n scale: opts.scale,\n })\n .then(resolve)\n .catch(reject);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n svgDataUrl = null as any;\n } catch (err) {\n return reject(err);\n }\n });\n}\n\nconst SVG_STYLE_PROPERTIES = [\n 'display',\n 'fill',\n 'fill-opacity',\n 'opacity',\n 'stroke',\n 'stroke-width',\n 'transform',\n 'border-collapse',\n];\nconst SVG_TEXT_STYLE_PROPERTIES = [\n 'font-family',\n 'font-size',\n 'font-weight',\n 'text-anchor',\n 'background-color',\n 'color',\n 'padding',\n 'text-align',\n 'border',\n];\n\nfunction toSVG(\n chartContainer: HTMLElement,\n legendsToSvgCallback: LegendContainer['toSVG'] | undefined,\n isRTL: boolean,\n background: string,\n) {\n const svg = chartContainer.querySelector<SVGSVGElement>('svg');\n if (!svg) {\n throw new Error('SVG not found');\n }\n\n let clonedSvg = d3Select(svg.cloneNode(true) as SVGSVGElement)\n .attr('width', null)\n .attr('height', null)\n .attr('viewBox', null);\n let svgElements = svg.getElementsByTagName('*');\n let clonedSvgElements = clonedSvg.node()!.getElementsByTagName('*');\n\n const TEXT_ELEMENTS = ['text'];\n const TABLE_ELEMENTS = ['table', 'thead', 'tbody', 'tr', 'th', 'td'];\n\n for (let i = 0; i < svgElements.length; i++) {\n const tag = svgElements[i].tagName.toLowerCase();\n\n if (TEXT_ELEMENTS.includes(tag) || TABLE_ELEMENTS.includes(tag)) {\n copyStyle([...SVG_STYLE_PROPERTIES, ...SVG_TEXT_STYLE_PROPERTIES], svgElements[i], clonedSvgElements[i]);\n } else {\n copyStyle(SVG_STYLE_PROPERTIES, svgElements[i], clonedSvgElements[i]);\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n svgElements = null as any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n clonedSvgElements = null as any;\n\n const { width: svgWidth, height: svgHeight } = svg.getBoundingClientRect();\n const legendGroup =\n typeof legendsToSvgCallback === 'function'\n ? legendsToSvgCallback(svgWidth, isRTL)\n : { node: null, width: 0, height: 0 };\n const w1 = Math.max(svgWidth, legendGroup.width);\n const h1 = svgHeight + legendGroup.height;\n\n if (legendGroup.node) {\n d3Select(legendGroup.node).attr('transform', `translate(0, ${svgHeight})`);\n clonedSvg.append(() => legendGroup.node);\n }\n clonedSvg\n .insert('rect', ':first-child')\n .attr('x', 0)\n .attr('y', 0)\n .attr('width', w1)\n .attr('height', h1)\n .attr('fill', background);\n clonedSvg\n .attr('width', w1)\n .attr('height', h1)\n .attr('viewBox', `0 0 ${w1} ${h1}`)\n .attr('direction', isRTL ? 'rtl' : 'ltr');\n\n const result = {\n node: clonedSvg.node(),\n width: w1,\n height: h1,\n };\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n clonedSvg = null as any;\n\n return result;\n}\n\nconst LEGEND_TEXT_STYLE_PROPERTIES_MAP = {\n color: 'fill',\n 'font-family': 'font-family',\n 'font-size': 'font-size',\n 'font-weight': 'font-weight',\n};\n\nexport function cloneLegendsToSVG(\n legends: Legend[],\n svgWidth: number,\n config: {\n selectedLegends: Record<string, boolean>;\n centerLegends: boolean;\n textClassName: string;\n isRTL: boolean;\n },\n legendContainer?: HTMLElement | null,\n): {\n node: SVGGElement | null;\n width: number;\n height: number;\n} {\n if (legends.length === 0) {\n return {\n node: null,\n width: 0,\n height: 0,\n };\n }\n\n const { selectedLegends, centerLegends, textClassName, isRTL } = config;\n const legendGroup = d3Create<SVGGElement>('svg:g');\n let legendX = centerLegends ? 0 : LEGEND_CONTAINER_MARGIN_START;\n let legendY = LEGEND_CONTAINER_MARGIN_TOP;\n let legendLine: { elem: Selection<SVGGElement, unknown, null, undefined>; width: number }[] = [];\n const legendLines: (typeof legendLine)[] = [];\n const legendLineWidths: number[] = [];\n const noLegendsSelected = Object.keys(selectedLegends).length === 0;\n\n for (let i = 0; i < legends.length; i++) {\n const textOffset = LEGEND_PADDING + LEGEND_SHAPE_SIZE + LEGEND_SHAPE_MARGIN_END;\n const legendText = createMeasurementSpan(legends[i].title, textClassName, legendContainer);\n const legendWidth = textOffset + legendText.getBoundingClientRect().width + LEGEND_PADDING;\n const legendItem = legendGroup.append('g');\n\n legendLine.push({ elem: legendItem, width: legendWidth });\n if (legendX + legendWidth > svgWidth && legendLine.length > 1) {\n legendLine.pop();\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n\n legendLine = [{ elem: legendItem, width: legendWidth }];\n legendX = centerLegends ? 0 : LEGEND_CONTAINER_MARGIN_START;\n legendY += LEGEND_HEIGHT;\n }\n\n const isLegendActive = selectedLegends[legends[i].title] || noLegendsSelected;\n\n legendItem\n .append('rect')\n .attr('x', legendX + (isRTL ? legendWidth - LEGEND_PADDING - LEGEND_SHAPE_SIZE : LEGEND_PADDING))\n .attr('y', legendY + LEGEND_PADDING)\n .attr('width', LEGEND_SHAPE_SIZE)\n .attr('height', LEGEND_SHAPE_SIZE)\n .style('fill', isLegendActive ? legends[i].color : 'transparent')\n .style('stroke-width', LEGEND_SHAPE_BORDER)\n .style('stroke', legends[i].color);\n\n legendItem\n .append('text')\n .attr('x', legendX + (isRTL ? legendWidth - textOffset : textOffset))\n .attr('y', legendY + LEGEND_PADDING)\n .attr('dominant-baseline', 'hanging')\n .style('opacity', isLegendActive ? 1 : INACTIVE_LEGEND_TEXT_OPACITY)\n .text(legends[i].title)\n .call(selection => copyStyle(LEGEND_TEXT_STYLE_PROPERTIES_MAP, legendText, selection.node()!));\n\n legendX += legendWidth;\n }\n\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n legendY += LEGEND_HEIGHT;\n\n if (centerLegends) {\n legendLines.forEach((ln, idx) => {\n const lineOffsetX = Math.max((svgWidth - legendLineWidths[idx]) / 2, 0);\n let remLineWidth = legendLineWidths[idx];\n let itemOffsetX = 0;\n ln.forEach(item => {\n const newOffsetX = lineOffsetX + (isRTL ? remLineWidth - item.width - itemOffsetX : 0);\n item.elem.attr('transform', `translate(${newOffsetX}, 0)`);\n remLineWidth -= item.width;\n itemOffsetX += item.width;\n });\n });\n } else if (isRTL) {\n const w1 = Math.max(svgWidth, ...legendLineWidths);\n legendLines.forEach(ln => {\n let remLineWidth = w1 - LEGEND_CONTAINER_MARGIN_START;\n let itemOffsetX = LEGEND_CONTAINER_MARGIN_START;\n ln.forEach(item => {\n const newOffsetX = remLineWidth - item.width - itemOffsetX;\n item.elem.attr('transform', `translate(${newOffsetX}, 0)`);\n remLineWidth -= item.width;\n itemOffsetX += item.width;\n });\n });\n }\n\n return {\n node: legendGroup.node(),\n width: Math.max(...legendLineWidths),\n height: legendY,\n };\n}\n\nfunction svgToPng(svgDataUrl: string, opts: ImageExportOptions = {}): Promise<string> {\n return new Promise((resolve, reject) => {\n const scale = opts.scale || 1;\n const w0 = opts.width || 300;\n const h0 = opts.height || 150;\n const w1 = scale * w0;\n const h1 = scale * h0;\n\n const canvas = document.createElement('canvas');\n const img = new Image();\n\n canvas.width = w1;\n canvas.height = h1;\n\n img.onload = function () {\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n return reject(new Error('Canvas context is null'));\n }\n\n ctx.clearRect(0, 0, w1, h1);\n ctx.drawImage(img, 0, 0, w1, h1);\n\n const imgData = canvas.toDataURL('image/png');\n resolve(imgData);\n };\n\n img.onerror = function (err) {\n reject(err);\n };\n\n img.src = svgDataUrl;\n });\n}\n\nconst hex2 = /^[\\da-f]{2}$/i;\nconst hex4 = /^[\\da-f]{4}$/i;\n\n/**\n * A ponyfill for the deprecated `unescape` method, taken from the `core-js` library.\n *\n * Source: {@link https://github.com/zloirock/core-js/blob/167136f479d3b8519953f2e4c534ecdd1031d3cf/packages/core-js/modules/es.unescape.js core-js/packages/core-js/modules/es.unescape.js}\n */\nfunction unescapePonyfill(str: string) {\n let result = '';\n const length = str.length;\n let index = 0;\n let chr;\n let part;\n while (index < length) {\n chr = str.charAt(index++);\n if (chr === '%') {\n if (str.charAt(index) === 'u') {\n part = str.slice(index + 1, index + 5);\n if (hex4.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 5;\n continue;\n }\n } else {\n part = str.slice(index, index + 2);\n if (hex2.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 2;\n continue;\n }\n }\n }\n result += chr;\n }\n return result;\n}\n"],"names":["create","d3Create","select","d3Select","copyStyle","createMeasurementSpan","resolveCSSVariables","LEGEND_CONTAINER_MARGIN_TOP","LEGEND_CONTAINER_MARGIN_START","LEGEND_PADDING","LEGEND_HEIGHT","LEGEND_SHAPE_BORDER","LEGEND_SHAPE_SIZE","LEGEND_SHAPE_MARGIN_END","INACTIVE_LEGEND_TEXT_OPACITY","toImage","chartContainer","legendsToSvgCallback","isRTL","opts","Promise","resolve","reject","Error","background","svg","toSVG","node","svgData","XMLSerializer","serializeToString","svgDataUrl","btoa","unescapePonyfill","encodeURIComponent","svgToPng","width","height","scale","then","catch","err","SVG_STYLE_PROPERTIES","SVG_TEXT_STYLE_PROPERTIES","querySelector","clonedSvg","cloneNode","attr","svgElements","getElementsByTagName","clonedSvgElements","TEXT_ELEMENTS","TABLE_ELEMENTS","i","length","tag","tagName","toLowerCase","includes","svgWidth","svgHeight","getBoundingClientRect","legendGroup","w1","Math","max","h1","append","insert","result","LEGEND_TEXT_STYLE_PROPERTIES_MAP","color","cloneLegendsToSVG","legends","config","legendContainer","selectedLegends","centerLegends","textClassName","legendX","legendY","legendLine","legendLines","legendLineWidths","noLegendsSelected","Object","keys","textOffset","legendText","title","legendWidth","legendItem","push","elem","pop","isLegendActive","style","text","call","selection","forEach","ln","idx","lineOffsetX","remLineWidth","itemOffsetX","item","newOffsetX","w0","h0","canvas","document","createElement","img","Image","onload","ctx","getContext","clearRect","drawImage","imgData","toDataURL","onerror","src","hex2","hex4","str","index","chr","part","charAt","slice","exec","String","fromCharCode","parseInt"],"mappings":"AAAA;AAEA,SAASA,UAAUC,QAAQ,EAAEC,UAAUC,QAAQ,QAAmB,eAAe;AACjF,SAASC,SAAS,EAAEC,qBAAqB,EAAEC,mBAAmB,QAAQ,UAAU;AAGhF,SACEC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,cAAc,EACdC,aAAa,EACbC,mBAAmB,EACnBC,iBAAiB,EACjBC,uBAAuB,EACvBC,4BAA4B,QACvB,gDAAgD;AAEvD,OAAO,SAASC,QACdC,cAA8C,EAC9CC,oBAA+C,EAC/CC,QAAiB,KAAK,EACtBC,OAA2B,CAAC,CAAC;IAE7B,OAAO,IAAIC,QAAQ,CAACC,SAASC;QAC3B,IAAI,CAACN,gBAAgB;YACnB,OAAOM,OAAO,IAAIC,MAAM;QAC1B;QAEA,IAAI;YACF,MAAMC,aACJ,OAAOL,KAAKK,UAAU,KAAK,WAAWlB,oBAAoBU,gBAAgBG,KAAKK,UAAU,IAAI;YAE/F,MAAMC,MAAMC,MAAMV,gBAAgBC,sBAAsBC,OAAOM;YAC/D,IAAI,CAACC,IAAIE,IAAI,EAAE;gBACb,OAAOL,OAAO,IAAIC,MAAM;YAC1B;YAEA,IAAIK,UAAU,IAAIC,gBAAgBC,iBAAiB,CAACL,IAAIE,IAAI;YAC5D,yFAAyF;YACzF,4BAA4B;YAC5BF,IAAIE,IAAI,GAAG;YAEX,IAAII,aAAa,+BAA+BC,KAAKC,iBAAiBC,mBAAmBN;YACzF,8DAA8D;YAC9DA,UAAU;YAEVO,SAASJ,YAAY;gBACnBK,OAAOjB,KAAKiB,KAAK,IAAIX,IAAIW,KAAK;gBAC9BC,QAAQlB,KAAKkB,MAAM,IAAIZ,IAAIY,MAAM;gBACjCC,OAAOnB,KAAKmB,KAAK;YACnB,GACGC,IAAI,CAAClB,SACLmB,KAAK,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ACD,SAAS5F,iBAAiB6F,GAAW;IACnC,IAAIzD,SAAS;IACb,MAAMf,SAASwE,IAAIxE,MAAM;IACzB,IAAIyE,QAAQ;IACZ,IAAIC;IACJ,IAAIC;IACJ,MAAOF,QAAQzE,OAAQ;QACrB0E,MAAMF,IAAII,MAAM,CAACH;QACjB,IAAIC,QAAQ,KAAK;YACf,IAAIF,IAAII,MAAM,CAACH,WAAW,KAAK;gBAC7BE,OAAOH,IAAIK,KAAK,CAACJ,QAAQ,GAAGA,QAAQ;gBACpC,IAAIF,KAAKO,IAAI,CAACH,OAAO;oBACnB5D,UAAUgE,OAAOC,YAAY,CAACC,SAASN,MAAM;oBAC7CF,SAAS;oBACT;gBACF;YACF,OAAO;gBACLE,OAAOH,IAAIK,KAAK,CAACJ,OAAOA,QAAQ;gBAChC,IAAIH,KAAKQ,IAAI,CAACH,OAAO;oBACnB5D,UAAUgE,OAAOC,YAAY,CAACC,SAASN,MAAM;oBAC7CF,SAAS;oBACT;gBACF;YACF;QACF;QACA1D,UAAU2D;IACZ;IACA,OAAO3D;AACT"}
|
|
1
|
+
{"version":3,"sources":["../src/utilities/image-export-utils.ts"],"sourcesContent":["'use client';\n\nimport { create as d3Create, select as d3Select, Selection } from 'd3-selection';\nimport { isHTMLElement } from '@fluentui/react-utilities';\nimport { copyStyle, createMeasurementSpan } from './index';\nimport { ImageExportOptions } from '../types/index';\nimport { Legend, LegendContainer } from '../Legends';\nimport {\n LEGEND_CONTAINER_MARGIN_TOP,\n LEGEND_CONTAINER_MARGIN_START,\n LEGEND_PADDING,\n LEGEND_HEIGHT,\n LEGEND_SHAPE_BORDER,\n LEGEND_SHAPE_SIZE,\n LEGEND_SHAPE_MARGIN_END,\n INACTIVE_LEGEND_TEXT_OPACITY,\n} from '../components/Legends/useLegendsStyles.styles';\n\nexport type GridChart = {\n container: HTMLElement | null | undefined;\n row?: number;\n col?: number;\n};\n\ntype SvgImage = {\n dataUrl: string;\n width: number;\n height: number;\n};\n\nexport async function exportChartsAsImage(\n charts: GridChart[],\n legendsToSvg?: LegendContainer['toSVG'],\n isRTL: boolean = false,\n opts: ImageExportOptions = {},\n): Promise<string> {\n if (charts.length === 0 && !legendsToSvg) {\n throw new Error('No charts or legends to export');\n }\n\n const chartImages = await Promise.all(\n charts.map(chart => {\n return new Promise<SvgImage>(resolve => {\n const svg = cloneStyledSVG(chart.container, isRTL);\n const svgDataUrl = svgToBase64(svg.node);\n resolve({ dataUrl: svgDataUrl, width: svg.width, height: svg.height });\n });\n }),\n );\n\n const grid: SvgImage[][] = []; // Sparse 2D array\n charts.forEach((chart, i) => {\n const row = chart.row || 0;\n const col = chart.col || 0;\n if (!grid[row]) {\n grid[row] = [];\n }\n grid[row][col] = chartImages[i];\n });\n\n if (legendsToSvg) {\n let totalWidth = 0;\n grid.forEach(row => {\n let rowWidth = 0;\n row.forEach(item => {\n rowWidth += item.width;\n });\n totalWidth = Math.max(totalWidth, rowWidth);\n });\n\n const svg = legendsToSvg(totalWidth, isRTL);\n if (svg.node) {\n const svgDataUrl = svgToBase64(svg.node);\n grid.push([{ dataUrl: svgDataUrl, width: svg.width, height: svg.height }]);\n }\n }\n\n return svgToPng(grid, opts);\n}\n\nconst SVG_STYLE_PROPERTIES = [\n 'display',\n 'fill',\n 'fill-opacity',\n 'opacity',\n 'stroke',\n 'stroke-width',\n 'transform',\n 'border-collapse',\n];\nconst SVG_TEXT_STYLE_PROPERTIES = [\n 'font-family',\n 'font-size',\n 'font-weight',\n 'text-anchor',\n 'background-color',\n 'color',\n 'padding',\n 'text-align',\n 'border',\n];\n\nconst ANNOTATION_HTML_STYLE_PROPERTIES = [\n 'align-items',\n 'background',\n 'background-color',\n 'border',\n 'border-radius',\n 'box-shadow',\n 'box-sizing',\n 'color',\n 'column-gap',\n 'display',\n 'flex',\n 'flex-direction',\n 'font-family',\n 'font-size',\n 'font-style',\n 'font-weight',\n 'gap',\n 'height',\n 'justify-content',\n 'letter-spacing',\n 'line-height',\n 'margin',\n 'max-height',\n 'max-width',\n 'min-height',\n 'min-width',\n 'opacity',\n 'overflow',\n 'padding',\n 'pointer-events',\n 'position',\n 'row-gap',\n 'text-align',\n 'text-decoration',\n 'text-transform',\n 'top',\n 'right',\n 'bottom',\n 'left',\n 'visibility',\n 'white-space',\n 'width',\n 'z-index',\n];\nconst ANNOTATION_FOREIGN_OBJECT_STYLE_PROPERTIES = ['overflow', 'pointer-events'];\n\nfunction cloneStyledSVG(chartContainer: HTMLElement | null | undefined, isRTL: boolean) {\n if (!chartContainer) {\n throw new Error('Chart container is not defined');\n }\n\n const svg = chartContainer.querySelector<SVGSVGElement>('svg');\n if (!svg) {\n throw new Error('SVG not found');\n }\n\n let clonedSvg = d3Select(svg.cloneNode(true) as SVGSVGElement)\n .attr('width', null)\n .attr('height', null)\n .attr('viewBox', null);\n let svgElements = svg.getElementsByTagName('*');\n let clonedSvgElements = clonedSvg.node()!.getElementsByTagName('*');\n\n const TEXT_ELEMENTS = ['text'];\n const TABLE_ELEMENTS = ['table', 'thead', 'tbody', 'tr', 'th', 'td'];\n\n for (let i = 0; i < svgElements.length; i++) {\n const tag = svgElements[i].tagName.toLowerCase();\n\n if (TEXT_ELEMENTS.includes(tag) || TABLE_ELEMENTS.includes(tag)) {\n copyStyle([...SVG_STYLE_PROPERTIES, ...SVG_TEXT_STYLE_PROPERTIES], svgElements[i], clonedSvgElements[i]);\n } else {\n copyStyle(SVG_STYLE_PROPERTIES, svgElements[i], clonedSvgElements[i]);\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n svgElements = null as any;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n clonedSvgElements = null as any;\n\n const originalForeignObjects = svg.querySelectorAll('foreignObject');\n const clonedForeignObjects = clonedSvg.node()!.querySelectorAll('foreignObject');\n\n originalForeignObjects.forEach((originalFo, index) => {\n const clonedFo = clonedForeignObjects[index];\n if (!clonedFo) {\n return;\n }\n\n const originalRoot = originalFo.firstElementChild as HTMLElement | null;\n const clonedRoot = clonedFo.firstElementChild as HTMLElement | null;\n\n if (originalRoot && clonedRoot) {\n copyStyle(ANNOTATION_HTML_STYLE_PROPERTIES, originalRoot, clonedRoot);\n }\n\n const originalHtmlElements = originalFo.querySelectorAll<HTMLElement>('*');\n const clonedHtmlElements = clonedFo.querySelectorAll<HTMLElement>('*');\n\n originalHtmlElements.forEach((originalEl, elementIndex) => {\n const clonedEl = clonedHtmlElements[elementIndex];\n if (clonedEl) {\n copyStyle(ANNOTATION_HTML_STYLE_PROPERTIES, originalEl, clonedEl);\n }\n });\n });\n\n const annotationSvg = chartContainer.querySelector<SVGSVGElement>('[data-chart-annotation-svg=\"true\"]');\n let annotationClone: SVGSVGElement | null = null;\n\n if (annotationSvg) {\n annotationClone = annotationSvg.cloneNode(true) as SVGSVGElement;\n copyStyle(SVG_STYLE_PROPERTIES, annotationSvg, annotationClone);\n\n const annotationElements = annotationSvg.getElementsByTagName('*');\n const clonedAnnotationElements = annotationClone.getElementsByTagName('*');\n\n for (let i = 0; i < annotationElements.length; i++) {\n const original = annotationElements[i];\n const cloned = clonedAnnotationElements[i];\n const tag = original.tagName.toLowerCase();\n const isSvgElement = original instanceof SVGElement;\n const isTextElement = tag === 'text';\n const isHtmlElement = isHTMLElement(original);\n\n if (isSvgElement) {\n if (isTextElement) {\n copyStyle([...SVG_STYLE_PROPERTIES, ...SVG_TEXT_STYLE_PROPERTIES], original, cloned);\n } else {\n copyStyle(SVG_STYLE_PROPERTIES, original, cloned);\n }\n }\n\n if (isHtmlElement) {\n copyStyle(ANNOTATION_HTML_STYLE_PROPERTIES, original, cloned);\n }\n\n if (tag === 'foreignobject') {\n copyStyle(ANNOTATION_FOREIGN_OBJECT_STYLE_PROPERTIES, original, cloned);\n }\n }\n }\n\n const { width, height } = svg.getBoundingClientRect();\n\n clonedSvg\n .attr('width', width)\n .attr('height', height)\n .attr('viewBox', `0 0 ${width} ${height}`)\n .attr('direction', isRTL ? 'rtl' : 'ltr');\n\n if (annotationClone) {\n clonedSvg.selectAll('[data-chart-annotation-layer=\"true\"]').remove();\n d3Select(annotationClone).attr('x', 0).attr('y', 0).attr('width', width).attr('height', height);\n clonedSvg.append(() => annotationClone as SVGSVGElement);\n }\n const result = {\n node: clonedSvg.node(),\n width,\n height,\n };\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n clonedSvg = null as any;\n\n return result;\n}\n\nconst LEGEND_TEXT_STYLE_PROPERTIES_MAP = {\n color: 'fill',\n 'font-family': 'font-family',\n 'font-size': 'font-size',\n 'font-weight': 'font-weight',\n};\n\nexport function cloneLegendsToSVG(\n legends: Legend[],\n svgWidth: number,\n config: {\n selectedLegends: Record<string, boolean>;\n centerLegends: boolean;\n textClassName: string;\n isRTL: boolean;\n },\n legendContainer?: HTMLElement | null,\n): {\n node: SVGSVGElement | null;\n width: number;\n height: number;\n} {\n if (legends.length === 0) {\n return {\n node: null,\n width: 0,\n height: 0,\n };\n }\n\n const { selectedLegends, centerLegends, textClassName, isRTL } = config;\n const legendGroup = d3Create<SVGGElement>('svg:g');\n let legendX = centerLegends ? 0 : LEGEND_CONTAINER_MARGIN_START;\n let legendY = LEGEND_CONTAINER_MARGIN_TOP;\n let legendLine: { elem: Selection<SVGGElement, unknown, null, undefined>; width: number }[] = [];\n const legendLines: (typeof legendLine)[] = [];\n const legendLineWidths: number[] = [];\n const noLegendsSelected = Object.keys(selectedLegends).length === 0;\n\n for (let i = 0; i < legends.length; i++) {\n const textOffset = LEGEND_PADDING + LEGEND_SHAPE_SIZE + LEGEND_SHAPE_MARGIN_END;\n const legendText = createMeasurementSpan(legends[i].title, textClassName, legendContainer);\n const legendWidth = textOffset + legendText.getBoundingClientRect().width + LEGEND_PADDING;\n const legendItem = legendGroup.append('g');\n\n legendLine.push({ elem: legendItem, width: legendWidth });\n if (legendX + legendWidth > svgWidth && legendLine.length > 1) {\n legendLine.pop();\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n\n legendLine = [{ elem: legendItem, width: legendWidth }];\n legendX = centerLegends ? 0 : LEGEND_CONTAINER_MARGIN_START;\n legendY += LEGEND_HEIGHT;\n }\n\n const isLegendActive = selectedLegends[legends[i].title] || noLegendsSelected;\n\n legendItem\n .append('rect')\n .attr('x', legendX + (isRTL ? legendWidth - LEGEND_PADDING - LEGEND_SHAPE_SIZE : LEGEND_PADDING))\n .attr('y', legendY + LEGEND_PADDING)\n .attr('width', LEGEND_SHAPE_SIZE)\n .attr('height', LEGEND_SHAPE_SIZE)\n .style('fill', isLegendActive ? legends[i].color : 'transparent')\n .style('stroke-width', LEGEND_SHAPE_BORDER)\n .style('stroke', legends[i].color);\n\n legendItem\n .append('text')\n .attr('x', legendX + (isRTL ? legendWidth - textOffset : textOffset))\n .attr('y', legendY + LEGEND_PADDING)\n .attr('dominant-baseline', 'hanging')\n .style('opacity', isLegendActive ? 1 : INACTIVE_LEGEND_TEXT_OPACITY)\n .text(legends[i].title)\n .call(selection => copyStyle(LEGEND_TEXT_STYLE_PROPERTIES_MAP, legendText, selection.node()!));\n\n legendX += legendWidth;\n }\n\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n legendY += LEGEND_HEIGHT;\n\n if (centerLegends) {\n legendLines.forEach((ln, idx) => {\n const lineOffsetX = Math.max((svgWidth - legendLineWidths[idx]) / 2, 0);\n let remLineWidth = legendLineWidths[idx];\n let itemOffsetX = 0;\n ln.forEach(item => {\n const newOffsetX = lineOffsetX + (isRTL ? remLineWidth - item.width - itemOffsetX : 0);\n item.elem.attr('transform', `translate(${newOffsetX}, 0)`);\n remLineWidth -= item.width;\n itemOffsetX += item.width;\n });\n });\n } else if (isRTL) {\n const w1 = Math.max(svgWidth, ...legendLineWidths);\n legendLines.forEach(ln => {\n let remLineWidth = w1 - LEGEND_CONTAINER_MARGIN_START;\n let itemOffsetX = LEGEND_CONTAINER_MARGIN_START;\n ln.forEach(item => {\n const newOffsetX = remLineWidth - item.width - itemOffsetX;\n item.elem.attr('transform', `translate(${newOffsetX}, 0)`);\n remLineWidth -= item.width;\n itemOffsetX += item.width;\n });\n });\n }\n\n const w1 = Math.max(svgWidth, ...legendLineWidths);\n const h1 = legendY;\n const svg = d3Create<SVGSVGElement>('svg').attr('width', w1).attr('height', h1).attr('viewBox', `0 0 ${w1} ${h1}`);\n svg.append(() => legendGroup.node()!);\n\n return {\n node: svg.node(),\n width: w1,\n height: h1,\n };\n}\n\ntype PositionedImage = SvgImage & {\n x: number;\n y: number;\n};\n\nasync function svgToPng(grid: SvgImage[][], opts: ImageExportOptions = {}): Promise<string> {\n let totalWidth = 0;\n let totalHeight = 0;\n\n const positionedImages: PositionedImage[] = grid\n .map(row => {\n let rowWidth = 0;\n let rowHeight = 0;\n\n const items = row.map(item => {\n const positioned = { ...item, x: rowWidth, y: totalHeight };\n rowWidth += item.width;\n rowHeight = Math.max(rowHeight, item.height);\n return positioned;\n });\n\n totalWidth = Math.max(totalWidth, rowWidth);\n totalHeight += rowHeight;\n\n return items;\n })\n .flat();\n\n const scale = opts.scale || 1;\n const w0 = opts.width || totalWidth;\n const h0 = opts.height || totalHeight;\n const scaleX = (scale * w0) / totalWidth;\n const scaleY = (scale * h0) / totalHeight;\n totalWidth = scaleX * totalWidth;\n totalHeight = scaleY * totalHeight;\n\n const canvas = document.createElement('canvas');\n canvas.width = totalWidth;\n canvas.height = totalHeight;\n\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n throw new Error('Canvas context is null');\n }\n\n ctx.fillStyle = opts.background || 'transparent';\n ctx.fillRect(0, 0, totalWidth, totalHeight);\n\n await Promise.all(\n positionedImages.map(\n item =>\n new Promise<void>((resolve, reject) => {\n const img = new Image();\n img.onload = () => {\n ctx.drawImage(img, scaleX * item.x, scaleY * item.y, scaleX * item.width, scaleY * item.height);\n resolve();\n };\n img.onerror = reject;\n img.src = item.dataUrl;\n }),\n ),\n );\n\n return canvas.toDataURL('image/png');\n}\n\nfunction svgToBase64(svgNode: SVGSVGElement | null) {\n if (!svgNode) {\n throw new Error('SVG node is null');\n }\n\n const svgData = new XMLSerializer().serializeToString(svgNode);\n const svgDataUrl = 'data:image/svg+xml;base64,' + btoa(unescapePonyfill(encodeURIComponent(svgData)));\n return svgDataUrl;\n}\n\nconst hex2 = /^[\\da-f]{2}$/i;\nconst hex4 = /^[\\da-f]{4}$/i;\n\n/**\n * A ponyfill for the deprecated `unescape` method, taken from the `core-js` library.\n *\n * Source: {@link https://github.com/zloirock/core-js/blob/167136f479d3b8519953f2e4c534ecdd1031d3cf/packages/core-js/modules/es.unescape.js core-js/packages/core-js/modules/es.unescape.js}\n */\nfunction unescapePonyfill(str: string) {\n let result = '';\n const length = str.length;\n let index = 0;\n let chr;\n let part;\n while (index < length) {\n chr = str.charAt(index++);\n if (chr === '%') {\n if (str.charAt(index) === 'u') {\n part = str.slice(index + 1, index + 5);\n if (hex4.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 5;\n continue;\n }\n } else {\n part = str.slice(index, index + 2);\n if (hex2.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 2;\n continue;\n }\n }\n }\n result += chr;\n }\n return result;\n}\n"],"names":["create","d3Create","select","d3Select","isHTMLElement","copyStyle","createMeasurementSpan","LEGEND_CONTAINER_MARGIN_TOP","LEGEND_CONTAINER_MARGIN_START","LEGEND_PADDING","LEGEND_HEIGHT","LEGEND_SHAPE_BORDER","LEGEND_SHAPE_SIZE","LEGEND_SHAPE_MARGIN_END","INACTIVE_LEGEND_TEXT_OPACITY","exportChartsAsImage","charts","legendsToSvg","isRTL","opts","length","Error","chartImages","Promise","all","map","chart","resolve","svg","cloneStyledSVG","container","svgDataUrl","svgToBase64","node","dataUrl","width","height","grid","forEach","i","row","col","totalWidth","rowWidth","item","Math","max","push","svgToPng","SVG_STYLE_PROPERTIES","SVG_TEXT_STYLE_PROPERTIES","ANNOTATION_HTML_STYLE_PROPERTIES","ANNOTATION_FOREIGN_OBJECT_STYLE_PROPERTIES","chartContainer","querySelector","clonedSvg","cloneNode","attr","svgElements","getElementsByTagName","clonedSvgElements","TEXT_ELEMENTS","TABLE_ELEMENTS","tag","tagName","toLowerCase","includes","originalForeignObjects","querySelectorAll","clonedForeignObjects","originalFo","index","clonedFo","originalRoot","firstElementChild","clonedRoot","originalHtmlElements","clonedHtmlElements","originalEl","elementIndex","clonedEl","annotationSvg","annotationClone","annotationElements","clonedAnnotationElements","original","cloned","isSvgElement","SVGElement","isTextElement","isHtmlElement","getBoundingClientRect","selectAll","remove","append","result","LEGEND_TEXT_STYLE_PROPERTIES_MAP","color","cloneLegendsToSVG","legends","svgWidth","config","legendContainer","selectedLegends","centerLegends","textClassName","legendGroup","legendX","legendY","legendLine","legendLines","legendLineWidths","noLegendsSelected","Object","keys","textOffset","legendText","title","legendWidth","legendItem","elem","pop","isLegendActive","style","text","call","selection","ln","idx","lineOffsetX","remLineWidth","itemOffsetX","newOffsetX","w1","h1","totalHeight","positionedImages","rowHeight","items","positioned","x","y","flat","scale","w0","h0","scaleX","scaleY","canvas","document","createElement","ctx","getContext","fillStyle","background","fillRect","reject","img","Image","onload","drawImage","onerror","src","toDataURL","svgNode","svgData","XMLSerializer","serializeToString","btoa","unescapePonyfill","encodeURIComponent","hex2","hex4","str","chr","part","charAt","slice","exec","String","fromCharCode","parseInt"],"mappings":"AAAA;AAEA,SAASA,UAAUC,QAAQ,EAAEC,UAAUC,QAAQ,QAAmB,eAAe;AACjF,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,SAAS,EAAEC,qBAAqB,QAAQ,UAAU;AAG3D,SACEC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,cAAc,EACdC,aAAa,EACbC,mBAAmB,EACnBC,iBAAiB,EACjBC,uBAAuB,EACvBC,4BAA4B,QACvB,gDAAgD;AAcvD,OAAO,eAAeC,oBACpBC,MAAmB,EACnBC,YAAuC,EACvCC,QAAiB,KAAK,EACtBC,OAA2B,CAAC,CAAC;IAE7B,IAAIH,OAAOI,MAAM,KAAK,KAAK,CAACH,cAAc;QACxC,MAAM,IAAII,MAAM;IAClB;IA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SAASyJ,IAAIzJ,MAAM;IACzB,IAAImD,QAAQ;IACZ,IAAIuG;IACJ,IAAIC;IACJ,MAAOxG,QAAQnD,OAAQ;QACrB0J,MAAMD,IAAIG,MAAM,CAACzG;QACjB,IAAIuG,QAAQ,KAAK;YACf,IAAID,IAAIG,MAAM,CAACzG,WAAW,KAAK;gBAC7BwG,OAAOF,IAAII,KAAK,CAAC1G,QAAQ,GAAGA,QAAQ;gBACpC,IAAIqG,KAAKM,IAAI,CAACH,OAAO;oBACnBhF,UAAUoF,OAAOC,YAAY,CAACC,SAASN,MAAM;oBAC7CxG,SAAS;oBACT;gBACF;YACF,OAAO;gBACLwG,OAAOF,IAAII,KAAK,CAAC1G,OAAOA,QAAQ;gBAChC,IAAIoG,KAAKO,IAAI,CAACH,OAAO;oBACnBhF,UAAUoF,OAAOC,YAAY,CAACC,SAASN,MAAM;oBAC7CxG,SAAS;oBACT;gBACF;YACF;QACF;QACAwB,UAAU+E;IACZ;IACA,OAAO/E;AACT"}
|
|
@@ -67,9 +67,13 @@ function yAxisTickFormatterInternal(value, limitWidth = false) {
|
|
|
67
67
|
* @param {IXAxisParams} xAxisParams
|
|
68
68
|
*/ export function createNumericXAxis(xAxisParams, tickParams, chartType, culture, scaleType, _useRtl) {
|
|
69
69
|
const { domainNRangeValues, showRoundOffXTickValues = false, xAxistickSize = 6, tickPadding = 10, xAxisCount, xAxisElement, hideTickOverlap, calcMaxLabelWidth, tickStep, tick0, tickText } = xAxisParams;
|
|
70
|
+
const dStartValue = domainNRangeValues.dStartValue;
|
|
71
|
+
const dEndValue = domainNRangeValues.dEndValue;
|
|
72
|
+
const finalXmin = xAxisParams.xMinValue !== undefined ? Math.min(dStartValue, xAxisParams.xMinValue) : dStartValue;
|
|
73
|
+
const finalXmax = xAxisParams.xMaxValue !== undefined ? Math.max(dEndValue, xAxisParams.xMaxValue) : dEndValue;
|
|
70
74
|
const xAxisScale = createNumericScale(scaleType).domain([
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
finalXmin,
|
|
76
|
+
finalXmax
|
|
73
77
|
]).range([
|
|
74
78
|
domainNRangeValues.rStartValue,
|
|
75
79
|
domainNRangeValues.rEndValue
|
|
@@ -503,7 +507,7 @@ function handleFloatingPointPrecisionError(num) {
|
|
|
503
507
|
}
|
|
504
508
|
return dataPointsArray;
|
|
505
509
|
}
|
|
506
|
-
export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl) {
|
|
510
|
+
export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axisData) {
|
|
507
511
|
const { yMinMaxValues = {
|
|
508
512
|
startValue: 0,
|
|
509
513
|
endValue: 0
|
|
@@ -545,6 +549,9 @@ export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl) {
|
|
|
545
549
|
yAxis.tickValues(customTickValues);
|
|
546
550
|
}
|
|
547
551
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
552
|
+
axisData.yAxisDomainValues = yAxisScale.domain();
|
|
553
|
+
var _yAxis_tickValues;
|
|
554
|
+
axisData.yAxisTickText = ((_yAxis_tickValues = yAxis.tickValues()) !== null && _yAxis_tickValues !== void 0 ? _yAxis_tickValues : yAxisScale.ticks(yAxisTickCount)).map(yAxis.tickFormat());
|
|
548
555
|
return yAxisScale;
|
|
549
556
|
}
|
|
550
557
|
export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDataset, chartType, useSecondaryYScale = false, roundedTicks = false, scaleType, _useRtl) {
|
|
@@ -597,13 +604,8 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
597
604
|
if (customTickValues) {
|
|
598
605
|
yAxis.tickValues(customTickValues);
|
|
599
606
|
axisData.yAxisDomainValues = customTickValues;
|
|
600
|
-
} else {
|
|
601
|
-
|
|
602
|
-
axisData.yAxisDomainValues = yAxisScale.ticks();
|
|
603
|
-
} else {
|
|
604
|
-
yAxis.tickValues(domainValues);
|
|
605
|
-
axisData.yAxisDomainValues = domainValues;
|
|
606
|
-
}
|
|
607
|
+
} else if (scaleType !== 'log') {
|
|
608
|
+
yAxis.tickValues(domainValues);
|
|
607
609
|
}
|
|
608
610
|
const tickFormat = (domainValue, index, defaultFormat)=>{
|
|
609
611
|
if (tickValues && tickText && typeof tickText[index] !== 'undefined') {
|
|
@@ -620,6 +622,9 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
620
622
|
};
|
|
621
623
|
yAxis.tickFormat((v, i)=>tickFormat(v, i, yAxisScale.tickFormat(yAxisTickCount)));
|
|
622
624
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true').style('direction', 'ltr').style('unicode-bidi', 'isolate').style('text-anchor', !useSecondaryYScale && (_useRtl ? 'start' : 'end')) : '';
|
|
625
|
+
axisData.yAxisDomainValues = yAxisScale.domain();
|
|
626
|
+
var _yAxis_tickValues;
|
|
627
|
+
axisData.yAxisTickText = ((_yAxis_tickValues = yAxis.tickValues()) !== null && _yAxis_tickValues !== void 0 ? _yAxis_tickValues : yAxisScale.ticks(yAxisTickCount)).map(yAxis.tickFormat());
|
|
623
628
|
return yAxisScale;
|
|
624
629
|
}
|
|
625
630
|
/**
|
|
@@ -627,7 +632,7 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
627
632
|
* @param yAxisParams
|
|
628
633
|
* @param dataPoints
|
|
629
634
|
* @param isRtl
|
|
630
|
-
*/ export const createStringYAxisForHorizontalBarChartWithAxis = (yAxisParams, dataPoints, isRtl, barWidth)=>{
|
|
635
|
+
*/ export const createStringYAxisForHorizontalBarChartWithAxis = (yAxisParams, dataPoints, isRtl, axisData, barWidth)=>{
|
|
631
636
|
const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement, yAxisPadding, tickValues, tickText } = yAxisParams;
|
|
632
637
|
let yAxisPaddingValue = yAxisPadding !== null && yAxisPadding !== void 0 ? yAxisPadding : 0.5;
|
|
633
638
|
yAxisPaddingValue = yAxisPaddingValue === 1 ? 0.99 : yAxisPaddingValue;
|
|
@@ -648,6 +653,7 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
648
653
|
};
|
|
649
654
|
const yAxis = axis.tickPadding(tickPadding).tickValues(customTickValues).tickFormat(tickFormat);
|
|
650
655
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text') : '';
|
|
656
|
+
axisData.yAxisTickText = yAxis.tickValues().map(yAxis.tickFormat());
|
|
651
657
|
return yAxisScale;
|
|
652
658
|
};
|
|
653
659
|
/**
|
|
@@ -655,7 +661,7 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
655
661
|
* @param yAxisParams
|
|
656
662
|
* @param dataPoints
|
|
657
663
|
* @param isRtl
|
|
658
|
-
*/ export const createStringYAxis = (yAxisParams, dataPoints, isRtl, barWidth, chartType)=>{
|
|
664
|
+
*/ export const createStringYAxis = (yAxisParams, dataPoints, isRtl, axisData, barWidth, chartType)=>{
|
|
659
665
|
const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement, yAxisPadding = 0, containerWidth, tickValues, tickText } = yAxisParams;
|
|
660
666
|
const yAxisScale = d3ScaleBand().domain(dataPoints).range([
|
|
661
667
|
containerHeight - margins.bottom,
|
|
@@ -680,6 +686,7 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
680
686
|
axis.tickSizeInner(-(containerWidth - margins.left - margins.right));
|
|
681
687
|
}
|
|
682
688
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text') : '';
|
|
689
|
+
axisData.yAxisTickText = yAxis.tickValues().map(yAxis.tickFormat());
|
|
683
690
|
return yAxisScale;
|
|
684
691
|
};
|
|
685
692
|
/**
|
|
@@ -705,27 +712,24 @@ export function calloutData(values) {
|
|
|
705
712
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
706
713
|
combinedResult.forEach((ele)=>{
|
|
707
714
|
const xValue = ele.x instanceof Date ? ele.x.getTime() : ele.x;
|
|
715
|
+
const newPoint = {
|
|
716
|
+
legend: ele.legend,
|
|
717
|
+
y: ele.y,
|
|
718
|
+
color: ele.color,
|
|
719
|
+
xAxisCalloutData: ele.xAxisCalloutData,
|
|
720
|
+
yAxisCalloutData: ele.yAxisCalloutData,
|
|
721
|
+
callOutAccessibilityData: ele.callOutAccessibilityData,
|
|
722
|
+
index: ele.index
|
|
723
|
+
};
|
|
708
724
|
if (xValue in xValToDataPoints) {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
yAxisCalloutData: ele.yAxisCalloutData,
|
|
715
|
-
callOutAccessibilityData: ele.callOutAccessibilityData,
|
|
716
|
-
index: ele.index
|
|
717
|
-
});
|
|
725
|
+
// Check if a point with the same legend and y-value already exists
|
|
726
|
+
const existingPoint = xValToDataPoints[xValue].find((p)=>p.legend === newPoint.legend && p.y === newPoint.y);
|
|
727
|
+
if (!existingPoint) {
|
|
728
|
+
xValToDataPoints[xValue].push(newPoint);
|
|
729
|
+
}
|
|
718
730
|
} else {
|
|
719
731
|
xValToDataPoints[xValue] = [
|
|
720
|
-
|
|
721
|
-
legend: ele.legend,
|
|
722
|
-
y: ele.y,
|
|
723
|
-
color: ele.color,
|
|
724
|
-
xAxisCalloutData: ele.xAxisCalloutData,
|
|
725
|
-
yAxisCalloutData: ele.yAxisCalloutData,
|
|
726
|
-
callOutAccessibilityData: ele.callOutAccessibilityData,
|
|
727
|
-
index: ele.index
|
|
728
|
-
}
|
|
732
|
+
newPoint
|
|
729
733
|
];
|
|
730
734
|
}
|
|
731
735
|
});
|
|
@@ -1012,12 +1016,12 @@ export function tooltipOfAxislabels(axistooltipProps) {
|
|
|
1012
1016
|
* @param {number} width
|
|
1013
1017
|
* @param {boolean} isRTL
|
|
1014
1018
|
* @returns {IDomainNRange}
|
|
1015
|
-
*/ export function domainRangeOfNumericForHorizontalBarChartWithAxis(points, margins, containerWidth, isRTL,
|
|
1019
|
+
*/ export function domainRangeOfNumericForHorizontalBarChartWithAxis(points, margins, containerWidth, isRTL, X_ORIGIN) {
|
|
1016
1020
|
const longestBars = computeLongestBars(groupChartDataByYValue(points), X_ORIGIN);
|
|
1017
1021
|
const xMax = longestBars.longestPositiveBar;
|
|
1018
1022
|
const xMin = longestBars.longestNegativeBar;
|
|
1019
|
-
const rMin =
|
|
1020
|
-
const rMax =
|
|
1023
|
+
const rMin = margins.left;
|
|
1024
|
+
const rMax = containerWidth - margins.right;
|
|
1021
1025
|
return isRTL ? {
|
|
1022
1026
|
dStartValue: xMax,
|
|
1023
1027
|
dEndValue: Math.min(xMin, X_ORIGIN),
|
|
@@ -1441,10 +1445,8 @@ export const isScalePaddingDefined = (prop, shorthandProp)=>{
|
|
|
1441
1445
|
return array[index];
|
|
1442
1446
|
}
|
|
1443
1447
|
export const HighContrastSelector = '@media screen and (-ms-high-contrast: active), screen and (forced-colors: active)';
|
|
1444
|
-
export const HighContrastSelectorWhite =
|
|
1445
|
-
'@media screen and (-ms-high-contrast:
|
|
1446
|
-
export const HighContrastSelectorBlack = // eslint-disable-next-line @fluentui/max-len
|
|
1447
|
-
'@media screen and (-ms-high-contrast: white-on-black), screen and (forced-colors: active) and (prefers-color-scheme: dark)';
|
|
1448
|
+
export const HighContrastSelectorWhite = '@media screen and (-ms-high-contrast: black-on-white), screen and (forced-colors: active) and (prefers-color-scheme: light)';
|
|
1449
|
+
export const HighContrastSelectorBlack = '@media screen and (-ms-high-contrast: white-on-black), screen and (forced-colors: active) and (prefers-color-scheme: dark)';
|
|
1448
1450
|
export const formatDate = (date, useUTC)=>{
|
|
1449
1451
|
const timeFormat = useUTC ? d3UtcFormat : d3TimeFormat;
|
|
1450
1452
|
return timeFormat('%-e %b %Y, %H:%M')(date) + (useUTC ? ' GMT' : '');
|