@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
package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { GriffelStyle, makeStyles, mergeClasses } from '@griffel/react';\nimport { VerticalStackedBarChartProps, VerticalStackedBarChartStyles } from './VerticalStackedBarChart.types';\nimport { SlotClassNames } from '@fluentui/react-utilities/src/index';\nimport { getBarLabelStyle, getTooltipStyle } from '../../utilities/index';\n\nexport const verticalstackedbarchartClassNames: SlotClassNames<VerticalStackedBarChartStyles> = {\n opacityChangeOnHover: 'fui-vsbc__opacityChangeOnHover',\n tooltip: 'fui-vsbc__tooltip',\n barLabel: 'fui-vsbc__barLabel',\n root: '',\n xAxis: '',\n yAxis: '',\n legendContainer: '',\n hover: '',\n descriptionMessage: '',\n axisTitle: '',\n chartTitle: '',\n shapeStyles: '',\n chartWrapper: '',\n svgTooltip: '',\n chart: '',\n axisAnnotation: '',\n};\n\nconst useStyles = makeStyles({\n opacityChangeOnHover: {\n cursor: 'default',\n },\n tooltip: getTooltipStyle() as GriffelStyle,\n barLabel: getBarLabelStyle() as GriffelStyle,\n});\n\nexport const useVerticalStackedBarChartStyles = (\n props: VerticalStackedBarChartProps,\n): VerticalStackedBarChartStyles => {\n const baseStyles = useStyles();\n\n return {\n opacityChangeOnHover: mergeClasses(\n verticalstackedbarchartClassNames.opacityChangeOnHover,\n baseStyles.opacityChangeOnHover,\n props.href ? 'pointer' : 'default',\n ),\n tooltip: mergeClasses(verticalstackedbarchartClassNames.tooltip, baseStyles.tooltip),\n barLabel: mergeClasses(verticalstackedbarchartClassNames.barLabel, baseStyles.barLabel),\n };\n};\n"],"names":["makeStyles","mergeClasses","getBarLabelStyle","getTooltipStyle","verticalstackedbarchartClassNames","opacityChangeOnHover","tooltip","barLabel","root","xAxis","yAxis","legendContainer","hover","descriptionMessage","axisTitle","chartTitle","shapeStyles","chartWrapper","svgTooltip","chart","axisAnnotation","useStyles","cursor","useVerticalStackedBarChartStyles","props","baseStyles","href"],"mappings":"AAAA;AAEA,SAAuBA,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAGxE,SAASC,gBAAgB,EAAEC,eAAe,QAAQ,wBAAwB;AAE1E,OAAO,MAAMC,oCAAmF;IAC9FC,sBAAsB;IACtBC,SAAS;IACTC,UAAU;IACVC,MAAM;IACNC,OAAO;IACPC,OAAO;IACPC,iBAAiB;IACjBC,OAAO;IACPC,oBAAoB;IACpBC,WAAW;IACXC,YAAY;IACZC,aAAa;IACbC,cAAc;IACdC,YAAY;IACZC,OAAO;IACPC,gBAAgB;
|
|
1
|
+
{"version":3,"sources":["../src/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.ts"],"sourcesContent":["'use client';\n\nimport { GriffelStyle, makeStyles, mergeClasses } from '@griffel/react';\nimport { VerticalStackedBarChartProps, VerticalStackedBarChartStyles } from './VerticalStackedBarChart.types';\nimport { SlotClassNames } from '@fluentui/react-utilities/src/index';\nimport { getBarLabelStyle, getTooltipStyle } from '../../utilities/index';\n\nexport const verticalstackedbarchartClassNames: SlotClassNames<VerticalStackedBarChartStyles> = {\n opacityChangeOnHover: 'fui-vsbc__opacityChangeOnHover',\n tooltip: 'fui-vsbc__tooltip',\n barLabel: 'fui-vsbc__barLabel',\n root: '',\n xAxis: '',\n yAxis: '',\n legendContainer: '',\n hover: '',\n descriptionMessage: '',\n axisTitle: '',\n chartTitle: '',\n shapeStyles: '',\n chartWrapper: '',\n svgTooltip: '',\n chart: '',\n axisAnnotation: '',\n plotContainer: '',\n annotationLayer: '',\n};\n\nconst useStyles = makeStyles({\n opacityChangeOnHover: {\n cursor: 'default',\n },\n tooltip: getTooltipStyle() as GriffelStyle,\n barLabel: getBarLabelStyle() as GriffelStyle,\n});\n\nexport const useVerticalStackedBarChartStyles = (\n props: VerticalStackedBarChartProps,\n): VerticalStackedBarChartStyles => {\n const baseStyles = useStyles();\n\n return {\n opacityChangeOnHover: mergeClasses(\n verticalstackedbarchartClassNames.opacityChangeOnHover,\n baseStyles.opacityChangeOnHover,\n props.href ? 'pointer' : 'default',\n ),\n tooltip: mergeClasses(verticalstackedbarchartClassNames.tooltip, baseStyles.tooltip),\n barLabel: mergeClasses(verticalstackedbarchartClassNames.barLabel, baseStyles.barLabel),\n };\n};\n"],"names":["makeStyles","mergeClasses","getBarLabelStyle","getTooltipStyle","verticalstackedbarchartClassNames","opacityChangeOnHover","tooltip","barLabel","root","xAxis","yAxis","legendContainer","hover","descriptionMessage","axisTitle","chartTitle","shapeStyles","chartWrapper","svgTooltip","chart","axisAnnotation","plotContainer","annotationLayer","useStyles","cursor","useVerticalStackedBarChartStyles","props","baseStyles","href"],"mappings":"AAAA;AAEA,SAAuBA,UAAU,EAAEC,YAAY,QAAQ,iBAAiB;AAGxE,SAASC,gBAAgB,EAAEC,eAAe,QAAQ,wBAAwB;AAE1E,OAAO,MAAMC,oCAAmF;IAC9FC,sBAAsB;IACtBC,SAAS;IACTC,UAAU;IACVC,MAAM;IACNC,OAAO;IACPC,OAAO;IACPC,iBAAiB;IACjBC,OAAO;IACPC,oBAAoB;IACpBC,WAAW;IACXC,YAAY;IACZC,aAAa;IACbC,cAAc;IACdC,YAAY;IACZC,OAAO;IACPC,gBAAgB;IAChBC,eAAe;IACfC,iBAAiB;AACnB,EAAE;AAEF,MAAMC,YAAYvB,WAAW;IAC3BK,sBAAsB;QACpBmB,QAAQ;IACV;IACAlB,SAASH;IACTI,UAAUL;AACZ;AAEA,OAAO,MAAMuB,mCAAmC,CAC9CC;IAEA,MAAMC,aAAaJ;IAEnB,OAAO;QACLlB,sBAAsBJ,aACpBG,kCAAkCC,oBAAoB,EACtDsB,WAAWtB,oBAAoB,EAC/BqB,MAAME,IAAI,GAAG,YAAY;QAE3BtB,SAASL,aAAaG,kCAAkCE,OAAO,EAAEqB,WAAWrB,OAAO;QACnFC,UAAUN,aAAaG,kCAAkCG,QAAQ,EAAEoB,WAAWpB,QAAQ;IACxF;AACF,EAAE"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './HorizontalBarChart';\nexport * from './DonutChart';\nexport * from './Legends';\nexport * from './LineChart';\nexport * from './VerticalBarChart';\nexport * from './VerticalStackedBarChart';\nexport * from './GroupedVerticalBarChart';\nexport * from './CartesianChart';\nexport * from './types/index';\nexport * from './Sparkline';\nexport * from './ScatterChart';\nexport * from './GaugeChart';\nexport * from './utilities/colors';\nexport * from './Popover';\nexport * from './ResponsiveContainer';\nexport * from './DeclarativeChart';\nexport * from './AreaChart';\nexport * from './HorizontalBarChartWithAxis';\nexport * from './HeatMapChart';\nexport * from './SankeyChart';\nexport * from './FunnelChart';\nexport * from './GanttChart';\nexport * from './ChartTable';\n"],"names":[],"mappings":"AAAA,cAAc,uBAAuB;AACrC,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,qBAAqB;AACnC,cAAc,4BAA4B;AAC1C,cAAc,4BAA4B;AAC1C,cAAc,mBAAmB;AACjC,cAAc,gBAAgB;AAC9B,cAAc,cAAc;AAC5B,cAAc,iBAAiB;AAC/B,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,YAAY;AAC1B,cAAc,wBAAwB;AACtC,cAAc,qBAAqB;AACnC,cAAc,cAAc;AAC5B,cAAc,+BAA+B;AAC7C,cAAc,iBAAiB;AAC/B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,eAAe;AAC7B,cAAc,eAAe"}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './HorizontalBarChart';\nexport * from './DonutChart';\nexport * from './Legends';\nexport * from './LineChart';\nexport * from './VerticalBarChart';\nexport * from './VerticalStackedBarChart';\nexport * from './GroupedVerticalBarChart';\nexport * from './CartesianChart';\nexport * from './types/index';\nexport * from './Sparkline';\nexport * from './ScatterChart';\nexport * from './GaugeChart';\nexport * from './utilities/colors';\nexport * from './Popover';\nexport * from './ResponsiveContainer';\nexport * from './DeclarativeChart';\nexport * from './AreaChart';\nexport * from './HorizontalBarChartWithAxis';\nexport * from './HeatMapChart';\nexport * from './SankeyChart';\nexport * from './FunnelChart';\nexport * from './GanttChart';\nexport * from './ChartTable';\nexport * from './AnnotationOnlyChart';\n"],"names":[],"mappings":"AAAA,cAAc,uBAAuB;AACrC,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,qBAAqB;AACnC,cAAc,4BAA4B;AAC1C,cAAc,4BAA4B;AAC1C,cAAc,mBAAmB;AACjC,cAAc,gBAAgB;AAC9B,cAAc,cAAc;AAC5B,cAAc,iBAAiB;AAC/B,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,YAAY;AAC1B,cAAc,wBAAwB;AACtC,cAAc,qBAAqB;AACnC,cAAc,cAAc;AAC5B,cAAc,+BAA+B;AAC7C,cAAc,iBAAiB;AAC/B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,eAAe;AAC7B,cAAc,eAAe;AAC7B,cAAc,wBAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/ChartAnnotation.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type ChartAnnotationCoordinate = {\n /** Cartesian data coordinates mapped through the chart scales or\n * Normalised coordinates within the plot area (0-1) or\n * Absolute pixel position relative to the chart's SVG origin\n */\n type: 'data' | 'relative' | 'pixel';\n /** x-axis value in the data domain */\n x: number | string | Date;\n /** y-axis value in the data domain */\n y: number | string | Date;\n /** Use the secondary y scale when available */\n yAxis?: 'primary' | 'secondary';\n};\n\nexport type ChartAnnotationHorizontalAlign = 'start' | 'center' | 'end';\nexport type ChartAnnotationVerticalAlign = 'top' | 'middle' | 'bottom';\n\nexport type ChartAnnotationArrowHead = 'none' | 'start' | 'end' | 'both';\n\nexport interface ChartAnnotationConnectorProps {\n /** Distance in pixels between the annotation element and the start of the connector. */\n startPadding?: number;\n /** Distance in pixels between the anchor point and the end of the connector. */\n endPadding?: number;\n /** Stroke colour for the connector. */\n strokeColor?: string;\n /** Stroke width in pixels. */\n strokeWidth?: number;\n /** SVG stroke dash array for dashed connectors. */\n dashArray?: string;\n /** Arrow head placement. Defaults to `'end'`. */\n arrow?: ChartAnnotationArrowHead;\n}\n\nexport interface ChartAnnotationLayoutProps {\n /** Horizontal alignment of the annotation relative to the anchor point */\n align?: ChartAnnotationHorizontalAlign;\n /** Vertical alignment of the annotation relative to the anchor point */\n verticalAlign?: ChartAnnotationVerticalAlign;\n /** Horizontal offset in pixels applied after alignment */\n offsetX?: number;\n /** Vertical offset in pixels applied after alignment */\n offsetY?: number;\n /** Optional maximum width for wrapped text */\n maxWidth?: number;\n /** Whether the annotation should remain inside the plot area */\n clipToBounds?: boolean;\n /** Additional CSS classes applied to the annotation wrapper */\n className?: string;\n}\n\nexport interface ChartAnnotationStyleProps {\n /** Text colour */\n textColor?: string;\n /** Background colour for the annotation container */\n backgroundColor?: string;\n /** Border colour */\n borderColor?: string;\n /** Border width */\n borderWidth?: number;\n /** Border style (solid, dashed, etc.) */\n borderStyle?: React.CSSProperties['borderStyle'];\n /** Border radius */\n borderRadius?: number;\n /** Box shadow applied to annotation */\n boxShadow?: string;\n /** Font size override */\n fontSize?: string;\n /** Font weight override */\n fontWeight?: React.CSSProperties['fontWeight'];\n /** Padding around the text. Accepts CSS shorthand notation */\n padding?: string;\n /** Opacity for the annotation container */\n opacity?: number;\n /** Optional class name applied to the annotation element */\n className?: string;\n /** Rotation, in degrees, applied to the annotation container */\n rotation?: number;\n}\n\nexport interface ChartAnnotationAccessibilityProps {\n /** Accessible label announced by assistive technologies */\n ariaLabel?: string;\n /** Accessible description id */\n ariaDescribedBy?: string;\n /** Custom role */\n role?: string;\n}\n\nexport interface ChartAnnotation {\n /** Optional id for React reconciliation */\n id?: string;\n /** Primary textual content */\n text: string;\n /** Coordinates describing where the annotation should be anchored */\n coordinates: ChartAnnotationCoordinate;\n /** Layout customisation */\n layout?: ChartAnnotationLayoutProps;\n /** Visual styling */\n style?: ChartAnnotationStyleProps;\n /** Optional connector line that links the annotation to its anchor. */\n connector?: ChartAnnotationConnectorProps;\n /** Accessibility metadata */\n accessibility?: ChartAnnotationAccessibilityProps;\n /** Optional application specific metadata */\n data?: Record<string, unknown>;\n}\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
package/lib/types/index.js
CHANGED
package/lib/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types/index.ts"],"sourcesContent":["export * from './DataPoint';\nexport * from './LegendDataItem';\n"],"names":[],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,mBAAmB"}
|
|
1
|
+
{"version":3,"sources":["../src/types/index.ts"],"sourcesContent":["export * from './DataPoint';\nexport * from './LegendDataItem';\nexport * from './ChartAnnotation';\n"],"names":[],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,mBAAmB;AACjC,cAAc,oBAAoB"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { HighContrastSelector } from '../utilities/utilities';
|
|
2
2
|
import { tokens, typographyStyles } from '@fluentui/react-theme';
|
|
3
|
-
import { shorthands } from '@griffel/react';
|
|
4
3
|
export const getTooltipStyle = () => {
|
|
5
4
|
return {
|
|
6
5
|
...typographyStyles.body1,
|
|
7
6
|
display: 'flex',
|
|
8
7
|
flexDirection: 'column',
|
|
9
|
-
|
|
8
|
+
padding: tokens.spacingHorizontalS,
|
|
10
9
|
position: 'absolute',
|
|
11
10
|
textAlign: 'center',
|
|
12
11
|
top: tokens.spacingVerticalNone,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HighContrastSelector","tokens","typographyStyles","
|
|
1
|
+
{"version":3,"names":["HighContrastSelector","tokens","typographyStyles","getTooltipStyle","body1","display","flexDirection","padding","spacingHorizontalS","position","textAlign","top","spacingVerticalNone","backgroundColor","colorNeutralBackground1","borderRadius","borderRadiusSmall","pointerEvents","color","colorNeutralForeground1","getAxisTitleStyle","caption2Strong","fontStyle","colorNeutralForeground2","fill","getBarLabelStyle","caption1Strong","forcedColorAdjust","getMarkerLabelStyle","textAnchor"],"sources":["Common.styles.js"],"sourcesContent":["import { HighContrastSelector } from '../utilities/utilities';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nexport const getTooltipStyle = ()=>{\n return {\n ...typographyStyles.body1,\n display: 'flex',\n flexDirection: 'column',\n padding: tokens.spacingHorizontalS,\n position: 'absolute',\n textAlign: 'center',\n top: tokens.spacingVerticalNone,\n backgroundColor: tokens.colorNeutralBackground1,\n borderRadius: tokens.borderRadiusSmall,\n pointerEvents: 'none',\n color: tokens.colorNeutralForeground1\n };\n};\nexport const getAxisTitleStyle = ()=>{\n return {\n ...typographyStyles.caption2Strong,\n fontStyle: 'normal',\n textAlign: 'center',\n color: tokens.colorNeutralForeground2,\n fill: tokens.colorNeutralForeground1,\n [HighContrastSelector]: {\n fill: 'CanvasText'\n }\n };\n};\nexport const getBarLabelStyle = ()=>{\n return {\n ...typographyStyles.caption1Strong,\n fill: tokens.colorNeutralForeground1,\n forcedColorAdjust: 'auto'\n };\n};\nexport const getMarkerLabelStyle = ()=>{\n return {\n ...typographyStyles.body1,\n fill: tokens.colorNeutralForeground1,\n textAnchor: 'middle',\n [HighContrastSelector]: {\n fill: 'CanvasText'\n }\n };\n};\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,uBAAuB;AAChE,OAAO,MAAMC,eAAe,GAAGA,CAAA,KAAI;EAC/B,OAAO;IACH,GAAGD,gBAAgB,CAACE,KAAK;IACzBC,OAAO,EAAE,MAAM;IACfC,aAAa,EAAE,QAAQ;IACvBC,OAAO,EAAEN,MAAM,CAACO,kBAAkB;IAClCC,QAAQ,EAAE,UAAU;IACpBC,SAAS,EAAE,QAAQ;IACnBC,GAAG,EAAEV,MAAM,CAACW,mBAAmB;IAC/BC,eAAe,EAAEZ,MAAM,CAACa,uBAAuB;IAC/CC,YAAY,EAAEd,MAAM,CAACe,iBAAiB;IACtCC,aAAa,EAAE,MAAM;IACrBC,KAAK,EAAEjB,MAAM,CAACkB;EAClB,CAAC;AACL,CAAC;AACD,OAAO,MAAMC,iBAAiB,GAAGA,CAAA,KAAI;EACjC,OAAO;IACH,GAAGlB,gBAAgB,CAACmB,cAAc;IAClCC,SAAS,EAAE,QAAQ;IACnBZ,SAAS,EAAE,QAAQ;IACnBQ,KAAK,EAAEjB,MAAM,CAACsB,uBAAuB;IACrCC,IAAI,EAAEvB,MAAM,CAACkB,uBAAuB;IACpC,CAACnB,oBAAoB,GAAG;MACpBwB,IAAI,EAAE;IACV;EACJ,CAAC;AACL,CAAC;AACD,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAAI;EAChC,OAAO;IACH,GAAGvB,gBAAgB,CAACwB,cAAc;IAClCF,IAAI,EAAEvB,MAAM,CAACkB,uBAAuB;IACpCQ,iBAAiB,EAAE;EACvB,CAAC;AACL,CAAC;AACD,OAAO,MAAMC,mBAAmB,GAAGA,CAAA,KAAI;EACnC,OAAO;IACH,GAAG1B,gBAAgB,CAACE,KAAK;IACzBoB,IAAI,EAAEvB,MAAM,CAACkB,uBAAuB;IACpCU,UAAU,EAAE,QAAQ;IACpB,CAAC7B,oBAAoB,GAAG;MACpBwB,IAAI,EAAE;IACV;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { HighContrastSelector } from '../utilities/utilities';
|
|
2
2
|
import { tokens, typographyStyles } from '@fluentui/react-theme';
|
|
3
|
-
import { shorthands } from '@griffel/react';
|
|
4
3
|
export const getTooltipStyle = ()=>{
|
|
5
4
|
return {
|
|
6
5
|
...typographyStyles.body1,
|
|
7
6
|
display: 'flex',
|
|
8
7
|
flexDirection: 'column',
|
|
9
|
-
|
|
8
|
+
padding: tokens.spacingHorizontalS,
|
|
10
9
|
position: 'absolute',
|
|
11
10
|
textAlign: 'center',
|
|
12
11
|
top: tokens.spacingVerticalNone,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utilities/Common.styles.ts"],"sourcesContent":["import { HighContrastSelector } from '../utilities/utilities';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/utilities/Common.styles.ts"],"sourcesContent":["import { HighContrastSelector } from '../utilities/utilities';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport { type GriffelStyle } from '@griffel/react';\n\nexport const getTooltipStyle = (): GriffelStyle => {\n return {\n ...typographyStyles.body1,\n display: 'flex',\n flexDirection: 'column',\n padding: tokens.spacingHorizontalS,\n position: 'absolute',\n textAlign: 'center',\n top: tokens.spacingVerticalNone,\n backgroundColor: tokens.colorNeutralBackground1,\n borderRadius: tokens.borderRadiusSmall,\n pointerEvents: 'none',\n color: tokens.colorNeutralForeground1,\n };\n};\n\nexport const getAxisTitleStyle = (): GriffelStyle => {\n return {\n ...typographyStyles.caption2Strong,\n fontStyle: 'normal',\n textAlign: 'center',\n color: tokens.colorNeutralForeground2,\n fill: tokens.colorNeutralForeground1,\n [HighContrastSelector]: {\n fill: 'CanvasText',\n },\n };\n};\n\nexport const getBarLabelStyle = (): GriffelStyle => {\n return {\n ...typographyStyles.caption1Strong, // Confirm styles\n fill: tokens.colorNeutralForeground1,\n forcedColorAdjust: 'auto',\n };\n};\n\nexport const getMarkerLabelStyle = (): GriffelStyle => {\n return {\n ...typographyStyles.body1,\n fill: tokens.colorNeutralForeground1,\n textAnchor: 'middle',\n [HighContrastSelector]: {\n fill: 'CanvasText',\n },\n };\n};\n"],"names":["HighContrastSelector","tokens","typographyStyles","getTooltipStyle","body1","display","flexDirection","padding","spacingHorizontalS","position","textAlign","top","spacingVerticalNone","backgroundColor","colorNeutralBackground1","borderRadius","borderRadiusSmall","pointerEvents","color","colorNeutralForeground1","getAxisTitleStyle","caption2Strong","fontStyle","colorNeutralForeground2","fill","getBarLabelStyle","caption1Strong","forcedColorAdjust","getMarkerLabelStyle","textAnchor"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,wBAAwB;AAGjE,OAAO,MAAMC,kBAAkB;IAC7B,OAAO;QACL,GAAGD,iBAAiBE,KAAK;QACzBC,SAAS;QACTC,eAAe;QACfC,SAASN,OAAOO,kBAAkB;QAClCC,UAAU;QACVC,WAAW;QACXC,KAAKV,OAAOW,mBAAmB;QAC/BC,iBAAiBZ,OAAOa,uBAAuB;QAC/CC,cAAcd,OAAOe,iBAAiB;QACtCC,eAAe;QACfC,OAAOjB,OAAOkB,uBAAuB;IACvC;AACF,EAAE;AAEF,OAAO,MAAMC,oBAAoB;IAC/B,OAAO;QACL,GAAGlB,iBAAiBmB,cAAc;QAClCC,WAAW;QACXZ,WAAW;QACXQ,OAAOjB,OAAOsB,uBAAuB;QACrCC,MAAMvB,OAAOkB,uBAAuB;QACpC,CAACnB,qBAAqB,EAAE;YACtBwB,MAAM;QACR;IACF;AACF,EAAE;AAEF,OAAO,MAAMC,mBAAmB;IAC9B,OAAO;QACL,GAAGvB,iBAAiBwB,cAAc;QAClCF,MAAMvB,OAAOkB,uBAAuB;QACpCQ,mBAAmB;IACrB;AACF,EAAE;AAEF,OAAO,MAAMC,sBAAsB;IACjC,OAAO;QACL,GAAG1B,iBAAiBE,KAAK;QACzBoB,MAAMvB,OAAOkB,uBAAuB;QACpCU,YAAY;QACZ,CAAC7B,qBAAqB,EAAE;YACtBwB,MAAM;QACR;IACF;AACF,EAAE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { create as d3Create, select as d3Select } from 'd3-selection';
|
|
3
|
+
import { isHTMLElement } from '@fluentui/react-utilities';
|
|
3
4
|
import { copyStyle, createMeasurementSpan, resolveCSSVariables } 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
6
|
export function toImage(chartContainer, legendsToSvgCallback, isRTL = false, opts = {}) {
|
|
@@ -53,6 +54,55 @@ const SVG_TEXT_STYLE_PROPERTIES = [
|
|
|
53
54
|
'text-align',
|
|
54
55
|
'border'
|
|
55
56
|
];
|
|
57
|
+
const ANNOTATION_HTML_STYLE_PROPERTIES = [
|
|
58
|
+
'align-items',
|
|
59
|
+
'background',
|
|
60
|
+
'background-color',
|
|
61
|
+
'border',
|
|
62
|
+
'border-radius',
|
|
63
|
+
'box-shadow',
|
|
64
|
+
'box-sizing',
|
|
65
|
+
'color',
|
|
66
|
+
'column-gap',
|
|
67
|
+
'display',
|
|
68
|
+
'flex',
|
|
69
|
+
'flex-direction',
|
|
70
|
+
'font-family',
|
|
71
|
+
'font-size',
|
|
72
|
+
'font-style',
|
|
73
|
+
'font-weight',
|
|
74
|
+
'gap',
|
|
75
|
+
'height',
|
|
76
|
+
'justify-content',
|
|
77
|
+
'letter-spacing',
|
|
78
|
+
'line-height',
|
|
79
|
+
'margin',
|
|
80
|
+
'max-height',
|
|
81
|
+
'max-width',
|
|
82
|
+
'min-height',
|
|
83
|
+
'min-width',
|
|
84
|
+
'opacity',
|
|
85
|
+
'overflow',
|
|
86
|
+
'padding',
|
|
87
|
+
'pointer-events',
|
|
88
|
+
'position',
|
|
89
|
+
'row-gap',
|
|
90
|
+
'text-align',
|
|
91
|
+
'text-decoration',
|
|
92
|
+
'text-transform',
|
|
93
|
+
'top',
|
|
94
|
+
'right',
|
|
95
|
+
'bottom',
|
|
96
|
+
'left',
|
|
97
|
+
'visibility',
|
|
98
|
+
'white-space',
|
|
99
|
+
'width',
|
|
100
|
+
'z-index'
|
|
101
|
+
];
|
|
102
|
+
const ANNOTATION_FOREIGN_OBJECT_STYLE_PROPERTIES = [
|
|
103
|
+
'overflow',
|
|
104
|
+
'pointer-events'
|
|
105
|
+
];
|
|
56
106
|
function toSVG(chartContainer, legendsToSvgCallback, isRTL, background) {
|
|
57
107
|
const svg = chartContainer.querySelector('svg');
|
|
58
108
|
if (!svg) {
|
|
@@ -87,6 +137,27 @@ function toSVG(chartContainer, legendsToSvgCallback, isRTL, background) {
|
|
|
87
137
|
svgElements = null;
|
|
88
138
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
139
|
clonedSvgElements = null;
|
|
140
|
+
const originalForeignObjects = svg.querySelectorAll('foreignObject');
|
|
141
|
+
const clonedForeignObjects = clonedSvg.node().querySelectorAll('foreignObject');
|
|
142
|
+
originalForeignObjects.forEach((originalFo, index)=>{
|
|
143
|
+
const clonedFo = clonedForeignObjects[index];
|
|
144
|
+
if (!clonedFo) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const originalRoot = originalFo.firstElementChild;
|
|
148
|
+
const clonedRoot = clonedFo.firstElementChild;
|
|
149
|
+
if (originalRoot && clonedRoot) {
|
|
150
|
+
copyStyle(ANNOTATION_HTML_STYLE_PROPERTIES, originalRoot, clonedRoot);
|
|
151
|
+
}
|
|
152
|
+
const originalHtmlElements = originalFo.querySelectorAll('*');
|
|
153
|
+
const clonedHtmlElements = clonedFo.querySelectorAll('*');
|
|
154
|
+
originalHtmlElements.forEach((originalEl, elementIndex)=>{
|
|
155
|
+
const clonedEl = clonedHtmlElements[elementIndex];
|
|
156
|
+
if (clonedEl) {
|
|
157
|
+
copyStyle(ANNOTATION_HTML_STYLE_PROPERTIES, originalEl, clonedEl);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
});
|
|
90
161
|
const { width: svgWidth, height: svgHeight } = svg.getBoundingClientRect();
|
|
91
162
|
const legendGroup = typeof legendsToSvgCallback === 'function' ? legendsToSvgCallback(svgWidth, isRTL) : {
|
|
92
163
|
node: null,
|
|
@@ -95,12 +166,49 @@ function toSVG(chartContainer, legendsToSvgCallback, isRTL, background) {
|
|
|
95
166
|
};
|
|
96
167
|
const w1 = Math.max(svgWidth, legendGroup.width);
|
|
97
168
|
const h1 = svgHeight + legendGroup.height;
|
|
169
|
+
const annotationSvg = chartContainer.querySelector('[data-chart-annotation-svg="true"]');
|
|
170
|
+
let annotationClone = null;
|
|
171
|
+
if (annotationSvg) {
|
|
172
|
+
annotationClone = annotationSvg.cloneNode(true);
|
|
173
|
+
copyStyle(SVG_STYLE_PROPERTIES, annotationSvg, annotationClone);
|
|
174
|
+
const annotationElements = annotationSvg.getElementsByTagName('*');
|
|
175
|
+
const clonedAnnotationElements = annotationClone.getElementsByTagName('*');
|
|
176
|
+
for(let i = 0; i < annotationElements.length; i++){
|
|
177
|
+
const original = annotationElements[i];
|
|
178
|
+
const cloned = clonedAnnotationElements[i];
|
|
179
|
+
const tag = original.tagName.toLowerCase();
|
|
180
|
+
const isSvgElement = original instanceof SVGElement;
|
|
181
|
+
const isTextElement = tag === 'text';
|
|
182
|
+
const isHtmlElement = isHTMLElement(original);
|
|
183
|
+
if (isSvgElement) {
|
|
184
|
+
if (isTextElement) {
|
|
185
|
+
copyStyle([
|
|
186
|
+
...SVG_STYLE_PROPERTIES,
|
|
187
|
+
...SVG_TEXT_STYLE_PROPERTIES
|
|
188
|
+
], original, cloned);
|
|
189
|
+
} else {
|
|
190
|
+
copyStyle(SVG_STYLE_PROPERTIES, original, cloned);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (isHtmlElement) {
|
|
194
|
+
copyStyle(ANNOTATION_HTML_STYLE_PROPERTIES, original, cloned);
|
|
195
|
+
}
|
|
196
|
+
if (tag === 'foreignobject') {
|
|
197
|
+
copyStyle(ANNOTATION_FOREIGN_OBJECT_STYLE_PROPERTIES, original, cloned);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
98
201
|
if (legendGroup.node) {
|
|
99
202
|
d3Select(legendGroup.node).attr('transform', `translate(0, ${svgHeight})`);
|
|
100
203
|
clonedSvg.append(()=>legendGroup.node);
|
|
101
204
|
}
|
|
102
205
|
clonedSvg.insert('rect', ':first-child').attr('x', 0).attr('y', 0).attr('width', w1).attr('height', h1).attr('fill', background);
|
|
103
206
|
clonedSvg.attr('width', w1).attr('height', h1).attr('viewBox', `0 0 ${w1} ${h1}`).attr('direction', isRTL ? 'rtl' : 'ltr');
|
|
207
|
+
if (annotationClone) {
|
|
208
|
+
clonedSvg.selectAll('[data-chart-annotation-layer="true"]').remove();
|
|
209
|
+
d3Select(annotationClone).attr('x', 0).attr('y', 0).attr('width', svgWidth).attr('height', svgHeight);
|
|
210
|
+
clonedSvg.append(()=>annotationClone);
|
|
211
|
+
}
|
|
104
212
|
const result = {
|
|
105
213
|
node: clonedSvg.node(),
|
|
106
214
|
width: w1,
|
|
@@ -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,MAAM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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, 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\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 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 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 { 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 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 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 if (annotationClone) {\n clonedSvg.selectAll('[data-chart-annotation-layer=\"true\"]').remove();\n d3Select(annotationClone).attr('x', 0).attr('y', 0).attr('width', svgWidth).attr('height', svgHeight);\n clonedSvg.append(() => annotationClone as SVGSVGElement);\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","isHTMLElement","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","ANNOTATION_HTML_STYLE_PROPERTIES","ANNOTATION_FOREIGN_OBJECT_STYLE_PROPERTIES","querySelector","clonedSvg","cloneNode","attr","svgElements","getElementsByTagName","clonedSvgElements","TEXT_ELEMENTS","TABLE_ELEMENTS","i","length","tag","tagName","toLowerCase","includes","originalForeignObjects","querySelectorAll","clonedForeignObjects","forEach","originalFo","index","clonedFo","originalRoot","firstElementChild","clonedRoot","originalHtmlElements","clonedHtmlElements","originalEl","elementIndex","clonedEl","svgWidth","svgHeight","getBoundingClientRect","legendGroup","w1","Math","max","h1","annotationSvg","annotationClone","annotationElements","clonedAnnotationElements","original","cloned","isSvgElement","SVGElement","isTextElement","isHtmlElement","append","insert","selectAll","remove","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","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","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,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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OW,SAAS,CAAC;YACjChI,QAAQ+H;QACV;QAEAP,IAAIS,OAAO,GAAG,SAAU7G,GAAG;YACzBnB,OAAOmB;QACT;QAEAoG,IAAIU,GAAG,GAAGxH;IACZ;AACF;AAEA,MAAMyH,OAAO;AACb,MAAMC,OAAO;AAEb;;;;CAIC,GACD,SAASxH,iBAAiByH,GAAW;IACnC,IAAIxD,SAAS;IACb,MAAM1C,SAASkG,IAAIlG,MAAM;IACzB,IAAIU,QAAQ;IACZ,IAAIyF;IACJ,IAAIC;IACJ,MAAO1F,QAAQV,OAAQ;QACrBmG,MAAMD,IAAIG,MAAM,CAAC3F;QACjB,IAAIyF,QAAQ,KAAK;YACf,IAAID,IAAIG,MAAM,CAAC3F,WAAW,KAAK;gBAC7B0F,OAAOF,IAAII,KAAK,CAAC5F,QAAQ,GAAGA,QAAQ;gBACpC,IAAIuF,KAAKM,IAAI,CAACH,OAAO;oBACnB1D,UAAU8D,OAAOC,YAAY,CAACC,SAASN,MAAM;oBAC7C1F,SAAS;oBACT;gBACF;YACF,OAAO;gBACL0F,OAAOF,IAAII,KAAK,CAAC5F,OAAOA,QAAQ;gBAChC,IAAIsF,KAAKO,IAAI,CAACH,OAAO;oBACnB1D,UAAU8D,OAAOC,YAAY,CAACC,SAASN,MAAM;oBAC7C1F,SAAS;oBACT;gBACF;YACF;QACF;QACAgC,UAAUyD;IACZ;IACA,OAAOzD;AACT"}
|
|
@@ -503,7 +503,7 @@ function handleFloatingPointPrecisionError(num) {
|
|
|
503
503
|
}
|
|
504
504
|
return dataPointsArray;
|
|
505
505
|
}
|
|
506
|
-
export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl) {
|
|
506
|
+
export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axisData) {
|
|
507
507
|
const { yMinMaxValues = {
|
|
508
508
|
startValue: 0,
|
|
509
509
|
endValue: 0
|
|
@@ -545,6 +545,9 @@ export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl) {
|
|
|
545
545
|
yAxis.tickValues(customTickValues);
|
|
546
546
|
}
|
|
547
547
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
|
|
548
|
+
axisData.yAxisDomainValues = yAxisScale.domain();
|
|
549
|
+
var _yAxis_tickValues;
|
|
550
|
+
axisData.yAxisTickText = ((_yAxis_tickValues = yAxis.tickValues()) !== null && _yAxis_tickValues !== void 0 ? _yAxis_tickValues : yAxisScale.ticks(yAxisTickCount)).map(yAxis.tickFormat());
|
|
548
551
|
return yAxisScale;
|
|
549
552
|
}
|
|
550
553
|
export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDataset, chartType, useSecondaryYScale = false, roundedTicks = false, scaleType, _useRtl) {
|
|
@@ -597,13 +600,8 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
597
600
|
if (customTickValues) {
|
|
598
601
|
yAxis.tickValues(customTickValues);
|
|
599
602
|
axisData.yAxisDomainValues = customTickValues;
|
|
600
|
-
} else {
|
|
601
|
-
|
|
602
|
-
axisData.yAxisDomainValues = yAxisScale.ticks();
|
|
603
|
-
} else {
|
|
604
|
-
yAxis.tickValues(domainValues);
|
|
605
|
-
axisData.yAxisDomainValues = domainValues;
|
|
606
|
-
}
|
|
603
|
+
} else if (scaleType !== 'log') {
|
|
604
|
+
yAxis.tickValues(domainValues);
|
|
607
605
|
}
|
|
608
606
|
const tickFormat = (domainValue, index, defaultFormat)=>{
|
|
609
607
|
if (tickValues && tickText && typeof tickText[index] !== 'undefined') {
|
|
@@ -620,6 +618,9 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
620
618
|
};
|
|
621
619
|
yAxis.tickFormat((v, i)=>tickFormat(v, i, yAxisScale.tickFormat(yAxisTickCount)));
|
|
622
620
|
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')) : '';
|
|
621
|
+
axisData.yAxisDomainValues = yAxisScale.domain();
|
|
622
|
+
var _yAxis_tickValues;
|
|
623
|
+
axisData.yAxisTickText = ((_yAxis_tickValues = yAxis.tickValues()) !== null && _yAxis_tickValues !== void 0 ? _yAxis_tickValues : yAxisScale.ticks(yAxisTickCount)).map(yAxis.tickFormat());
|
|
623
624
|
return yAxisScale;
|
|
624
625
|
}
|
|
625
626
|
/**
|
|
@@ -627,7 +628,7 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
627
628
|
* @param yAxisParams
|
|
628
629
|
* @param dataPoints
|
|
629
630
|
* @param isRtl
|
|
630
|
-
*/ export const createStringYAxisForHorizontalBarChartWithAxis = (yAxisParams, dataPoints, isRtl, barWidth)=>{
|
|
631
|
+
*/ export const createStringYAxisForHorizontalBarChartWithAxis = (yAxisParams, dataPoints, isRtl, axisData, barWidth)=>{
|
|
631
632
|
const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement, yAxisPadding, tickValues, tickText } = yAxisParams;
|
|
632
633
|
let yAxisPaddingValue = yAxisPadding !== null && yAxisPadding !== void 0 ? yAxisPadding : 0.5;
|
|
633
634
|
yAxisPaddingValue = yAxisPaddingValue === 1 ? 0.99 : yAxisPaddingValue;
|
|
@@ -648,6 +649,7 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
648
649
|
};
|
|
649
650
|
const yAxis = axis.tickPadding(tickPadding).tickValues(customTickValues).tickFormat(tickFormat);
|
|
650
651
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text') : '';
|
|
652
|
+
axisData.yAxisTickText = yAxis.tickValues().map(yAxis.tickFormat());
|
|
651
653
|
return yAxisScale;
|
|
652
654
|
};
|
|
653
655
|
/**
|
|
@@ -655,7 +657,7 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
655
657
|
* @param yAxisParams
|
|
656
658
|
* @param dataPoints
|
|
657
659
|
* @param isRtl
|
|
658
|
-
*/ export const createStringYAxis = (yAxisParams, dataPoints, isRtl, barWidth, chartType)=>{
|
|
660
|
+
*/ export const createStringYAxis = (yAxisParams, dataPoints, isRtl, axisData, barWidth, chartType)=>{
|
|
659
661
|
const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement, yAxisPadding = 0, containerWidth, tickValues, tickText } = yAxisParams;
|
|
660
662
|
const yAxisScale = d3ScaleBand().domain(dataPoints).range([
|
|
661
663
|
containerHeight - margins.bottom,
|
|
@@ -680,6 +682,7 @@ export function createNumericYAxis(yAxisParams, isRtl, axisData, isIntegralDatas
|
|
|
680
682
|
axis.tickSizeInner(-(containerWidth - margins.left - margins.right));
|
|
681
683
|
}
|
|
682
684
|
yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text') : '';
|
|
685
|
+
axisData.yAxisTickText = yAxis.tickValues().map(yAxis.tickFormat());
|
|
683
686
|
return yAxisScale;
|
|
684
687
|
};
|
|
685
688
|
/**
|
|
@@ -1012,12 +1015,12 @@ export function tooltipOfAxislabels(axistooltipProps) {
|
|
|
1012
1015
|
* @param {number} width
|
|
1013
1016
|
* @param {boolean} isRTL
|
|
1014
1017
|
* @returns {IDomainNRange}
|
|
1015
|
-
*/ export function domainRangeOfNumericForHorizontalBarChartWithAxis(points, margins, containerWidth, isRTL,
|
|
1018
|
+
*/ export function domainRangeOfNumericForHorizontalBarChartWithAxis(points, margins, containerWidth, isRTL, X_ORIGIN) {
|
|
1016
1019
|
const longestBars = computeLongestBars(groupChartDataByYValue(points), X_ORIGIN);
|
|
1017
1020
|
const xMax = longestBars.longestPositiveBar;
|
|
1018
1021
|
const xMin = longestBars.longestNegativeBar;
|
|
1019
|
-
const rMin =
|
|
1020
|
-
const rMax =
|
|
1022
|
+
const rMin = margins.left;
|
|
1023
|
+
const rMax = containerWidth - margins.right;
|
|
1021
1024
|
return isRTL ? {
|
|
1022
1025
|
dStartValue: xMax,
|
|
1023
1026
|
dEndValue: Math.min(xMin, X_ORIGIN),
|