@fluentui/react-charts 9.2.2 → 9.2.4
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 +74 -2
- package/dist/index.d.ts +187 -15
- package/lib/components/AreaChart/AreaChart.js +7 -4
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +4 -3
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +5 -16
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +90 -6
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +83 -38
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +19 -3
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +8 -23
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +214 -107
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +25 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +1618 -259
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/useArcStyles.styles.js +8 -3
- package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js +6 -2
- package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +8 -3
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.js +21 -4
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +8 -4
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js +4 -2
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js +2 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +1 -2
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +31 -10
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +6 -18
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +6 -22
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +175 -114
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js +1 -1
- package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +7 -3
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +5 -2
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +26 -6
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +349 -176
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +28 -8
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js +9 -14
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
- package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +12 -25
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -12
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +139 -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 +29 -8
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +10 -15
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +28 -5
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +10 -7
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +7 -20
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +159 -47
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +9 -7
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +6 -20
- 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/SVGTooltipText.js.map +1 -1
- 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 +324 -147
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +6 -3
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +2 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +4 -15
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +90 -6
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +83 -37
- 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/useCartesianChartStyles.styles.js +17 -2
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +6 -22
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +212 -107
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +31 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +1652 -260
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +12 -3
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js +6 -2
- package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +7 -2
- 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/useDonutChartStyles.styles.js +32 -4
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +8 -4
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js +4 -2
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +2 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +1 -2
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +30 -9
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +4 -20
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +5 -21
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +174 -113
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js +1 -1
- package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +10 -3
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +5 -2
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +347 -175
- 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/useLineChartStyles.styles.js +35 -5
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +7 -13
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +23 -33
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +1 -12
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +137 -79
- 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 +39 -6
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +9 -14
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +27 -4
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +7 -4
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +5 -18
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +158 -46
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +7 -4
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +5 -19
- 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/SVGTooltipText.js.map +1 -1
- 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 +337 -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
|
@@ -9,6 +9,12 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
NON_PLOT_KEY_PREFIX: function() {
|
|
13
|
+
return NON_PLOT_KEY_PREFIX;
|
|
14
|
+
},
|
|
15
|
+
SINGLE_REPEAT: function() {
|
|
16
|
+
return SINGLE_REPEAT;
|
|
17
|
+
},
|
|
12
18
|
_getGaugeAxisColor: function() {
|
|
13
19
|
return _getGaugeAxisColor;
|
|
14
20
|
},
|
|
@@ -18,18 +24,48 @@ _export(exports, {
|
|
|
18
24
|
findArrayAttributes: function() {
|
|
19
25
|
return findArrayAttributes;
|
|
20
26
|
},
|
|
27
|
+
getAllupLegendsProps: function() {
|
|
28
|
+
return getAllupLegendsProps;
|
|
29
|
+
},
|
|
30
|
+
getGridProperties: function() {
|
|
31
|
+
return getGridProperties;
|
|
32
|
+
},
|
|
33
|
+
getNumberAtIndexOrDefault: function() {
|
|
34
|
+
return getNumberAtIndexOrDefault;
|
|
35
|
+
},
|
|
36
|
+
getValidXYRanges: function() {
|
|
37
|
+
return getValidXYRanges;
|
|
38
|
+
},
|
|
39
|
+
isNonPlotType: function() {
|
|
40
|
+
return isNonPlotType;
|
|
41
|
+
},
|
|
42
|
+
normalizeObjectArrayForGVBC: function() {
|
|
43
|
+
return normalizeObjectArrayForGVBC;
|
|
44
|
+
},
|
|
21
45
|
projectPolarToCartesian: function() {
|
|
22
46
|
return projectPolarToCartesian;
|
|
23
47
|
},
|
|
48
|
+
resolveXAxisPoint: function() {
|
|
49
|
+
return resolveXAxisPoint;
|
|
50
|
+
},
|
|
51
|
+
transformPlotlyJsonToAreaChartProps: function() {
|
|
52
|
+
return transformPlotlyJsonToAreaChartProps;
|
|
53
|
+
},
|
|
24
54
|
transformPlotlyJsonToChartTableProps: function() {
|
|
25
55
|
return transformPlotlyJsonToChartTableProps;
|
|
26
56
|
},
|
|
27
57
|
transformPlotlyJsonToDonutProps: function() {
|
|
28
58
|
return transformPlotlyJsonToDonutProps;
|
|
29
59
|
},
|
|
60
|
+
transformPlotlyJsonToFunnelChartProps: function() {
|
|
61
|
+
return transformPlotlyJsonToFunnelChartProps;
|
|
62
|
+
},
|
|
30
63
|
transformPlotlyJsonToGVBCProps: function() {
|
|
31
64
|
return transformPlotlyJsonToGVBCProps;
|
|
32
65
|
},
|
|
66
|
+
transformPlotlyJsonToGanttChartProps: function() {
|
|
67
|
+
return transformPlotlyJsonToGanttChartProps;
|
|
68
|
+
},
|
|
33
69
|
transformPlotlyJsonToGaugeProps: function() {
|
|
34
70
|
return transformPlotlyJsonToGaugeProps;
|
|
35
71
|
},
|
|
@@ -39,6 +75,9 @@ _export(exports, {
|
|
|
39
75
|
transformPlotlyJsonToHorizontalBarWithAxisProps: function() {
|
|
40
76
|
return transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
41
77
|
},
|
|
78
|
+
transformPlotlyJsonToLineChartProps: function() {
|
|
79
|
+
return transformPlotlyJsonToLineChartProps;
|
|
80
|
+
},
|
|
42
81
|
transformPlotlyJsonToSankeyProps: function() {
|
|
43
82
|
return transformPlotlyJsonToSankeyProps;
|
|
44
83
|
},
|
|
@@ -56,11 +95,15 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
|
|
|
56
95
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
57
96
|
const _d3array = require("d3-array");
|
|
58
97
|
const _d3scale = require("d3-scale");
|
|
98
|
+
const _d3format = require("d3-format");
|
|
59
99
|
const _colors = require("../../utilities/colors");
|
|
60
100
|
const _utilities = require("../../utilities/utilities");
|
|
61
101
|
const _chartutilities = require("@fluentui/chart-utilities");
|
|
62
102
|
const _d3shape = require("d3-shape");
|
|
63
103
|
const _PlotlyColorAdapter = require("./PlotlyColorAdapter");
|
|
104
|
+
const _d3color = require("d3-color");
|
|
105
|
+
const NON_PLOT_KEY_PREFIX = 'nonplot_';
|
|
106
|
+
const SINGLE_REPEAT = 'repeat(1, 1fr)';
|
|
64
107
|
const dashOptions = {
|
|
65
108
|
dot: {
|
|
66
109
|
strokeDasharray: '1, 5',
|
|
@@ -109,6 +152,47 @@ function getTitles(layout) {
|
|
|
109
152
|
};
|
|
110
153
|
return titles;
|
|
111
154
|
}
|
|
155
|
+
const getXAxisTickFormat = (series, layout)=>{
|
|
156
|
+
const xAxis = getXAxisProperties(series, layout);
|
|
157
|
+
if (xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat) {
|
|
158
|
+
return {
|
|
159
|
+
tickFormat: xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return {};
|
|
163
|
+
};
|
|
164
|
+
const getYAxisTickFormat = (series, layout)=>{
|
|
165
|
+
const yAxis = getYAxisProperties(series, layout);
|
|
166
|
+
if (yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat) {
|
|
167
|
+
return {
|
|
168
|
+
yAxisTickFormat: (0, _d3format.format)(yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat)
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return {};
|
|
172
|
+
};
|
|
173
|
+
const getYMinMaxValues = (series, layout)=>{
|
|
174
|
+
var _getYAxisProperties;
|
|
175
|
+
const range = (_getYAxisProperties = getYAxisProperties(series, layout)) === null || _getYAxisProperties === void 0 ? void 0 : _getYAxisProperties.range;
|
|
176
|
+
if (range && range.length === 2) {
|
|
177
|
+
return {
|
|
178
|
+
yMinValue: range[0],
|
|
179
|
+
yMaxValue: range[1]
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return {};
|
|
183
|
+
};
|
|
184
|
+
const getYAxisProperties = (series, layout)=>{
|
|
185
|
+
return layout === null || layout === void 0 ? void 0 : layout.yaxis;
|
|
186
|
+
};
|
|
187
|
+
const getXAxisProperties = (series, layout)=>{
|
|
188
|
+
return layout === null || layout === void 0 ? void 0 : layout.xaxis;
|
|
189
|
+
};
|
|
190
|
+
const getFormattedCalloutYData = (yVal, yAxisFormat)=>{
|
|
191
|
+
if (typeof (yAxisFormat === null || yAxisFormat === void 0 ? void 0 : yAxisFormat.yAxisTickFormat) === 'function' && typeof yVal === 'number') {
|
|
192
|
+
return yAxisFormat.yAxisTickFormat(yVal);
|
|
193
|
+
}
|
|
194
|
+
return (0, _chartutilities.formatToLocaleString)(yVal);
|
|
195
|
+
};
|
|
112
196
|
const correctYearMonth = (xValues)=>{
|
|
113
197
|
const presentYear = new Date().getFullYear();
|
|
114
198
|
if (xValues.length > 0 && Array.isArray(xValues[0])) {
|
|
@@ -118,24 +202,35 @@ const correctYearMonth = (xValues)=>{
|
|
|
118
202
|
const parsedDate = `${possiblyMonthValue} 01, ${presentYear}`;
|
|
119
203
|
return (0, _chartutilities.isDate)(parsedDate) ? new Date(parsedDate) : null;
|
|
120
204
|
});
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
205
|
+
const filteredDateIndexPairs = dates.map((date, index)=>[
|
|
206
|
+
date,
|
|
207
|
+
index
|
|
208
|
+
]).filter(([date])=>date !== null);
|
|
209
|
+
for(let i = filteredDateIndexPairs.length - 1; i > 0; i--){
|
|
210
|
+
const currentDate = filteredDateIndexPairs[i][0];
|
|
211
|
+
const previousDate = filteredDateIndexPairs[i - 1][0];
|
|
212
|
+
const currentMonth = currentDate.getMonth();
|
|
213
|
+
const previousMonth = previousDate.getMonth();
|
|
214
|
+
const currentYear = currentDate.getFullYear();
|
|
215
|
+
const previousYear = previousDate.getFullYear();
|
|
126
216
|
if (previousMonth >= currentMonth) {
|
|
127
|
-
|
|
217
|
+
filteredDateIndexPairs[i - 1][0].setFullYear(currentYear - 1);
|
|
128
218
|
} else if (previousYear > currentYear) {
|
|
129
|
-
|
|
219
|
+
filteredDateIndexPairs[i - 1][0].setFullYear(currentYear);
|
|
130
220
|
}
|
|
221
|
+
dates[filteredDateIndexPairs[i - 1][1]] = filteredDateIndexPairs[i - 1][0];
|
|
131
222
|
}
|
|
132
223
|
xValues = xValues.map((month, index)=>{
|
|
224
|
+
if (dates[index] === null) {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
133
227
|
return `${month} 01, ${dates[index].getFullYear()}`;
|
|
134
228
|
});
|
|
135
229
|
return xValues;
|
|
136
230
|
};
|
|
137
|
-
const usesSecondaryYScale = (series)=>{
|
|
138
|
-
|
|
231
|
+
const usesSecondaryYScale = (series, layout)=>{
|
|
232
|
+
var _layout_yaxis2, _layout_yaxis21;
|
|
233
|
+
return series.yaxis === 'y2' && ((layout === null || layout === void 0 ? void 0 : (_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.anchor) === 'x' || (layout === null || layout === void 0 ? void 0 : (_layout_yaxis21 = layout.yaxis2) === null || _layout_yaxis21 === void 0 ? void 0 : _layout_yaxis21.side) === 'right');
|
|
139
234
|
};
|
|
140
235
|
const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>{
|
|
141
236
|
var _layout_yaxis2, _layout_yaxis21, _layout_yaxis2_title, _layout_yaxis22;
|
|
@@ -143,7 +238,7 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
|
|
|
143
238
|
let yMinValue;
|
|
144
239
|
let yMaxValue;
|
|
145
240
|
data.forEach((series)=>{
|
|
146
|
-
if (usesSecondaryYScale(series)) {
|
|
241
|
+
if (usesSecondaryYScale(series, layout)) {
|
|
147
242
|
containsSecondaryYAxis = true;
|
|
148
243
|
const yValues = series.y;
|
|
149
244
|
if (yValues) {
|
|
@@ -177,32 +272,194 @@ const _getGaugeAxisColor = (colorway, colorwayType, color, colorMap, isDarkTheme
|
|
|
177
272
|
const extractedColors = (0, _PlotlyColorAdapter.extractColor)(colorway, colorwayType, color, colorMap, isDarkTheme);
|
|
178
273
|
return (0, _PlotlyColorAdapter.resolveColor)(extractedColors, 0, '', colorMap, isDarkTheme);
|
|
179
274
|
};
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
275
|
+
const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNumber)=>{
|
|
276
|
+
if (x === null || x === undefined) {
|
|
277
|
+
return '';
|
|
278
|
+
}
|
|
279
|
+
if (isXYearCategory) {
|
|
280
|
+
return x.toString();
|
|
281
|
+
}
|
|
282
|
+
if (isXString) {
|
|
283
|
+
if (isXDate) {
|
|
284
|
+
const date = new Date(x);
|
|
285
|
+
return date;
|
|
286
|
+
}
|
|
287
|
+
if (isXNumber) {
|
|
288
|
+
return parseFloat(x);
|
|
289
|
+
}
|
|
290
|
+
return x;
|
|
291
|
+
}
|
|
292
|
+
return x;
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* Checks if a key should be ignored during normalization
|
|
296
|
+
* @param key The key to check
|
|
297
|
+
* @returns true if the key should be ignored
|
|
298
|
+
*/ const shouldIgnoreKey = (key)=>{
|
|
299
|
+
const lowerKey = key.toLowerCase();
|
|
300
|
+
if (lowerKey.includes('style') || lowerKey === 'style') {
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
// Use regex to match common CSS property patterns
|
|
304
|
+
// (color, fill, stroke, border, background, font, shadow, outline, etc.)
|
|
305
|
+
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');
|
|
306
|
+
if (cssKeyRegex.test(lowerKey)) {
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
309
|
+
return false;
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Flattens a nested object into a single level object with dot notation keys
|
|
313
|
+
* @param obj Object to flatten
|
|
314
|
+
* @param prefix Optional prefix for keys
|
|
315
|
+
* @returns Flattened object
|
|
316
|
+
*/ const flattenObject = (obj, prefix = '')=>{
|
|
317
|
+
const flattened = {};
|
|
318
|
+
for(const key in obj){
|
|
319
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
320
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
321
|
+
const value = obj[key];
|
|
322
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof Date)) {
|
|
323
|
+
// Recursively flatten nested objects
|
|
324
|
+
Object.assign(flattened, flattenObject(value, newKey));
|
|
325
|
+
} else {
|
|
326
|
+
flattened[newKey] = value;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return flattened;
|
|
331
|
+
};
|
|
332
|
+
const normalizeObjectArrayForGVBC = (data, xLabels)=>{
|
|
333
|
+
if (!data || data.length === 0) {
|
|
334
|
+
return {
|
|
335
|
+
traces: [],
|
|
336
|
+
x: []
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
// Use provided xLabels if available, otherwise default to Item 1, Item 2, ...
|
|
340
|
+
const x = xLabels && xLabels.length === data.length ? xLabels : data.map((_, index)=>`Item ${index + 1}`);
|
|
341
|
+
// First, flatten all objects and collect all unique keys, excluding style keys
|
|
342
|
+
const flattenedObjects = data.map((item, index)=>{
|
|
343
|
+
if (typeof item === 'object' && item !== null) {
|
|
344
|
+
const flattened = flattenObject(item);
|
|
345
|
+
// Only keep keys where the value is numeric (number or numeric string) and not a style key
|
|
346
|
+
const filtered = {};
|
|
347
|
+
Object.keys(flattened).forEach((key)=>{
|
|
348
|
+
const value = flattened[key];
|
|
349
|
+
if (!shouldIgnoreKey(key) && (typeof value === 'number' || typeof value === 'string' && (0, _chartutilities.isNumber)(value))) {
|
|
350
|
+
filtered[key] = value;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
return filtered;
|
|
354
|
+
} else if (typeof item === 'number' || typeof item === 'string' && (0, _chartutilities.isNumber)(item)) {
|
|
355
|
+
// Only keep primitive numeric values
|
|
356
|
+
return {
|
|
357
|
+
[x[index] || `item_${index}`]: item
|
|
197
358
|
};
|
|
198
359
|
} else {
|
|
199
|
-
|
|
360
|
+
// Non-numeric primitive, ignore by returning empty object
|
|
361
|
+
return {};
|
|
200
362
|
}
|
|
201
363
|
});
|
|
364
|
+
// Collect all unique keys across all objects
|
|
365
|
+
const allKeys = new Set();
|
|
366
|
+
flattenedObjects.forEach((obj)=>{
|
|
367
|
+
Object.keys(obj).forEach((key)=>allKeys.add(key));
|
|
368
|
+
});
|
|
369
|
+
// Create traces for each key (property)
|
|
370
|
+
const traces = [];
|
|
371
|
+
allKeys.forEach((key)=>{
|
|
372
|
+
const yValues = [];
|
|
373
|
+
let hasValidData = false;
|
|
374
|
+
let isNumericData = false;
|
|
375
|
+
flattenedObjects.forEach((obj, index)=>{
|
|
376
|
+
const value = obj[key];
|
|
377
|
+
if (typeof value === 'number') {
|
|
378
|
+
yValues.push(value);
|
|
379
|
+
hasValidData = true;
|
|
380
|
+
isNumericData = true;
|
|
381
|
+
} else if (typeof value === 'string' && (0, _chartutilities.isNumber)(value)) {
|
|
382
|
+
yValues.push(parseFloat(value));
|
|
383
|
+
hasValidData = true;
|
|
384
|
+
isNumericData = true;
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
// Only create trace if we have valid numeric data
|
|
388
|
+
if (hasValidData && isNumericData) {
|
|
389
|
+
const trace = {
|
|
390
|
+
type: 'bar',
|
|
391
|
+
name: key,
|
|
392
|
+
x,
|
|
393
|
+
y: yValues
|
|
394
|
+
};
|
|
395
|
+
traces.push(trace);
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
return {
|
|
399
|
+
traces,
|
|
400
|
+
x
|
|
401
|
+
};
|
|
402
|
+
};
|
|
403
|
+
const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
404
|
+
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _firstData_marker, _input_layout3, _input_layout4, _input_layout5, _input_layout6;
|
|
405
|
+
const firstData = input.data[0];
|
|
406
|
+
var _input_layout_piecolorway, _input_layout_piecolorway1;
|
|
407
|
+
// extract colors for each series only once
|
|
408
|
+
// use piecolorway if available
|
|
409
|
+
// otherwise, default to colorway from template
|
|
410
|
+
const colors = (0, _PlotlyColorAdapter.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);
|
|
411
|
+
const mapLegendToDataPoint = {};
|
|
412
|
+
if (colors) {
|
|
413
|
+
var _firstData_labels;
|
|
414
|
+
(_firstData_labels = firstData.labels) === null || _firstData_labels === void 0 ? void 0 : _firstData_labels.forEach((label, index)=>{
|
|
415
|
+
const value = getNumberAtIndexOrDefault(firstData.values, index);
|
|
416
|
+
if ((0, _chartutilities.isInvalidValue)(value) || value < 0) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const legend = `${label}`;
|
|
420
|
+
// resolve color for each legend from the extracted colors
|
|
421
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(colors, index, legend, colorMap, isDarkTheme);
|
|
422
|
+
if (!mapLegendToDataPoint[legend]) {
|
|
423
|
+
mapLegendToDataPoint[legend] = {
|
|
424
|
+
legend,
|
|
425
|
+
data: value,
|
|
426
|
+
color
|
|
427
|
+
};
|
|
428
|
+
} else {
|
|
429
|
+
mapLegendToDataPoint[legend].data += value;
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
} else {
|
|
433
|
+
// Sort labels by value descending before mapping
|
|
434
|
+
if (firstData.labels && firstData.values) {
|
|
435
|
+
const labelValuePairs = firstData.labels.map((label, index)=>({
|
|
436
|
+
label,
|
|
437
|
+
value: getNumberAtIndexOrDefault(firstData.values, index),
|
|
438
|
+
index
|
|
439
|
+
}));
|
|
440
|
+
// Filter out invalid values
|
|
441
|
+
const validPairs = labelValuePairs.filter((pair)=>!(0, _chartutilities.isInvalidValue)(pair.value));
|
|
442
|
+
// Sort descending by value
|
|
443
|
+
validPairs.sort((a, b)=>b.value - a.value);
|
|
444
|
+
validPairs.forEach((pair, sortedIdx)=>{
|
|
445
|
+
const legend = `${pair.label}`;
|
|
446
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(colors, sortedIdx, legend, colorMap, isDarkTheme);
|
|
447
|
+
if (!mapLegendToDataPoint[legend]) {
|
|
448
|
+
mapLegendToDataPoint[legend] = {
|
|
449
|
+
legend,
|
|
450
|
+
data: pair.value,
|
|
451
|
+
color
|
|
452
|
+
};
|
|
453
|
+
} else {
|
|
454
|
+
mapLegendToDataPoint[legend].data += pair.value;
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
}
|
|
202
459
|
var _input_layout_width;
|
|
203
|
-
const width = (_input_layout_width = (
|
|
460
|
+
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;
|
|
204
461
|
var _input_layout_height;
|
|
205
|
-
const height = (_input_layout_height = (
|
|
462
|
+
const height = (_input_layout_height = (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 220;
|
|
206
463
|
const hideLabels = firstData.textinfo ? ![
|
|
207
464
|
'value',
|
|
208
465
|
'percent',
|
|
@@ -210,15 +467,15 @@ const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, isDarkTh
|
|
|
210
467
|
].includes(firstData.textinfo) : false;
|
|
211
468
|
const donutMarginHorizontal = hideLabels ? 0 : 80;
|
|
212
469
|
const donutMarginVertical = 40 + (hideLabels ? 0 : 40);
|
|
213
|
-
const innerRadius = firstData.hole ? firstData.hole * (Math.min(width - donutMarginHorizontal, height - donutMarginVertical) / 2) :
|
|
470
|
+
const innerRadius = firstData.hole ? firstData.hole * (Math.min(width - donutMarginHorizontal, height - donutMarginVertical) / 2) : _utilities.MIN_DONUT_RADIUS;
|
|
214
471
|
const { chartTitle } = getTitles(input.layout);
|
|
215
472
|
return {
|
|
216
473
|
data: {
|
|
217
474
|
chartTitle,
|
|
218
475
|
chartData: Object.values(mapLegendToDataPoint)
|
|
219
476
|
},
|
|
220
|
-
hideLegend: ((
|
|
221
|
-
width: (
|
|
477
|
+
hideLegend: isMultiPlot || ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false,
|
|
478
|
+
width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
|
|
222
479
|
height,
|
|
223
480
|
innerRadius,
|
|
224
481
|
hideLabels,
|
|
@@ -229,66 +486,88 @@ const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, isDarkTh
|
|
|
229
486
|
roundCorners: true
|
|
230
487
|
};
|
|
231
488
|
};
|
|
232
|
-
const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
489
|
+
const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
233
490
|
var _input_layout, _input_layout1, _vsbcData_;
|
|
234
491
|
const mapXToDataPoints = {};
|
|
235
492
|
let yMaxValue = 0;
|
|
236
493
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
237
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
494
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
495
|
+
let colorScale = undefined;
|
|
496
|
+
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
238
497
|
let yMinValue = 0;
|
|
239
498
|
input.data.forEach((series, index1)=>{
|
|
240
|
-
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line
|
|
499
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line;
|
|
500
|
+
colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
|
|
241
501
|
const isXYearCategory = (0, _chartutilities.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
242
502
|
// extract bar colors for each series only once
|
|
243
503
|
const extractedBarColors = (0, _PlotlyColorAdapter.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);
|
|
244
504
|
// extract line colors for each series only once
|
|
245
505
|
const extractedLineColors = (0, _PlotlyColorAdapter.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);
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
legend,
|
|
263
|
-
data: yVal,
|
|
264
|
-
color
|
|
265
|
-
});
|
|
266
|
-
yMaxValue = Math.max(yMaxValue, yVal);
|
|
267
|
-
} else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
268
|
-
var _series_line;
|
|
269
|
-
const lineColor = (0, _PlotlyColorAdapter.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
270
|
-
const lineOptions = getLineOptions(series.line);
|
|
271
|
-
const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
|
|
272
|
-
const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
273
|
-
mapXToDataPoints[x].lineData.push({
|
|
274
|
-
legend,
|
|
275
|
-
legendShape,
|
|
276
|
-
y: yVal,
|
|
277
|
-
color: lineColor,
|
|
278
|
-
...lineOptions ? {
|
|
279
|
-
lineOptions
|
|
280
|
-
} : {},
|
|
281
|
-
useSecondaryYScale: usesSecondaryYScale(series)
|
|
282
|
-
});
|
|
283
|
-
if (!usesSecondaryYScale(series)) {
|
|
284
|
-
yMaxValue = Math.max(yMaxValue, yVal);
|
|
506
|
+
const xValues = series.x;
|
|
507
|
+
const isXDate = (0, _chartutilities.isDateArray)(xValues);
|
|
508
|
+
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
509
|
+
const isXNumber = (0, _chartutilities.isNumberArray)(xValues);
|
|
510
|
+
const validXYRanges = getValidXYRanges(series);
|
|
511
|
+
validXYRanges.forEach(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
512
|
+
const rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
513
|
+
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
514
|
+
rangeXValues.forEach((x, index2)=>{
|
|
515
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
516
|
+
if (!mapXToDataPoints[x]) {
|
|
517
|
+
mapXToDataPoints[x] = {
|
|
518
|
+
xAxisPoint: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber),
|
|
519
|
+
chartData: [],
|
|
520
|
+
lineData: []
|
|
521
|
+
};
|
|
285
522
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
523
|
+
const legend = legends[index1];
|
|
524
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
525
|
+
const color = colorScale ? colorScale((0, _chartutilities.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) : (0, _PlotlyColorAdapter.resolveColor)(extractedBarColors, index2, legend, colorMap, isDarkTheme);
|
|
526
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
|
|
527
|
+
const yVal = rangeYValues[index2];
|
|
528
|
+
const yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
|
|
529
|
+
if (series.type === 'bar') {
|
|
530
|
+
var _rgb_copy_formatHex8;
|
|
531
|
+
mapXToDataPoints[x].chartData.push({
|
|
532
|
+
legend,
|
|
533
|
+
data: yVal,
|
|
534
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
535
|
+
opacity
|
|
536
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
537
|
+
yAxisCalloutData
|
|
538
|
+
});
|
|
539
|
+
if (typeof yVal === 'number') {
|
|
540
|
+
yMaxValue = Math.max(yMaxValue, yVal);
|
|
541
|
+
}
|
|
542
|
+
} else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
543
|
+
var _series_mode;
|
|
544
|
+
const lineColor = (0, _PlotlyColorAdapter.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
545
|
+
const lineOptions = !((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('text')) ? getLineOptions(series.line) : undefined;
|
|
546
|
+
const legendShape = getLegendShape(series);
|
|
547
|
+
var _rgb_copy_formatHex81;
|
|
548
|
+
mapXToDataPoints[x].lineData.push({
|
|
549
|
+
legend: legend + (validXYRanges.length > 1 ? `.${rangeIdx + 1}` : ''),
|
|
550
|
+
legendShape,
|
|
551
|
+
y: yVal,
|
|
552
|
+
color: (_rgb_copy_formatHex81 = (0, _d3color.rgb)(lineColor).copy({
|
|
553
|
+
opacity
|
|
554
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex81 !== void 0 ? _rgb_copy_formatHex81 : color,
|
|
555
|
+
lineOptions: {
|
|
556
|
+
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
557
|
+
mode: series.mode
|
|
558
|
+
},
|
|
559
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
560
|
+
yAxisCalloutData
|
|
561
|
+
});
|
|
562
|
+
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
563
|
+
yMaxValue = Math.max(yMaxValue, yVal);
|
|
564
|
+
yMinValue = Math.min(yMinValue, yVal);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
yMaxValue = Math.max(yMaxValue, yVal);
|
|
568
|
+
});
|
|
289
569
|
});
|
|
290
570
|
});
|
|
291
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
292
571
|
const vsbcData = Object.values(mapXToDataPoints);
|
|
293
572
|
var _input_layout_height;
|
|
294
573
|
return {
|
|
@@ -298,28 +577,70 @@ const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, isDarkThe
|
|
|
298
577
|
barWidth: 'auto',
|
|
299
578
|
yMaxValue,
|
|
300
579
|
yMinValue,
|
|
301
|
-
chartTitle,
|
|
302
|
-
xAxisTitle,
|
|
303
|
-
yAxisTitle,
|
|
304
580
|
mode: 'plotly',
|
|
305
581
|
...secondaryYAxisValues,
|
|
306
582
|
wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
|
|
307
583
|
hideTickOverlap: true,
|
|
308
584
|
barGapMax: 2,
|
|
309
585
|
hideLegend,
|
|
310
|
-
roundCorners: true
|
|
586
|
+
roundCorners: true,
|
|
587
|
+
showYAxisLables: true,
|
|
588
|
+
noOfCharsToTruncate: 20,
|
|
589
|
+
showYAxisLablesTooltip: true,
|
|
590
|
+
...getTitles(input.layout),
|
|
591
|
+
...getXAxisTickFormat(input.data[0], input.layout),
|
|
592
|
+
...yAxisTickFormat,
|
|
593
|
+
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
594
|
+
...getBarProps(input.data, input.layout),
|
|
595
|
+
...getYMinMaxValues(input.data[0], input.layout),
|
|
596
|
+
...getAxisTickProps(input.data, input.layout)
|
|
311
597
|
};
|
|
312
598
|
};
|
|
313
|
-
const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
314
|
-
var
|
|
599
|
+
const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
600
|
+
var _processedInput_layout, _processedInput_layout1, _gvbcData_;
|
|
601
|
+
// Handle object arrays in y values by normalizing the data first
|
|
602
|
+
let processedInput = {
|
|
603
|
+
...input
|
|
604
|
+
};
|
|
605
|
+
// Check if any bar traces have object arrays as y values
|
|
606
|
+
const hasObjectArrayData = input.data.some((series)=>series.type === 'bar' && (0, _chartutilities.isObjectArray)(series.y));
|
|
607
|
+
if (hasObjectArrayData) {
|
|
608
|
+
// Process each trace that has object array y values
|
|
609
|
+
const processedData = input.data.map((series, index)=>{
|
|
610
|
+
if (series.type === 'bar' && (0, _chartutilities.isObjectArray)(series.y)) {
|
|
611
|
+
// Normalize the object array to create multiple traces for GVBC
|
|
612
|
+
const { traces } = normalizeObjectArrayForGVBC(series.y, Array.isArray(series.x) ? series.x : undefined);
|
|
613
|
+
// Return all the new traces, each representing a property from the objects
|
|
614
|
+
return traces.map((trace)=>({
|
|
615
|
+
...trace,
|
|
616
|
+
// Copy other properties from the original series if needed
|
|
617
|
+
marker: series.marker
|
|
618
|
+
}));
|
|
619
|
+
}
|
|
620
|
+
return [
|
|
621
|
+
series
|
|
622
|
+
];
|
|
623
|
+
}).flat();
|
|
624
|
+
processedInput = {
|
|
625
|
+
...input,
|
|
626
|
+
data: processedData
|
|
627
|
+
};
|
|
628
|
+
}
|
|
315
629
|
const mapXToDataPoints = {};
|
|
316
|
-
const secondaryYAxisValues = getSecondaryYAxisValues(
|
|
317
|
-
const { legends, hideLegend } = getLegendProps(
|
|
318
|
-
|
|
319
|
-
|
|
630
|
+
const secondaryYAxisValues = getSecondaryYAxisValues(processedInput.data, processedInput.layout, 0, 0);
|
|
631
|
+
const { legends, hideLegend } = getLegendProps(processedInput.data, processedInput.layout, isMultiPlot);
|
|
632
|
+
let colorScale = undefined;
|
|
633
|
+
const yAxisTickFormat = getYAxisTickFormat(processedInput.data[0], processedInput.layout);
|
|
634
|
+
processedInput.data.forEach((series, index1)=>{
|
|
635
|
+
var _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout, _series_marker, _series_x;
|
|
636
|
+
colorScale = (0, _PlotlyColorAdapter.createColorScale)(processedInput.layout, series, colorScale);
|
|
320
637
|
// extract colors for each series only once
|
|
321
|
-
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
638
|
+
const extractedColors = (0, _PlotlyColorAdapter.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);
|
|
322
639
|
(_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
|
|
640
|
+
var _series_y;
|
|
641
|
+
if ((0, _chartutilities.isInvalidValue)(x) || (0, _chartutilities.isInvalidValue)((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2])) {
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
323
644
|
if (!mapXToDataPoints[x]) {
|
|
324
645
|
mapXToDataPoints[x] = {
|
|
325
646
|
name: x.toString(),
|
|
@@ -327,64 +648,82 @@ const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, isDarkThe
|
|
|
327
648
|
};
|
|
328
649
|
}
|
|
329
650
|
if (series.type === 'bar') {
|
|
330
|
-
var
|
|
651
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
331
652
|
const legend = legends[index1];
|
|
332
|
-
// resolve color for each legend's bars from the extracted colors
|
|
333
|
-
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors,
|
|
334
|
-
|
|
653
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
654
|
+
const color = colorScale ? colorScale((0, _chartutilities.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) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index2, legend, colorMap, isDarkTheme);
|
|
655
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
|
|
656
|
+
const yVal = series.y[index2];
|
|
657
|
+
var _rgb_copy_formatHex8;
|
|
335
658
|
mapXToDataPoints[x].series.push({
|
|
336
659
|
key: legend,
|
|
337
|
-
data:
|
|
660
|
+
data: yVal,
|
|
338
661
|
xAxisCalloutData: x,
|
|
339
|
-
color,
|
|
662
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
663
|
+
opacity
|
|
664
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
340
665
|
legend,
|
|
341
|
-
useSecondaryYScale: usesSecondaryYScale(series)
|
|
666
|
+
useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout),
|
|
667
|
+
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
|
|
342
668
|
});
|
|
343
669
|
}
|
|
344
670
|
});
|
|
345
671
|
});
|
|
346
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
347
672
|
const gvbcData = Object.values(mapXToDataPoints);
|
|
348
|
-
var
|
|
673
|
+
var _processedInput_layout_height;
|
|
349
674
|
return {
|
|
350
675
|
data: gvbcData,
|
|
351
|
-
width: (
|
|
352
|
-
height: (
|
|
676
|
+
width: (_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : _processedInput_layout.width,
|
|
677
|
+
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,
|
|
353
678
|
barWidth: 'auto',
|
|
354
|
-
chartTitle,
|
|
355
|
-
xAxisTitle,
|
|
356
|
-
yAxisTitle,
|
|
357
679
|
mode: 'plotly',
|
|
358
680
|
...secondaryYAxisValues,
|
|
359
681
|
hideTickOverlap: true,
|
|
360
682
|
wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
|
|
361
683
|
hideLegend,
|
|
362
|
-
roundCorners: true
|
|
684
|
+
roundCorners: true,
|
|
685
|
+
...getTitles(processedInput.layout),
|
|
686
|
+
...getAxisCategoryOrderProps(processedInput.data, processedInput.layout),
|
|
687
|
+
...getYMinMaxValues(processedInput.data[0], processedInput.layout),
|
|
688
|
+
...getXAxisTickFormat(processedInput.data[0], processedInput.layout),
|
|
689
|
+
...yAxisTickFormat,
|
|
690
|
+
...getBarProps(processedInput.data, processedInput.layout),
|
|
691
|
+
...getAxisTickProps(processedInput.data, processedInput.layout)
|
|
363
692
|
};
|
|
364
693
|
};
|
|
365
|
-
const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
694
|
+
const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
366
695
|
var _input_layout, _input_layout1, _vbcData_;
|
|
367
696
|
const vbcData = [];
|
|
368
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
697
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
698
|
+
let colorScale = undefined;
|
|
369
699
|
input.data.forEach((series, seriesIdx)=>{
|
|
370
700
|
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_xbins, _series_xbins1, _series_xbins2;
|
|
371
701
|
if (!series.x) {
|
|
372
702
|
return;
|
|
373
703
|
}
|
|
704
|
+
colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
|
|
374
705
|
// extract colors for each series only once
|
|
375
706
|
const extractedColors = (0, _PlotlyColorAdapter.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);
|
|
376
|
-
const
|
|
707
|
+
const xValues = [];
|
|
708
|
+
const yValues = [];
|
|
709
|
+
series.x.forEach((xVal, index)=>{
|
|
710
|
+
const yVal = getNumberAtIndexOrDefault(series.y, index);
|
|
711
|
+
if ((0, _chartutilities.isInvalidValue)(xVal) || (0, _chartutilities.isInvalidValue)(yVal)) {
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
xValues.push(xVal);
|
|
715
|
+
yValues.push(yVal);
|
|
716
|
+
});
|
|
717
|
+
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
377
718
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
378
719
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
379
|
-
const xBins = createBins(
|
|
720
|
+
const xBins = createBins(xValues, (_series_xbins = series.xbins) === null || _series_xbins === void 0 ? void 0 : _series_xbins.start, (_series_xbins1 = series.xbins) === null || _series_xbins1 === void 0 ? void 0 : _series_xbins1.end, (_series_xbins2 = series.xbins) === null || _series_xbins2 === void 0 ? void 0 : _series_xbins2.size);
|
|
380
721
|
const yBins = xBins.map(()=>[]);
|
|
381
722
|
let total = 0;
|
|
382
|
-
|
|
723
|
+
xValues.forEach((xVal, index)=>{
|
|
383
724
|
const binIdx = findBinIndex(xBins, xVal, isXString);
|
|
384
725
|
if (binIdx !== -1) {
|
|
385
|
-
|
|
386
|
-
var _series_y_index;
|
|
387
|
-
yBins[binIdx].push((_series_y_index = (_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index]) !== null && _series_y_index !== void 0 ? _series_y_index : 1);
|
|
726
|
+
yBins[binIdx].push(yValues[index]);
|
|
388
727
|
}
|
|
389
728
|
});
|
|
390
729
|
const y = yBins.map((bin)=>{
|
|
@@ -393,141 +732,210 @@ const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkThem
|
|
|
393
732
|
return yVal;
|
|
394
733
|
});
|
|
395
734
|
xBins.forEach((bin, index)=>{
|
|
735
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
396
736
|
const legend = legends[seriesIdx];
|
|
397
|
-
// resolve color for each legend's bars from the extracted colors
|
|
398
|
-
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors,
|
|
737
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
738
|
+
const color = colorScale ? colorScale((0, _chartutilities.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[index % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
739
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index);
|
|
399
740
|
const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
741
|
+
var _rgb_copy_formatHex8;
|
|
400
742
|
vbcData.push({
|
|
401
743
|
x: isXString ? bin.join(', ') : getBinCenter(bin),
|
|
402
744
|
y: yVal,
|
|
403
745
|
legend,
|
|
404
|
-
color,
|
|
746
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
747
|
+
opacity
|
|
748
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
405
749
|
...isXString ? {} : {
|
|
406
750
|
xAxisCalloutData: `[${bin.x0} - ${bin.x1})`
|
|
407
751
|
}
|
|
408
752
|
});
|
|
409
753
|
});
|
|
410
754
|
});
|
|
411
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
412
755
|
var _input_layout_height;
|
|
413
756
|
return {
|
|
414
757
|
data: vbcData,
|
|
415
758
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
416
759
|
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,
|
|
417
|
-
chartTitle,
|
|
418
|
-
xAxisTitle,
|
|
419
|
-
yAxisTitle,
|
|
420
760
|
mode: 'histogram',
|
|
421
761
|
hideTickOverlap: true,
|
|
422
762
|
wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
|
|
423
763
|
maxBarWidth: 50,
|
|
424
764
|
hideLegend,
|
|
425
|
-
roundCorners: true
|
|
765
|
+
roundCorners: true,
|
|
766
|
+
...getTitles(input.layout),
|
|
767
|
+
...getYMinMaxValues(input.data[0], input.layout),
|
|
768
|
+
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
426
769
|
};
|
|
427
770
|
};
|
|
428
|
-
const
|
|
771
|
+
const transformPlotlyJsonToAreaChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
772
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
|
|
773
|
+
};
|
|
774
|
+
const transformPlotlyJsonToLineChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
775
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'line', colorMap, colorwayType, isDarkTheme);
|
|
776
|
+
};
|
|
777
|
+
const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
778
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
779
|
+
};
|
|
780
|
+
const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
|
|
781
|
+
var _input_data_, _input_layout, _input_layout1;
|
|
782
|
+
const isScatterMarkers = [
|
|
783
|
+
'text',
|
|
784
|
+
'markers',
|
|
785
|
+
'text+markers',
|
|
786
|
+
'markers+text',
|
|
787
|
+
'lines+markers',
|
|
788
|
+
'markers+line',
|
|
789
|
+
'text+lines+markers',
|
|
790
|
+
'lines+markers+text'
|
|
791
|
+
].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
|
|
792
|
+
const isAreaChart = chartType === 'area';
|
|
793
|
+
const isScatterChart = chartType === 'scatter';
|
|
429
794
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
430
795
|
let mode = 'tonexty';
|
|
431
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
796
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
797
|
+
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
432
798
|
const chartData = input.data.map((series, index)=>{
|
|
433
|
-
var
|
|
799
|
+
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
|
|
800
|
+
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;
|
|
434
801
|
// extract colors for each series only once
|
|
435
|
-
const extractedColors = (0, _PlotlyColorAdapter.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,
|
|
802
|
+
const extractedColors = (0, _PlotlyColorAdapter.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, colors, colorMap, isDarkTheme);
|
|
436
803
|
const xValues = series.x;
|
|
437
|
-
const
|
|
804
|
+
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
438
805
|
const isXDate = (0, _chartutilities.isDateArray)(xValues);
|
|
439
806
|
const isXNumber = (0, _chartutilities.isNumberArray)(xValues);
|
|
807
|
+
const isXYearCategory = (0, _chartutilities.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
440
808
|
const legend = legends[index];
|
|
441
809
|
// resolve color for each legend's lines from the extracted colors
|
|
442
810
|
const seriesColor = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
811
|
+
const seriesOpacity = (0, _PlotlyColorAdapter.getOpacity)(series, index);
|
|
443
812
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
444
|
-
|
|
445
|
-
const
|
|
446
|
-
const legendShape =
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
813
|
+
// if mode contains 'text', we prioritize showing the text over curving the line
|
|
814
|
+
const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
|
|
815
|
+
const legendShape = getLegendShape(series);
|
|
816
|
+
const validXYRanges = getValidXYRanges(series);
|
|
817
|
+
return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
818
|
+
var _series_marker, _input_layout, _input_layout_polar_angularaxis, _input_layout_polar, _input_layout1, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout2;
|
|
819
|
+
const rangeXValues = xValues.slice(rangeStart, rangeEnd);
|
|
820
|
+
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
821
|
+
const markerSizes = (0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? series.marker.size.slice(rangeStart, rangeEnd) : [];
|
|
822
|
+
const textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : undefined;
|
|
823
|
+
var _rgb_copy_formatHex8;
|
|
824
|
+
return {
|
|
825
|
+
legend,
|
|
826
|
+
legendShape,
|
|
827
|
+
data: rangeXValues.map((x, i)=>{
|
|
828
|
+
var _series_marker, _series_marker1;
|
|
829
|
+
return {
|
|
830
|
+
x: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber),
|
|
831
|
+
y: rangeYValues[i],
|
|
832
|
+
...Array.isArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? {
|
|
833
|
+
markerSize: markerSizes[i]
|
|
834
|
+
} : typeof ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.size) === 'number' ? {
|
|
835
|
+
markerSize: series.marker.size
|
|
836
|
+
} : {},
|
|
837
|
+
...textValues ? {
|
|
838
|
+
text: textValues[i]
|
|
839
|
+
} : {},
|
|
840
|
+
yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat)
|
|
841
|
+
};
|
|
842
|
+
}),
|
|
843
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(seriesColor).copy({
|
|
844
|
+
opacity: seriesOpacity
|
|
845
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
|
|
846
|
+
lineOptions: {
|
|
847
|
+
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
848
|
+
mode: series.type !== 'scatterpolar' ? series.mode : 'scatterpolar',
|
|
849
|
+
// originXOffset is not typed on Layout, but may be present in input.layout as a part of projection of
|
|
850
|
+
// scatter polar coordingates to cartesian coordinates
|
|
851
|
+
...series.type === 'scatterpolar' ? {
|
|
852
|
+
originXOffset: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.__polarOriginX,
|
|
853
|
+
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,
|
|
854
|
+
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,
|
|
855
|
+
axisLabel: series.__axisLabel ? series.__axisLabel : {}
|
|
459
856
|
} : {}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
857
|
+
},
|
|
858
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
859
|
+
};
|
|
860
|
+
});
|
|
861
|
+
}).flat();
|
|
862
|
+
const yMinMax = getYMinMaxValues(input.data[0], input.layout);
|
|
863
|
+
if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
|
|
864
|
+
const yMinMaxValues = (0, _utilities.findNumericMinMaxOfY)(chartData);
|
|
865
|
+
yMinMax.yMinValue = yMinMaxValues.startValue;
|
|
866
|
+
yMinMax.yMaxValue = yMinMaxValues.endValue;
|
|
867
|
+
}
|
|
868
|
+
const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
|
|
471
869
|
const chartProps = {
|
|
472
|
-
chartTitle,
|
|
473
870
|
lineChartData: chartData
|
|
474
871
|
};
|
|
872
|
+
const scatterChartProps = {
|
|
873
|
+
scatterChartData: chartData
|
|
874
|
+
};
|
|
875
|
+
var _input_layout_height;
|
|
876
|
+
const commonProps = {
|
|
877
|
+
supportNegativeData: true,
|
|
878
|
+
...secondaryYAxisValues,
|
|
879
|
+
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
880
|
+
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,
|
|
881
|
+
hideTickOverlap: true,
|
|
882
|
+
hideLegend,
|
|
883
|
+
useUTC: false,
|
|
884
|
+
optimizeLargeData: numDataPoints > 1000,
|
|
885
|
+
...getTitles(input.layout),
|
|
886
|
+
...getXAxisTickFormat(input.data[0], input.layout),
|
|
887
|
+
...yAxisTickFormat,
|
|
888
|
+
...getAxisScaleTypeProps(input.data, input.layout),
|
|
889
|
+
...getAxisTickProps(input.data, input.layout)
|
|
890
|
+
};
|
|
475
891
|
if (isAreaChart) {
|
|
476
|
-
var _input_layout, _input_layout1;
|
|
477
|
-
var _input_layout_height;
|
|
478
892
|
return {
|
|
479
893
|
data: chartProps,
|
|
480
|
-
supportNegativeData: true,
|
|
481
|
-
xAxisTitle,
|
|
482
|
-
yAxisTitle,
|
|
483
|
-
...secondaryYAxisValues,
|
|
484
894
|
mode,
|
|
485
|
-
|
|
486
|
-
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,
|
|
487
|
-
hideTickOverlap: true,
|
|
488
|
-
useUTC: false,
|
|
489
|
-
hideLegend
|
|
895
|
+
...commonProps
|
|
490
896
|
};
|
|
491
897
|
} else {
|
|
492
|
-
var _input_layout2, _input_layout3;
|
|
493
|
-
var _input_layout_height1;
|
|
494
898
|
return {
|
|
495
|
-
data: chartProps,
|
|
496
|
-
supportNegativeData: true,
|
|
497
|
-
xAxisTitle,
|
|
498
|
-
yAxisTitle,
|
|
499
|
-
...secondaryYAxisValues,
|
|
899
|
+
data: isScatterChart ? scatterChartProps : chartProps,
|
|
500
900
|
roundedTicks: true,
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
hideLegend
|
|
901
|
+
...commonProps,
|
|
902
|
+
...yMinMax,
|
|
903
|
+
...isScatterChart ? {
|
|
904
|
+
showYAxisLablesTooltip: true,
|
|
905
|
+
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
906
|
+
} : {}
|
|
508
907
|
};
|
|
509
908
|
}
|
|
510
909
|
};
|
|
511
|
-
const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
910
|
+
const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
512
911
|
var _input_layout, _input_layout_margin, _input_layout1, _input_layout_margin1, _input_layout2, _input_layout_yaxis2, _input_layout3, _input_layout_yaxis21, _input_layout4, _input_layout_yaxis2_title, _input_layout_yaxis22, _input_layout5, _input_layout6;
|
|
513
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
912
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
913
|
+
let colorScale = undefined;
|
|
514
914
|
const chartData = input.data.map((series, index)=>{
|
|
515
915
|
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
|
|
916
|
+
colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
|
|
516
917
|
// extract colors for each series only once
|
|
517
918
|
const extractedColors = (0, _PlotlyColorAdapter.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);
|
|
518
919
|
const legend = legends[index];
|
|
519
|
-
// resolve color for each legend's bars from the extracted colors
|
|
520
|
-
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
521
920
|
return series.y.map((yValue, i)=>{
|
|
921
|
+
var _series_x, _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
922
|
+
if ((0, _chartutilities.isInvalidValue)((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]) || (0, _chartutilities.isInvalidValue)(yValue)) {
|
|
923
|
+
return null;
|
|
924
|
+
}
|
|
925
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
926
|
+
const color = colorScale ? colorScale((0, _chartutilities.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) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, i, legend, colorMap, isDarkTheme);
|
|
927
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, i);
|
|
928
|
+
var _rgb_copy_formatHex8;
|
|
522
929
|
return {
|
|
523
930
|
x: series.x[i],
|
|
524
931
|
y: yValue,
|
|
525
932
|
legend,
|
|
526
|
-
color
|
|
933
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
934
|
+
opacity
|
|
935
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
527
936
|
};
|
|
528
|
-
});
|
|
529
|
-
}).
|
|
530
|
-
.reverse();
|
|
937
|
+
}).filter((point)=>point !== null);
|
|
938
|
+
}).flat();
|
|
531
939
|
var _input_layout_height;
|
|
532
940
|
const chartHeight = (_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 : 450;
|
|
533
941
|
var _input_layout_margin_l;
|
|
@@ -539,12 +947,8 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorw
|
|
|
539
947
|
const scalingFactor = 0.01;
|
|
540
948
|
const gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
541
949
|
const barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
542
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
543
950
|
return {
|
|
544
951
|
data: chartData,
|
|
545
|
-
chartTitle,
|
|
546
|
-
xAxisTitle,
|
|
547
|
-
yAxisTitle,
|
|
548
952
|
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) || '',
|
|
549
953
|
barHeight,
|
|
550
954
|
showYAxisLables: true,
|
|
@@ -554,31 +958,102 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorw
|
|
|
554
958
|
noOfCharsToTruncate: 20,
|
|
555
959
|
showYAxisLablesTooltip: true,
|
|
556
960
|
hideLegend,
|
|
557
|
-
roundCorners: true
|
|
961
|
+
roundCorners: true,
|
|
962
|
+
...getTitles(input.layout),
|
|
963
|
+
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
964
|
+
...getBarProps(input.data, input.layout, true),
|
|
965
|
+
...getAxisTickProps(input.data, input.layout)
|
|
558
966
|
};
|
|
559
967
|
};
|
|
560
|
-
const
|
|
968
|
+
const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
561
969
|
var _input_layout, _input_layout1;
|
|
970
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
971
|
+
let colorScale = undefined;
|
|
972
|
+
const chartData = input.data.map((series, index)=>{
|
|
973
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_xaxis, _input_layout1;
|
|
974
|
+
colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
|
|
975
|
+
// extract colors for each series only once
|
|
976
|
+
const extractedColors = (0, _PlotlyColorAdapter.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);
|
|
977
|
+
const legend = legends[index];
|
|
978
|
+
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' || (0, _chartutilities.isDateArray)(series.x);
|
|
979
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
980
|
+
const convertXValueToNumber = (value)=>{
|
|
981
|
+
return (0, _chartutilities.isInvalidValue)(value) ? 0 : isXDate ? +parseLocalDate(value) : +value;
|
|
982
|
+
};
|
|
983
|
+
return series.y.map((yVal, i)=>{
|
|
984
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _series_base, _series_x;
|
|
985
|
+
if ((0, _chartutilities.isInvalidValue)(yVal)) {
|
|
986
|
+
return null;
|
|
987
|
+
}
|
|
988
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
989
|
+
const color = colorScale ? colorScale((0, _chartutilities.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) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, i, legend, colorMap, isDarkTheme);
|
|
990
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, i);
|
|
991
|
+
const base = convertXValueToNumber((_series_base = series.base) === null || _series_base === void 0 ? void 0 : _series_base[i]);
|
|
992
|
+
const xVal = convertXValueToNumber((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]);
|
|
993
|
+
var _rgb_copy_formatHex8;
|
|
994
|
+
return {
|
|
995
|
+
x: {
|
|
996
|
+
start: isXDate ? new Date(base) : base,
|
|
997
|
+
end: isXDate ? new Date(base + xVal) : base + xVal
|
|
998
|
+
},
|
|
999
|
+
y: yVal,
|
|
1000
|
+
legend,
|
|
1001
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
1002
|
+
opacity
|
|
1003
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
1004
|
+
};
|
|
1005
|
+
}).filter((point)=>point !== null);
|
|
1006
|
+
}).flat();
|
|
1007
|
+
var _input_layout_height;
|
|
1008
|
+
return {
|
|
1009
|
+
data: chartData,
|
|
1010
|
+
showYAxisLables: true,
|
|
1011
|
+
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,
|
|
1012
|
+
width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
|
|
1013
|
+
hideTickOverlap: true,
|
|
1014
|
+
hideLegend,
|
|
1015
|
+
noOfCharsToTruncate: 20,
|
|
1016
|
+
showYAxisLablesTooltip: true,
|
|
1017
|
+
roundCorners: true,
|
|
1018
|
+
useUTC: false,
|
|
1019
|
+
...getTitles(input.layout),
|
|
1020
|
+
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
1021
|
+
...getBarProps(input.data, input.layout, true),
|
|
1022
|
+
...getAxisTickProps(input.data, input.layout)
|
|
1023
|
+
};
|
|
1024
|
+
};
|
|
1025
|
+
const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
1026
|
+
var _input_layout, _input_layout_coloraxis, _input_layout1, _input_layout_template_layout, _input_layout_template, _input_layout2, _input_layout_template_data_histogram2d_, _input_layout_template_data_histogram2d, _input_layout_template_data, _input_layout_template1, _input_layout3, _input_layout_template_data_heatmap_, _input_layout_template_data_heatmap, _input_layout_template_data1, _input_layout_template2, _input_layout4, _input_layout5, _input_layout6;
|
|
562
1027
|
const firstData = input.data[0];
|
|
563
1028
|
const heatmapDataPoints = [];
|
|
564
1029
|
let zMin = Number.POSITIVE_INFINITY;
|
|
565
1030
|
let zMax = Number.NEGATIVE_INFINITY;
|
|
566
1031
|
if (firstData.type === 'histogram2d') {
|
|
567
|
-
var _firstData_xbins, _firstData_xbins1, _firstData_xbins2, _firstData_ybins, _firstData_ybins1, _firstData_ybins2
|
|
568
|
-
const
|
|
569
|
-
const
|
|
570
|
-
const
|
|
571
|
-
const yBins = createBins(firstData.y, (_firstData_ybins = firstData.ybins) === null || _firstData_ybins === void 0 ? void 0 : _firstData_ybins.start, (_firstData_ybins1 = firstData.ybins) === null || _firstData_ybins1 === void 0 ? void 0 : _firstData_ybins1.end, (_firstData_ybins2 = firstData.ybins) === null || _firstData_ybins2 === void 0 ? void 0 : _firstData_ybins2.size);
|
|
572
|
-
const zBins = yBins.map(()=>xBins.map(()=>[]));
|
|
573
|
-
let total = 0;
|
|
1032
|
+
var _firstData_x, _firstData_xbins, _firstData_xbins1, _firstData_xbins2, _firstData_ybins, _firstData_ybins1, _firstData_ybins2;
|
|
1033
|
+
const xValues = [];
|
|
1034
|
+
const yValues = [];
|
|
1035
|
+
const zValues = [];
|
|
574
1036
|
(_firstData_x = firstData.x) === null || _firstData_x === void 0 ? void 0 : _firstData_x.forEach((xVal, index)=>{
|
|
575
1037
|
var _firstData_y;
|
|
1038
|
+
const zVal = getNumberAtIndexOrDefault(firstData.z, index);
|
|
1039
|
+
if ((0, _chartutilities.isInvalidValue)(xVal) || (0, _chartutilities.isInvalidValue)((_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y[index]) || (0, _chartutilities.isInvalidValue)(zVal)) {
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
xValues.push(xVal);
|
|
1043
|
+
yValues.push(firstData.y[index]);
|
|
1044
|
+
zValues.push(zVal);
|
|
1045
|
+
});
|
|
1046
|
+
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
1047
|
+
const isYString = (0, _chartutilities.isStringArray)(yValues);
|
|
1048
|
+
const xBins = createBins(xValues, (_firstData_xbins = firstData.xbins) === null || _firstData_xbins === void 0 ? void 0 : _firstData_xbins.start, (_firstData_xbins1 = firstData.xbins) === null || _firstData_xbins1 === void 0 ? void 0 : _firstData_xbins1.end, (_firstData_xbins2 = firstData.xbins) === null || _firstData_xbins2 === void 0 ? void 0 : _firstData_xbins2.size);
|
|
1049
|
+
const yBins = createBins(yValues, (_firstData_ybins = firstData.ybins) === null || _firstData_ybins === void 0 ? void 0 : _firstData_ybins.start, (_firstData_ybins1 = firstData.ybins) === null || _firstData_ybins1 === void 0 ? void 0 : _firstData_ybins1.end, (_firstData_ybins2 = firstData.ybins) === null || _firstData_ybins2 === void 0 ? void 0 : _firstData_ybins2.size);
|
|
1050
|
+
const zBins = yBins.map(()=>xBins.map(()=>[]));
|
|
1051
|
+
let total = 0;
|
|
1052
|
+
xValues.forEach((xVal, index)=>{
|
|
576
1053
|
const xBinIdx = findBinIndex(xBins, xVal, isXString);
|
|
577
|
-
const yBinIdx = findBinIndex(yBins,
|
|
1054
|
+
const yBinIdx = findBinIndex(yBins, yValues[index], isYString);
|
|
578
1055
|
if (xBinIdx !== -1 && yBinIdx !== -1) {
|
|
579
|
-
|
|
580
|
-
var _firstData_z_index;
|
|
581
|
-
zBins[yBinIdx][xBinIdx].push((_firstData_z_index = (_firstData_z = firstData.z) === null || _firstData_z === void 0 ? void 0 : _firstData_z[index]) !== null && _firstData_z_index !== void 0 ? _firstData_z_index : 1);
|
|
1056
|
+
zBins[yBinIdx][xBinIdx].push(zValues[index]);
|
|
582
1057
|
}
|
|
583
1058
|
});
|
|
584
1059
|
const z = zBins.map((row)=>{
|
|
@@ -640,9 +1115,23 @@ const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
|
640
1115
|
(0, _colors.getColorFromToken)(_colors.DataVizPalette.color2),
|
|
641
1116
|
(0, _colors.getColorFromToken)(_colors.DataVizPalette.color3)
|
|
642
1117
|
];
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
1118
|
+
var _firstData_colorscale, _ref, _ref1, _ref2, _ref3;
|
|
1119
|
+
let colorscale = (_ref3 = (_ref2 = (_ref1 = (_ref = (_firstData_colorscale = firstData === null || firstData === void 0 ? void 0 : firstData.colorscale) !== null && _firstData_colorscale !== void 0 ? _firstData_colorscale : (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.colorscale) !== null && _ref !== void 0 ? _ref : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout1.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : _input_layout_coloraxis.colorscale) !== null && _ref1 !== void 0 ? _ref1 : (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_template = _input_layout2.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.colorscale) !== null && _ref2 !== void 0 ? _ref2 : firstData.type === 'histogram2d' && ((_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_data = _input_layout_template1.data) === null || _input_layout_template_data === void 0 ? void 0 : (_input_layout_template_data_histogram2d = _input_layout_template_data.histogram2d) === null || _input_layout_template_data_histogram2d === void 0 ? void 0 : (_input_layout_template_data_histogram2d_ = _input_layout_template_data_histogram2d[0]) === null || _input_layout_template_data_histogram2d_ === void 0 ? void 0 : _input_layout_template_data_histogram2d_.colorscale)) !== null && _ref3 !== void 0 ? _ref3 : (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_template2 = _input_layout4.template) === null || _input_layout_template2 === void 0 ? void 0 : (_input_layout_template_data1 = _input_layout_template2.data) === null || _input_layout_template_data1 === void 0 ? void 0 : (_input_layout_template_data_heatmap = _input_layout_template_data1.heatmap) === null || _input_layout_template_data_heatmap === void 0 ? void 0 : (_input_layout_template_data_heatmap_ = _input_layout_template_data_heatmap[0]) === null || _input_layout_template_data_heatmap_ === void 0 ? void 0 : _input_layout_template_data_heatmap_.colorscale;
|
|
1120
|
+
// determine if the types diverging, sequential or sequentialminus are present in colorscale
|
|
1121
|
+
if (colorscale && typeof colorscale === 'object' && ('diverging' in colorscale || 'sequential' in colorscale || 'sequentialminus' in colorscale)) {
|
|
1122
|
+
const isDivergent = zMin < 0 && zMax > 0; // Data spans both positive and negative values
|
|
1123
|
+
const isSequential = zMin >= 0; // Data is entirely positive
|
|
1124
|
+
const isSequentialMinus = zMax <= 0; // Data is entirely negative
|
|
1125
|
+
if (isDivergent) {
|
|
1126
|
+
colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.diverging;
|
|
1127
|
+
} else if (isSequential) {
|
|
1128
|
+
colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.sequential;
|
|
1129
|
+
} else if (isSequentialMinus) {
|
|
1130
|
+
colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.sequentialminus;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
|
|
1134
|
+
const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
|
|
646
1135
|
var _input_layout_height;
|
|
647
1136
|
return {
|
|
648
1137
|
data: [
|
|
@@ -652,28 +1141,36 @@ const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
|
652
1141
|
rangeValuesForColorScale,
|
|
653
1142
|
hideLegend: true,
|
|
654
1143
|
showYAxisLables: true,
|
|
655
|
-
chartTitle,
|
|
656
|
-
xAxisTitle,
|
|
657
|
-
yAxisTitle,
|
|
658
1144
|
sortOrder: 'none',
|
|
659
|
-
width: (
|
|
660
|
-
height: (_input_layout_height = (
|
|
1145
|
+
width: (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.width,
|
|
1146
|
+
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,
|
|
661
1147
|
hideTickOverlap: true,
|
|
662
1148
|
noOfCharsToTruncate: 20,
|
|
663
1149
|
showYAxisLablesTooltip: true,
|
|
664
|
-
wrapXAxisLables: true
|
|
1150
|
+
wrapXAxisLables: true,
|
|
1151
|
+
...getTitles(input.layout),
|
|
1152
|
+
...getAxisCategoryOrderProps([
|
|
1153
|
+
firstData
|
|
1154
|
+
], input.layout),
|
|
1155
|
+
...getAxisTickProps(input.data, input.layout)
|
|
665
1156
|
};
|
|
666
1157
|
};
|
|
667
|
-
const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
1158
|
+
const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
668
1159
|
var _input_layout_template_layout, _input_layout_template, _input_layout, _node_label, _input_layout1, _input_layout2;
|
|
669
1160
|
const { link, node } = input.data[0];
|
|
670
1161
|
var _link_value;
|
|
671
|
-
const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>
|
|
1162
|
+
const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>{
|
|
1163
|
+
var _link_source, _link_target;
|
|
1164
|
+
if ((0, _chartutilities.isInvalidValue)(val) || (0, _chartutilities.isInvalidValue)(link === null || link === void 0 ? void 0 : (_link_source = link.source) === null || _link_source === void 0 ? void 0 : _link_source[index]) || (0, _chartutilities.isInvalidValue)(link === null || link === void 0 ? void 0 : (_link_target = link.target) === null || _link_target === void 0 ? void 0 : _link_target[index])) {
|
|
1165
|
+
return null;
|
|
1166
|
+
}
|
|
1167
|
+
return {
|
|
672
1168
|
value: val,
|
|
673
1169
|
source: link === null || link === void 0 ? void 0 : link.source[index],
|
|
674
1170
|
target: link === null || link === void 0 ? void 0 : link.target[index]
|
|
675
|
-
}
|
|
676
|
-
|
|
1171
|
+
};
|
|
1172
|
+
}) // Filter out negative nodes, unequal nodes and self-references (circular links)
|
|
1173
|
+
.filter((x)=>x !== null && x.source >= 0 && x.target >= 0 && x.source !== x.target);
|
|
677
1174
|
const extractedNodeColors = (0, _PlotlyColorAdapter.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, node === null || node === void 0 ? void 0 : node.color, colorMap, isDarkTheme);
|
|
678
1175
|
const sankeyChartData = {
|
|
679
1176
|
nodes: (_node_label = node.label) === null || _node_label === void 0 ? void 0 : _node_label.map((label, index)=>{
|
|
@@ -707,7 +1204,7 @@ const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType, isDarkT
|
|
|
707
1204
|
height: (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 468
|
|
708
1205
|
};
|
|
709
1206
|
};
|
|
710
|
-
const transformPlotlyJsonToGaugeProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
1207
|
+
const transformPlotlyJsonToGaugeProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
711
1208
|
var _firstData_gauge, _input_layout_template_layout, _input_layout_template, _input_layout, _firstData_gauge_steps, _firstData_gauge1, _firstData_gauge_axis_range, _firstData_gauge_axis, _firstData_gauge2, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _firstData_gauge_axis1, _firstData_gauge3, _firstData_gauge_axis_range1, _firstData_gauge_axis2, _firstData_gauge4, _firstData_delta, _firstData_gauge_axis_range2, _firstData_gauge_axis3, _firstData_gauge5, _firstData_gauge_axis_range3, _firstData_gauge_axis4, _firstData_gauge6, _firstData_gauge_axis_range4, _firstData_gauge_axis5, _firstData_gauge7, _firstData_gauge_axis_range5, _firstData_gauge_axis6, _firstData_gauge8, _input_layout2, _input_layout3, _firstData_gauge_steps1, _firstData_gauge9;
|
|
712
1209
|
const firstData = input.data[0];
|
|
713
1210
|
const stepsColors = ((_firstData_gauge = firstData.gauge) === null || _firstData_gauge === void 0 ? void 0 : _firstData_gauge.steps) ? firstData.gauge.steps.map((step)=>step.color) : undefined;
|
|
@@ -782,59 +1279,445 @@ const transformPlotlyJsonToGaugeProps = (input, colorMap, colorwayType, isDarkTh
|
|
|
782
1279
|
const cleanText = (text)=>{
|
|
783
1280
|
return text.replace(/<[^&]*?>/g, '').replace(/<[^>]*>/g, '').replace(/<br>|\\u003cbr\\u003e|<br>/gi, '').replace(/\$[^$]*\$/g, '$').trim();
|
|
784
1281
|
};
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
1282
|
+
const formatValue = (value, colIndex, cells)=>{
|
|
1283
|
+
if (value === null || typeof value === 'boolean') {
|
|
1284
|
+
return value;
|
|
1285
|
+
}
|
|
1286
|
+
const formatStr = Array.isArray(cells.format) ? cells.format[colIndex] : cells.format;
|
|
1287
|
+
const prefix = Array.isArray(cells.prefix) ? cells.prefix[colIndex] : cells.prefix;
|
|
1288
|
+
const suffix = Array.isArray(cells.suffix) ? cells.suffix[colIndex] : cells.suffix;
|
|
1289
|
+
let formatted = value;
|
|
1290
|
+
if (typeof value === 'number') {
|
|
1291
|
+
if (typeof formatStr === 'string') {
|
|
1292
|
+
try {
|
|
1293
|
+
formatted = (0, _d3format.format)(formatStr)(value);
|
|
1294
|
+
} catch {
|
|
1295
|
+
formatted = (0, _utilities.formatScientificLimitWidth)(value);
|
|
1296
|
+
}
|
|
1297
|
+
} else {
|
|
1298
|
+
formatted = (0, _utilities.formatScientificLimitWidth)(value);
|
|
792
1299
|
}
|
|
793
|
-
|
|
794
|
-
|
|
1300
|
+
}
|
|
1301
|
+
return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
|
|
1302
|
+
};
|
|
1303
|
+
const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
1304
|
+
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, _tableData_header, _input_layout_template_data1, _input_layout_template1, _input_layout2, _input_layout3, _input_layout4;
|
|
1305
|
+
const tableData = input.data[0];
|
|
1306
|
+
const normalizeHeaders = (values, header)=>{
|
|
1307
|
+
const cleanedValues = Array.isArray(values[0]) ? values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' ')) : values.map((cell)=>cleanText(cell));
|
|
1308
|
+
return cleanedValues.map((value, colIndex)=>{
|
|
1309
|
+
var _header_font, _header_font1, _header_fill;
|
|
1310
|
+
const fontColorRaw = header === null || header === void 0 ? void 0 : (_header_font = header.font) === null || _header_font === void 0 ? void 0 : _header_font.color;
|
|
1311
|
+
let fontColor;
|
|
1312
|
+
if (Array.isArray(fontColorRaw)) {
|
|
1313
|
+
var _fontColorRaw_colIndex;
|
|
1314
|
+
const colorEntry = (_fontColorRaw_colIndex = fontColorRaw[colIndex]) !== null && _fontColorRaw_colIndex !== void 0 ? _fontColorRaw_colIndex : fontColorRaw[0];
|
|
1315
|
+
if (Array.isArray(colorEntry)) {
|
|
1316
|
+
fontColor = typeof colorEntry[0] === 'string' ? colorEntry[0] : undefined;
|
|
1317
|
+
} else if (typeof colorEntry === 'string') {
|
|
1318
|
+
fontColor = colorEntry;
|
|
1319
|
+
}
|
|
1320
|
+
} else if (typeof fontColorRaw === 'string') {
|
|
1321
|
+
fontColor = fontColorRaw;
|
|
1322
|
+
}
|
|
1323
|
+
const fontSizeRaw = header === null || header === void 0 ? void 0 : (_header_font1 = header.font) === null || _header_font1 === void 0 ? void 0 : _header_font1.size;
|
|
1324
|
+
let fontSize;
|
|
1325
|
+
if (Array.isArray(fontSizeRaw)) {
|
|
1326
|
+
var _fontSizeRaw_colIndex;
|
|
1327
|
+
const fontSizeEntry = (_fontSizeRaw_colIndex = fontSizeRaw[colIndex]) !== null && _fontSizeRaw_colIndex !== void 0 ? _fontSizeRaw_colIndex : fontSizeRaw[0];
|
|
1328
|
+
var _fontSizeRaw__colIndex;
|
|
1329
|
+
fontSize = Array.isArray(fontSizeRaw[0]) ? (_fontSizeRaw__colIndex = fontSizeRaw[0][colIndex]) !== null && _fontSizeRaw__colIndex !== void 0 ? _fontSizeRaw__colIndex : fontSizeRaw[0][0] : typeof fontSizeEntry === 'number' ? fontSizeEntry : undefined;
|
|
1330
|
+
} else if (typeof fontSizeRaw === 'number') {
|
|
1331
|
+
fontSize = fontSizeRaw;
|
|
1332
|
+
}
|
|
1333
|
+
const updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
1334
|
+
const fillColorRaw = header === null || header === void 0 ? void 0 : (_header_fill = header.fill) === null || _header_fill === void 0 ? void 0 : _header_fill.color;
|
|
1335
|
+
var _fillColorRaw_updatedColIndex;
|
|
1336
|
+
const backgroundColor = Array.isArray(fillColorRaw) ? (_fillColorRaw_updatedColIndex = fillColorRaw[updatedColIndex]) !== null && _fillColorRaw_updatedColIndex !== void 0 ? _fillColorRaw_updatedColIndex : fillColorRaw[0] : fillColorRaw;
|
|
1337
|
+
const textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
|
|
1338
|
+
var _textAlignRaw_colIndex;
|
|
1339
|
+
const textAlign = Array.isArray(textAlignRaw) ? (_textAlignRaw_colIndex = textAlignRaw[colIndex]) !== null && _textAlignRaw_colIndex !== void 0 ? _textAlignRaw_colIndex : textAlignRaw[0] : textAlignRaw;
|
|
1340
|
+
const style = {
|
|
1341
|
+
...typeof fontColor === 'string' ? {
|
|
1342
|
+
color: fontColor
|
|
1343
|
+
} : {},
|
|
1344
|
+
...typeof fontSize === 'number' ? {
|
|
1345
|
+
fontSize
|
|
1346
|
+
} : {},
|
|
1347
|
+
...typeof backgroundColor === 'string' ? {
|
|
1348
|
+
backgroundColor
|
|
1349
|
+
} : {},
|
|
1350
|
+
...textAlign ? {
|
|
1351
|
+
textAlign
|
|
1352
|
+
} : {}
|
|
1353
|
+
};
|
|
1354
|
+
return {
|
|
1355
|
+
value,
|
|
1356
|
+
style
|
|
1357
|
+
};
|
|
1358
|
+
});
|
|
795
1359
|
};
|
|
796
1360
|
var _tableData_cells_values;
|
|
797
1361
|
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 : [];
|
|
798
|
-
const
|
|
799
|
-
|
|
1362
|
+
const cells = tableData.cells && Object.keys(tableData.cells).length > 0 ? 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;
|
|
1363
|
+
const rows = columns[0].map((_, rowIndex)=>columns.map((col, colIndex)=>{
|
|
1364
|
+
var _cells_font, _cells_font1, _cells_fill;
|
|
1365
|
+
const cellValue = col[rowIndex];
|
|
1366
|
+
const cleanValue = typeof cellValue === 'string' ? cleanText(cellValue) : cellValue;
|
|
1367
|
+
const formattedValue = typeof cleanValue === 'string' || typeof cleanValue === 'number' ? formatValue(cleanValue, colIndex, cells) : cleanValue;
|
|
1368
|
+
const rawFontColor = cells === null || cells === void 0 ? void 0 : (_cells_font = cells.font) === null || _cells_font === void 0 ? void 0 : _cells_font.color;
|
|
1369
|
+
let fontColor;
|
|
1370
|
+
if (Array.isArray(rawFontColor)) {
|
|
1371
|
+
var _rawFontColor_colIndex;
|
|
1372
|
+
const entry = (_rawFontColor_colIndex = rawFontColor[colIndex]) !== null && _rawFontColor_colIndex !== void 0 ? _rawFontColor_colIndex : rawFontColor[0];
|
|
1373
|
+
const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1374
|
+
fontColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
1375
|
+
} else if (typeof rawFontColor === 'string') {
|
|
1376
|
+
fontColor = rawFontColor;
|
|
1377
|
+
}
|
|
1378
|
+
const rawFontSize = cells === null || cells === void 0 ? void 0 : (_cells_font1 = cells.font) === null || _cells_font1 === void 0 ? void 0 : _cells_font1.size;
|
|
1379
|
+
let fontSize;
|
|
1380
|
+
if (Array.isArray(rawFontSize)) {
|
|
1381
|
+
var _rawFontSize_colIndex;
|
|
1382
|
+
const entry = (_rawFontSize_colIndex = rawFontSize[colIndex]) !== null && _rawFontSize_colIndex !== void 0 ? _rawFontSize_colIndex : rawFontSize[0];
|
|
1383
|
+
const fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1384
|
+
fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
|
|
1385
|
+
} else if (typeof rawFontSize === 'number') {
|
|
1386
|
+
fontSize = rawFontSize;
|
|
1387
|
+
}
|
|
1388
|
+
const updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
1389
|
+
const rawBackgroundColor = cells === null || cells === void 0 ? void 0 : (_cells_fill = cells.fill) === null || _cells_fill === void 0 ? void 0 : _cells_fill.color;
|
|
1390
|
+
let backgroundColor;
|
|
1391
|
+
if (Array.isArray(rawBackgroundColor)) {
|
|
1392
|
+
var _rawBackgroundColor_updatedColIndex;
|
|
1393
|
+
const entry = (_rawBackgroundColor_updatedColIndex = rawBackgroundColor[updatedColIndex]) !== null && _rawBackgroundColor_updatedColIndex !== void 0 ? _rawBackgroundColor_updatedColIndex : rawBackgroundColor[0];
|
|
1394
|
+
const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1395
|
+
backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
1396
|
+
} else if (typeof rawBackgroundColor === 'string') {
|
|
1397
|
+
backgroundColor = rawBackgroundColor;
|
|
1398
|
+
}
|
|
1399
|
+
var _cells_align_colIndex;
|
|
1400
|
+
const rawTextAlign = Array.isArray(cells === null || cells === void 0 ? void 0 : cells.align) ? (_cells_align_colIndex = cells.align[colIndex]) !== null && _cells_align_colIndex !== void 0 ? _cells_align_colIndex : cells.align[0] : cells === null || cells === void 0 ? void 0 : cells.align;
|
|
1401
|
+
const textAlign = rawTextAlign;
|
|
1402
|
+
const style = {
|
|
1403
|
+
...fontColor ? {
|
|
1404
|
+
color: fontColor
|
|
1405
|
+
} : {},
|
|
1406
|
+
...typeof fontSize === 'number' ? {
|
|
1407
|
+
fontSize
|
|
1408
|
+
} : {},
|
|
1409
|
+
...backgroundColor ? {
|
|
1410
|
+
backgroundColor
|
|
1411
|
+
} : {},
|
|
1412
|
+
...textAlign ? {
|
|
1413
|
+
textAlign
|
|
1414
|
+
} : {}
|
|
1415
|
+
};
|
|
800
1416
|
return {
|
|
801
|
-
value:
|
|
1417
|
+
value: formattedValue,
|
|
1418
|
+
style
|
|
802
1419
|
};
|
|
803
1420
|
}));
|
|
804
1421
|
const styles = {
|
|
805
1422
|
root: {
|
|
806
|
-
...((
|
|
1423
|
+
...((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_font = _input_layout1.font) === null || _input_layout_font === void 0 ? void 0 : _input_layout_font.size) ? {
|
|
807
1424
|
fontSize: input.layout.font.size
|
|
808
1425
|
} : {}
|
|
809
1426
|
}
|
|
810
1427
|
};
|
|
811
1428
|
var _tableData_header_values;
|
|
812
1429
|
return {
|
|
813
|
-
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 : []).
|
|
814
|
-
value
|
|
815
|
-
})),
|
|
1430
|
+
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 : [], tableData.header && Object.keys(tableData.header).length > 0 ? tableData.header : (_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_data1.table[0].header),
|
|
816
1431
|
rows,
|
|
817
|
-
width: (
|
|
818
|
-
height: (
|
|
1432
|
+
width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
|
|
1433
|
+
height: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height,
|
|
819
1434
|
styles
|
|
820
1435
|
};
|
|
821
1436
|
};
|
|
1437
|
+
function getCategoriesAndValues(series) {
|
|
1438
|
+
const orientation = series.orientation || 'h';
|
|
1439
|
+
var _series_labels, _ref;
|
|
1440
|
+
const y = (_ref = (_series_labels = series.labels) !== null && _series_labels !== void 0 ? _series_labels : series.y) !== null && _ref !== void 0 ? _ref : series.stage;
|
|
1441
|
+
var _series_values, _ref1;
|
|
1442
|
+
const x = (_ref1 = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : series.x) !== null && _ref1 !== void 0 ? _ref1 : series.value;
|
|
1443
|
+
const xIsString = (0, _chartutilities.isStringArray)(x);
|
|
1444
|
+
const yIsString = (0, _chartutilities.isStringArray)(y);
|
|
1445
|
+
const xIsNumber = (0, _chartutilities.isNumberArray)(x);
|
|
1446
|
+
const yIsNumber = (0, _chartutilities.isNumberArray)(y);
|
|
1447
|
+
// Helper to ensure array of (string | number)
|
|
1448
|
+
const toArray = (arr)=>{
|
|
1449
|
+
if (Array.isArray(arr)) {
|
|
1450
|
+
return arr;
|
|
1451
|
+
}
|
|
1452
|
+
if (typeof arr === 'string' || typeof arr === 'number') {
|
|
1453
|
+
return [
|
|
1454
|
+
arr
|
|
1455
|
+
];
|
|
1456
|
+
}
|
|
1457
|
+
return [];
|
|
1458
|
+
};
|
|
1459
|
+
if (orientation === 'h') {
|
|
1460
|
+
if (yIsString && xIsNumber) {
|
|
1461
|
+
return {
|
|
1462
|
+
categories: toArray(y),
|
|
1463
|
+
values: toArray(x)
|
|
1464
|
+
};
|
|
1465
|
+
} else if (xIsString && yIsNumber) {
|
|
1466
|
+
return {
|
|
1467
|
+
categories: toArray(x),
|
|
1468
|
+
values: toArray(y)
|
|
1469
|
+
};
|
|
1470
|
+
} else {
|
|
1471
|
+
return {
|
|
1472
|
+
categories: yIsString ? toArray(y) : toArray(x),
|
|
1473
|
+
values: yIsString ? toArray(x) : toArray(y)
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
} else {
|
|
1477
|
+
if (xIsString && yIsNumber) {
|
|
1478
|
+
return {
|
|
1479
|
+
categories: toArray(x),
|
|
1480
|
+
values: toArray(y)
|
|
1481
|
+
};
|
|
1482
|
+
} else if (yIsString && xIsNumber) {
|
|
1483
|
+
return {
|
|
1484
|
+
categories: toArray(y),
|
|
1485
|
+
values: toArray(x)
|
|
1486
|
+
};
|
|
1487
|
+
} else {
|
|
1488
|
+
return {
|
|
1489
|
+
categories: xIsString ? toArray(x) : toArray(y),
|
|
1490
|
+
values: xIsString ? toArray(y) : toArray(x)
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
const transformPlotlyJsonToFunnelChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
1496
|
+
var _input_layout, _input_layout1, _input_data_, _input_layout2;
|
|
1497
|
+
const funnelData = [];
|
|
1498
|
+
// Determine if data is stacked based on multiple series with multiple values per series
|
|
1499
|
+
const isStacked = input.data.length > 1 && input.data.every((series)=>{
|
|
1500
|
+
var _series_values, _ref;
|
|
1501
|
+
const values = (_ref = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : series.x) !== null && _ref !== void 0 ? _ref : series.value;
|
|
1502
|
+
var _series_labels, _ref1;
|
|
1503
|
+
const labels = (_ref1 = (_series_labels = series.labels) !== null && _series_labels !== void 0 ? _series_labels : series.y) !== null && _ref1 !== void 0 ? _ref1 : series.stage;
|
|
1504
|
+
return Array.isArray(labels) && Array.isArray(values) && values.length > 1 && labels.length > 1;
|
|
1505
|
+
});
|
|
1506
|
+
if (isStacked) {
|
|
1507
|
+
// Assign a color per series/category and use it for all subValues of that category
|
|
1508
|
+
const seriesColors = {};
|
|
1509
|
+
input.data.forEach((series, seriesIdx)=>{
|
|
1510
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_marker1;
|
|
1511
|
+
const category = series.name || `Category ${seriesIdx + 1}`;
|
|
1512
|
+
var _series_marker_colors;
|
|
1513
|
+
// Use the same color for this category across all stages
|
|
1514
|
+
const extractedColors = (0, _PlotlyColorAdapter.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);
|
|
1515
|
+
// Always use the first color for the series/category
|
|
1516
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, 0, category, colorMap, isDarkTheme);
|
|
1517
|
+
seriesColors[category] = color;
|
|
1518
|
+
var _series_labels, _ref;
|
|
1519
|
+
const labels = (_ref = (_series_labels = series.labels) !== null && _series_labels !== void 0 ? _series_labels : series.y) !== null && _ref !== void 0 ? _ref : series.stage;
|
|
1520
|
+
var _series_values, _ref1;
|
|
1521
|
+
const values = (_ref1 = (_series_values = series.values) !== null && _series_values !== void 0 ? _series_values : series.x) !== null && _ref1 !== void 0 ? _ref1 : series.value;
|
|
1522
|
+
if (!(0, _chartutilities.isArrayOrTypedArray)(labels) || !(0, _chartutilities.isArrayOrTypedArray)(values)) {
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1525
|
+
if (labels && (0, _chartutilities.isArrayOrTypedArray)(labels) && labels.length > 0) {
|
|
1526
|
+
labels.forEach((label, i)=>{
|
|
1527
|
+
const stageIndex = funnelData.findIndex((stage)=>stage.stage === label);
|
|
1528
|
+
const valueNum = Number(values[i]);
|
|
1529
|
+
if (isNaN(valueNum)) {
|
|
1530
|
+
return;
|
|
1531
|
+
}
|
|
1532
|
+
if (stageIndex === -1) {
|
|
1533
|
+
funnelData.push({
|
|
1534
|
+
stage: label,
|
|
1535
|
+
subValues: [
|
|
1536
|
+
{
|
|
1537
|
+
category,
|
|
1538
|
+
value: valueNum,
|
|
1539
|
+
color
|
|
1540
|
+
}
|
|
1541
|
+
]
|
|
1542
|
+
});
|
|
1543
|
+
} else {
|
|
1544
|
+
funnelData[stageIndex].subValues.push({
|
|
1545
|
+
category,
|
|
1546
|
+
value: valueNum,
|
|
1547
|
+
color
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
});
|
|
1553
|
+
} else {
|
|
1554
|
+
// Non-stacked data handling (multiple series with single-value arrays)
|
|
1555
|
+
input.data.forEach((series, seriesIdx)=>{
|
|
1556
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_marker1;
|
|
1557
|
+
const { categories, values } = getCategoriesAndValues(series);
|
|
1558
|
+
if (!(0, _chartutilities.isArrayOrTypedArray)(categories) || !(0, _chartutilities.isArrayOrTypedArray)(values)) {
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1561
|
+
var _series_marker_colors;
|
|
1562
|
+
const extractedColors = (0, _PlotlyColorAdapter.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);
|
|
1563
|
+
categories.forEach((label, i)=>{
|
|
1564
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, i, label, colorMap, isDarkTheme);
|
|
1565
|
+
const valueNum = Number(values[i]);
|
|
1566
|
+
if (isNaN(valueNum)) {
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
funnelData.push({
|
|
1570
|
+
stage: label,
|
|
1571
|
+
value: valueNum,
|
|
1572
|
+
color
|
|
1573
|
+
});
|
|
1574
|
+
});
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
return {
|
|
1578
|
+
data: funnelData,
|
|
1579
|
+
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
1580
|
+
height: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height,
|
|
1581
|
+
orientation: ((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.orientation) === 'v' ? 'horizontal' : 'vertical',
|
|
1582
|
+
hideLegend: isMultiPlot || ((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.showlegend) === false
|
|
1583
|
+
};
|
|
1584
|
+
};
|
|
822
1585
|
const projectPolarToCartesian = (input)=>{
|
|
1586
|
+
var _input_layout, _input_layout1;
|
|
823
1587
|
const projection = {
|
|
824
1588
|
...input
|
|
825
1589
|
};
|
|
1590
|
+
// Find the global min and max radius across all series
|
|
1591
|
+
let minRadius = 0;
|
|
1592
|
+
let maxRadius = 0;
|
|
1593
|
+
for(let sindex = 0; sindex < input.data.length; sindex++){
|
|
1594
|
+
const rVals = input.data[sindex].r;
|
|
1595
|
+
if (rVals && (0, _chartutilities.isArrayOrTypedArray)(rVals)) {
|
|
1596
|
+
for(let ptindex = 0; ptindex < rVals.length; ptindex++){
|
|
1597
|
+
if (!(0, _chartutilities.isInvalidValue)(rVals[ptindex])) {
|
|
1598
|
+
minRadius = Math.min(minRadius, rVals[ptindex]);
|
|
1599
|
+
maxRadius = Math.max(maxRadius, rVals[ptindex]);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
// If there are negative radii, compute the shift
|
|
1605
|
+
const radiusShift = minRadius < 0 ? -minRadius : 0;
|
|
1606
|
+
// Collect all unique theta values from all scatterpolar series for equal spacing
|
|
1607
|
+
const allThetaValues = new Set();
|
|
1608
|
+
for(let sindex = 0; sindex < input.data.length; sindex++){
|
|
1609
|
+
const series = input.data[sindex];
|
|
1610
|
+
if (series.theta && (0, _chartutilities.isArrayOrTypedArray)(series.theta)) {
|
|
1611
|
+
series.theta.forEach((theta)=>allThetaValues.add(String(theta)));
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
// Project all points and create a perfect square domain
|
|
1615
|
+
const allX = [];
|
|
1616
|
+
const allY = [];
|
|
1617
|
+
let originX = null;
|
|
826
1618
|
for(let sindex = 0; sindex < input.data.length; sindex++){
|
|
1619
|
+
var _input_layout_polar_angularaxis, _input_layout_polar, _input_layout2, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout3;
|
|
827
1620
|
const series = input.data[sindex];
|
|
1621
|
+
// If scatterpolar, set __axisLabel to all unique theta values for equal spacing
|
|
1622
|
+
if ((0, _chartutilities.isArrayOrTypedArray)(series.theta)) {
|
|
1623
|
+
series.__axisLabel = Array.from(allThetaValues);
|
|
1624
|
+
}
|
|
828
1625
|
series.x = [];
|
|
829
1626
|
series.y = [];
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
1627
|
+
const thetas = series.theta;
|
|
1628
|
+
const rVals = series.r;
|
|
1629
|
+
// Skip if rVals or thetas are not arrays
|
|
1630
|
+
if (!(0, _chartutilities.isArrayOrTypedArray)(rVals) || !(0, _chartutilities.isArrayOrTypedArray)(thetas)) {
|
|
1631
|
+
projection.data[sindex] = series;
|
|
1632
|
+
continue;
|
|
1633
|
+
}
|
|
1634
|
+
// retrieve polar axis settings
|
|
1635
|
+
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;
|
|
1636
|
+
var _input_layout_polar_angularaxis_rotation;
|
|
1637
|
+
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;
|
|
1638
|
+
// Compute tick positions if categorical
|
|
1639
|
+
let uniqueTheta = [];
|
|
1640
|
+
let categorical = false;
|
|
1641
|
+
if (!(0, _chartutilities.isNumberArray)(thetas)) {
|
|
1642
|
+
uniqueTheta = Array.from(new Set(thetas));
|
|
1643
|
+
categorical = true;
|
|
1644
|
+
}
|
|
1645
|
+
for(let ptindex = 0; ptindex < rVals.length; ptindex++){
|
|
1646
|
+
if ((0, _chartutilities.isInvalidValue)(thetas === null || thetas === void 0 ? void 0 : thetas[ptindex]) || (0, _chartutilities.isInvalidValue)(rVals === null || rVals === void 0 ? void 0 : rVals[ptindex])) {
|
|
1647
|
+
continue;
|
|
1648
|
+
}
|
|
1649
|
+
// Map theta to angle in radians
|
|
1650
|
+
let thetaRad;
|
|
1651
|
+
if (categorical) {
|
|
1652
|
+
const idx = uniqueTheta.indexOf(thetas[ptindex]);
|
|
1653
|
+
const step = 2 * Math.PI / uniqueTheta.length;
|
|
1654
|
+
thetaRad = startAngleInRad + dirMultiplier * idx * step;
|
|
1655
|
+
} else {
|
|
1656
|
+
thetaRad = startAngleInRad + dirMultiplier * (thetas[ptindex] * Math.PI / 180);
|
|
1657
|
+
}
|
|
1658
|
+
// Shift only the polar origin (not the cartesian)
|
|
1659
|
+
const rawRadius = rVals[ptindex];
|
|
1660
|
+
const polarRadius = rawRadius + radiusShift; // Only for projection
|
|
1661
|
+
// Calculate cartesian coordinates (with shifted polar origin)
|
|
1662
|
+
const x = polarRadius * Math.cos(thetaRad);
|
|
1663
|
+
const y = polarRadius * Math.sin(thetaRad);
|
|
1664
|
+
// Calculate the cartesian coordinates of the original polar origin (0,0)
|
|
1665
|
+
// This is the point that should be mapped to (0,0) in cartesian coordinates
|
|
1666
|
+
if (sindex === 0 && ptindex === 0) {
|
|
1667
|
+
// For polar origin (r=0, θ=0), cartesian coordinates are (0,0)
|
|
1668
|
+
// But since we shifted the radius by radiusShift, the cartesian origin is at (radiusShift, 0)
|
|
1669
|
+
originX = radiusShift;
|
|
1670
|
+
}
|
|
1671
|
+
series.x.push(x);
|
|
1672
|
+
series.y.push(y);
|
|
1673
|
+
allX.push(x);
|
|
1674
|
+
allY.push(y);
|
|
1675
|
+
}
|
|
1676
|
+
// Map text to each data point for downstream chart rendering
|
|
1677
|
+
if (series.x && series.y) {
|
|
1678
|
+
series.data = series.x.map((xVal, idx)=>({
|
|
1679
|
+
x: xVal,
|
|
1680
|
+
y: series.y[idx],
|
|
1681
|
+
...series.text ? {
|
|
1682
|
+
text: series.text[idx]
|
|
1683
|
+
} : {}
|
|
1684
|
+
}));
|
|
835
1685
|
}
|
|
836
1686
|
projection.data[sindex] = series;
|
|
837
1687
|
}
|
|
1688
|
+
// 7. Recenter all cartesian coordinates
|
|
1689
|
+
if (originX !== null) {
|
|
1690
|
+
for(let sindex = 0; sindex < projection.data.length; sindex++){
|
|
1691
|
+
const series = projection.data[sindex];
|
|
1692
|
+
if (series.x && series.y) {
|
|
1693
|
+
series.x = series.x.map((v)=>v - originX);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
// Also recenter allX for normalization
|
|
1697
|
+
for(let i = 0; i < allX.length; i++){
|
|
1698
|
+
allX[i] = allX[i] - originX;
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
// 8. Find the maximum absolute value among all x and y
|
|
1702
|
+
let maxAbs = Math.max(...allX.map(Math.abs), ...allY.map(Math.abs));
|
|
1703
|
+
maxAbs = maxAbs === 0 ? 1 : maxAbs;
|
|
1704
|
+
// 9. Rescale all points so that the largest |x| or |y| is 0.5
|
|
1705
|
+
for(let sindex = 0; sindex < projection.data.length; sindex++){
|
|
1706
|
+
const series = projection.data[sindex];
|
|
1707
|
+
if (series.x && series.y) {
|
|
1708
|
+
series.x = series.x.map((v)=>v / (2 * maxAbs));
|
|
1709
|
+
series.y = series.y.map((v)=>v / (2 * maxAbs));
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
// 10. Customize layout for perfect square with absolute positioning
|
|
1713
|
+
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;
|
|
1714
|
+
projection.layout = {
|
|
1715
|
+
...projection.layout,
|
|
1716
|
+
width: size,
|
|
1717
|
+
height: size
|
|
1718
|
+
};
|
|
1719
|
+
// Attach originX as custom properties
|
|
1720
|
+
projection.layout.__polarOriginX = originX !== null && originX !== void 0 ? originX : undefined;
|
|
838
1721
|
return projection;
|
|
839
1722
|
};
|
|
840
1723
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -905,11 +1788,6 @@ function getLineOptions(line) {
|
|
|
905
1788
|
}
|
|
906
1789
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
907
1790
|
}
|
|
908
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
909
|
-
const isStringArray = (arr)=>{
|
|
910
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
911
|
-
return (0, _chartutilities.isArrayOfType)(arr, (value)=>typeof value === 'string');
|
|
912
|
-
};
|
|
913
1791
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|
|
914
1792
|
const findBinIndex = (bins, value, isString)=>{
|
|
915
1793
|
if (typeof value === 'undefined' || value === null) {
|
|
@@ -928,7 +1806,7 @@ const createBins = (data, binStart, binEnd, binSize)=>{
|
|
|
928
1806
|
if (!data || data.length === 0) {
|
|
929
1807
|
return [];
|
|
930
1808
|
}
|
|
931
|
-
if (isStringArray(data)) {
|
|
1809
|
+
if ((0, _chartutilities.isStringArray)(data)) {
|
|
932
1810
|
const categories = Array.from(new Set(data));
|
|
933
1811
|
const start = typeof binStart === 'number' ? Math.ceil(binStart) : 0;
|
|
934
1812
|
const stop = typeof binEnd === 'number' ? Math.floor(binEnd) + 1 : categories.length;
|
|
@@ -945,11 +1823,11 @@ const createBins = (data, binStart, binEnd, binSize)=>{
|
|
|
945
1823
|
]);
|
|
946
1824
|
if (typeof binSize === 'number' && binSize > 0) {
|
|
947
1825
|
const thresholds = [];
|
|
948
|
-
const precision = Math.max(
|
|
949
|
-
let th = precisionRound(minVal, precision);
|
|
950
|
-
while(th < precisionRound(maxVal + binSize, precision)){
|
|
1826
|
+
const precision = Math.max((0, _utilities.calculatePrecision)(minVal), (0, _utilities.calculatePrecision)(binSize));
|
|
1827
|
+
let th = (0, _utilities.precisionRound)(minVal, precision);
|
|
1828
|
+
while(th < (0, _utilities.precisionRound)(maxVal + binSize, precision)){
|
|
951
1829
|
thresholds.push(th);
|
|
952
|
-
th = precisionRound(th + binSize, precision);
|
|
1830
|
+
th = (0, _utilities.precisionRound)(th + binSize, precision);
|
|
953
1831
|
}
|
|
954
1832
|
minVal = thresholds[0];
|
|
955
1833
|
maxVal = thresholds[thresholds.length - 1];
|
|
@@ -995,16 +1873,65 @@ const calculateHistNorm = (histnorm, value, total, dx, dy = 1)=>{
|
|
|
995
1873
|
return value;
|
|
996
1874
|
}
|
|
997
1875
|
};
|
|
998
|
-
const
|
|
999
|
-
var
|
|
1000
|
-
|
|
1001
|
-
|
|
1876
|
+
const getLegendShape = (series)=>{
|
|
1877
|
+
var _series_line, _series_mode;
|
|
1878
|
+
const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
|
|
1879
|
+
if (dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot') {
|
|
1880
|
+
return 'dottedLine';
|
|
1881
|
+
} else if ((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('markers')) {
|
|
1882
|
+
return 'circle';
|
|
1883
|
+
}
|
|
1884
|
+
return 'default';
|
|
1002
1885
|
};
|
|
1003
|
-
const
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1886
|
+
const getAllupLegendsProps = (input, colorMap, colorwayType, traceInfo, isDarkTheme)=>{
|
|
1887
|
+
const allupLegends = [];
|
|
1888
|
+
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1889
|
+
const toShowLegend = input.data.reduce((acc, series)=>{
|
|
1890
|
+
return acc || series.showlegend === true || series.showlegend === undefined;
|
|
1891
|
+
}, false);
|
|
1892
|
+
if (toShowLegend) {
|
|
1893
|
+
input.data.forEach((series, index)=>{
|
|
1894
|
+
if (traceInfo[index].type === 'donut') {
|
|
1895
|
+
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _pieSeries_marker, _pieSeries_labels;
|
|
1896
|
+
const pieSeries = series;
|
|
1897
|
+
var _input_layout_piecolorway, _input_layout_piecolorway1;
|
|
1898
|
+
const colors = (0, _PlotlyColorAdapter.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);
|
|
1899
|
+
(_pieSeries_labels = pieSeries.labels) === null || _pieSeries_labels === void 0 ? void 0 : _pieSeries_labels.forEach((label, labelIndex)=>{
|
|
1900
|
+
const legend = `${label}`;
|
|
1901
|
+
// resolve color for each legend from the extracted colors
|
|
1902
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(colors, labelIndex, legend, colorMap, isDarkTheme);
|
|
1903
|
+
if (legend !== '' && allupLegends.some((group)=>group.title === legend) === false) {
|
|
1904
|
+
allupLegends.push({
|
|
1905
|
+
title: legend,
|
|
1906
|
+
color
|
|
1907
|
+
});
|
|
1908
|
+
}
|
|
1909
|
+
});
|
|
1910
|
+
} else if (isNonPlotType(traceInfo[index].type) === false) {
|
|
1911
|
+
var _plotSeries_line, _plotSeries_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout3;
|
|
1912
|
+
const plotSeries = series;
|
|
1913
|
+
const name = plotSeries.legendgroup;
|
|
1914
|
+
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);
|
|
1915
|
+
const legendShape = getLegendShape(plotSeries);
|
|
1916
|
+
const resolvedColor = (0, _PlotlyColorAdapter.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);
|
|
1917
|
+
if (name !== undefined && name !== '' && allupLegends.some((group)=>group.title === name) === false) {
|
|
1918
|
+
allupLegends.push({
|
|
1919
|
+
title: name,
|
|
1920
|
+
color: resolvedColor,
|
|
1921
|
+
shape: legendShape
|
|
1922
|
+
});
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
return {
|
|
1928
|
+
legends: allupLegends,
|
|
1929
|
+
centerLegends: true,
|
|
1930
|
+
enabledWrapLines: true,
|
|
1931
|
+
canSelectMultipleLegends: true
|
|
1932
|
+
};
|
|
1006
1933
|
};
|
|
1007
|
-
const getLegendProps = (data, layout)=>{
|
|
1934
|
+
const getLegendProps = (data, layout, isMultiPlot)=>{
|
|
1008
1935
|
const legends = [];
|
|
1009
1936
|
if (data.length === 1) {
|
|
1010
1937
|
legends.push(data[0].name || '');
|
|
@@ -1013,9 +1940,474 @@ const getLegendProps = (data, layout)=>{
|
|
|
1013
1940
|
legends.push(series.name || `Series ${index + 1}`);
|
|
1014
1941
|
});
|
|
1015
1942
|
}
|
|
1016
|
-
const
|
|
1943
|
+
const hideLegendsData = data.every((series)=>series.showlegend === false);
|
|
1944
|
+
const hideLegendsInferred = (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false || (layout === null || layout === void 0 ? void 0 : layout.showlegend) !== true && legends.length < 2;
|
|
1017
1945
|
return {
|
|
1018
1946
|
legends,
|
|
1019
|
-
hideLegend:
|
|
1947
|
+
hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData
|
|
1020
1948
|
};
|
|
1021
1949
|
};
|
|
1950
|
+
const getNumberAtIndexOrDefault = (data, index)=>{
|
|
1951
|
+
if ((0, _chartutilities.isArrayOrTypedArray)(data)) {
|
|
1952
|
+
if (typeof data[index] !== 'number' || !isFinite(data[index])) {
|
|
1953
|
+
return;
|
|
1954
|
+
}
|
|
1955
|
+
return data[index];
|
|
1956
|
+
}
|
|
1957
|
+
return 1;
|
|
1958
|
+
};
|
|
1959
|
+
const getValidXYRanges = (series)=>{
|
|
1960
|
+
if (!(0, _chartutilities.isArrayOrTypedArray)(series.x) || !(0, _chartutilities.isArrayOrTypedArray)(series.y)) {
|
|
1961
|
+
return [];
|
|
1962
|
+
}
|
|
1963
|
+
const ranges = [];
|
|
1964
|
+
let start = 0;
|
|
1965
|
+
let end = 0;
|
|
1966
|
+
for(; end < series.x.length; end++){
|
|
1967
|
+
if ((0, _chartutilities.isInvalidValue)(series.x[end]) || (0, _chartutilities.isInvalidValue)(series.y[end])) {
|
|
1968
|
+
if (end - start > 0) {
|
|
1969
|
+
ranges.push([
|
|
1970
|
+
start,
|
|
1971
|
+
end
|
|
1972
|
+
]);
|
|
1973
|
+
}
|
|
1974
|
+
start = end + 1;
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
if (end - start > 0) {
|
|
1978
|
+
ranges.push([
|
|
1979
|
+
start,
|
|
1980
|
+
end
|
|
1981
|
+
]);
|
|
1982
|
+
}
|
|
1983
|
+
return ranges;
|
|
1984
|
+
};
|
|
1985
|
+
const getIndexFromKey = (key, pattern)=>{
|
|
1986
|
+
const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1987
|
+
return parseInt(normalizedKey, 10) - 1;
|
|
1988
|
+
};
|
|
1989
|
+
const isNonPlotType = (chartType)=>{
|
|
1990
|
+
return [
|
|
1991
|
+
'donut',
|
|
1992
|
+
'sankey',
|
|
1993
|
+
'pie'
|
|
1994
|
+
].includes(chartType);
|
|
1995
|
+
};
|
|
1996
|
+
const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
|
|
1997
|
+
const domainX = [];
|
|
1998
|
+
const domainY = [];
|
|
1999
|
+
let cartesianDomains = 0;
|
|
2000
|
+
const annotations = {};
|
|
2001
|
+
let templateRows = '1fr';
|
|
2002
|
+
let templateColumns = '1fr';
|
|
2003
|
+
const gridLayout = {};
|
|
2004
|
+
if (!isMultiPlot) {
|
|
2005
|
+
return {
|
|
2006
|
+
templateRows,
|
|
2007
|
+
templateColumns,
|
|
2008
|
+
layout: gridLayout
|
|
2009
|
+
};
|
|
2010
|
+
}
|
|
2011
|
+
const layout = schema === null || schema === void 0 ? void 0 : schema.layout;
|
|
2012
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
2013
|
+
Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach((key)=>{
|
|
2014
|
+
if (key.startsWith('xaxis')) {
|
|
2015
|
+
var _layout_key;
|
|
2016
|
+
const index = getIndexFromKey(key, 'xaxis');
|
|
2017
|
+
var _layout_key_anchor;
|
|
2018
|
+
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';
|
|
2019
|
+
const anchorIndex = getIndexFromKey(anchor, 'y');
|
|
2020
|
+
if (index !== anchorIndex) {
|
|
2021
|
+
throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
|
|
2022
|
+
}
|
|
2023
|
+
const xAxisLayout = layout[key];
|
|
2024
|
+
const domainXInfo = {
|
|
2025
|
+
start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
|
|
2026
|
+
end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1
|
|
2027
|
+
};
|
|
2028
|
+
domainX.push(domainXInfo);
|
|
2029
|
+
} else if (key.startsWith('yaxis')) {
|
|
2030
|
+
var _layout_key1;
|
|
2031
|
+
const index = getIndexFromKey(key, 'yaxis');
|
|
2032
|
+
var _layout_key_anchor1;
|
|
2033
|
+
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';
|
|
2034
|
+
const anchorIndex = getIndexFromKey(anchor, 'x');
|
|
2035
|
+
if (index !== anchorIndex) {
|
|
2036
|
+
var _layout_yaxis2;
|
|
2037
|
+
if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
|
|
2038
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
2039
|
+
return {
|
|
2040
|
+
templateRows,
|
|
2041
|
+
templateColumns
|
|
2042
|
+
};
|
|
2043
|
+
}
|
|
2044
|
+
throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
|
|
2045
|
+
}
|
|
2046
|
+
const yAxisLayout = layout[key];
|
|
2047
|
+
const domainYInfo = {
|
|
2048
|
+
start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
|
|
2049
|
+
end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1
|
|
2050
|
+
};
|
|
2051
|
+
domainY.push(domainYInfo);
|
|
2052
|
+
}
|
|
2053
|
+
});
|
|
2054
|
+
}
|
|
2055
|
+
cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
|
|
2056
|
+
validTracesInfo.forEach((trace, index)=>{
|
|
2057
|
+
if (isNonPlotType(trace.type)) {
|
|
2058
|
+
var _schema_data, _series_domain, _series_domain1, _series_domain2, _series_domain3;
|
|
2059
|
+
const series = schema === null || schema === void 0 ? void 0 : (_schema_data = schema.data) === null || _schema_data === void 0 ? void 0 : _schema_data[index];
|
|
2060
|
+
const domainXInfo = {
|
|
2061
|
+
start: ((_series_domain = series.domain) === null || _series_domain === void 0 ? void 0 : _series_domain.x) ? series.domain.x[0] : 0,
|
|
2062
|
+
end: ((_series_domain1 = series.domain) === null || _series_domain1 === void 0 ? void 0 : _series_domain1.x) ? series.domain.x[1] : 1
|
|
2063
|
+
};
|
|
2064
|
+
const domainYInfo = {
|
|
2065
|
+
start: ((_series_domain2 = series.domain) === null || _series_domain2 === void 0 ? void 0 : _series_domain2.y) ? series.domain.y[0] : 0,
|
|
2066
|
+
end: ((_series_domain3 = series.domain) === null || _series_domain3 === void 0 ? void 0 : _series_domain3.y) ? series.domain.y[1] : 1
|
|
2067
|
+
};
|
|
2068
|
+
domainX.push(domainXInfo);
|
|
2069
|
+
domainY.push(domainYInfo);
|
|
2070
|
+
}
|
|
2071
|
+
});
|
|
2072
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
2073
|
+
var _layout_annotations;
|
|
2074
|
+
(_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
|
|
2075
|
+
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 ? [
|
|
2076
|
+
idx
|
|
2077
|
+
] : []);
|
|
2078
|
+
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);
|
|
2079
|
+
if (yMatch !== -1) {
|
|
2080
|
+
if (annotations[yMatch] === undefined) {
|
|
2081
|
+
annotations[yMatch] = {};
|
|
2082
|
+
}
|
|
2083
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
2084
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
2085
|
+
} else {
|
|
2086
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2091
|
+
if (domainX.length > 0) {
|
|
2092
|
+
const uniqueXIntervals = new Map();
|
|
2093
|
+
domainX.forEach((interval)=>{
|
|
2094
|
+
const key = `${interval.start}-${interval.end}`;
|
|
2095
|
+
if (!uniqueXIntervals.has(key)) {
|
|
2096
|
+
uniqueXIntervals.set(key, interval);
|
|
2097
|
+
}
|
|
2098
|
+
});
|
|
2099
|
+
const sortedXStart = Array.from(uniqueXIntervals.values()).map((interval)=>interval.start).sort();
|
|
2100
|
+
templateColumns = `repeat(${sortedXStart.length}, 1fr)`;
|
|
2101
|
+
domainX.forEach((interval, index)=>{
|
|
2102
|
+
const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
|
|
2103
|
+
const columnIndex = sortedXStart.findIndex((start)=>start === interval.start);
|
|
2104
|
+
const columnNumber = columnIndex + 1; // Column numbers are 1-based
|
|
2105
|
+
const annotationProps = annotations[index];
|
|
2106
|
+
const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
2107
|
+
const row = {
|
|
2108
|
+
row: -1,
|
|
2109
|
+
column: columnNumber,
|
|
2110
|
+
xAnnotation,
|
|
2111
|
+
xDomain: interval,
|
|
2112
|
+
yDomain: {
|
|
2113
|
+
start: 0,
|
|
2114
|
+
end: 1
|
|
2115
|
+
}
|
|
2116
|
+
};
|
|
2117
|
+
gridLayout[cellName] = row;
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
if (domainY.length > 0) {
|
|
2121
|
+
const uniqueYIntervals = new Map();
|
|
2122
|
+
domainY.forEach((interval)=>{
|
|
2123
|
+
const key = `${interval.start}-${interval.end}`;
|
|
2124
|
+
if (!uniqueYIntervals.has(key)) {
|
|
2125
|
+
uniqueYIntervals.set(key, interval);
|
|
2126
|
+
}
|
|
2127
|
+
});
|
|
2128
|
+
const sortedYStart = Array.from(uniqueYIntervals.values()).map((interval)=>interval.start).sort();
|
|
2129
|
+
const numberOfRows = sortedYStart.length;
|
|
2130
|
+
templateRows = `repeat(${numberOfRows}, 1fr)`;
|
|
2131
|
+
domainY.forEach((interval, index)=>{
|
|
2132
|
+
const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
|
|
2133
|
+
const rowIndex = sortedYStart.findIndex((start)=>start === interval.start);
|
|
2134
|
+
const rowNumber = numberOfRows - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
|
|
2135
|
+
const annotationProps = annotations[index];
|
|
2136
|
+
const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
2137
|
+
const cell = gridLayout[cellName];
|
|
2138
|
+
if (cell !== undefined) {
|
|
2139
|
+
cell.row = rowNumber;
|
|
2140
|
+
cell.yAnnotation = yAnnotation;
|
|
2141
|
+
cell.yDomain = interval;
|
|
2142
|
+
}
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
2145
|
+
return {
|
|
2146
|
+
templateRows,
|
|
2147
|
+
templateColumns,
|
|
2148
|
+
layout: gridLayout
|
|
2149
|
+
};
|
|
2150
|
+
};
|
|
2151
|
+
/**
|
|
2152
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/category_order_defaults.js#L50}
|
|
2153
|
+
*/ const getAxisCategoryOrderProps = (data, layout)=>{
|
|
2154
|
+
const result = {};
|
|
2155
|
+
const axesById = {
|
|
2156
|
+
x: layout === null || layout === void 0 ? void 0 : layout.xaxis,
|
|
2157
|
+
y: layout === null || layout === void 0 ? void 0 : layout.yaxis
|
|
2158
|
+
};
|
|
2159
|
+
Object.keys(axesById).forEach((axId)=>{
|
|
2160
|
+
const ax = axesById[axId];
|
|
2161
|
+
const axLetter = axId[0];
|
|
2162
|
+
const propName = `${axLetter}AxisCategoryOrder`;
|
|
2163
|
+
const values = [];
|
|
2164
|
+
data.forEach((series)=>{
|
|
2165
|
+
var _series_axLetter;
|
|
2166
|
+
(_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
|
|
2167
|
+
if (!(0, _chartutilities.isInvalidValue)(val)) {
|
|
2168
|
+
values.push(val);
|
|
2169
|
+
}
|
|
2170
|
+
});
|
|
2171
|
+
});
|
|
2172
|
+
const isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || (0, _chartutilities.isStringArray)(values) && !(0, _chartutilities.isNumberArray)(values) && !(0, _chartutilities.isDateArray)(values);
|
|
2173
|
+
if (!isAxisTypeCategory) {
|
|
2174
|
+
return;
|
|
2175
|
+
}
|
|
2176
|
+
const isValidArray = (0, _chartutilities.isArrayOrTypedArray)(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
|
|
2177
|
+
if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
|
|
2178
|
+
result[propName] = ax.categoryarray;
|
|
2179
|
+
return;
|
|
2180
|
+
}
|
|
2181
|
+
if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
|
|
2182
|
+
const categoriesInTraceOrder = Array.from(new Set(values));
|
|
2183
|
+
result[propName] = categoriesInTraceOrder;
|
|
2184
|
+
return;
|
|
2185
|
+
}
|
|
2186
|
+
result[propName] = ax.categoryorder;
|
|
2187
|
+
});
|
|
2188
|
+
return result;
|
|
2189
|
+
};
|
|
2190
|
+
const getBarProps = (data, layout, isHorizontal)=>{
|
|
2191
|
+
let padding;
|
|
2192
|
+
if (typeof (layout === null || layout === void 0 ? void 0 : layout.bargap) === 'number') {
|
|
2193
|
+
if (layout.bargap >= 0 && layout.bargap <= 1) {
|
|
2194
|
+
padding = layout.bargap;
|
|
2195
|
+
} else {
|
|
2196
|
+
// 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.
|
|
2197
|
+
// However, we don't use this value as our default padding because it causes the bars to
|
|
2198
|
+
// appear disproportionately wide in large containers.
|
|
2199
|
+
padding = 0.2;
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
const plotlyBarWidths = data.map((series)=>{
|
|
2203
|
+
if (series.type === 'bar' && ((0, _chartutilities.isArrayOrTypedArray)(series.width) || typeof series.width === 'number')) {
|
|
2204
|
+
return series.width;
|
|
2205
|
+
}
|
|
2206
|
+
return [];
|
|
2207
|
+
}).flat();
|
|
2208
|
+
const maxPlotlyBarWidth = (0, _d3array.max)(plotlyBarWidths);
|
|
2209
|
+
if (typeof maxPlotlyBarWidth === 'number') {
|
|
2210
|
+
padding = 1 - maxPlotlyBarWidth;
|
|
2211
|
+
padding = Math.max(0, Math.min(padding, 1));
|
|
2212
|
+
}
|
|
2213
|
+
if (typeof padding === 'undefined') {
|
|
2214
|
+
return {};
|
|
2215
|
+
}
|
|
2216
|
+
if (isHorizontal) {
|
|
2217
|
+
return {
|
|
2218
|
+
maxBarHeight: 1000,
|
|
2219
|
+
yAxisPadding: padding
|
|
2220
|
+
};
|
|
2221
|
+
}
|
|
2222
|
+
return {
|
|
2223
|
+
barWidth: 'auto',
|
|
2224
|
+
maxBarWidth: 1000,
|
|
2225
|
+
xAxisInnerPadding: padding,
|
|
2226
|
+
xAxisOuterPadding: padding / 2
|
|
2227
|
+
};
|
|
2228
|
+
};
|
|
2229
|
+
const getAxisScaleTypeProps = (data, layout)=>{
|
|
2230
|
+
var _axisObjects_x, _axisObjects_y, _axisObjects_y2;
|
|
2231
|
+
const result = {};
|
|
2232
|
+
const axisObjects = getAxisObjects(data, layout);
|
|
2233
|
+
if (((_axisObjects_x = axisObjects.x) === null || _axisObjects_x === void 0 ? void 0 : _axisObjects_x.type) === 'log') {
|
|
2234
|
+
result.xScaleType = 'log';
|
|
2235
|
+
}
|
|
2236
|
+
if (((_axisObjects_y = axisObjects.y) === null || _axisObjects_y === void 0 ? void 0 : _axisObjects_y.type) === 'log') {
|
|
2237
|
+
result.yScaleType = 'log';
|
|
2238
|
+
}
|
|
2239
|
+
if (((_axisObjects_y2 = axisObjects.y2) === null || _axisObjects_y2 === void 0 ? void 0 : _axisObjects_y2.type) === 'log') {
|
|
2240
|
+
result.secondaryYScaleType = 'log';
|
|
2241
|
+
}
|
|
2242
|
+
return result;
|
|
2243
|
+
};
|
|
2244
|
+
/**
|
|
2245
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/tick_value_defaults.js#L8}
|
|
2246
|
+
*/ const getAxisTickProps = (data, layout)=>{
|
|
2247
|
+
const props = {};
|
|
2248
|
+
const axisObjects = getAxisObjects(data, layout);
|
|
2249
|
+
Object.keys(axisObjects).forEach((axId)=>{
|
|
2250
|
+
const ax = axisObjects[axId];
|
|
2251
|
+
if (!ax) {
|
|
2252
|
+
return;
|
|
2253
|
+
}
|
|
2254
|
+
const axType = getAxisType(data, axId[0], ax);
|
|
2255
|
+
if ((!ax.tickmode || ax.tickmode === 'array') && (0, _chartutilities.isArrayOrTypedArray)(ax.tickvals)) {
|
|
2256
|
+
const tickValues = axType === 'date' ? ax.tickvals.map((v)=>new Date(v)) : ax.tickvals;
|
|
2257
|
+
if (axId === 'x') {
|
|
2258
|
+
props.tickValues = tickValues;
|
|
2259
|
+
} else if (axId === 'y') {
|
|
2260
|
+
props.yAxisTickValues = tickValues;
|
|
2261
|
+
}
|
|
2262
|
+
return;
|
|
2263
|
+
}
|
|
2264
|
+
if ((!ax.tickmode || ax.tickmode === 'linear') && ax.dtick) {
|
|
2265
|
+
const dtick = plotlyDtick(ax.dtick, axType);
|
|
2266
|
+
const tick0 = plotlyTick0(ax.tick0, axType, dtick);
|
|
2267
|
+
if (axId === 'x') {
|
|
2268
|
+
props.xAxis = {
|
|
2269
|
+
tickStep: dtick,
|
|
2270
|
+
tick0: tick0
|
|
2271
|
+
};
|
|
2272
|
+
} else if (axId === 'y') {
|
|
2273
|
+
props.yAxis = {
|
|
2274
|
+
tickStep: dtick,
|
|
2275
|
+
tick0: tick0
|
|
2276
|
+
};
|
|
2277
|
+
}
|
|
2278
|
+
return;
|
|
2279
|
+
}
|
|
2280
|
+
if ((!ax.tickmode || ax.tickmode === 'auto') && typeof ax.nticks === 'number' && ax.nticks >= 0) {
|
|
2281
|
+
if (axId === 'x') {
|
|
2282
|
+
props.xAxisTickCount = ax.nticks;
|
|
2283
|
+
} else if (axId === 'y') {
|
|
2284
|
+
props.yAxisTickCount = ax.nticks;
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
});
|
|
2288
|
+
return props;
|
|
2289
|
+
};
|
|
2290
|
+
/**
|
|
2291
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L16}
|
|
2292
|
+
*/ const plotlyDtick = (dtick, axType)=>{
|
|
2293
|
+
const isLogAx = axType === 'log';
|
|
2294
|
+
const isDateAx = axType === 'date';
|
|
2295
|
+
const isCatAx = axType === 'category';
|
|
2296
|
+
const dtickDflt = isDateAx ? 86400000 : 1;
|
|
2297
|
+
if (!dtick) {
|
|
2298
|
+
return dtickDflt;
|
|
2299
|
+
}
|
|
2300
|
+
if ((0, _chartutilities.isNumber)(dtick)) {
|
|
2301
|
+
dtick = Number(dtick);
|
|
2302
|
+
if (dtick <= 0) {
|
|
2303
|
+
return dtickDflt;
|
|
2304
|
+
}
|
|
2305
|
+
if (isCatAx) {
|
|
2306
|
+
// category dtick must be positive integers
|
|
2307
|
+
return Math.max(1, Math.round(dtick));
|
|
2308
|
+
}
|
|
2309
|
+
if (isDateAx) {
|
|
2310
|
+
// date dtick must be at least 0.1ms (our current precision)
|
|
2311
|
+
return Math.max(0.1, dtick);
|
|
2312
|
+
}
|
|
2313
|
+
return dtick;
|
|
2314
|
+
}
|
|
2315
|
+
if (typeof dtick !== 'string' || !(isDateAx || isLogAx)) {
|
|
2316
|
+
return dtickDflt;
|
|
2317
|
+
}
|
|
2318
|
+
const prefix = dtick.charAt(0);
|
|
2319
|
+
const dtickNum = (0, _chartutilities.isNumber)(dtick.slice(1)) ? Number(dtick.slice(1)) : 0;
|
|
2320
|
+
if (dtickNum <= 0 || !(isDateAx && prefix === 'M' && dtickNum === Math.round(dtickNum) || // "L<f>" gives ticks linearly spaced in data (not in position) every (float) f
|
|
2321
|
+
isLogAx && prefix === 'L' || // "D1" gives powers of 10 with all small digits between, "D2" gives only 2 and 5
|
|
2322
|
+
isLogAx && prefix === 'D' && (dtickNum === 1 || dtickNum === 2))) {
|
|
2323
|
+
return dtickDflt;
|
|
2324
|
+
}
|
|
2325
|
+
return dtick;
|
|
2326
|
+
};
|
|
2327
|
+
/**
|
|
2328
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L70}
|
|
2329
|
+
*/ const plotlyTick0 = (tick0, axType, dtick)=>{
|
|
2330
|
+
if (axType === 'date') {
|
|
2331
|
+
return (0, _chartutilities.isDate)(tick0) ? new Date(tick0) : new Date(_utilities.DEFAULT_DATE_STRING);
|
|
2332
|
+
}
|
|
2333
|
+
if (dtick === 'D1' || dtick === 'D2') {
|
|
2334
|
+
// D1 and D2 modes ignore tick0 entirely
|
|
2335
|
+
return undefined;
|
|
2336
|
+
}
|
|
2337
|
+
// Aside from date axes, tick0 must be numeric
|
|
2338
|
+
return (0, _chartutilities.isNumber)(tick0) ? Number(tick0) : 0;
|
|
2339
|
+
};
|
|
2340
|
+
const getAxisObjects = (data, layout)=>{
|
|
2341
|
+
// Traces are grouped by their xaxis property, and for each group/subplot, the adapter functions
|
|
2342
|
+
// are called with the corresponding filtered data. As a result, all traces passed to an adapter
|
|
2343
|
+
// function share the same xaxis.
|
|
2344
|
+
let xAxisId;
|
|
2345
|
+
const yAxisIds = new Set();
|
|
2346
|
+
data.forEach((series)=>{
|
|
2347
|
+
const axisIds = (0, _chartutilities.getAxisIds)(series);
|
|
2348
|
+
xAxisId = axisIds.x;
|
|
2349
|
+
yAxisIds.add(axisIds.y);
|
|
2350
|
+
});
|
|
2351
|
+
const axisObjects = {};
|
|
2352
|
+
if (typeof xAxisId === 'number') {
|
|
2353
|
+
axisObjects.x = layout === null || layout === void 0 ? void 0 : layout[(0, _chartutilities.getAxisKey)('x', xAxisId)];
|
|
2354
|
+
}
|
|
2355
|
+
const sortedYAxisIds = Array.from(yAxisIds).sort();
|
|
2356
|
+
if (sortedYAxisIds.length > 0) {
|
|
2357
|
+
axisObjects.y = layout === null || layout === void 0 ? void 0 : layout[(0, _chartutilities.getAxisKey)('y', sortedYAxisIds[0])];
|
|
2358
|
+
}
|
|
2359
|
+
if (sortedYAxisIds.length > 1) {
|
|
2360
|
+
axisObjects.y2 = layout === null || layout === void 0 ? void 0 : layout[(0, _chartutilities.getAxisKey)('y', sortedYAxisIds[1])];
|
|
2361
|
+
}
|
|
2362
|
+
return axisObjects;
|
|
2363
|
+
};
|
|
2364
|
+
const getAxisType = (data, axLetter, ax)=>{
|
|
2365
|
+
const values = [];
|
|
2366
|
+
data.forEach((series)=>{
|
|
2367
|
+
var _series_axLetter;
|
|
2368
|
+
(_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
|
|
2369
|
+
if (!(0, _chartutilities.isInvalidValue)(val)) {
|
|
2370
|
+
values.push(val);
|
|
2371
|
+
}
|
|
2372
|
+
});
|
|
2373
|
+
});
|
|
2374
|
+
// Note: When ax.type is explicitly specified, Plotly casts the values to match that type.
|
|
2375
|
+
// Therefore, simply checking the type of the values may not be sufficient. At the moment,
|
|
2376
|
+
// we don’t always perform this casting ourselves and instead use the values as provided.
|
|
2377
|
+
if ((0, _chartutilities.isNumberArray)(values)) {
|
|
2378
|
+
if ((ax === null || ax === void 0 ? void 0 : ax.type) === 'log') {
|
|
2379
|
+
return 'log';
|
|
2380
|
+
}
|
|
2381
|
+
return 'linear';
|
|
2382
|
+
}
|
|
2383
|
+
if ((0, _chartutilities.isDateArray)(values)) {
|
|
2384
|
+
return 'date';
|
|
2385
|
+
}
|
|
2386
|
+
if ((0, _chartutilities.isStringArray)(values)) {
|
|
2387
|
+
return 'category';
|
|
2388
|
+
}
|
|
2389
|
+
};
|
|
2390
|
+
/**
|
|
2391
|
+
* This is experimental. Use it only with valid datetime strings to verify if they conform to the ISO 8601 format.
|
|
2392
|
+
*/ const isoDateRegex = /^\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z)?)?$/;
|
|
2393
|
+
/**
|
|
2394
|
+
* We want to display localized date and time in the charts, so the useUTC prop is set to false.
|
|
2395
|
+
* But this can sometimes cause the formatters to display the datetime incorrectly.
|
|
2396
|
+
* To work around this issue, we use this function to adjust datetime strings so that they are always interpreted
|
|
2397
|
+
* as local time, allowing the formatters to produce the correct output.
|
|
2398
|
+
*
|
|
2399
|
+
* FIXME: The formatters should always produce a clear and accurate localized output, regardless of the
|
|
2400
|
+
* format used to create the date object.
|
|
2401
|
+
*/ const parseLocalDate = (value)=>{
|
|
2402
|
+
if (typeof value === 'string') {
|
|
2403
|
+
const match = value.match(isoDateRegex);
|
|
2404
|
+
if (match) {
|
|
2405
|
+
if (!match[3]) {
|
|
2406
|
+
value += 'T00:00';
|
|
2407
|
+
} else if (match[6]) {
|
|
2408
|
+
value = value.replace('Z', '');
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
return new Date(value);
|
|
2413
|
+
};
|