@fluentui/react-charts 9.2.3 → 9.3.0
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 +79 -10
- package/dist/index.d.ts +98 -5
- package/lib/components/AreaChart/AreaChart.js +8 -6
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +4 -2
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +4 -15
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +95 -8
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.js +5 -3
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +3 -2
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +45 -42
- 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 +14 -5
- package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +19 -14
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +7 -33
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +5 -3
- 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 +56 -16
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +19 -0
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +1096 -337
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/imageExporter.js +1 -0
- package/lib/components/DeclarativeChart/imageExporter.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.js +8 -8
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.types.js.map +1 -1
- package/lib/components/DonutChart/Arc/useArcStyles.styles.js +9 -2
- package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js +6 -1
- package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +61 -25
- 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 +1 -0
- package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib/components/DonutChart/Pie/Pie.types.js.map +1 -1
- package/lib/components/DonutChart/Pie/usePieStyles.styles.js +2 -0
- package/lib/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/Pie/usePieStyles.styles.raw.js +1 -0
- package/lib/components/DonutChart/Pie/usePieStyles.styles.raw.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.js +23 -4
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +9 -4
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js +11 -5
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js +2 -0
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js +1 -0
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.js +1 -0
- package/lib/components/GanttChart/GanttChart.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +2 -2
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +2 -0
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js +1 -0
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +15 -9
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +6 -17
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +5 -21
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +2 -1
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -0
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +1 -0
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js +3 -3
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +8 -2
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +5 -1
- 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/useHorizontalBarChartWithAxisStyles.styles.js +2 -0
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +1 -0
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib/components/Legends/Legends.js +1 -0
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/Legends/OverflowMenu.js +1 -0
- package/lib/components/Legends/OverflowMenu.js.map +1 -1
- package/lib/components/Legends/shape.js +1 -0
- package/lib/components/Legends/shape.js.map +1 -1
- package/lib/components/Legends/useLegendsStyles.styles.js +2 -0
- package/lib/components/Legends/useLegendsStyles.styles.js.map +1 -1
- package/lib/components/Legends/useLegendsStyles.styles.raw.js +1 -0
- package/lib/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +284 -281
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.js.map +1 -1
- package/lib/components/LineChart/eventAnnotation/LabelLink.js +1 -0
- package/lib/components/LineChart/eventAnnotation/LabelLink.js.map +1 -1
- package/lib/components/LineChart/eventAnnotation/Textbox.js +1 -0
- package/lib/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +25 -10
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js +5 -21
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ResponsiveContainer/ResponsiveContainer.js +1 -0
- package/lib/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
- package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.js +2 -0
- package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.js.map +1 -1
- package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js +1 -0
- package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js.map +1 -1
- package/lib/components/ResponsiveContainer/withResponsiveContainer.js +1 -0
- package/lib/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.js +1 -0
- package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +14 -25
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +3 -12
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +121 -81
- 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 -7
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +5 -22
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/Sparkline/Sparkline.js +1 -0
- package/lib/components/Sparkline/Sparkline.js.map +1 -1
- package/lib/components/Sparkline/useSparklineStyles.styles.js +2 -0
- package/lib/components/Sparkline/useSparklineStyles.styles.js.map +1 -1
- package/lib/components/Sparkline/useSparklineStyles.styles.raw.js +1 -0
- package/lib/components/Sparkline/useSparklineStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +17 -12
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +10 -6
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +6 -19
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +30 -25
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +9 -6
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +5 -19
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib/types/DataPoint.js +3 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/Common.styles.js +47 -0
- package/lib/utilities/Common.styles.js.map +1 -0
- package/lib/utilities/Common.styles.raw.js +47 -0
- package/lib/utilities/Common.styles.raw.js.map +1 -0
- package/lib/utilities/FocusableTooltipText.js +1 -0
- package/lib/utilities/FocusableTooltipText.js.map +1 -1
- package/lib/utilities/SVGTooltipText.js +1 -0
- package/lib/utilities/SVGTooltipText.js.map +1 -1
- package/lib/utilities/image-export-utils.js +1 -0
- package/lib/utilities/image-export-utils.js.map +1 -1
- package/lib/utilities/index.js +1 -0
- package/lib/utilities/index.js.map +1 -1
- package/lib/utilities/scatterpolar-utils.js +52 -0
- package/lib/utilities/scatterpolar-utils.js.map +1 -0
- package/lib/utilities/utilities.js +314 -146
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +7 -5
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +1 -0
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -14
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +95 -8
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +4 -3
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +3 -2
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +45 -42
- 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 +14 -5
- package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +16 -13
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +5 -32
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +4 -3
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +3 -2
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +60 -20
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +22 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +1109 -338
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/imageExporter.js +1 -0
- package/lib-commonjs/components/DeclarativeChart/imageExporter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js +8 -8
- package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +11 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js +6 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +61 -25
- 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 +2 -1
- package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/Pie.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js +1 -0
- package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.raw.js +1 -0
- package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +33 -4
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +9 -4
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js +11 -5
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js +1 -0
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js +1 -0
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.js +1 -0
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +2 -2
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +1 -0
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js +1 -0
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +15 -9
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +3 -19
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +4 -20
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +2 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +1 -0
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +1 -0
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js +3 -3
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +10 -2
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +5 -1
- 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/useHorizontalBarChartWithAxisStyles.styles.js +1 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +1 -0
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js +1 -0
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/Legends/OverflowMenu.js +1 -0
- package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
- package/lib-commonjs/components/Legends/shape.js +1 -0
- package/lib-commonjs/components/Legends/shape.js.map +1 -1
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.js +1 -0
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -1
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js +1 -0
- package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +282 -279
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js +1 -0
- package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js.map +1 -1
- package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js +1 -0
- package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +31 -9
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +3 -20
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js +1 -0
- package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.js +1 -0
- package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js +1 -0
- package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js +2 -1
- package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.js +1 -0
- package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +24 -33
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -12
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +118 -78
- 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 +14 -7
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +3 -20
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/Sparkline/Sparkline.js +1 -0
- package/lib-commonjs/components/Sparkline/Sparkline.js.map +1 -1
- package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js +1 -0
- package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js.map +1 -1
- package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.raw.js +1 -0
- package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +16 -11
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +6 -3
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +4 -17
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +29 -24
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +6 -3
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +4 -18
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js +3 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.js +71 -0
- package/lib-commonjs/utilities/Common.styles.js.map +1 -0
- package/lib-commonjs/utilities/Common.styles.raw.js +71 -0
- package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -0
- package/lib-commonjs/utilities/FocusableTooltipText.js +2 -1
- package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/SVGTooltipText.js +1 -0
- package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
- package/lib-commonjs/utilities/image-export-utils.js +1 -0
- package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
- package/lib-commonjs/utilities/index.js +1 -0
- package/lib-commonjs/utilities/index.js.map +1 -1
- package/lib-commonjs/utilities/scatterpolar-utils.js +67 -0
- package/lib-commonjs/utilities/scatterpolar-utils.js.map +1 -0
- package/lib-commonjs/utilities/utilities.js +327 -137
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
- package/package.json +10 -10
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
/* eslint-disable one-var */ /* eslint-disable vars-on-top */ /* eslint-disable no-var */ import * as React from 'react';
|
|
2
3
|
import { bin as d3Bin, extent as d3Extent, sum as d3Sum, min as d3Min, max as d3Max, range as d3Range } from 'd3-array';
|
|
3
4
|
import { scaleLinear as d3ScaleLinear } from 'd3-scale';
|
|
4
5
|
import { format as d3Format } from 'd3-format';
|
|
5
6
|
import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
|
|
6
|
-
import { findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS } from '../../utilities/utilities';
|
|
7
|
-
import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue } from '@fluentui/chart-utilities';
|
|
7
|
+
import { DEFAULT_DATE_STRING, findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS, calculatePrecision, precisionRound } from '../../utilities/utilities';
|
|
8
|
+
import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, formatToLocaleString, isNumber, isObjectArray, getAxisIds, getAxisKey } from '@fluentui/chart-utilities';
|
|
8
9
|
import { curveCardinal as d3CurveCardinal } from 'd3-shape';
|
|
9
|
-
import { getOpacity, extractColor, resolveColor } from './PlotlyColorAdapter';
|
|
10
|
+
import { getOpacity, extractColor, resolveColor, createColorScale } from './PlotlyColorAdapter';
|
|
10
11
|
import { rgb } from 'd3-color';
|
|
12
|
+
export const NON_PLOT_KEY_PREFIX = 'nonplot_';
|
|
13
|
+
export const SINGLE_REPEAT = 'repeat(1, 1fr)';
|
|
11
14
|
const dashOptions = {
|
|
12
15
|
dot: {
|
|
13
16
|
strokeDasharray: '1, 5',
|
|
@@ -56,6 +59,47 @@ function getTitles(layout) {
|
|
|
56
59
|
};
|
|
57
60
|
return titles;
|
|
58
61
|
}
|
|
62
|
+
const getXAxisTickFormat = (series, layout)=>{
|
|
63
|
+
const xAxis = getXAxisProperties(series, layout);
|
|
64
|
+
if (xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat) {
|
|
65
|
+
return {
|
|
66
|
+
tickFormat: xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {};
|
|
70
|
+
};
|
|
71
|
+
const getYAxisTickFormat = (series, layout)=>{
|
|
72
|
+
const yAxis = getYAxisProperties(series, layout);
|
|
73
|
+
if (yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat) {
|
|
74
|
+
return {
|
|
75
|
+
yAxisTickFormat: d3Format(yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return {};
|
|
79
|
+
};
|
|
80
|
+
const getYMinMaxValues = (series, layout)=>{
|
|
81
|
+
var _getYAxisProperties;
|
|
82
|
+
const range = (_getYAxisProperties = getYAxisProperties(series, layout)) === null || _getYAxisProperties === void 0 ? void 0 : _getYAxisProperties.range;
|
|
83
|
+
if (range && range.length === 2) {
|
|
84
|
+
return {
|
|
85
|
+
yMinValue: range[0],
|
|
86
|
+
yMaxValue: range[1]
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return {};
|
|
90
|
+
};
|
|
91
|
+
const getYAxisProperties = (series, layout)=>{
|
|
92
|
+
return layout === null || layout === void 0 ? void 0 : layout.yaxis;
|
|
93
|
+
};
|
|
94
|
+
const getXAxisProperties = (series, layout)=>{
|
|
95
|
+
return layout === null || layout === void 0 ? void 0 : layout.xaxis;
|
|
96
|
+
};
|
|
97
|
+
const getFormattedCalloutYData = (yVal, yAxisFormat)=>{
|
|
98
|
+
if (typeof (yAxisFormat === null || yAxisFormat === void 0 ? void 0 : yAxisFormat.yAxisTickFormat) === 'function' && typeof yVal === 'number') {
|
|
99
|
+
return yAxisFormat.yAxisTickFormat(yVal);
|
|
100
|
+
}
|
|
101
|
+
return formatToLocaleString(yVal);
|
|
102
|
+
};
|
|
59
103
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
104
|
export const correctYearMonth = (xValues)=>{
|
|
61
105
|
const presentYear = new Date().getFullYear();
|
|
@@ -155,8 +199,122 @@ export const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNum
|
|
|
155
199
|
}
|
|
156
200
|
return x;
|
|
157
201
|
};
|
|
202
|
+
/**
|
|
203
|
+
* Checks if a key should be ignored during normalization
|
|
204
|
+
* @param key The key to check
|
|
205
|
+
* @returns true if the key should be ignored
|
|
206
|
+
*/ const shouldIgnoreKey = (key)=>{
|
|
207
|
+
const lowerKey = key.toLowerCase();
|
|
208
|
+
if (lowerKey.includes('style') || lowerKey === 'style') {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
// Use regex to match common CSS property patterns
|
|
212
|
+
// (color, fill, stroke, border, background, font, shadow, outline, etc.)
|
|
213
|
+
const cssKeyRegex = new RegExp('^(color|fill|stroke|border|background|font|shadow|outline|margin|padding|gap|align|justify|display|flex|grid|' + 'text|line|letter|word|vertical|horizontal|overflow|position|top|right|bottom|left|zindex|z-index|opacity|' + 'filter|clip|cursor|resize|transition|animation|transform|box|column|row|direction|visibility|' + 'content|width|height|aspect|image|user|pointer|caret|scroll|%)|(-webkit-|-moz-|-ms-|-o-)', 'i');
|
|
214
|
+
if (cssKeyRegex.test(lowerKey)) {
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
return false;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Flattens a nested object into a single level object with dot notation keys
|
|
221
|
+
* @param obj Object to flatten
|
|
222
|
+
* @param prefix Optional prefix for keys
|
|
223
|
+
* @returns Flattened object
|
|
224
|
+
*/ const flattenObject = (obj, prefix = '')=>{
|
|
225
|
+
const flattened = {};
|
|
226
|
+
for(const key in obj){
|
|
227
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
228
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
229
|
+
const value = obj[key];
|
|
230
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof Date)) {
|
|
231
|
+
// Recursively flatten nested objects
|
|
232
|
+
Object.assign(flattened, flattenObject(value, newKey));
|
|
233
|
+
} else {
|
|
234
|
+
flattened[newKey] = value;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return flattened;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Normalizes an array of objects by flattening nested structures and creating grouped data
|
|
242
|
+
* Uses json_normalize approach with D3 color detection and filtering
|
|
243
|
+
* @param data Array of objects to normalize
|
|
244
|
+
* @returns Object containing traces for grouped vertical bar chart
|
|
245
|
+
*/ export const normalizeObjectArrayForGVBC = (data, xLabels)=>{
|
|
246
|
+
if (!data || data.length === 0) {
|
|
247
|
+
return {
|
|
248
|
+
traces: [],
|
|
249
|
+
x: []
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
// Use provided xLabels if available, otherwise default to Item 1, Item 2, ...
|
|
253
|
+
const x = xLabels && xLabels.length === data.length ? xLabels : data.map((_, index)=>`Item ${index + 1}`);
|
|
254
|
+
// First, flatten all objects and collect all unique keys, excluding style keys
|
|
255
|
+
const flattenedObjects = data.map((item, index)=>{
|
|
256
|
+
if (typeof item === 'object' && item !== null) {
|
|
257
|
+
const flattened = flattenObject(item);
|
|
258
|
+
// Only keep keys where the value is numeric (number or numeric string) and not a style key
|
|
259
|
+
const filtered = {};
|
|
260
|
+
Object.keys(flattened).forEach((key)=>{
|
|
261
|
+
const value = flattened[key];
|
|
262
|
+
if (!shouldIgnoreKey(key) && (typeof value === 'number' || typeof value === 'string' && isNumber(value))) {
|
|
263
|
+
filtered[key] = value;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
return filtered;
|
|
267
|
+
} else if (typeof item === 'number' || typeof item === 'string' && isNumber(item)) {
|
|
268
|
+
// Only keep primitive numeric values
|
|
269
|
+
return {
|
|
270
|
+
[x[index] || `item_${index}`]: item
|
|
271
|
+
};
|
|
272
|
+
} else {
|
|
273
|
+
// Non-numeric primitive, ignore by returning empty object
|
|
274
|
+
return {};
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
// Collect all unique keys across all objects
|
|
278
|
+
const allKeys = new Set();
|
|
279
|
+
flattenedObjects.forEach((obj)=>{
|
|
280
|
+
Object.keys(obj).forEach((key)=>allKeys.add(key));
|
|
281
|
+
});
|
|
282
|
+
// Create traces for each key (property)
|
|
283
|
+
const traces = [];
|
|
284
|
+
allKeys.forEach((key)=>{
|
|
285
|
+
const yValues = [];
|
|
286
|
+
let hasValidData = false;
|
|
287
|
+
let isNumericData = false;
|
|
288
|
+
flattenedObjects.forEach((obj, index)=>{
|
|
289
|
+
const value = obj[key];
|
|
290
|
+
if (typeof value === 'number') {
|
|
291
|
+
yValues.push(value);
|
|
292
|
+
hasValidData = true;
|
|
293
|
+
isNumericData = true;
|
|
294
|
+
} else if (typeof value === 'string' && isNumber(value)) {
|
|
295
|
+
yValues.push(parseFloat(value));
|
|
296
|
+
hasValidData = true;
|
|
297
|
+
isNumericData = true;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
// Only create trace if we have valid numeric data
|
|
301
|
+
if (hasValidData && isNumericData) {
|
|
302
|
+
const trace = {
|
|
303
|
+
type: 'bar',
|
|
304
|
+
name: key,
|
|
305
|
+
x,
|
|
306
|
+
y: yValues
|
|
307
|
+
};
|
|
308
|
+
traces.push(trace);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
return {
|
|
312
|
+
traces,
|
|
313
|
+
x
|
|
314
|
+
};
|
|
315
|
+
};
|
|
158
316
|
export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
159
|
-
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _firstData_marker,
|
|
317
|
+
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _firstData_marker, _input_layout3, _input_layout4, _input_layout5, _input_layout6;
|
|
160
318
|
const firstData = input.data[0];
|
|
161
319
|
var _input_layout_piecolorway, _input_layout_piecolorway1;
|
|
162
320
|
// extract colors for each series only once
|
|
@@ -164,24 +322,53 @@ export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, co
|
|
|
164
322
|
// otherwise, default to colorway from template
|
|
165
323
|
const colors = extractColor((_input_layout_piecolorway = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.piecolorway) !== null && _input_layout_piecolorway !== void 0 ? _input_layout_piecolorway : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_input_layout_piecolorway1 = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.piecolorway) !== null && _input_layout_piecolorway1 !== void 0 ? _input_layout_piecolorway1 : firstData === null || firstData === void 0 ? void 0 : (_firstData_marker = firstData.marker) === null || _firstData_marker === void 0 ? void 0 : _firstData_marker.colors, colorMap, isDarkTheme);
|
|
166
324
|
const mapLegendToDataPoint = {};
|
|
167
|
-
(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
325
|
+
if (colors) {
|
|
326
|
+
var _firstData_labels;
|
|
327
|
+
(_firstData_labels = firstData.labels) === null || _firstData_labels === void 0 ? void 0 : _firstData_labels.forEach((label, index)=>{
|
|
328
|
+
const value = getNumberAtIndexOrDefault(firstData.values, index);
|
|
329
|
+
if (isInvalidValue(value) || value < 0) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const legend = `${label}`;
|
|
333
|
+
// resolve color for each legend from the extracted colors
|
|
334
|
+
const color = resolveColor(colors, index, legend, colorMap, isDarkTheme);
|
|
335
|
+
if (!mapLegendToDataPoint[legend]) {
|
|
336
|
+
mapLegendToDataPoint[legend] = {
|
|
337
|
+
legend,
|
|
338
|
+
data: value,
|
|
339
|
+
color
|
|
340
|
+
};
|
|
341
|
+
} else {
|
|
342
|
+
mapLegendToDataPoint[legend].data += value;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
} else {
|
|
346
|
+
// Sort labels by value descending before mapping
|
|
347
|
+
if (firstData.labels && firstData.values) {
|
|
348
|
+
const labelValuePairs = firstData.labels.map((label, index)=>({
|
|
349
|
+
label,
|
|
350
|
+
value: getNumberAtIndexOrDefault(firstData.values, index),
|
|
351
|
+
index
|
|
352
|
+
}));
|
|
353
|
+
// Filter out invalid values
|
|
354
|
+
const validPairs = labelValuePairs.filter((pair)=>!isInvalidValue(pair.value));
|
|
355
|
+
// Sort descending by value
|
|
356
|
+
validPairs.sort((a, b)=>b.value - a.value);
|
|
357
|
+
validPairs.forEach((pair, sortedIdx)=>{
|
|
358
|
+
const legend = `${pair.label}`;
|
|
359
|
+
const color = resolveColor(colors, sortedIdx, legend, colorMap, isDarkTheme);
|
|
360
|
+
if (!mapLegendToDataPoint[legend]) {
|
|
361
|
+
mapLegendToDataPoint[legend] = {
|
|
362
|
+
legend,
|
|
363
|
+
data: pair.value,
|
|
364
|
+
color
|
|
365
|
+
};
|
|
366
|
+
} else {
|
|
367
|
+
mapLegendToDataPoint[legend].data += pair.value;
|
|
368
|
+
}
|
|
369
|
+
});
|
|
183
370
|
}
|
|
184
|
-
}
|
|
371
|
+
}
|
|
185
372
|
var _input_layout_width;
|
|
186
373
|
const width = (_input_layout_width = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width) !== null && _input_layout_width !== void 0 ? _input_layout_width : 440;
|
|
187
374
|
var _input_layout_height;
|
|
@@ -200,7 +387,7 @@ export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, co
|
|
|
200
387
|
chartTitle,
|
|
201
388
|
chartData: Object.values(mapLegendToDataPoint)
|
|
202
389
|
},
|
|
203
|
-
hideLegend: ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false
|
|
390
|
+
hideLegend: isMultiPlot || ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false,
|
|
204
391
|
width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
|
|
205
392
|
height,
|
|
206
393
|
innerRadius,
|
|
@@ -219,17 +406,16 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
219
406
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
220
407
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
221
408
|
let colorScale = undefined;
|
|
409
|
+
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
222
410
|
let yMinValue = 0;
|
|
223
411
|
input.data.forEach((series, index1)=>{
|
|
224
|
-
var
|
|
225
|
-
|
|
226
|
-
colorScale = createColorScale(input.layout, series);
|
|
227
|
-
}
|
|
412
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line;
|
|
413
|
+
colorScale = createColorScale(input.layout, series, colorScale);
|
|
228
414
|
const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
|
|
229
415
|
// extract bar colors for each series only once
|
|
230
|
-
const extractedBarColors = extractColor((
|
|
416
|
+
const extractedBarColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
231
417
|
// extract line colors for each series only once
|
|
232
|
-
const extractedLineColors = extractColor((
|
|
418
|
+
const extractedLineColors = extractColor((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
|
|
233
419
|
const xValues = series.x;
|
|
234
420
|
const isXDate = isDateArray(xValues);
|
|
235
421
|
const isXString = isStringArray(xValues);
|
|
@@ -252,6 +438,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
252
438
|
const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index2 % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedBarColors, index2, legend, colorMap, isDarkTheme);
|
|
253
439
|
const opacity = getOpacity(series, index2);
|
|
254
440
|
const yVal = rangeYValues[index2];
|
|
441
|
+
const yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
|
|
255
442
|
if (series.type === 'bar') {
|
|
256
443
|
var _rgb_copy_formatHex8;
|
|
257
444
|
mapXToDataPoints[x].chartData.push({
|
|
@@ -259,7 +446,8 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
259
446
|
data: yVal,
|
|
260
447
|
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
261
448
|
opacity
|
|
262
|
-
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
449
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
450
|
+
yAxisCalloutData
|
|
263
451
|
});
|
|
264
452
|
if (typeof yVal === 'number') {
|
|
265
453
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -281,7 +469,8 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
281
469
|
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
282
470
|
mode: series.mode
|
|
283
471
|
},
|
|
284
|
-
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
472
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
473
|
+
yAxisCalloutData
|
|
285
474
|
});
|
|
286
475
|
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
287
476
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -292,7 +481,6 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
292
481
|
});
|
|
293
482
|
});
|
|
294
483
|
});
|
|
295
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
296
484
|
const vsbcData = Object.values(mapXToDataPoints);
|
|
297
485
|
var _input_layout_height;
|
|
298
486
|
return {
|
|
@@ -302,9 +490,6 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
302
490
|
barWidth: 'auto',
|
|
303
491
|
yMaxValue,
|
|
304
492
|
yMinValue,
|
|
305
|
-
chartTitle,
|
|
306
|
-
xAxisTitle,
|
|
307
|
-
yAxisTitle,
|
|
308
493
|
mode: 'plotly',
|
|
309
494
|
...secondaryYAxisValues,
|
|
310
495
|
wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
|
|
@@ -315,36 +500,55 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
315
500
|
showYAxisLables: true,
|
|
316
501
|
noOfCharsToTruncate: 20,
|
|
317
502
|
showYAxisLablesTooltip: true,
|
|
318
|
-
...
|
|
503
|
+
...getTitles(input.layout),
|
|
504
|
+
...getXAxisTickFormat(input.data[0], input.layout),
|
|
505
|
+
...yAxisTickFormat,
|
|
506
|
+
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
507
|
+
...getBarProps(input.data, input.layout),
|
|
508
|
+
...getYMinMaxValues(input.data[0], input.layout),
|
|
509
|
+
...getAxisTickProps(input.data, input.layout)
|
|
319
510
|
};
|
|
320
511
|
};
|
|
321
|
-
const createColorScale = (layout, series)=>{
|
|
322
|
-
var _layout_coloraxis, _series_marker, _layout_coloraxis1, _layout_coloraxis2;
|
|
323
|
-
const scale = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis = layout.coloraxis) === null || _layout_coloraxis === void 0 ? void 0 : _layout_coloraxis.colorscale;
|
|
324
|
-
const colorValues = (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color;
|
|
325
|
-
var _layout_coloraxis_cmin, _layout_coloraxis_cmax;
|
|
326
|
-
const [dMin, dMax] = [
|
|
327
|
-
(_layout_coloraxis_cmin = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis1 = layout.coloraxis) === null || _layout_coloraxis1 === void 0 ? void 0 : _layout_coloraxis1.cmin) !== null && _layout_coloraxis_cmin !== void 0 ? _layout_coloraxis_cmin : Math.min(...colorValues),
|
|
328
|
-
(_layout_coloraxis_cmax = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis2 = layout.coloraxis) === null || _layout_coloraxis2 === void 0 ? void 0 : _layout_coloraxis2.cmax) !== null && _layout_coloraxis_cmax !== void 0 ? _layout_coloraxis_cmax : Math.max(...colorValues)
|
|
329
|
-
];
|
|
330
|
-
// Normalize colorscale domain to actual data domain
|
|
331
|
-
const scaleDomain = scale.map(([pos])=>dMin + pos * (dMax - dMin));
|
|
332
|
-
const scaleColors = scale.map((item)=>item[1]);
|
|
333
|
-
return d3ScaleLinear().domain(scaleDomain).range(scaleColors);
|
|
334
|
-
};
|
|
335
512
|
export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
336
|
-
var
|
|
513
|
+
var _processedInput_layout, _processedInput_layout1, _gvbcData_;
|
|
514
|
+
// Handle object arrays in y values by normalizing the data first
|
|
515
|
+
let processedInput = {
|
|
516
|
+
...input
|
|
517
|
+
};
|
|
518
|
+
// Check if any bar traces have object arrays as y values
|
|
519
|
+
const hasObjectArrayData = input.data.some((series)=>series.type === 'bar' && isObjectArray(series.y));
|
|
520
|
+
if (hasObjectArrayData) {
|
|
521
|
+
// Process each trace that has object array y values
|
|
522
|
+
const processedData = input.data.map((series, index)=>{
|
|
523
|
+
if (series.type === 'bar' && isObjectArray(series.y)) {
|
|
524
|
+
// Normalize the object array to create multiple traces for GVBC
|
|
525
|
+
const { traces } = normalizeObjectArrayForGVBC(series.y, Array.isArray(series.x) ? series.x : undefined);
|
|
526
|
+
// Return all the new traces, each representing a property from the objects
|
|
527
|
+
return traces.map((trace)=>({
|
|
528
|
+
...trace,
|
|
529
|
+
// Copy other properties from the original series if needed
|
|
530
|
+
marker: series.marker
|
|
531
|
+
}));
|
|
532
|
+
}
|
|
533
|
+
return [
|
|
534
|
+
series
|
|
535
|
+
];
|
|
536
|
+
}).flat();
|
|
537
|
+
processedInput = {
|
|
538
|
+
...input,
|
|
539
|
+
data: processedData
|
|
540
|
+
};
|
|
541
|
+
}
|
|
337
542
|
const mapXToDataPoints = {};
|
|
338
|
-
const secondaryYAxisValues = getSecondaryYAxisValues(
|
|
339
|
-
const { legends, hideLegend } = getLegendProps(
|
|
543
|
+
const secondaryYAxisValues = getSecondaryYAxisValues(processedInput.data, processedInput.layout, 0, 0);
|
|
544
|
+
const { legends, hideLegend } = getLegendProps(processedInput.data, processedInput.layout, isMultiPlot);
|
|
340
545
|
let colorScale = undefined;
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
546
|
+
const yAxisTickFormat = getYAxisTickFormat(processedInput.data[0], processedInput.layout);
|
|
547
|
+
processedInput.data.forEach((series, index1)=>{
|
|
548
|
+
var _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout, _series_marker, _series_x;
|
|
549
|
+
colorScale = createColorScale(processedInput.layout, series, colorScale);
|
|
346
550
|
// extract colors for each series only once
|
|
347
|
-
const extractedColors = extractColor((
|
|
551
|
+
const extractedColors = extractColor((_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : (_processedInput_layout_template = _processedInput_layout.template) === null || _processedInput_layout_template === void 0 ? void 0 : (_processedInput_layout_template_layout = _processedInput_layout_template.layout) === null || _processedInput_layout_template_layout === void 0 ? void 0 : _processedInput_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
348
552
|
(_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
|
|
349
553
|
var _series_y;
|
|
350
554
|
if (isInvalidValue(x) || isInvalidValue((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2])) {
|
|
@@ -362,38 +566,42 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
362
566
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
363
567
|
const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index2 % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, index2, legend, colorMap, isDarkTheme);
|
|
364
568
|
const opacity = getOpacity(series, index2);
|
|
569
|
+
const yVal = series.y[index2];
|
|
365
570
|
var _rgb_copy_formatHex8;
|
|
366
571
|
mapXToDataPoints[x].series.push({
|
|
367
572
|
key: legend,
|
|
368
|
-
data:
|
|
573
|
+
data: yVal,
|
|
369
574
|
xAxisCalloutData: x,
|
|
370
575
|
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
371
576
|
opacity
|
|
372
577
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
373
578
|
legend,
|
|
374
|
-
useSecondaryYScale: usesSecondaryYScale(series,
|
|
579
|
+
useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout),
|
|
580
|
+
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
|
|
375
581
|
});
|
|
376
582
|
}
|
|
377
583
|
});
|
|
378
584
|
});
|
|
379
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
380
585
|
const gvbcData = Object.values(mapXToDataPoints);
|
|
381
|
-
var
|
|
586
|
+
var _processedInput_layout_height;
|
|
382
587
|
return {
|
|
383
588
|
data: gvbcData,
|
|
384
|
-
width: (
|
|
385
|
-
height: (
|
|
589
|
+
width: (_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : _processedInput_layout.width,
|
|
590
|
+
height: (_processedInput_layout_height = (_processedInput_layout1 = processedInput.layout) === null || _processedInput_layout1 === void 0 ? void 0 : _processedInput_layout1.height) !== null && _processedInput_layout_height !== void 0 ? _processedInput_layout_height : 350,
|
|
386
591
|
barWidth: 'auto',
|
|
387
|
-
chartTitle,
|
|
388
|
-
xAxisTitle,
|
|
389
|
-
yAxisTitle,
|
|
390
592
|
mode: 'plotly',
|
|
391
593
|
...secondaryYAxisValues,
|
|
392
594
|
hideTickOverlap: true,
|
|
393
595
|
wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
|
|
394
596
|
hideLegend,
|
|
395
597
|
roundCorners: true,
|
|
396
|
-
...
|
|
598
|
+
...getTitles(processedInput.layout),
|
|
599
|
+
...getAxisCategoryOrderProps(processedInput.data, processedInput.layout),
|
|
600
|
+
...getYMinMaxValues(processedInput.data[0], processedInput.layout),
|
|
601
|
+
...getXAxisTickFormat(processedInput.data[0], processedInput.layout),
|
|
602
|
+
...yAxisTickFormat,
|
|
603
|
+
...getBarProps(processedInput.data, processedInput.layout),
|
|
604
|
+
...getAxisTickProps(processedInput.data, processedInput.layout)
|
|
397
605
|
};
|
|
398
606
|
};
|
|
399
607
|
export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -402,15 +610,13 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
|
|
|
402
610
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
403
611
|
let colorScale = undefined;
|
|
404
612
|
input.data.forEach((series, seriesIdx)=>{
|
|
405
|
-
var
|
|
613
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_xbins, _series_xbins1, _series_xbins2;
|
|
406
614
|
if (!series.x) {
|
|
407
615
|
return;
|
|
408
616
|
}
|
|
409
|
-
|
|
410
|
-
colorScale = createColorScale(input.layout, series);
|
|
411
|
-
}
|
|
617
|
+
colorScale = createColorScale(input.layout, series, colorScale);
|
|
412
618
|
// extract colors for each series only once
|
|
413
|
-
const extractedColors = extractColor((
|
|
619
|
+
const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
414
620
|
const xValues = [];
|
|
415
621
|
const yValues = [];
|
|
416
622
|
series.x.forEach((xVal, index)=>{
|
|
@@ -459,21 +665,19 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
|
|
|
459
665
|
});
|
|
460
666
|
});
|
|
461
667
|
});
|
|
462
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
463
668
|
var _input_layout_height;
|
|
464
669
|
return {
|
|
465
670
|
data: vbcData,
|
|
466
671
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
467
672
|
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
468
|
-
chartTitle,
|
|
469
|
-
xAxisTitle,
|
|
470
|
-
yAxisTitle,
|
|
471
673
|
mode: 'histogram',
|
|
472
674
|
hideTickOverlap: true,
|
|
473
675
|
wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
|
|
474
676
|
maxBarWidth: 50,
|
|
475
677
|
hideLegend,
|
|
476
678
|
roundCorners: true,
|
|
679
|
+
...getTitles(input.layout),
|
|
680
|
+
...getYMinMaxValues(input.data[0], input.layout),
|
|
477
681
|
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
478
682
|
};
|
|
479
683
|
};
|
|
@@ -487,20 +691,23 @@ export const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, color
|
|
|
487
691
|
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
488
692
|
};
|
|
489
693
|
const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
|
|
490
|
-
var _input_data_;
|
|
694
|
+
var _input_data_, _input_layout, _input_layout1;
|
|
491
695
|
const isScatterMarkers = [
|
|
696
|
+
'text',
|
|
492
697
|
'markers',
|
|
493
698
|
'text+markers',
|
|
494
699
|
'markers+text',
|
|
495
700
|
'lines+markers',
|
|
496
701
|
'markers+line',
|
|
497
|
-
'text+lines+markers'
|
|
702
|
+
'text+lines+markers',
|
|
703
|
+
'lines+markers+text'
|
|
498
704
|
].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
|
|
499
705
|
const isAreaChart = chartType === 'area';
|
|
500
706
|
const isScatterChart = chartType === 'scatter';
|
|
501
707
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
502
708
|
let mode = 'tonexty';
|
|
503
709
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
710
|
+
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
504
711
|
const chartData = input.data.map((series, index)=>{
|
|
505
712
|
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
|
|
506
713
|
const colors = isScatterMarkers ? (series === null || series === void 0 ? void 0 : (_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('line')) ? (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color : (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color : (_series_line1 = series.line) === null || _series_line1 === void 0 ? void 0 : _series_line1.color;
|
|
@@ -516,11 +723,12 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
516
723
|
const seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
517
724
|
const seriesOpacity = getOpacity(series, index);
|
|
518
725
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
519
|
-
|
|
726
|
+
// if mode contains 'text', we prioritize showing the text over curving the line
|
|
727
|
+
const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
|
|
520
728
|
const legendShape = getLegendShape(series);
|
|
521
729
|
const validXYRanges = getValidXYRanges(series);
|
|
522
730
|
return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
523
|
-
var _series_marker;
|
|
731
|
+
var _series_marker, _input_layout, _input_layout_polar_angularaxis, _input_layout_polar, _input_layout1, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout2;
|
|
524
732
|
const rangeXValues = xValues.slice(rangeStart, rangeEnd);
|
|
525
733
|
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
526
734
|
const markerSizes = isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? series.marker.size.slice(rangeStart, rangeEnd) : [];
|
|
@@ -541,7 +749,8 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
541
749
|
} : {},
|
|
542
750
|
...textValues ? {
|
|
543
751
|
text: textValues[i]
|
|
544
|
-
} : {}
|
|
752
|
+
} : {},
|
|
753
|
+
yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat)
|
|
545
754
|
};
|
|
546
755
|
}),
|
|
547
756
|
color: (_rgb_copy_formatHex8 = rgb(seriesColor).copy({
|
|
@@ -549,58 +758,65 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
549
758
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
|
|
550
759
|
lineOptions: {
|
|
551
760
|
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
552
|
-
mode: series.mode
|
|
761
|
+
mode: series.type !== 'scatterpolar' ? series.mode : 'scatterpolar',
|
|
762
|
+
// originXOffset is not typed on Layout, but may be present in input.layout as a part of projection of
|
|
763
|
+
// scatter polar coordingates to cartesian coordinates
|
|
764
|
+
...series.type === 'scatterpolar' ? {
|
|
765
|
+
originXOffset: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.__polarOriginX,
|
|
766
|
+
direction: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_polar = _input_layout1.polar) === null || _input_layout_polar === void 0 ? void 0 : (_input_layout_polar_angularaxis = _input_layout_polar.angularaxis) === null || _input_layout_polar_angularaxis === void 0 ? void 0 : _input_layout_polar_angularaxis.direction,
|
|
767
|
+
rotation: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_polar1 = _input_layout2.polar) === null || _input_layout_polar1 === void 0 ? void 0 : (_input_layout_polar_angularaxis1 = _input_layout_polar1.angularaxis) === null || _input_layout_polar_angularaxis1 === void 0 ? void 0 : _input_layout_polar_angularaxis1.rotation,
|
|
768
|
+
axisLabel: series.__axisLabel ? series.__axisLabel : {}
|
|
769
|
+
} : {}
|
|
553
770
|
},
|
|
554
771
|
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
555
772
|
};
|
|
556
773
|
});
|
|
557
774
|
}).flat();
|
|
558
|
-
const
|
|
559
|
-
|
|
775
|
+
const yMinMax = getYMinMaxValues(input.data[0], input.layout);
|
|
776
|
+
if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
|
|
777
|
+
const yMinMaxValues = findNumericMinMaxOfY(chartData);
|
|
778
|
+
yMinMax.yMinValue = yMinMaxValues.startValue;
|
|
779
|
+
yMinMax.yMaxValue = yMinMaxValues.endValue;
|
|
780
|
+
}
|
|
560
781
|
const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
|
|
561
782
|
const chartProps = {
|
|
562
|
-
chartTitle,
|
|
563
783
|
lineChartData: chartData
|
|
564
784
|
};
|
|
565
785
|
const scatterChartProps = {
|
|
566
|
-
chartTitle,
|
|
567
786
|
scatterChartData: chartData
|
|
568
787
|
};
|
|
788
|
+
var _input_layout_height;
|
|
789
|
+
const commonProps = {
|
|
790
|
+
supportNegativeData: true,
|
|
791
|
+
...secondaryYAxisValues,
|
|
792
|
+
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
793
|
+
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
794
|
+
hideTickOverlap: true,
|
|
795
|
+
hideLegend,
|
|
796
|
+
useUTC: false,
|
|
797
|
+
optimizeLargeData: numDataPoints > 1000,
|
|
798
|
+
...getTitles(input.layout),
|
|
799
|
+
...getXAxisTickFormat(input.data[0], input.layout),
|
|
800
|
+
...yAxisTickFormat,
|
|
801
|
+
...getAxisScaleTypeProps(input.data, input.layout),
|
|
802
|
+
...getAxisTickProps(input.data, input.layout)
|
|
803
|
+
};
|
|
569
804
|
if (isAreaChart) {
|
|
570
|
-
var _input_layout, _input_layout1;
|
|
571
|
-
var _input_layout_height;
|
|
572
805
|
return {
|
|
573
806
|
data: chartProps,
|
|
574
|
-
supportNegativeData: true,
|
|
575
|
-
xAxisTitle,
|
|
576
|
-
yAxisTitle,
|
|
577
|
-
...secondaryYAxisValues,
|
|
578
807
|
mode,
|
|
579
|
-
|
|
580
|
-
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
581
|
-
hideTickOverlap: true,
|
|
582
|
-
useUTC: false,
|
|
583
|
-
hideLegend,
|
|
584
|
-
optimizeLargeData: numDataPoints > 1000
|
|
808
|
+
...commonProps
|
|
585
809
|
};
|
|
586
810
|
} else {
|
|
587
|
-
var _input_layout2, _input_layout3;
|
|
588
|
-
var _input_layout_height1;
|
|
589
811
|
return {
|
|
590
812
|
data: isScatterChart ? scatterChartProps : chartProps,
|
|
591
|
-
supportNegativeData: true,
|
|
592
|
-
xAxisTitle,
|
|
593
|
-
yAxisTitle,
|
|
594
|
-
...secondaryYAxisValues,
|
|
595
813
|
roundedTicks: true,
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
hideLegend,
|
|
603
|
-
optimizeLargeData: numDataPoints > 1000
|
|
814
|
+
...commonProps,
|
|
815
|
+
...yMinMax,
|
|
816
|
+
...isScatterChart ? {
|
|
817
|
+
showYAxisLablesTooltip: true,
|
|
818
|
+
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
819
|
+
} : {}
|
|
604
820
|
};
|
|
605
821
|
}
|
|
606
822
|
};
|
|
@@ -609,12 +825,10 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
|
|
|
609
825
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
610
826
|
let colorScale = undefined;
|
|
611
827
|
const chartData = input.data.map((series, index)=>{
|
|
612
|
-
var
|
|
613
|
-
|
|
614
|
-
colorScale = createColorScale(input.layout, series);
|
|
615
|
-
}
|
|
828
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
|
|
829
|
+
colorScale = createColorScale(input.layout, series, colorScale);
|
|
616
830
|
// extract colors for each series only once
|
|
617
|
-
const extractedColors = extractColor((
|
|
831
|
+
const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
618
832
|
const legend = legends[index];
|
|
619
833
|
return series.y.map((yValue, i)=>{
|
|
620
834
|
var _series_x, _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
@@ -646,12 +860,8 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
|
|
|
646
860
|
const scalingFactor = 0.01;
|
|
647
861
|
const gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
648
862
|
const barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
649
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
650
863
|
return {
|
|
651
864
|
data: chartData,
|
|
652
|
-
chartTitle,
|
|
653
|
-
xAxisTitle,
|
|
654
|
-
yAxisTitle,
|
|
655
865
|
secondaryYAxistitle: typeof ((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_yaxis2 = _input_layout3.yaxis2) === null || _input_layout_yaxis2 === void 0 ? void 0 : _input_layout_yaxis2.title) === 'string' ? (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_yaxis21 = _input_layout4.yaxis2) === null || _input_layout_yaxis21 === void 0 ? void 0 : _input_layout_yaxis21.title : ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_yaxis22 = _input_layout5.yaxis2) === null || _input_layout_yaxis22 === void 0 ? void 0 : (_input_layout_yaxis2_title = _input_layout_yaxis22.title) === null || _input_layout_yaxis2_title === void 0 ? void 0 : _input_layout_yaxis2_title.text) || '',
|
|
656
866
|
barHeight,
|
|
657
867
|
showYAxisLables: true,
|
|
@@ -662,7 +872,67 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
|
|
|
662
872
|
showYAxisLablesTooltip: true,
|
|
663
873
|
hideLegend,
|
|
664
874
|
roundCorners: true,
|
|
665
|
-
...
|
|
875
|
+
...getTitles(input.layout),
|
|
876
|
+
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
877
|
+
...getBarProps(input.data, input.layout, true),
|
|
878
|
+
...getAxisTickProps(input.data, input.layout)
|
|
879
|
+
};
|
|
880
|
+
};
|
|
881
|
+
export const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
882
|
+
var _input_layout, _input_layout1;
|
|
883
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
884
|
+
let colorScale = undefined;
|
|
885
|
+
const chartData = input.data.map((series, index)=>{
|
|
886
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_xaxis, _input_layout1;
|
|
887
|
+
colorScale = createColorScale(input.layout, series, colorScale);
|
|
888
|
+
// extract colors for each series only once
|
|
889
|
+
const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
890
|
+
const legend = legends[index];
|
|
891
|
+
const isXDate = ((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_xaxis = _input_layout1.xaxis) === null || _input_layout_xaxis === void 0 ? void 0 : _input_layout_xaxis.type) === 'date' || isDateArray(series.x);
|
|
892
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
893
|
+
const convertXValueToNumber = (value)=>{
|
|
894
|
+
return isInvalidValue(value) ? 0 : isXDate ? +parseLocalDate(value) : +value;
|
|
895
|
+
};
|
|
896
|
+
return series.y.map((yVal, i)=>{
|
|
897
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _series_base, _series_x;
|
|
898
|
+
if (isInvalidValue(yVal)) {
|
|
899
|
+
return null;
|
|
900
|
+
}
|
|
901
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
902
|
+
const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[i % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, i, legend, colorMap, isDarkTheme);
|
|
903
|
+
const opacity = getOpacity(series, i);
|
|
904
|
+
const base = convertXValueToNumber((_series_base = series.base) === null || _series_base === void 0 ? void 0 : _series_base[i]);
|
|
905
|
+
const xVal = convertXValueToNumber((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]);
|
|
906
|
+
var _rgb_copy_formatHex8;
|
|
907
|
+
return {
|
|
908
|
+
x: {
|
|
909
|
+
start: isXDate ? new Date(base) : base,
|
|
910
|
+
end: isXDate ? new Date(base + xVal) : base + xVal
|
|
911
|
+
},
|
|
912
|
+
y: yVal,
|
|
913
|
+
legend,
|
|
914
|
+
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
915
|
+
opacity
|
|
916
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
917
|
+
};
|
|
918
|
+
}).filter((point)=>point !== null);
|
|
919
|
+
}).flat();
|
|
920
|
+
var _input_layout_height;
|
|
921
|
+
return {
|
|
922
|
+
data: chartData,
|
|
923
|
+
showYAxisLables: true,
|
|
924
|
+
height: (_input_layout_height = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
925
|
+
width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
|
|
926
|
+
hideTickOverlap: true,
|
|
927
|
+
hideLegend,
|
|
928
|
+
noOfCharsToTruncate: 20,
|
|
929
|
+
showYAxisLablesTooltip: true,
|
|
930
|
+
roundCorners: true,
|
|
931
|
+
useUTC: false,
|
|
932
|
+
...getTitles(input.layout),
|
|
933
|
+
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
934
|
+
...getBarProps(input.data, input.layout, true),
|
|
935
|
+
...getAxisTickProps(input.data, input.layout)
|
|
666
936
|
};
|
|
667
937
|
};
|
|
668
938
|
export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -776,7 +1046,6 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
|
|
|
776
1046
|
}
|
|
777
1047
|
const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
|
|
778
1048
|
const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
|
|
779
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
780
1049
|
var _input_layout_height;
|
|
781
1050
|
return {
|
|
782
1051
|
data: [
|
|
@@ -786,9 +1055,6 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
|
|
|
786
1055
|
rangeValuesForColorScale,
|
|
787
1056
|
hideLegend: true,
|
|
788
1057
|
showYAxisLables: true,
|
|
789
|
-
chartTitle,
|
|
790
|
-
xAxisTitle,
|
|
791
|
-
yAxisTitle,
|
|
792
1058
|
sortOrder: 'none',
|
|
793
1059
|
width: (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.width,
|
|
794
1060
|
height: (_input_layout_height = (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
@@ -796,9 +1062,11 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
|
|
|
796
1062
|
noOfCharsToTruncate: 20,
|
|
797
1063
|
showYAxisLablesTooltip: true,
|
|
798
1064
|
wrapXAxisLables: true,
|
|
1065
|
+
...getTitles(input.layout),
|
|
799
1066
|
...getAxisCategoryOrderProps([
|
|
800
1067
|
firstData
|
|
801
|
-
], input.layout)
|
|
1068
|
+
], input.layout),
|
|
1069
|
+
...getAxisTickProps(input.data, input.layout)
|
|
802
1070
|
};
|
|
803
1071
|
};
|
|
804
1072
|
export const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -946,37 +1214,49 @@ const formatValue = (value, colIndex, cells)=>{
|
|
|
946
1214
|
}
|
|
947
1215
|
return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
|
|
948
1216
|
};
|
|
1217
|
+
function resolveCellStyle(raw, rowIndex, colIndex) {
|
|
1218
|
+
if (Array.isArray(raw)) {
|
|
1219
|
+
var _raw_colIndex;
|
|
1220
|
+
const rowEntry = (_raw_colIndex = raw[colIndex]) !== null && _raw_colIndex !== void 0 ? _raw_colIndex : raw[0];
|
|
1221
|
+
if (Array.isArray(rowEntry)) {
|
|
1222
|
+
var _rowEntry_rowIndex;
|
|
1223
|
+
return (_rowEntry_rowIndex = rowEntry[rowIndex]) !== null && _rowEntry_rowIndex !== void 0 ? _rowEntry_rowIndex : rowEntry[0];
|
|
1224
|
+
}
|
|
1225
|
+
return rowEntry;
|
|
1226
|
+
}
|
|
1227
|
+
return raw;
|
|
1228
|
+
}
|
|
1229
|
+
function mergeCells(tableCells, templateCells) {
|
|
1230
|
+
var _tableCells_values, _ref, _tableCells_align, _templateCells_fill, _tableCells_fill, _templateCells_font, _tableCells_font, _tableCells_format, _tableCells_prefix, _tableCells_suffix;
|
|
1231
|
+
return {
|
|
1232
|
+
values: (_ref = (_tableCells_values = tableCells === null || tableCells === void 0 ? void 0 : tableCells.values) !== null && _tableCells_values !== void 0 ? _tableCells_values : templateCells === null || templateCells === void 0 ? void 0 : templateCells.values) !== null && _ref !== void 0 ? _ref : [],
|
|
1233
|
+
align: (_tableCells_align = tableCells === null || tableCells === void 0 ? void 0 : tableCells.align) !== null && _tableCells_align !== void 0 ? _tableCells_align : templateCells === null || templateCells === void 0 ? void 0 : templateCells.align,
|
|
1234
|
+
fill: {
|
|
1235
|
+
...(_templateCells_fill = templateCells === null || templateCells === void 0 ? void 0 : templateCells.fill) !== null && _templateCells_fill !== void 0 ? _templateCells_fill : {},
|
|
1236
|
+
...(_tableCells_fill = tableCells === null || tableCells === void 0 ? void 0 : tableCells.fill) !== null && _tableCells_fill !== void 0 ? _tableCells_fill : {}
|
|
1237
|
+
},
|
|
1238
|
+
font: {
|
|
1239
|
+
...(_templateCells_font = templateCells === null || templateCells === void 0 ? void 0 : templateCells.font) !== null && _templateCells_font !== void 0 ? _templateCells_font : {},
|
|
1240
|
+
...(_tableCells_font = tableCells === null || tableCells === void 0 ? void 0 : tableCells.font) !== null && _tableCells_font !== void 0 ? _tableCells_font : {}
|
|
1241
|
+
},
|
|
1242
|
+
format: (_tableCells_format = tableCells === null || tableCells === void 0 ? void 0 : tableCells.format) !== null && _tableCells_format !== void 0 ? _tableCells_format : templateCells === null || templateCells === void 0 ? void 0 : templateCells.format,
|
|
1243
|
+
prefix: (_tableCells_prefix = tableCells === null || tableCells === void 0 ? void 0 : tableCells.prefix) !== null && _tableCells_prefix !== void 0 ? _tableCells_prefix : templateCells === null || templateCells === void 0 ? void 0 : templateCells.prefix,
|
|
1244
|
+
suffix: (_tableCells_suffix = tableCells === null || tableCells === void 0 ? void 0 : tableCells.suffix) !== null && _tableCells_suffix !== void 0 ? _tableCells_suffix : templateCells === null || templateCells === void 0 ? void 0 : templateCells.suffix
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
949
1247
|
export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
950
|
-
var _tableData_cells, _input_layout_template_data, _input_layout_template, _input_layout, _input_layout_font, _input_layout1,
|
|
1248
|
+
var _tableData_cells, _input_layout_template_data_table_, _input_layout_template_data_table, _input_layout_template_data, _input_layout_template, _input_layout, _input_layout_font, _input_layout1, _input_layout_template_data_table_1, _input_layout_template_data_table1, _input_layout_template_data1, _input_layout_template1, _input_layout2, _tableData_header, _input_layout3, _input_layout4;
|
|
951
1249
|
const tableData = input.data[0];
|
|
952
1250
|
const normalizeHeaders = (values, header)=>{
|
|
953
1251
|
const cleanedValues = Array.isArray(values[0]) ? values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' ')) : values.map((cell)=>cleanText(cell));
|
|
954
1252
|
return cleanedValues.map((value, colIndex)=>{
|
|
955
1253
|
var _header_font, _header_font1, _header_fill;
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
} else if (typeof colorEntry === 'string') {
|
|
963
|
-
fontColor = colorEntry;
|
|
964
|
-
}
|
|
965
|
-
} else if (typeof fontColorRaw === 'string') {
|
|
966
|
-
fontColor = fontColorRaw;
|
|
967
|
-
}
|
|
968
|
-
const fontSizeRaw = header === null || header === void 0 ? void 0 : (_header_font1 = header.font) === null || _header_font1 === void 0 ? void 0 : _header_font1.size;
|
|
969
|
-
let fontSize;
|
|
970
|
-
if (Array.isArray(fontSizeRaw)) {
|
|
971
|
-
fontSize = Array.isArray(fontSizeRaw[0]) ? fontSizeRaw[0][colIndex] : fontSizeRaw[colIndex];
|
|
972
|
-
} else if (typeof fontSizeRaw === 'number') {
|
|
973
|
-
fontSize = fontSizeRaw;
|
|
974
|
-
}
|
|
975
|
-
const updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
976
|
-
const fillColorRaw = header === null || header === void 0 ? void 0 : (_header_fill = header.fill) === null || _header_fill === void 0 ? void 0 : _header_fill.color;
|
|
977
|
-
const backgroundColor = Array.isArray(fillColorRaw) ? fillColorRaw[updatedColIndex] : fillColorRaw;
|
|
978
|
-
const textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
|
|
979
|
-
const textAlign = Array.isArray(textAlignRaw) ? textAlignRaw[colIndex] : textAlignRaw;
|
|
1254
|
+
//headers are at first row only
|
|
1255
|
+
const rowIndex = 0;
|
|
1256
|
+
const fontColor = resolveCellStyle(header === null || header === void 0 ? void 0 : (_header_font = header.font) === null || _header_font === void 0 ? void 0 : _header_font.color, rowIndex, colIndex);
|
|
1257
|
+
const fontSize = resolveCellStyle(header === null || header === void 0 ? void 0 : (_header_font1 = header.font) === null || _header_font1 === void 0 ? void 0 : _header_font1.size, rowIndex, colIndex);
|
|
1258
|
+
const backgroundColor = resolveCellStyle(header === null || header === void 0 ? void 0 : (_header_fill = header.fill) === null || _header_fill === void 0 ? void 0 : _header_fill.color, rowIndex, colIndex);
|
|
1259
|
+
const textAlign = resolveCellStyle(header === null || header === void 0 ? void 0 : header.align, rowIndex, colIndex);
|
|
980
1260
|
const style = {
|
|
981
1261
|
...typeof fontColor === 'string' ? {
|
|
982
1262
|
color: fontColor
|
|
@@ -999,42 +1279,16 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
|
|
|
999
1279
|
};
|
|
1000
1280
|
var _tableData_cells_values;
|
|
1001
1281
|
const columns = (_tableData_cells_values = (_tableData_cells = tableData.cells) === null || _tableData_cells === void 0 ? void 0 : _tableData_cells.values) !== null && _tableData_cells_values !== void 0 ? _tableData_cells_values : [];
|
|
1002
|
-
const cells = tableData.cells
|
|
1282
|
+
const cells = mergeCells(tableData.cells, (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_data = _input_layout_template.data) === null || _input_layout_template_data === void 0 ? void 0 : (_input_layout_template_data_table = _input_layout_template_data.table) === null || _input_layout_template_data_table === void 0 ? void 0 : (_input_layout_template_data_table_ = _input_layout_template_data_table[0]) === null || _input_layout_template_data_table_ === void 0 ? void 0 : _input_layout_template_data_table_.cells);
|
|
1003
1283
|
const rows = columns[0].map((_, rowIndex)=>columns.map((col, colIndex)=>{
|
|
1004
1284
|
var _cells_font, _cells_font1, _cells_fill;
|
|
1005
1285
|
const cellValue = col[rowIndex];
|
|
1006
1286
|
const cleanValue = typeof cellValue === 'string' ? cleanText(cellValue) : cellValue;
|
|
1007
1287
|
const formattedValue = typeof cleanValue === 'string' || typeof cleanValue === 'number' ? formatValue(cleanValue, colIndex, cells) : cleanValue;
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1013
|
-
fontColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
1014
|
-
} else if (typeof rawFontColor === 'string') {
|
|
1015
|
-
fontColor = rawFontColor;
|
|
1016
|
-
}
|
|
1017
|
-
const rawFontSize = cells === null || cells === void 0 ? void 0 : (_cells_font1 = cells.font) === null || _cells_font1 === void 0 ? void 0 : _cells_font1.size;
|
|
1018
|
-
let fontSize;
|
|
1019
|
-
if (Array.isArray(rawFontSize)) {
|
|
1020
|
-
const entry = rawFontSize[colIndex];
|
|
1021
|
-
const fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1022
|
-
fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
|
|
1023
|
-
} else if (typeof rawFontSize === 'number') {
|
|
1024
|
-
fontSize = rawFontSize;
|
|
1025
|
-
}
|
|
1026
|
-
const updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
1027
|
-
const rawBackgroundColor = cells === null || cells === void 0 ? void 0 : (_cells_fill = cells.fill) === null || _cells_fill === void 0 ? void 0 : _cells_fill.color;
|
|
1028
|
-
let backgroundColor;
|
|
1029
|
-
if (Array.isArray(rawBackgroundColor)) {
|
|
1030
|
-
const entry = rawBackgroundColor[updatedColIndex];
|
|
1031
|
-
const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1032
|
-
backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
1033
|
-
} else if (typeof rawBackgroundColor === 'string') {
|
|
1034
|
-
backgroundColor = rawBackgroundColor;
|
|
1035
|
-
}
|
|
1036
|
-
const rawTextAlign = Array.isArray(cells === null || cells === void 0 ? void 0 : cells.align) ? cells.align[colIndex] : cells === null || cells === void 0 ? void 0 : cells.align;
|
|
1037
|
-
const textAlign = rawTextAlign;
|
|
1288
|
+
const fontColor = resolveCellStyle(cells === null || cells === void 0 ? void 0 : (_cells_font = cells.font) === null || _cells_font === void 0 ? void 0 : _cells_font.color, rowIndex, colIndex);
|
|
1289
|
+
const fontSize = resolveCellStyle(cells === null || cells === void 0 ? void 0 : (_cells_font1 = cells.font) === null || _cells_font1 === void 0 ? void 0 : _cells_font1.size, rowIndex, colIndex);
|
|
1290
|
+
const backgroundColor = resolveCellStyle(cells === null || cells === void 0 ? void 0 : (_cells_fill = cells.fill) === null || _cells_fill === void 0 ? void 0 : _cells_fill.color, rowIndex, colIndex);
|
|
1291
|
+
const textAlign = resolveCellStyle(cells === null || cells === void 0 ? void 0 : cells.align, rowIndex, colIndex);
|
|
1038
1292
|
const style = {
|
|
1039
1293
|
...fontColor ? {
|
|
1040
1294
|
color: fontColor
|
|
@@ -1061,37 +1315,314 @@ export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMa
|
|
|
1061
1315
|
} : {}
|
|
1062
1316
|
}
|
|
1063
1317
|
};
|
|
1318
|
+
const templateHeader = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_template1 = _input_layout2.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_data1 = _input_layout_template1.data) === null || _input_layout_template_data1 === void 0 ? void 0 : (_input_layout_template_data_table1 = _input_layout_template_data1.table) === null || _input_layout_template_data_table1 === void 0 ? void 0 : (_input_layout_template_data_table_1 = _input_layout_template_data_table1[0]) === null || _input_layout_template_data_table_1 === void 0 ? void 0 : _input_layout_template_data_table_1.header;
|
|
1319
|
+
const tableHeader = tableData.header;
|
|
1320
|
+
var _tableHeader_align, _templateHeader_fill, _tableHeader_fill, _templateHeader_font, _tableHeader_font, _tableHeader_values, _ref;
|
|
1321
|
+
const header = {
|
|
1322
|
+
align: (_tableHeader_align = tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.align) !== null && _tableHeader_align !== void 0 ? _tableHeader_align : templateHeader === null || templateHeader === void 0 ? void 0 : templateHeader.align,
|
|
1323
|
+
fill: {
|
|
1324
|
+
...(_templateHeader_fill = templateHeader === null || templateHeader === void 0 ? void 0 : templateHeader.fill) !== null && _templateHeader_fill !== void 0 ? _templateHeader_fill : {},
|
|
1325
|
+
...(_tableHeader_fill = tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.fill) !== null && _tableHeader_fill !== void 0 ? _tableHeader_fill : {}
|
|
1326
|
+
},
|
|
1327
|
+
font: {
|
|
1328
|
+
...(_templateHeader_font = templateHeader === null || templateHeader === void 0 ? void 0 : templateHeader.font) !== null && _templateHeader_font !== void 0 ? _templateHeader_font : {},
|
|
1329
|
+
...(_tableHeader_font = tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.font) !== null && _tableHeader_font !== void 0 ? _tableHeader_font : {}
|
|
1330
|
+
},
|
|
1331
|
+
values: (_ref = (_tableHeader_values = tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.values) !== null && _tableHeader_values !== void 0 ? _tableHeader_values : templateHeader === null || templateHeader === void 0 ? void 0 : templateHeader.values) !== null && _ref !== void 0 ? _ref : []
|
|
1332
|
+
};
|
|
1064
1333
|
var _tableData_header_values;
|
|
1065
1334
|
return {
|
|
1066
|
-
headers: normalizeHeaders((_tableData_header_values = (_tableData_header = tableData.header) === null || _tableData_header === void 0 ? void 0 : _tableData_header.values) !== null && _tableData_header_values !== void 0 ? _tableData_header_values : [],
|
|
1335
|
+
headers: normalizeHeaders((_tableData_header_values = (_tableData_header = tableData.header) === null || _tableData_header === void 0 ? void 0 : _tableData_header.values) !== null && _tableData_header_values !== void 0 ? _tableData_header_values : [], header),
|
|
1067
1336
|
rows,
|
|
1068
1337
|
width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
|
|
1069
1338
|
height: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height,
|
|
1070
1339
|
styles
|
|
1071
1340
|
};
|
|
1072
1341
|
};
|
|
1342
|
+
function getCategoriesAndValues(series) {
|
|
1343
|
+
const orientation = series.orientation || 'h';
|
|
1344
|
+
var _series_labels, _ref;
|
|
1345
|
+
const y = (_ref = (_series_labels = series.labels) !== null && _series_labels !== void 0 ? _series_labels : series.y) !== null && _ref !== void 0 ? _ref : series.stage;
|
|
1346
|
+
var _series_values, _ref1;
|
|
1347
|
+
const x = (_ref1 = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : series.x) !== null && _ref1 !== void 0 ? _ref1 : series.value;
|
|
1348
|
+
const xIsString = isStringArray(x);
|
|
1349
|
+
const yIsString = isStringArray(y);
|
|
1350
|
+
const xIsNumber = isNumberArray(x);
|
|
1351
|
+
const yIsNumber = isNumberArray(y);
|
|
1352
|
+
// Helper to ensure array of (string | number)
|
|
1353
|
+
const toArray = (arr)=>{
|
|
1354
|
+
if (Array.isArray(arr)) {
|
|
1355
|
+
return arr;
|
|
1356
|
+
}
|
|
1357
|
+
if (typeof arr === 'string' || typeof arr === 'number') {
|
|
1358
|
+
return [
|
|
1359
|
+
arr
|
|
1360
|
+
];
|
|
1361
|
+
}
|
|
1362
|
+
return [];
|
|
1363
|
+
};
|
|
1364
|
+
if (orientation === 'h') {
|
|
1365
|
+
if (yIsString && xIsNumber) {
|
|
1366
|
+
return {
|
|
1367
|
+
categories: toArray(y),
|
|
1368
|
+
values: toArray(x)
|
|
1369
|
+
};
|
|
1370
|
+
} else if (xIsString && yIsNumber) {
|
|
1371
|
+
return {
|
|
1372
|
+
categories: toArray(x),
|
|
1373
|
+
values: toArray(y)
|
|
1374
|
+
};
|
|
1375
|
+
} else {
|
|
1376
|
+
return {
|
|
1377
|
+
categories: yIsString ? toArray(y) : toArray(x),
|
|
1378
|
+
values: yIsString ? toArray(x) : toArray(y)
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
} else {
|
|
1382
|
+
if (xIsString && yIsNumber) {
|
|
1383
|
+
return {
|
|
1384
|
+
categories: toArray(x),
|
|
1385
|
+
values: toArray(y)
|
|
1386
|
+
};
|
|
1387
|
+
} else if (yIsString && xIsNumber) {
|
|
1388
|
+
return {
|
|
1389
|
+
categories: toArray(y),
|
|
1390
|
+
values: toArray(x)
|
|
1391
|
+
};
|
|
1392
|
+
} else {
|
|
1393
|
+
return {
|
|
1394
|
+
categories: xIsString ? toArray(x) : toArray(y),
|
|
1395
|
+
values: xIsString ? toArray(y) : toArray(x)
|
|
1396
|
+
};
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
export const transformPlotlyJsonToFunnelChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
1401
|
+
var _input_layout, _input_layout1, _input_data_, _input_layout2;
|
|
1402
|
+
const funnelData = [];
|
|
1403
|
+
// Determine if data is stacked based on multiple series with multiple values per series
|
|
1404
|
+
const isStacked = input.data.length > 1 && input.data.every((series)=>{
|
|
1405
|
+
var _series_values, _ref;
|
|
1406
|
+
const values = (_ref = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : series.x) !== null && _ref !== void 0 ? _ref : series.value;
|
|
1407
|
+
var _series_labels, _ref1;
|
|
1408
|
+
const labels = (_ref1 = (_series_labels = series.labels) !== null && _series_labels !== void 0 ? _series_labels : series.y) !== null && _ref1 !== void 0 ? _ref1 : series.stage;
|
|
1409
|
+
return Array.isArray(labels) && Array.isArray(values) && values.length > 1 && labels.length > 1;
|
|
1410
|
+
});
|
|
1411
|
+
if (isStacked) {
|
|
1412
|
+
// Assign a color per series/category and use it for all subValues of that category
|
|
1413
|
+
const seriesColors = {};
|
|
1414
|
+
input.data.forEach((series, seriesIdx)=>{
|
|
1415
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_marker1;
|
|
1416
|
+
const category = series.name || `Category ${seriesIdx + 1}`;
|
|
1417
|
+
var _series_marker_colors;
|
|
1418
|
+
// Use the same color for this category across all stages
|
|
1419
|
+
const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker_colors = (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.colors) !== null && _series_marker_colors !== void 0 ? _series_marker_colors : (_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color, colorMap, isDarkTheme);
|
|
1420
|
+
// Always use the first color for the series/category
|
|
1421
|
+
const color = resolveColor(extractedColors, 0, category, colorMap, isDarkTheme);
|
|
1422
|
+
seriesColors[category] = color;
|
|
1423
|
+
var _series_labels, _ref;
|
|
1424
|
+
const labels = (_ref = (_series_labels = series.labels) !== null && _series_labels !== void 0 ? _series_labels : series.y) !== null && _ref !== void 0 ? _ref : series.stage;
|
|
1425
|
+
var _series_values, _ref1;
|
|
1426
|
+
const values = (_ref1 = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : series.x) !== null && _ref1 !== void 0 ? _ref1 : series.value;
|
|
1427
|
+
if (!isArrayOrTypedArray(labels) || !isArrayOrTypedArray(values)) {
|
|
1428
|
+
return;
|
|
1429
|
+
}
|
|
1430
|
+
if (labels && isArrayOrTypedArray(labels) && labels.length > 0) {
|
|
1431
|
+
labels.forEach((label, i)=>{
|
|
1432
|
+
const stageIndex = funnelData.findIndex((stage)=>stage.stage === label);
|
|
1433
|
+
const valueNum = Number(values[i]);
|
|
1434
|
+
if (isNaN(valueNum)) {
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
if (stageIndex === -1) {
|
|
1438
|
+
funnelData.push({
|
|
1439
|
+
stage: label,
|
|
1440
|
+
subValues: [
|
|
1441
|
+
{
|
|
1442
|
+
category,
|
|
1443
|
+
value: valueNum,
|
|
1444
|
+
color
|
|
1445
|
+
}
|
|
1446
|
+
]
|
|
1447
|
+
});
|
|
1448
|
+
} else {
|
|
1449
|
+
funnelData[stageIndex].subValues.push({
|
|
1450
|
+
category,
|
|
1451
|
+
value: valueNum,
|
|
1452
|
+
color
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
});
|
|
1458
|
+
} else {
|
|
1459
|
+
// Non-stacked data handling (multiple series with single-value arrays)
|
|
1460
|
+
input.data.forEach((series, seriesIdx)=>{
|
|
1461
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_marker1;
|
|
1462
|
+
const { categories, values } = getCategoriesAndValues(series);
|
|
1463
|
+
if (!isArrayOrTypedArray(categories) || !isArrayOrTypedArray(values)) {
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
var _series_marker_colors;
|
|
1467
|
+
const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker_colors = (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.colors) !== null && _series_marker_colors !== void 0 ? _series_marker_colors : (_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color, colorMap, isDarkTheme);
|
|
1468
|
+
categories.forEach((label, i)=>{
|
|
1469
|
+
const color = resolveColor(extractedColors, i, label, colorMap, isDarkTheme);
|
|
1470
|
+
const valueNum = Number(values[i]);
|
|
1471
|
+
if (isNaN(valueNum)) {
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1474
|
+
funnelData.push({
|
|
1475
|
+
stage: label,
|
|
1476
|
+
value: valueNum,
|
|
1477
|
+
color
|
|
1478
|
+
});
|
|
1479
|
+
});
|
|
1480
|
+
});
|
|
1481
|
+
}
|
|
1482
|
+
return {
|
|
1483
|
+
data: funnelData,
|
|
1484
|
+
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
1485
|
+
height: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height,
|
|
1486
|
+
orientation: ((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.orientation) === 'v' ? 'horizontal' : 'vertical',
|
|
1487
|
+
hideLegend: isMultiPlot || ((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.showlegend) === false
|
|
1488
|
+
};
|
|
1489
|
+
};
|
|
1073
1490
|
export const projectPolarToCartesian = (input)=>{
|
|
1491
|
+
var _input_layout, _input_layout1;
|
|
1074
1492
|
const projection = {
|
|
1075
1493
|
...input
|
|
1076
1494
|
};
|
|
1495
|
+
// Find the global min and max radius across all series
|
|
1496
|
+
let minRadius = 0;
|
|
1497
|
+
let maxRadius = 0;
|
|
1077
1498
|
for(let sindex = 0; sindex < input.data.length; sindex++){
|
|
1078
|
-
|
|
1499
|
+
const rVals = input.data[sindex].r;
|
|
1500
|
+
if (rVals && isArrayOrTypedArray(rVals)) {
|
|
1501
|
+
for(let ptindex = 0; ptindex < rVals.length; ptindex++){
|
|
1502
|
+
if (!isInvalidValue(rVals[ptindex])) {
|
|
1503
|
+
minRadius = Math.min(minRadius, rVals[ptindex]);
|
|
1504
|
+
maxRadius = Math.max(maxRadius, rVals[ptindex]);
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
// If there are negative radii, compute the shift
|
|
1510
|
+
const radiusShift = minRadius < 0 ? -minRadius : 0;
|
|
1511
|
+
// Collect all unique theta values from all scatterpolar series for equal spacing
|
|
1512
|
+
const allThetaValues = new Set();
|
|
1513
|
+
for(let sindex = 0; sindex < input.data.length; sindex++){
|
|
1514
|
+
const series = input.data[sindex];
|
|
1515
|
+
if (series.theta && isArrayOrTypedArray(series.theta)) {
|
|
1516
|
+
series.theta.forEach((theta)=>allThetaValues.add(String(theta)));
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
// Project all points and create a perfect square domain
|
|
1520
|
+
const allX = [];
|
|
1521
|
+
const allY = [];
|
|
1522
|
+
let originX = null;
|
|
1523
|
+
for(let sindex = 0; sindex < input.data.length; sindex++){
|
|
1524
|
+
var _input_layout_polar_angularaxis, _input_layout_polar, _input_layout2, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout3;
|
|
1079
1525
|
const series = input.data[sindex];
|
|
1526
|
+
// If scatterpolar, set __axisLabel to all unique theta values for equal spacing
|
|
1527
|
+
if (isArrayOrTypedArray(series.theta)) {
|
|
1528
|
+
series.__axisLabel = Array.from(allThetaValues);
|
|
1529
|
+
}
|
|
1080
1530
|
series.x = [];
|
|
1081
1531
|
series.y = [];
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1532
|
+
const thetas = series.theta;
|
|
1533
|
+
const rVals = series.r;
|
|
1534
|
+
// Skip if rVals or thetas are not arrays
|
|
1535
|
+
if (!isArrayOrTypedArray(rVals) || !isArrayOrTypedArray(thetas)) {
|
|
1536
|
+
projection.data[sindex] = series;
|
|
1537
|
+
continue;
|
|
1538
|
+
}
|
|
1539
|
+
// retrieve polar axis settings
|
|
1540
|
+
const dirMultiplier = ((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_polar = _input_layout2.polar) === null || _input_layout_polar === void 0 ? void 0 : (_input_layout_polar_angularaxis = _input_layout_polar.angularaxis) === null || _input_layout_polar_angularaxis === void 0 ? void 0 : _input_layout_polar_angularaxis.direction) === 'clockwise' ? -1 : 1;
|
|
1541
|
+
var _input_layout_polar_angularaxis_rotation;
|
|
1542
|
+
const startAngleInRad = ((_input_layout_polar_angularaxis_rotation = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_polar1 = _input_layout3.polar) === null || _input_layout_polar1 === void 0 ? void 0 : (_input_layout_polar_angularaxis1 = _input_layout_polar1.angularaxis) === null || _input_layout_polar_angularaxis1 === void 0 ? void 0 : _input_layout_polar_angularaxis1.rotation) !== null && _input_layout_polar_angularaxis_rotation !== void 0 ? _input_layout_polar_angularaxis_rotation : 0) * Math.PI / 180;
|
|
1543
|
+
// Compute tick positions if categorical
|
|
1544
|
+
let uniqueTheta = [];
|
|
1545
|
+
let categorical = false;
|
|
1546
|
+
if (!isNumberArray(thetas)) {
|
|
1547
|
+
uniqueTheta = Array.from(new Set(thetas));
|
|
1548
|
+
categorical = true;
|
|
1549
|
+
}
|
|
1550
|
+
for(let ptindex = 0; ptindex < rVals.length; ptindex++){
|
|
1551
|
+
if (isInvalidValue(thetas === null || thetas === void 0 ? void 0 : thetas[ptindex]) || isInvalidValue(rVals === null || rVals === void 0 ? void 0 : rVals[ptindex])) {
|
|
1086
1552
|
continue;
|
|
1087
1553
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1554
|
+
// Map theta to angle in radians
|
|
1555
|
+
let thetaRad;
|
|
1556
|
+
if (categorical) {
|
|
1557
|
+
const idx = uniqueTheta.indexOf(thetas[ptindex]);
|
|
1558
|
+
const step = 2 * Math.PI / uniqueTheta.length;
|
|
1559
|
+
thetaRad = startAngleInRad + dirMultiplier * idx * step;
|
|
1560
|
+
} else {
|
|
1561
|
+
thetaRad = startAngleInRad + dirMultiplier * (thetas[ptindex] * Math.PI / 180);
|
|
1562
|
+
}
|
|
1563
|
+
// Shift only the polar origin (not the cartesian)
|
|
1564
|
+
const rawRadius = rVals[ptindex];
|
|
1565
|
+
const polarRadius = rawRadius + radiusShift; // Only for projection
|
|
1566
|
+
// Calculate cartesian coordinates (with shifted polar origin)
|
|
1567
|
+
const x = polarRadius * Math.cos(thetaRad);
|
|
1568
|
+
const y = polarRadius * Math.sin(thetaRad);
|
|
1569
|
+
// Calculate the cartesian coordinates of the original polar origin (0,0)
|
|
1570
|
+
// This is the point that should be mapped to (0,0) in cartesian coordinates
|
|
1571
|
+
if (sindex === 0 && ptindex === 0) {
|
|
1572
|
+
// For polar origin (r=0, θ=0), cartesian coordinates are (0,0)
|
|
1573
|
+
// But since we shifted the radius by radiusShift, the cartesian origin is at (radiusShift, 0)
|
|
1574
|
+
originX = radiusShift;
|
|
1575
|
+
}
|
|
1576
|
+
series.x.push(x);
|
|
1577
|
+
series.y.push(y);
|
|
1578
|
+
allX.push(x);
|
|
1579
|
+
allY.push(y);
|
|
1580
|
+
}
|
|
1581
|
+
// Map text to each data point for downstream chart rendering
|
|
1582
|
+
if (series.x && series.y) {
|
|
1583
|
+
series.data = series.x.map((xVal, idx)=>({
|
|
1584
|
+
x: xVal,
|
|
1585
|
+
y: series.y[idx],
|
|
1586
|
+
...series.text ? {
|
|
1587
|
+
text: series.text[idx]
|
|
1588
|
+
} : {}
|
|
1589
|
+
}));
|
|
1092
1590
|
}
|
|
1093
1591
|
projection.data[sindex] = series;
|
|
1094
1592
|
}
|
|
1593
|
+
// 7. Recenter all cartesian coordinates
|
|
1594
|
+
if (originX !== null) {
|
|
1595
|
+
for(let sindex = 0; sindex < projection.data.length; sindex++){
|
|
1596
|
+
const series = projection.data[sindex];
|
|
1597
|
+
if (series.x && series.y) {
|
|
1598
|
+
series.x = series.x.map((v)=>v - originX);
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
// Also recenter allX for normalization
|
|
1602
|
+
for(let i = 0; i < allX.length; i++){
|
|
1603
|
+
allX[i] = allX[i] - originX;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
// 8. Find the maximum absolute value among all x and y
|
|
1607
|
+
let maxAbs = Math.max(...allX.map(Math.abs), ...allY.map(Math.abs));
|
|
1608
|
+
maxAbs = maxAbs === 0 ? 1 : maxAbs;
|
|
1609
|
+
// 9. Rescale all points so that the largest |x| or |y| is 0.5
|
|
1610
|
+
for(let sindex = 0; sindex < projection.data.length; sindex++){
|
|
1611
|
+
const series = projection.data[sindex];
|
|
1612
|
+
if (series.x && series.y) {
|
|
1613
|
+
series.x = series.x.map((v)=>v / (2 * maxAbs));
|
|
1614
|
+
series.y = series.y.map((v)=>v / (2 * maxAbs));
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
// 10. Customize layout for perfect square with absolute positioning
|
|
1618
|
+
const size = ((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width) || ((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) || 500;
|
|
1619
|
+
projection.layout = {
|
|
1620
|
+
...projection.layout,
|
|
1621
|
+
width: size,
|
|
1622
|
+
height: size
|
|
1623
|
+
};
|
|
1624
|
+
// Attach originX as custom properties
|
|
1625
|
+
projection.layout.__polarOriginX = originX !== null && originX !== void 0 ? originX : undefined;
|
|
1095
1626
|
return projection;
|
|
1096
1627
|
};
|
|
1097
1628
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1202,7 +1733,7 @@ const createBins = (data, binStart, binEnd, binSize)=>{
|
|
|
1202
1733
|
]);
|
|
1203
1734
|
if (typeof binSize === 'number' && binSize > 0) {
|
|
1204
1735
|
const thresholds = [];
|
|
1205
|
-
const precision = Math.max(
|
|
1736
|
+
const precision = Math.max(calculatePrecision(minVal), calculatePrecision(binSize));
|
|
1206
1737
|
let th = precisionRound(minVal, precision);
|
|
1207
1738
|
while(th < precisionRound(maxVal + binSize, precision)){
|
|
1208
1739
|
thresholds.push(th);
|
|
@@ -1252,15 +1783,6 @@ const calculateHistNorm = (histnorm, value, total, dx, dy = 1)=>{
|
|
|
1252
1783
|
return value;
|
|
1253
1784
|
}
|
|
1254
1785
|
};
|
|
1255
|
-
const getPrecision = (value)=>{
|
|
1256
|
-
var _value_toString_split_;
|
|
1257
|
-
var _value_toString_split__length;
|
|
1258
|
-
return (_value_toString_split__length = (_value_toString_split_ = value.toString().split('.')[1]) === null || _value_toString_split_ === void 0 ? void 0 : _value_toString_split_.length) !== null && _value_toString_split__length !== void 0 ? _value_toString_split__length : 0;
|
|
1259
|
-
};
|
|
1260
|
-
const precisionRound = (value, precision)=>{
|
|
1261
|
-
const factor = Math.pow(10, precision);
|
|
1262
|
-
return Math.round(value * factor) / factor;
|
|
1263
|
-
};
|
|
1264
1786
|
const getLegendShape = (series)=>{
|
|
1265
1787
|
var _series_line, _series_mode;
|
|
1266
1788
|
const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
|
|
@@ -1271,25 +1793,44 @@ const getLegendShape = (series)=>{
|
|
|
1271
1793
|
}
|
|
1272
1794
|
return 'default';
|
|
1273
1795
|
};
|
|
1274
|
-
export const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
1796
|
+
export const getAllupLegendsProps = (input, colorMap, colorwayType, traceInfo, isDarkTheme)=>{
|
|
1275
1797
|
const allupLegends = [];
|
|
1276
1798
|
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1277
1799
|
const toShowLegend = input.data.reduce((acc, series)=>{
|
|
1278
|
-
return acc || series.showlegend === true;
|
|
1800
|
+
return acc || series.showlegend === true || series.showlegend === undefined;
|
|
1279
1801
|
}, false);
|
|
1280
1802
|
if (toShowLegend) {
|
|
1281
1803
|
input.data.forEach((series, index)=>{
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
color
|
|
1291
|
-
|
|
1804
|
+
if (traceInfo[index].type === 'donut') {
|
|
1805
|
+
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _pieSeries_marker, _pieSeries_labels;
|
|
1806
|
+
const pieSeries = series;
|
|
1807
|
+
var _input_layout_piecolorway, _input_layout_piecolorway1;
|
|
1808
|
+
const colors = extractColor((_input_layout_piecolorway = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.piecolorway) !== null && _input_layout_piecolorway !== void 0 ? _input_layout_piecolorway : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_input_layout_piecolorway1 = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.piecolorway) !== null && _input_layout_piecolorway1 !== void 0 ? _input_layout_piecolorway1 : pieSeries === null || pieSeries === void 0 ? void 0 : (_pieSeries_marker = pieSeries.marker) === null || _pieSeries_marker === void 0 ? void 0 : _pieSeries_marker.colors, colorMap, isDarkTheme);
|
|
1809
|
+
(_pieSeries_labels = pieSeries.labels) === null || _pieSeries_labels === void 0 ? void 0 : _pieSeries_labels.forEach((label, labelIndex)=>{
|
|
1810
|
+
const legend = `${label}`;
|
|
1811
|
+
// resolve color for each legend from the extracted colors
|
|
1812
|
+
const color = resolveColor(colors, labelIndex, legend, colorMap, isDarkTheme);
|
|
1813
|
+
if (legend !== '' && allupLegends.some((group)=>group.title === legend) === false) {
|
|
1814
|
+
allupLegends.push({
|
|
1815
|
+
title: legend,
|
|
1816
|
+
color
|
|
1817
|
+
});
|
|
1818
|
+
}
|
|
1292
1819
|
});
|
|
1820
|
+
} else if (isNonPlotType(traceInfo[index].type) === false) {
|
|
1821
|
+
var _plotSeries_line, _plotSeries_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout3;
|
|
1822
|
+
const plotSeries = series;
|
|
1823
|
+
const name = plotSeries.legendgroup;
|
|
1824
|
+
const color = ((_plotSeries_line = plotSeries.line) === null || _plotSeries_line === void 0 ? void 0 : _plotSeries_line.color) || ((_plotSeries_marker = plotSeries.marker) === null || _plotSeries_marker === void 0 ? void 0 : _plotSeries_marker.color);
|
|
1825
|
+
const legendShape = getLegendShape(plotSeries);
|
|
1826
|
+
const resolvedColor = extractColor((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_template1 = _input_layout3.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, color, colorMap, isDarkTheme);
|
|
1827
|
+
if (name !== undefined && name !== '' && allupLegends.some((group)=>group.title === name) === false) {
|
|
1828
|
+
allupLegends.push({
|
|
1829
|
+
title: name,
|
|
1830
|
+
color: resolvedColor,
|
|
1831
|
+
shape: legendShape
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1293
1834
|
}
|
|
1294
1835
|
});
|
|
1295
1836
|
}
|
|
@@ -1355,28 +1896,21 @@ const getIndexFromKey = (key, pattern)=>{
|
|
|
1355
1896
|
const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1356
1897
|
return parseInt(normalizedKey, 10) - 1;
|
|
1357
1898
|
};
|
|
1358
|
-
export const
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1899
|
+
export const isNonPlotType = (chartType)=>{
|
|
1900
|
+
return [
|
|
1901
|
+
'donut',
|
|
1902
|
+
'sankey',
|
|
1903
|
+
'pie'
|
|
1904
|
+
].includes(chartType);
|
|
1905
|
+
};
|
|
1906
|
+
export const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
|
|
1907
|
+
const domainX = [];
|
|
1908
|
+
const domainY = [];
|
|
1909
|
+
let cartesianDomains = 0;
|
|
1362
1910
|
const annotations = {};
|
|
1363
1911
|
let templateRows = '1fr';
|
|
1364
1912
|
let templateColumns = '1fr';
|
|
1365
1913
|
const gridLayout = {};
|
|
1366
|
-
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1367
|
-
return {
|
|
1368
|
-
templateRows,
|
|
1369
|
-
templateColumns,
|
|
1370
|
-
layout: gridLayout
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
if (!layout.xaxis || !layout.yaxis) {
|
|
1374
|
-
return {
|
|
1375
|
-
templateRows,
|
|
1376
|
-
templateColumns,
|
|
1377
|
-
layout: gridLayout
|
|
1378
|
-
};
|
|
1379
|
-
}
|
|
1380
1914
|
if (!isMultiPlot) {
|
|
1381
1915
|
return {
|
|
1382
1916
|
templateRows,
|
|
@@ -1384,144 +1918,144 @@ export const getGridProperties = (layout, isMultiPlot)=>{
|
|
|
1384
1918
|
layout: gridLayout
|
|
1385
1919
|
};
|
|
1386
1920
|
}
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
gridX[index] = (_layout_key_domain = (_layout_key1 = layout[key]) === null || _layout_key1 === void 0 ? void 0 : _layout_key1.domain) !== null && _layout_key_domain !== void 0 ? _layout_key_domain : [];
|
|
1399
|
-
} else if (key.startsWith('yaxis')) {
|
|
1400
|
-
var _layout_key2, _layout_key3;
|
|
1401
|
-
const index = getIndexFromKey(key, 'yaxis');
|
|
1402
|
-
var _layout_key_anchor1;
|
|
1403
|
-
const anchor = (_layout_key_anchor1 = (_layout_key2 = layout[key]) === null || _layout_key2 === void 0 ? void 0 : _layout_key2.anchor) !== null && _layout_key_anchor1 !== void 0 ? _layout_key_anchor1 : 'x';
|
|
1404
|
-
const anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1405
|
-
if (index !== anchorIndex) {
|
|
1406
|
-
var _layout_yaxis2;
|
|
1407
|
-
if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
|
|
1408
|
-
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1409
|
-
return {
|
|
1410
|
-
templateRows,
|
|
1411
|
-
templateColumns
|
|
1412
|
-
};
|
|
1921
|
+
const layout = schema === null || schema === void 0 ? void 0 : schema.layout;
|
|
1922
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
1923
|
+
Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach((key)=>{
|
|
1924
|
+
if (key.startsWith('xaxis')) {
|
|
1925
|
+
var _layout_key;
|
|
1926
|
+
const index = getIndexFromKey(key, 'xaxis');
|
|
1927
|
+
var _layout_key_anchor;
|
|
1928
|
+
const anchor = (_layout_key_anchor = (_layout_key = layout[key]) === null || _layout_key === void 0 ? void 0 : _layout_key.anchor) !== null && _layout_key_anchor !== void 0 ? _layout_key_anchor : 'y';
|
|
1929
|
+
const anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1930
|
+
if (index !== anchorIndex) {
|
|
1931
|
+
throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
|
|
1413
1932
|
}
|
|
1414
|
-
|
|
1933
|
+
const xAxisLayout = layout[key];
|
|
1934
|
+
const domainXInfo = {
|
|
1935
|
+
start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
|
|
1936
|
+
end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1
|
|
1937
|
+
};
|
|
1938
|
+
domainX.push(domainXInfo);
|
|
1939
|
+
} else if (key.startsWith('yaxis')) {
|
|
1940
|
+
var _layout_key1;
|
|
1941
|
+
const index = getIndexFromKey(key, 'yaxis');
|
|
1942
|
+
var _layout_key_anchor1;
|
|
1943
|
+
const anchor = (_layout_key_anchor1 = (_layout_key1 = layout[key]) === null || _layout_key1 === void 0 ? void 0 : _layout_key1.anchor) !== null && _layout_key_anchor1 !== void 0 ? _layout_key_anchor1 : 'x';
|
|
1944
|
+
const anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1945
|
+
if (index !== anchorIndex) {
|
|
1946
|
+
var _layout_yaxis2;
|
|
1947
|
+
if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
|
|
1948
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1949
|
+
return {
|
|
1950
|
+
templateRows,
|
|
1951
|
+
templateColumns
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
|
|
1955
|
+
}
|
|
1956
|
+
const yAxisLayout = layout[key];
|
|
1957
|
+
const domainYInfo = {
|
|
1958
|
+
start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
|
|
1959
|
+
end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1
|
|
1960
|
+
};
|
|
1961
|
+
domainY.push(domainYInfo);
|
|
1415
1962
|
}
|
|
1416
|
-
|
|
1417
|
-
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
|
|
1966
|
+
validTracesInfo.forEach((trace, index)=>{
|
|
1967
|
+
if (isNonPlotType(trace.type)) {
|
|
1968
|
+
var _schema_data, _series_domain, _series_domain1, _series_domain2, _series_domain3;
|
|
1969
|
+
const series = schema === null || schema === void 0 ? void 0 : (_schema_data = schema.data) === null || _schema_data === void 0 ? void 0 : _schema_data[index];
|
|
1970
|
+
const domainXInfo = {
|
|
1971
|
+
start: ((_series_domain = series.domain) === null || _series_domain === void 0 ? void 0 : _series_domain.x) ? series.domain.x[0] : 0,
|
|
1972
|
+
end: ((_series_domain1 = series.domain) === null || _series_domain1 === void 0 ? void 0 : _series_domain1.x) ? series.domain.x[1] : 1
|
|
1973
|
+
};
|
|
1974
|
+
const domainYInfo = {
|
|
1975
|
+
start: ((_series_domain2 = series.domain) === null || _series_domain2 === void 0 ? void 0 : _series_domain2.y) ? series.domain.y[0] : 0,
|
|
1976
|
+
end: ((_series_domain3 = series.domain) === null || _series_domain3 === void 0 ? void 0 : _series_domain3.y) ? series.domain.y[1] : 1
|
|
1977
|
+
};
|
|
1978
|
+
domainX.push(domainXInfo);
|
|
1979
|
+
domainY.push(domainYInfo);
|
|
1418
1980
|
}
|
|
1419
1981
|
});
|
|
1420
|
-
(
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1982
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
1983
|
+
var _layout_annotations;
|
|
1984
|
+
(_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
|
|
1985
|
+
const xMatches = domainX.flatMap((interval, idx)=>(annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval.start && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval.end ? [
|
|
1986
|
+
idx
|
|
1987
|
+
] : []);
|
|
1988
|
+
const yMatch = domainY.findIndex((interval, yIndex)=>xMatches.includes(yIndex) && (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval.start && (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval.end);
|
|
1989
|
+
if (yMatch !== -1) {
|
|
1990
|
+
if (annotations[yMatch] === undefined) {
|
|
1991
|
+
annotations[yMatch] = {};
|
|
1992
|
+
}
|
|
1993
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1994
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1995
|
+
} else {
|
|
1996
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1997
|
+
}
|
|
1433
1998
|
}
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
if (
|
|
1999
|
+
});
|
|
2000
|
+
}
|
|
2001
|
+
if (domainX.length > 0) {
|
|
1437
2002
|
const uniqueXIntervals = new Map();
|
|
1438
|
-
|
|
1439
|
-
const key = `${interval
|
|
2003
|
+
domainX.forEach((interval)=>{
|
|
2004
|
+
const key = `${interval.start}-${interval.end}`;
|
|
1440
2005
|
if (!uniqueXIntervals.has(key)) {
|
|
1441
2006
|
uniqueXIntervals.set(key, interval);
|
|
1442
2007
|
}
|
|
1443
2008
|
});
|
|
1444
|
-
const
|
|
1445
|
-
templateColumns =
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
return;
|
|
1451
|
-
}
|
|
1452
|
-
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
2009
|
+
const sortedXStart = Array.from(uniqueXIntervals.values()).map((interval)=>interval.start).sort();
|
|
2010
|
+
templateColumns = `repeat(${sortedXStart.length}, 1fr)`;
|
|
2011
|
+
domainX.forEach((interval, index)=>{
|
|
2012
|
+
const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
|
|
2013
|
+
const columnIndex = sortedXStart.findIndex((start)=>start === interval.start);
|
|
2014
|
+
const columnNumber = columnIndex + 1; // Column numbers are 1-based
|
|
1453
2015
|
const annotationProps = annotations[index];
|
|
1454
2016
|
const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1455
|
-
if (interval[0] < lastIntervalEnd) {
|
|
1456
|
-
columnNumber = 1;
|
|
1457
|
-
}
|
|
1458
|
-
lastIntervalEnd = interval[1];
|
|
1459
2017
|
const row = {
|
|
1460
2018
|
row: -1,
|
|
1461
2019
|
column: columnNumber,
|
|
1462
|
-
xAnnotation
|
|
2020
|
+
xAnnotation,
|
|
2021
|
+
xDomain: interval,
|
|
2022
|
+
yDomain: {
|
|
2023
|
+
start: 0,
|
|
2024
|
+
end: 1
|
|
2025
|
+
}
|
|
1463
2026
|
};
|
|
1464
2027
|
gridLayout[cellName] = row;
|
|
1465
|
-
columnNumber += 1;
|
|
1466
2028
|
});
|
|
1467
2029
|
}
|
|
1468
|
-
|
|
1469
|
-
var _cell_column;
|
|
1470
|
-
return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
|
|
1471
|
-
}));
|
|
1472
|
-
const columnFill = {};
|
|
1473
|
-
for(let i = 1; i <= numColumns; i++){
|
|
1474
|
-
columnFill[i] = {
|
|
1475
|
-
row: 1,
|
|
1476
|
-
fillDomain: 0
|
|
1477
|
-
};
|
|
1478
|
-
}
|
|
1479
|
-
if (gridY.length > 0) {
|
|
2030
|
+
if (domainY.length > 0) {
|
|
1480
2031
|
const uniqueYIntervals = new Map();
|
|
1481
|
-
|
|
1482
|
-
const key = `${interval
|
|
2032
|
+
domainY.forEach((interval)=>{
|
|
2033
|
+
const key = `${interval.start}-${interval.end}`;
|
|
1483
2034
|
if (!uniqueYIntervals.has(key)) {
|
|
1484
2035
|
uniqueYIntervals.set(key, interval);
|
|
1485
2036
|
}
|
|
1486
2037
|
});
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
const
|
|
2038
|
+
const sortedYStart = Array.from(uniqueYIntervals.values()).map((interval)=>interval.start).sort();
|
|
2039
|
+
const numberOfRows = sortedYStart.length;
|
|
2040
|
+
templateRows = `repeat(${numberOfRows}, 1fr)`;
|
|
2041
|
+
domainY.forEach((interval, index)=>{
|
|
2042
|
+
const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
|
|
2043
|
+
const rowIndex = sortedYStart.findIndex((start)=>start === interval.start);
|
|
2044
|
+
const rowNumber = numberOfRows - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
|
|
1494
2045
|
const annotationProps = annotations[index];
|
|
1495
2046
|
const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1496
2047
|
const cell = gridLayout[cellName];
|
|
1497
2048
|
if (cell !== undefined) {
|
|
1498
|
-
cell.row =
|
|
2049
|
+
cell.row = rowNumber;
|
|
1499
2050
|
cell.yAnnotation = yAnnotation;
|
|
2051
|
+
cell.yDomain = interval;
|
|
1500
2052
|
}
|
|
1501
|
-
columnFill[cell.column].fillDomain = interval[1];
|
|
1502
|
-
columnFill[cell.column].row += 1;
|
|
1503
2053
|
});
|
|
1504
2054
|
}
|
|
1505
|
-
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1506
|
-
const reversedGridLayout = {};
|
|
1507
|
-
// find the maximum row number
|
|
1508
|
-
const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1509
|
-
var _cell_row;
|
|
1510
|
-
return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
|
|
1511
|
-
}));
|
|
1512
|
-
// iterate over the gridLayout and reverse the row numbers
|
|
1513
|
-
Object.keys(gridLayout).forEach((key)=>{
|
|
1514
|
-
const cell = gridLayout[key];
|
|
1515
|
-
if (cell.row !== undefined) {
|
|
1516
|
-
// reverse the row number
|
|
1517
|
-
cell.row = maxRowNumber - cell.row + 1;
|
|
1518
|
-
}
|
|
1519
|
-
reversedGridLayout[key] = cell;
|
|
1520
|
-
});
|
|
1521
2055
|
return {
|
|
1522
2056
|
templateRows,
|
|
1523
2057
|
templateColumns,
|
|
1524
|
-
layout:
|
|
2058
|
+
layout: gridLayout
|
|
1525
2059
|
};
|
|
1526
2060
|
};
|
|
1527
2061
|
/**
|
|
@@ -1563,3 +2097,228 @@ export const getGridProperties = (layout, isMultiPlot)=>{
|
|
|
1563
2097
|
});
|
|
1564
2098
|
return result;
|
|
1565
2099
|
};
|
|
2100
|
+
const getBarProps = (data, layout, isHorizontal)=>{
|
|
2101
|
+
let padding;
|
|
2102
|
+
if (typeof (layout === null || layout === void 0 ? void 0 : layout.bargap) === 'number') {
|
|
2103
|
+
if (layout.bargap >= 0 && layout.bargap <= 1) {
|
|
2104
|
+
padding = layout.bargap;
|
|
2105
|
+
} else {
|
|
2106
|
+
// Plotly uses a default bargap of 0.2, as noted here: https://github.com/plotly/plotly.js/blob/1d5a249e43dd31ae50acf02117a19e5ac97387e9/src/traces/bar/layout_defaults.js#L58.
|
|
2107
|
+
// However, we don't use this value as our default padding because it causes the bars to
|
|
2108
|
+
// appear disproportionately wide in large containers.
|
|
2109
|
+
padding = 0.2;
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
const plotlyBarWidths = data.map((series)=>{
|
|
2113
|
+
if (series.type === 'bar' && (isArrayOrTypedArray(series.width) || typeof series.width === 'number')) {
|
|
2114
|
+
return series.width;
|
|
2115
|
+
}
|
|
2116
|
+
return [];
|
|
2117
|
+
}).flat();
|
|
2118
|
+
const maxPlotlyBarWidth = d3Max(plotlyBarWidths);
|
|
2119
|
+
if (typeof maxPlotlyBarWidth === 'number') {
|
|
2120
|
+
padding = 1 - maxPlotlyBarWidth;
|
|
2121
|
+
padding = Math.max(0, Math.min(padding, 1));
|
|
2122
|
+
}
|
|
2123
|
+
if (typeof padding === 'undefined') {
|
|
2124
|
+
return {};
|
|
2125
|
+
}
|
|
2126
|
+
if (isHorizontal) {
|
|
2127
|
+
return {
|
|
2128
|
+
maxBarHeight: 1000,
|
|
2129
|
+
yAxisPadding: padding
|
|
2130
|
+
};
|
|
2131
|
+
}
|
|
2132
|
+
return {
|
|
2133
|
+
barWidth: 'auto',
|
|
2134
|
+
maxBarWidth: 1000,
|
|
2135
|
+
xAxisInnerPadding: padding,
|
|
2136
|
+
xAxisOuterPadding: padding / 2
|
|
2137
|
+
};
|
|
2138
|
+
};
|
|
2139
|
+
const getAxisScaleTypeProps = (data, layout)=>{
|
|
2140
|
+
var _axisObjects_x, _axisObjects_y, _axisObjects_y2;
|
|
2141
|
+
const result = {};
|
|
2142
|
+
const axisObjects = getAxisObjects(data, layout);
|
|
2143
|
+
if (((_axisObjects_x = axisObjects.x) === null || _axisObjects_x === void 0 ? void 0 : _axisObjects_x.type) === 'log') {
|
|
2144
|
+
result.xScaleType = 'log';
|
|
2145
|
+
}
|
|
2146
|
+
if (((_axisObjects_y = axisObjects.y) === null || _axisObjects_y === void 0 ? void 0 : _axisObjects_y.type) === 'log') {
|
|
2147
|
+
result.yScaleType = 'log';
|
|
2148
|
+
}
|
|
2149
|
+
if (((_axisObjects_y2 = axisObjects.y2) === null || _axisObjects_y2 === void 0 ? void 0 : _axisObjects_y2.type) === 'log') {
|
|
2150
|
+
result.secondaryYScaleType = 'log';
|
|
2151
|
+
}
|
|
2152
|
+
return result;
|
|
2153
|
+
};
|
|
2154
|
+
/**
|
|
2155
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/tick_value_defaults.js#L8}
|
|
2156
|
+
*/ const getAxisTickProps = (data, layout)=>{
|
|
2157
|
+
const props = {};
|
|
2158
|
+
const axisObjects = getAxisObjects(data, layout);
|
|
2159
|
+
Object.keys(axisObjects).forEach((axId)=>{
|
|
2160
|
+
const ax = axisObjects[axId];
|
|
2161
|
+
if (!ax) {
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
const axType = getAxisType(data, axId[0], ax);
|
|
2165
|
+
if ((!ax.tickmode || ax.tickmode === 'array') && isArrayOrTypedArray(ax.tickvals)) {
|
|
2166
|
+
const tickValues = axType === 'date' ? ax.tickvals.map((v)=>new Date(v)) : ax.tickvals;
|
|
2167
|
+
if (axId === 'x') {
|
|
2168
|
+
props.tickValues = tickValues;
|
|
2169
|
+
} else if (axId === 'y') {
|
|
2170
|
+
props.yAxisTickValues = tickValues;
|
|
2171
|
+
}
|
|
2172
|
+
return;
|
|
2173
|
+
}
|
|
2174
|
+
if ((!ax.tickmode || ax.tickmode === 'linear') && ax.dtick) {
|
|
2175
|
+
const dtick = plotlyDtick(ax.dtick, axType);
|
|
2176
|
+
const tick0 = plotlyTick0(ax.tick0, axType, dtick);
|
|
2177
|
+
if (axId === 'x') {
|
|
2178
|
+
props.xAxis = {
|
|
2179
|
+
tickStep: dtick,
|
|
2180
|
+
tick0: tick0
|
|
2181
|
+
};
|
|
2182
|
+
} else if (axId === 'y') {
|
|
2183
|
+
props.yAxis = {
|
|
2184
|
+
tickStep: dtick,
|
|
2185
|
+
tick0: tick0
|
|
2186
|
+
};
|
|
2187
|
+
}
|
|
2188
|
+
return;
|
|
2189
|
+
}
|
|
2190
|
+
if ((!ax.tickmode || ax.tickmode === 'auto') && typeof ax.nticks === 'number' && ax.nticks >= 0) {
|
|
2191
|
+
if (axId === 'x') {
|
|
2192
|
+
props.xAxisTickCount = ax.nticks;
|
|
2193
|
+
} else if (axId === 'y') {
|
|
2194
|
+
props.yAxisTickCount = ax.nticks;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
});
|
|
2198
|
+
return props;
|
|
2199
|
+
};
|
|
2200
|
+
/**
|
|
2201
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L16}
|
|
2202
|
+
*/ const plotlyDtick = (dtick, axType)=>{
|
|
2203
|
+
const isLogAx = axType === 'log';
|
|
2204
|
+
const isDateAx = axType === 'date';
|
|
2205
|
+
const isCatAx = axType === 'category';
|
|
2206
|
+
const dtickDflt = isDateAx ? 86400000 : 1;
|
|
2207
|
+
if (!dtick) {
|
|
2208
|
+
return dtickDflt;
|
|
2209
|
+
}
|
|
2210
|
+
if (isNumber(dtick)) {
|
|
2211
|
+
dtick = Number(dtick);
|
|
2212
|
+
if (dtick <= 0) {
|
|
2213
|
+
return dtickDflt;
|
|
2214
|
+
}
|
|
2215
|
+
if (isCatAx) {
|
|
2216
|
+
// category dtick must be positive integers
|
|
2217
|
+
return Math.max(1, Math.round(dtick));
|
|
2218
|
+
}
|
|
2219
|
+
if (isDateAx) {
|
|
2220
|
+
// date dtick must be at least 0.1ms (our current precision)
|
|
2221
|
+
return Math.max(0.1, dtick);
|
|
2222
|
+
}
|
|
2223
|
+
return dtick;
|
|
2224
|
+
}
|
|
2225
|
+
if (typeof dtick !== 'string' || !(isDateAx || isLogAx)) {
|
|
2226
|
+
return dtickDflt;
|
|
2227
|
+
}
|
|
2228
|
+
const prefix = dtick.charAt(0);
|
|
2229
|
+
const dtickNum = isNumber(dtick.slice(1)) ? Number(dtick.slice(1)) : 0;
|
|
2230
|
+
if (dtickNum <= 0 || !// "M<n>" gives ticks every (integer) n months
|
|
2231
|
+
(isDateAx && prefix === 'M' && dtickNum === Math.round(dtickNum) || // "L<f>" gives ticks linearly spaced in data (not in position) every (float) f
|
|
2232
|
+
isLogAx && prefix === 'L' || // "D1" gives powers of 10 with all small digits between, "D2" gives only 2 and 5
|
|
2233
|
+
isLogAx && prefix === 'D' && (dtickNum === 1 || dtickNum === 2))) {
|
|
2234
|
+
return dtickDflt;
|
|
2235
|
+
}
|
|
2236
|
+
return dtick;
|
|
2237
|
+
};
|
|
2238
|
+
/**
|
|
2239
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L70}
|
|
2240
|
+
*/ const plotlyTick0 = (tick0, axType, dtick)=>{
|
|
2241
|
+
if (axType === 'date') {
|
|
2242
|
+
return isDate(tick0) ? new Date(tick0) : new Date(DEFAULT_DATE_STRING);
|
|
2243
|
+
}
|
|
2244
|
+
if (dtick === 'D1' || dtick === 'D2') {
|
|
2245
|
+
// D1 and D2 modes ignore tick0 entirely
|
|
2246
|
+
return undefined;
|
|
2247
|
+
}
|
|
2248
|
+
// Aside from date axes, tick0 must be numeric
|
|
2249
|
+
return isNumber(tick0) ? Number(tick0) : 0;
|
|
2250
|
+
};
|
|
2251
|
+
const getAxisObjects = (data, layout)=>{
|
|
2252
|
+
// Traces are grouped by their xaxis property, and for each group/subplot, the adapter functions
|
|
2253
|
+
// are called with the corresponding filtered data. As a result, all traces passed to an adapter
|
|
2254
|
+
// function share the same xaxis.
|
|
2255
|
+
let xAxisId;
|
|
2256
|
+
const yAxisIds = new Set();
|
|
2257
|
+
data.forEach((series)=>{
|
|
2258
|
+
const axisIds = getAxisIds(series);
|
|
2259
|
+
xAxisId = axisIds.x;
|
|
2260
|
+
yAxisIds.add(axisIds.y);
|
|
2261
|
+
});
|
|
2262
|
+
const axisObjects = {};
|
|
2263
|
+
if (typeof xAxisId === 'number') {
|
|
2264
|
+
axisObjects.x = layout === null || layout === void 0 ? void 0 : layout[getAxisKey('x', xAxisId)];
|
|
2265
|
+
}
|
|
2266
|
+
const sortedYAxisIds = Array.from(yAxisIds).sort();
|
|
2267
|
+
if (sortedYAxisIds.length > 0) {
|
|
2268
|
+
axisObjects.y = layout === null || layout === void 0 ? void 0 : layout[getAxisKey('y', sortedYAxisIds[0])];
|
|
2269
|
+
}
|
|
2270
|
+
if (sortedYAxisIds.length > 1) {
|
|
2271
|
+
axisObjects.y2 = layout === null || layout === void 0 ? void 0 : layout[getAxisKey('y', sortedYAxisIds[1])];
|
|
2272
|
+
}
|
|
2273
|
+
return axisObjects;
|
|
2274
|
+
};
|
|
2275
|
+
const getAxisType = (data, axLetter, ax)=>{
|
|
2276
|
+
const values = [];
|
|
2277
|
+
data.forEach((series)=>{
|
|
2278
|
+
var _series_axLetter;
|
|
2279
|
+
(_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
|
|
2280
|
+
if (!isInvalidValue(val)) {
|
|
2281
|
+
values.push(val);
|
|
2282
|
+
}
|
|
2283
|
+
});
|
|
2284
|
+
});
|
|
2285
|
+
// Note: When ax.type is explicitly specified, Plotly casts the values to match that type.
|
|
2286
|
+
// Therefore, simply checking the type of the values may not be sufficient. At the moment,
|
|
2287
|
+
// we don’t always perform this casting ourselves and instead use the values as provided.
|
|
2288
|
+
if (isNumberArray(values)) {
|
|
2289
|
+
if ((ax === null || ax === void 0 ? void 0 : ax.type) === 'log') {
|
|
2290
|
+
return 'log';
|
|
2291
|
+
}
|
|
2292
|
+
return 'linear';
|
|
2293
|
+
}
|
|
2294
|
+
if (isDateArray(values)) {
|
|
2295
|
+
return 'date';
|
|
2296
|
+
}
|
|
2297
|
+
if (isStringArray(values)) {
|
|
2298
|
+
return 'category';
|
|
2299
|
+
}
|
|
2300
|
+
};
|
|
2301
|
+
/**
|
|
2302
|
+
* This is experimental. Use it only with valid datetime strings to verify if they conform to the ISO 8601 format.
|
|
2303
|
+
*/ const isoDateRegex = /^\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z)?)?$/;
|
|
2304
|
+
/**
|
|
2305
|
+
* We want to display localized date and time in the charts, so the useUTC prop is set to false.
|
|
2306
|
+
* But this can sometimes cause the formatters to display the datetime incorrectly.
|
|
2307
|
+
* To work around this issue, we use this function to adjust datetime strings so that they are always interpreted
|
|
2308
|
+
* as local time, allowing the formatters to produce the correct output.
|
|
2309
|
+
*
|
|
2310
|
+
* FIXME: The formatters should always produce a clear and accurate localized output, regardless of the
|
|
2311
|
+
* format used to create the date object.
|
|
2312
|
+
*/ const parseLocalDate = (value)=>{
|
|
2313
|
+
if (typeof value === 'string') {
|
|
2314
|
+
const match = value.match(isoDateRegex);
|
|
2315
|
+
if (match) {
|
|
2316
|
+
if (!match[3]) {
|
|
2317
|
+
value += 'T00:00';
|
|
2318
|
+
} else if (match[6]) {
|
|
2319
|
+
value = value.replace('Z', '');
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
return new Date(value);
|
|
2324
|
+
};
|