@fluentui/react-charts 9.2.3 → 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 +49 -10
- package/dist/index.d.ts +98 -5
- package/lib/components/AreaChart/AreaChart.js +3 -3
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -2
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -15
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +89 -6
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +38 -34
- 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 +17 -14
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +6 -33
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +55 -16
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +19 -0
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +1058 -291
- 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 +6 -1
- 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/GaugeChart/GaugeChart.js +1 -2
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +2 -2
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +4 -17
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +4 -21
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.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/LineChart/LineChart.js +271 -271
- 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 +23 -10
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js +4 -21
- 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 +114 -75
- 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 +11 -7
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +4 -22
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +2 -2
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +8 -6
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +5 -19
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +2 -2
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +7 -6
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +4 -19
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib/types/DataPoint.js +3 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/Common.styles.js +47 -0
- package/lib/utilities/Common.styles.js.map +1 -0
- package/lib/utilities/Common.styles.raw.js +47 -0
- package/lib/utilities/Common.styles.raw.js.map +1 -0
- package/lib/utilities/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 +309 -142
- package/lib/utilities/utilities.js.map +1 -1
- package/lib/utilities/vbc-utils.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +2 -2
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -14
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +89 -6
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +38 -34
- 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 +15 -13
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +4 -32
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +58 -19
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +22 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +1070 -291
- 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 +6 -1
- 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/GaugeChart/GaugeChart.js +1 -2
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +2 -2
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -19
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -20
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.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/LineChart/LineChart.js +269 -269
- 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 +30 -9
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +2 -20
- 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 +112 -73
- 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 +13 -7
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +2 -20
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +5 -3
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -17
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +5 -3
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -18
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js +3 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/Common.styles.js +71 -0
- package/lib-commonjs/utilities/Common.styles.js.map +1 -0
- package/lib-commonjs/utilities/Common.styles.raw.js +71 -0
- package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -0
- package/lib-commonjs/utilities/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 +322 -133
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
- package/package.json +9 -9
|
@@ -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
|
},
|
|
@@ -30,6 +36,12 @@ _export(exports, {
|
|
|
30
36
|
getValidXYRanges: function() {
|
|
31
37
|
return getValidXYRanges;
|
|
32
38
|
},
|
|
39
|
+
isNonPlotType: function() {
|
|
40
|
+
return isNonPlotType;
|
|
41
|
+
},
|
|
42
|
+
normalizeObjectArrayForGVBC: function() {
|
|
43
|
+
return normalizeObjectArrayForGVBC;
|
|
44
|
+
},
|
|
33
45
|
projectPolarToCartesian: function() {
|
|
34
46
|
return projectPolarToCartesian;
|
|
35
47
|
},
|
|
@@ -45,9 +57,15 @@ _export(exports, {
|
|
|
45
57
|
transformPlotlyJsonToDonutProps: function() {
|
|
46
58
|
return transformPlotlyJsonToDonutProps;
|
|
47
59
|
},
|
|
60
|
+
transformPlotlyJsonToFunnelChartProps: function() {
|
|
61
|
+
return transformPlotlyJsonToFunnelChartProps;
|
|
62
|
+
},
|
|
48
63
|
transformPlotlyJsonToGVBCProps: function() {
|
|
49
64
|
return transformPlotlyJsonToGVBCProps;
|
|
50
65
|
},
|
|
66
|
+
transformPlotlyJsonToGanttChartProps: function() {
|
|
67
|
+
return transformPlotlyJsonToGanttChartProps;
|
|
68
|
+
},
|
|
51
69
|
transformPlotlyJsonToGaugeProps: function() {
|
|
52
70
|
return transformPlotlyJsonToGaugeProps;
|
|
53
71
|
},
|
|
@@ -84,6 +102,8 @@ const _chartutilities = require("@fluentui/chart-utilities");
|
|
|
84
102
|
const _d3shape = require("d3-shape");
|
|
85
103
|
const _PlotlyColorAdapter = require("./PlotlyColorAdapter");
|
|
86
104
|
const _d3color = require("d3-color");
|
|
105
|
+
const NON_PLOT_KEY_PREFIX = 'nonplot_';
|
|
106
|
+
const SINGLE_REPEAT = 'repeat(1, 1fr)';
|
|
87
107
|
const dashOptions = {
|
|
88
108
|
dot: {
|
|
89
109
|
strokeDasharray: '1, 5',
|
|
@@ -132,6 +152,47 @@ function getTitles(layout) {
|
|
|
132
152
|
};
|
|
133
153
|
return titles;
|
|
134
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
|
+
};
|
|
135
196
|
const correctYearMonth = (xValues)=>{
|
|
136
197
|
const presentYear = new Date().getFullYear();
|
|
137
198
|
if (xValues.length > 0 && Array.isArray(xValues[0])) {
|
|
@@ -230,8 +291,117 @@ const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNumber)=>{
|
|
|
230
291
|
}
|
|
231
292
|
return x;
|
|
232
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
|
|
358
|
+
};
|
|
359
|
+
} else {
|
|
360
|
+
// Non-numeric primitive, ignore by returning empty object
|
|
361
|
+
return {};
|
|
362
|
+
}
|
|
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
|
+
};
|
|
233
403
|
const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
234
|
-
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _firstData_marker,
|
|
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;
|
|
235
405
|
const firstData = input.data[0];
|
|
236
406
|
var _input_layout_piecolorway, _input_layout_piecolorway1;
|
|
237
407
|
// extract colors for each series only once
|
|
@@ -239,24 +409,53 @@ const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayT
|
|
|
239
409
|
// otherwise, default to colorway from template
|
|
240
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);
|
|
241
411
|
const mapLegendToDataPoint = {};
|
|
242
|
-
(
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
+
});
|
|
258
457
|
}
|
|
259
|
-
}
|
|
458
|
+
}
|
|
260
459
|
var _input_layout_width;
|
|
261
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;
|
|
262
461
|
var _input_layout_height;
|
|
@@ -275,7 +474,7 @@ const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayT
|
|
|
275
474
|
chartTitle,
|
|
276
475
|
chartData: Object.values(mapLegendToDataPoint)
|
|
277
476
|
},
|
|
278
|
-
hideLegend: ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false
|
|
477
|
+
hideLegend: isMultiPlot || ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false,
|
|
279
478
|
width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
|
|
280
479
|
height,
|
|
281
480
|
innerRadius,
|
|
@@ -294,17 +493,16 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
294
493
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
295
494
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
296
495
|
let colorScale = undefined;
|
|
496
|
+
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
297
497
|
let yMinValue = 0;
|
|
298
498
|
input.data.forEach((series, index1)=>{
|
|
299
|
-
var
|
|
300
|
-
|
|
301
|
-
colorScale = createColorScale(input.layout, series);
|
|
302
|
-
}
|
|
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);
|
|
303
501
|
const isXYearCategory = (0, _chartutilities.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
304
502
|
// extract bar colors for each series only once
|
|
305
|
-
const extractedBarColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
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);
|
|
306
504
|
// extract line colors for each series only once
|
|
307
|
-
const extractedLineColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
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);
|
|
308
506
|
const xValues = series.x;
|
|
309
507
|
const isXDate = (0, _chartutilities.isDateArray)(xValues);
|
|
310
508
|
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
@@ -327,6 +525,7 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
327
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);
|
|
328
526
|
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
|
|
329
527
|
const yVal = rangeYValues[index2];
|
|
528
|
+
const yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
|
|
330
529
|
if (series.type === 'bar') {
|
|
331
530
|
var _rgb_copy_formatHex8;
|
|
332
531
|
mapXToDataPoints[x].chartData.push({
|
|
@@ -334,7 +533,8 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
334
533
|
data: yVal,
|
|
335
534
|
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
336
535
|
opacity
|
|
337
|
-
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
536
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
537
|
+
yAxisCalloutData
|
|
338
538
|
});
|
|
339
539
|
if (typeof yVal === 'number') {
|
|
340
540
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -356,7 +556,8 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
356
556
|
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
357
557
|
mode: series.mode
|
|
358
558
|
},
|
|
359
|
-
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
559
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
560
|
+
yAxisCalloutData
|
|
360
561
|
});
|
|
361
562
|
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
362
563
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -367,7 +568,6 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
367
568
|
});
|
|
368
569
|
});
|
|
369
570
|
});
|
|
370
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
371
571
|
const vsbcData = Object.values(mapXToDataPoints);
|
|
372
572
|
var _input_layout_height;
|
|
373
573
|
return {
|
|
@@ -377,9 +577,6 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
377
577
|
barWidth: 'auto',
|
|
378
578
|
yMaxValue,
|
|
379
579
|
yMinValue,
|
|
380
|
-
chartTitle,
|
|
381
|
-
xAxisTitle,
|
|
382
|
-
yAxisTitle,
|
|
383
580
|
mode: 'plotly',
|
|
384
581
|
...secondaryYAxisValues,
|
|
385
582
|
wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
|
|
@@ -390,36 +587,55 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
390
587
|
showYAxisLables: true,
|
|
391
588
|
noOfCharsToTruncate: 20,
|
|
392
589
|
showYAxisLablesTooltip: true,
|
|
393
|
-
...
|
|
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)
|
|
394
597
|
};
|
|
395
598
|
};
|
|
396
|
-
const createColorScale = (layout, series)=>{
|
|
397
|
-
var _layout_coloraxis, _series_marker, _layout_coloraxis1, _layout_coloraxis2;
|
|
398
|
-
const scale = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis = layout.coloraxis) === null || _layout_coloraxis === void 0 ? void 0 : _layout_coloraxis.colorscale;
|
|
399
|
-
const colorValues = (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color;
|
|
400
|
-
var _layout_coloraxis_cmin, _layout_coloraxis_cmax;
|
|
401
|
-
const [dMin, dMax] = [
|
|
402
|
-
(_layout_coloraxis_cmin = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis1 = layout.coloraxis) === null || _layout_coloraxis1 === void 0 ? void 0 : _layout_coloraxis1.cmin) !== null && _layout_coloraxis_cmin !== void 0 ? _layout_coloraxis_cmin : Math.min(...colorValues),
|
|
403
|
-
(_layout_coloraxis_cmax = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis2 = layout.coloraxis) === null || _layout_coloraxis2 === void 0 ? void 0 : _layout_coloraxis2.cmax) !== null && _layout_coloraxis_cmax !== void 0 ? _layout_coloraxis_cmax : Math.max(...colorValues)
|
|
404
|
-
];
|
|
405
|
-
// Normalize colorscale domain to actual data domain
|
|
406
|
-
const scaleDomain = scale.map(([pos])=>dMin + pos * (dMax - dMin));
|
|
407
|
-
const scaleColors = scale.map((item)=>item[1]);
|
|
408
|
-
return (0, _d3scale.scaleLinear)().domain(scaleDomain).range(scaleColors);
|
|
409
|
-
};
|
|
410
599
|
const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
411
|
-
var
|
|
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
|
+
}
|
|
412
629
|
const mapXToDataPoints = {};
|
|
413
|
-
const secondaryYAxisValues = getSecondaryYAxisValues(
|
|
414
|
-
const { legends, hideLegend } = getLegendProps(
|
|
630
|
+
const secondaryYAxisValues = getSecondaryYAxisValues(processedInput.data, processedInput.layout, 0, 0);
|
|
631
|
+
const { legends, hideLegend } = getLegendProps(processedInput.data, processedInput.layout, isMultiPlot);
|
|
415
632
|
let colorScale = undefined;
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
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);
|
|
421
637
|
// extract colors for each series only once
|
|
422
|
-
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);
|
|
423
639
|
(_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
|
|
424
640
|
var _series_y;
|
|
425
641
|
if ((0, _chartutilities.isInvalidValue)(x) || (0, _chartutilities.isInvalidValue)((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2])) {
|
|
@@ -437,38 +653,42 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
437
653
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
438
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);
|
|
439
655
|
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
|
|
656
|
+
const yVal = series.y[index2];
|
|
440
657
|
var _rgb_copy_formatHex8;
|
|
441
658
|
mapXToDataPoints[x].series.push({
|
|
442
659
|
key: legend,
|
|
443
|
-
data:
|
|
660
|
+
data: yVal,
|
|
444
661
|
xAxisCalloutData: x,
|
|
445
662
|
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
446
663
|
opacity
|
|
447
664
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
448
665
|
legend,
|
|
449
|
-
useSecondaryYScale: usesSecondaryYScale(series,
|
|
666
|
+
useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout),
|
|
667
|
+
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
|
|
450
668
|
});
|
|
451
669
|
}
|
|
452
670
|
});
|
|
453
671
|
});
|
|
454
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
455
672
|
const gvbcData = Object.values(mapXToDataPoints);
|
|
456
|
-
var
|
|
673
|
+
var _processedInput_layout_height;
|
|
457
674
|
return {
|
|
458
675
|
data: gvbcData,
|
|
459
|
-
width: (
|
|
460
|
-
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,
|
|
461
678
|
barWidth: 'auto',
|
|
462
|
-
chartTitle,
|
|
463
|
-
xAxisTitle,
|
|
464
|
-
yAxisTitle,
|
|
465
679
|
mode: 'plotly',
|
|
466
680
|
...secondaryYAxisValues,
|
|
467
681
|
hideTickOverlap: true,
|
|
468
682
|
wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
|
|
469
683
|
hideLegend,
|
|
470
684
|
roundCorners: true,
|
|
471
|
-
...
|
|
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)
|
|
472
692
|
};
|
|
473
693
|
};
|
|
474
694
|
const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -477,15 +697,13 @@ const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayTyp
|
|
|
477
697
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
478
698
|
let colorScale = undefined;
|
|
479
699
|
input.data.forEach((series, seriesIdx)=>{
|
|
480
|
-
var
|
|
700
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_xbins, _series_xbins1, _series_xbins2;
|
|
481
701
|
if (!series.x) {
|
|
482
702
|
return;
|
|
483
703
|
}
|
|
484
|
-
|
|
485
|
-
colorScale = createColorScale(input.layout, series);
|
|
486
|
-
}
|
|
704
|
+
colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
|
|
487
705
|
// extract colors for each series only once
|
|
488
|
-
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
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);
|
|
489
707
|
const xValues = [];
|
|
490
708
|
const yValues = [];
|
|
491
709
|
series.x.forEach((xVal, index)=>{
|
|
@@ -534,21 +752,19 @@ const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayTyp
|
|
|
534
752
|
});
|
|
535
753
|
});
|
|
536
754
|
});
|
|
537
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
538
755
|
var _input_layout_height;
|
|
539
756
|
return {
|
|
540
757
|
data: vbcData,
|
|
541
758
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
542
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,
|
|
543
|
-
chartTitle,
|
|
544
|
-
xAxisTitle,
|
|
545
|
-
yAxisTitle,
|
|
546
760
|
mode: 'histogram',
|
|
547
761
|
hideTickOverlap: true,
|
|
548
762
|
wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
|
|
549
763
|
maxBarWidth: 50,
|
|
550
764
|
hideLegend,
|
|
551
765
|
roundCorners: true,
|
|
766
|
+
...getTitles(input.layout),
|
|
767
|
+
...getYMinMaxValues(input.data[0], input.layout),
|
|
552
768
|
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
553
769
|
};
|
|
554
770
|
};
|
|
@@ -562,20 +778,23 @@ const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, colorMap, co
|
|
|
562
778
|
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
563
779
|
};
|
|
564
780
|
const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
|
|
565
|
-
var _input_data_;
|
|
781
|
+
var _input_data_, _input_layout, _input_layout1;
|
|
566
782
|
const isScatterMarkers = [
|
|
783
|
+
'text',
|
|
567
784
|
'markers',
|
|
568
785
|
'text+markers',
|
|
569
786
|
'markers+text',
|
|
570
787
|
'lines+markers',
|
|
571
788
|
'markers+line',
|
|
572
|
-
'text+lines+markers'
|
|
789
|
+
'text+lines+markers',
|
|
790
|
+
'lines+markers+text'
|
|
573
791
|
].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
|
|
574
792
|
const isAreaChart = chartType === 'area';
|
|
575
793
|
const isScatterChart = chartType === 'scatter';
|
|
576
794
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
577
795
|
let mode = 'tonexty';
|
|
578
796
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
797
|
+
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
579
798
|
const chartData = input.data.map((series, index)=>{
|
|
580
799
|
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
|
|
581
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;
|
|
@@ -591,11 +810,12 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
591
810
|
const seriesColor = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
592
811
|
const seriesOpacity = (0, _PlotlyColorAdapter.getOpacity)(series, index);
|
|
593
812
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
594
|
-
|
|
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;
|
|
595
815
|
const legendShape = getLegendShape(series);
|
|
596
816
|
const validXYRanges = getValidXYRanges(series);
|
|
597
817
|
return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
598
|
-
var _series_marker;
|
|
818
|
+
var _series_marker, _input_layout, _input_layout_polar_angularaxis, _input_layout_polar, _input_layout1, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout2;
|
|
599
819
|
const rangeXValues = xValues.slice(rangeStart, rangeEnd);
|
|
600
820
|
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
601
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) : [];
|
|
@@ -616,7 +836,8 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
616
836
|
} : {},
|
|
617
837
|
...textValues ? {
|
|
618
838
|
text: textValues[i]
|
|
619
|
-
} : {}
|
|
839
|
+
} : {},
|
|
840
|
+
yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat)
|
|
620
841
|
};
|
|
621
842
|
}),
|
|
622
843
|
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(seriesColor).copy({
|
|
@@ -624,58 +845,65 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
624
845
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
|
|
625
846
|
lineOptions: {
|
|
626
847
|
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
627
|
-
mode: series.mode
|
|
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 : {}
|
|
856
|
+
} : {}
|
|
628
857
|
},
|
|
629
858
|
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
630
859
|
};
|
|
631
860
|
});
|
|
632
861
|
}).flat();
|
|
633
|
-
const
|
|
634
|
-
|
|
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
|
+
}
|
|
635
868
|
const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
|
|
636
869
|
const chartProps = {
|
|
637
|
-
chartTitle,
|
|
638
870
|
lineChartData: chartData
|
|
639
871
|
};
|
|
640
872
|
const scatterChartProps = {
|
|
641
|
-
chartTitle,
|
|
642
873
|
scatterChartData: chartData
|
|
643
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
|
+
};
|
|
644
891
|
if (isAreaChart) {
|
|
645
|
-
var _input_layout, _input_layout1;
|
|
646
|
-
var _input_layout_height;
|
|
647
892
|
return {
|
|
648
893
|
data: chartProps,
|
|
649
|
-
supportNegativeData: true,
|
|
650
|
-
xAxisTitle,
|
|
651
|
-
yAxisTitle,
|
|
652
|
-
...secondaryYAxisValues,
|
|
653
894
|
mode,
|
|
654
|
-
|
|
655
|
-
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,
|
|
656
|
-
hideTickOverlap: true,
|
|
657
|
-
useUTC: false,
|
|
658
|
-
hideLegend,
|
|
659
|
-
optimizeLargeData: numDataPoints > 1000
|
|
895
|
+
...commonProps
|
|
660
896
|
};
|
|
661
897
|
} else {
|
|
662
|
-
var _input_layout2, _input_layout3;
|
|
663
|
-
var _input_layout_height1;
|
|
664
898
|
return {
|
|
665
899
|
data: isScatterChart ? scatterChartProps : chartProps,
|
|
666
|
-
supportNegativeData: true,
|
|
667
|
-
xAxisTitle,
|
|
668
|
-
yAxisTitle,
|
|
669
|
-
...secondaryYAxisValues,
|
|
670
900
|
roundedTicks: true,
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
hideLegend,
|
|
678
|
-
optimizeLargeData: numDataPoints > 1000
|
|
901
|
+
...commonProps,
|
|
902
|
+
...yMinMax,
|
|
903
|
+
...isScatterChart ? {
|
|
904
|
+
showYAxisLablesTooltip: true,
|
|
905
|
+
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
906
|
+
} : {}
|
|
679
907
|
};
|
|
680
908
|
}
|
|
681
909
|
};
|
|
@@ -684,12 +912,10 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
|
|
|
684
912
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
685
913
|
let colorScale = undefined;
|
|
686
914
|
const chartData = input.data.map((series, index)=>{
|
|
687
|
-
var
|
|
688
|
-
|
|
689
|
-
colorScale = createColorScale(input.layout, series);
|
|
690
|
-
}
|
|
915
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
|
|
916
|
+
colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
|
|
691
917
|
// extract colors for each series only once
|
|
692
|
-
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
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);
|
|
693
919
|
const legend = legends[index];
|
|
694
920
|
return series.y.map((yValue, i)=>{
|
|
695
921
|
var _series_x, _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
@@ -721,12 +947,8 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
|
|
|
721
947
|
const scalingFactor = 0.01;
|
|
722
948
|
const gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
723
949
|
const barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
724
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
725
950
|
return {
|
|
726
951
|
data: chartData,
|
|
727
|
-
chartTitle,
|
|
728
|
-
xAxisTitle,
|
|
729
|
-
yAxisTitle,
|
|
730
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) || '',
|
|
731
953
|
barHeight,
|
|
732
954
|
showYAxisLables: true,
|
|
@@ -737,7 +959,67 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
|
|
|
737
959
|
showYAxisLablesTooltip: true,
|
|
738
960
|
hideLegend,
|
|
739
961
|
roundCorners: true,
|
|
740
|
-
...
|
|
962
|
+
...getTitles(input.layout),
|
|
963
|
+
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
964
|
+
...getBarProps(input.data, input.layout, true),
|
|
965
|
+
...getAxisTickProps(input.data, input.layout)
|
|
966
|
+
};
|
|
967
|
+
};
|
|
968
|
+
const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
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)
|
|
741
1023
|
};
|
|
742
1024
|
};
|
|
743
1025
|
const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -850,7 +1132,6 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
|
|
|
850
1132
|
}
|
|
851
1133
|
const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
|
|
852
1134
|
const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
|
|
853
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
854
1135
|
var _input_layout_height;
|
|
855
1136
|
return {
|
|
856
1137
|
data: [
|
|
@@ -860,9 +1141,6 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
|
|
|
860
1141
|
rangeValuesForColorScale,
|
|
861
1142
|
hideLegend: true,
|
|
862
1143
|
showYAxisLables: true,
|
|
863
|
-
chartTitle,
|
|
864
|
-
xAxisTitle,
|
|
865
|
-
yAxisTitle,
|
|
866
1144
|
sortOrder: 'none',
|
|
867
1145
|
width: (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.width,
|
|
868
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,
|
|
@@ -870,9 +1148,11 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
|
|
|
870
1148
|
noOfCharsToTruncate: 20,
|
|
871
1149
|
showYAxisLablesTooltip: true,
|
|
872
1150
|
wrapXAxisLables: true,
|
|
1151
|
+
...getTitles(input.layout),
|
|
873
1152
|
...getAxisCategoryOrderProps([
|
|
874
1153
|
firstData
|
|
875
|
-
], input.layout)
|
|
1154
|
+
], input.layout),
|
|
1155
|
+
...getAxisTickProps(input.data, input.layout)
|
|
876
1156
|
};
|
|
877
1157
|
};
|
|
878
1158
|
const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -1021,7 +1301,7 @@ const formatValue = (value, colIndex, cells)=>{
|
|
|
1021
1301
|
return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
|
|
1022
1302
|
};
|
|
1023
1303
|
const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
1024
|
-
var _tableData_cells, _input_layout_template_data, _input_layout_template, _input_layout, _input_layout_font, _input_layout1, _tableData_header,
|
|
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;
|
|
1025
1305
|
const tableData = input.data[0];
|
|
1026
1306
|
const normalizeHeaders = (values, header)=>{
|
|
1027
1307
|
const cleanedValues = Array.isArray(values[0]) ? values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' ')) : values.map((cell)=>cleanText(cell));
|
|
@@ -1030,7 +1310,8 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1030
1310
|
const fontColorRaw = header === null || header === void 0 ? void 0 : (_header_font = header.font) === null || _header_font === void 0 ? void 0 : _header_font.color;
|
|
1031
1311
|
let fontColor;
|
|
1032
1312
|
if (Array.isArray(fontColorRaw)) {
|
|
1033
|
-
|
|
1313
|
+
var _fontColorRaw_colIndex;
|
|
1314
|
+
const colorEntry = (_fontColorRaw_colIndex = fontColorRaw[colIndex]) !== null && _fontColorRaw_colIndex !== void 0 ? _fontColorRaw_colIndex : fontColorRaw[0];
|
|
1034
1315
|
if (Array.isArray(colorEntry)) {
|
|
1035
1316
|
fontColor = typeof colorEntry[0] === 'string' ? colorEntry[0] : undefined;
|
|
1036
1317
|
} else if (typeof colorEntry === 'string') {
|
|
@@ -1042,15 +1323,20 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1042
1323
|
const fontSizeRaw = header === null || header === void 0 ? void 0 : (_header_font1 = header.font) === null || _header_font1 === void 0 ? void 0 : _header_font1.size;
|
|
1043
1324
|
let fontSize;
|
|
1044
1325
|
if (Array.isArray(fontSizeRaw)) {
|
|
1045
|
-
|
|
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;
|
|
1046
1330
|
} else if (typeof fontSizeRaw === 'number') {
|
|
1047
1331
|
fontSize = fontSizeRaw;
|
|
1048
1332
|
}
|
|
1049
1333
|
const updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
1050
1334
|
const fillColorRaw = header === null || header === void 0 ? void 0 : (_header_fill = header.fill) === null || _header_fill === void 0 ? void 0 : _header_fill.color;
|
|
1051
|
-
|
|
1335
|
+
var _fillColorRaw_updatedColIndex;
|
|
1336
|
+
const backgroundColor = Array.isArray(fillColorRaw) ? (_fillColorRaw_updatedColIndex = fillColorRaw[updatedColIndex]) !== null && _fillColorRaw_updatedColIndex !== void 0 ? _fillColorRaw_updatedColIndex : fillColorRaw[0] : fillColorRaw;
|
|
1052
1337
|
const textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
|
|
1053
|
-
|
|
1338
|
+
var _textAlignRaw_colIndex;
|
|
1339
|
+
const textAlign = Array.isArray(textAlignRaw) ? (_textAlignRaw_colIndex = textAlignRaw[colIndex]) !== null && _textAlignRaw_colIndex !== void 0 ? _textAlignRaw_colIndex : textAlignRaw[0] : textAlignRaw;
|
|
1054
1340
|
const style = {
|
|
1055
1341
|
...typeof fontColor === 'string' ? {
|
|
1056
1342
|
color: fontColor
|
|
@@ -1073,7 +1359,7 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1073
1359
|
};
|
|
1074
1360
|
var _tableData_cells_values;
|
|
1075
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 : [];
|
|
1076
|
-
const cells = tableData.cells.
|
|
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;
|
|
1077
1363
|
const rows = columns[0].map((_, rowIndex)=>columns.map((col, colIndex)=>{
|
|
1078
1364
|
var _cells_font, _cells_font1, _cells_fill;
|
|
1079
1365
|
const cellValue = col[rowIndex];
|
|
@@ -1082,7 +1368,8 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1082
1368
|
const rawFontColor = cells === null || cells === void 0 ? void 0 : (_cells_font = cells.font) === null || _cells_font === void 0 ? void 0 : _cells_font.color;
|
|
1083
1369
|
let fontColor;
|
|
1084
1370
|
if (Array.isArray(rawFontColor)) {
|
|
1085
|
-
|
|
1371
|
+
var _rawFontColor_colIndex;
|
|
1372
|
+
const entry = (_rawFontColor_colIndex = rawFontColor[colIndex]) !== null && _rawFontColor_colIndex !== void 0 ? _rawFontColor_colIndex : rawFontColor[0];
|
|
1086
1373
|
const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1087
1374
|
fontColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
1088
1375
|
} else if (typeof rawFontColor === 'string') {
|
|
@@ -1091,7 +1378,8 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1091
1378
|
const rawFontSize = cells === null || cells === void 0 ? void 0 : (_cells_font1 = cells.font) === null || _cells_font1 === void 0 ? void 0 : _cells_font1.size;
|
|
1092
1379
|
let fontSize;
|
|
1093
1380
|
if (Array.isArray(rawFontSize)) {
|
|
1094
|
-
|
|
1381
|
+
var _rawFontSize_colIndex;
|
|
1382
|
+
const entry = (_rawFontSize_colIndex = rawFontSize[colIndex]) !== null && _rawFontSize_colIndex !== void 0 ? _rawFontSize_colIndex : rawFontSize[0];
|
|
1095
1383
|
const fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1096
1384
|
fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
|
|
1097
1385
|
} else if (typeof rawFontSize === 'number') {
|
|
@@ -1101,13 +1389,15 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1101
1389
|
const rawBackgroundColor = cells === null || cells === void 0 ? void 0 : (_cells_fill = cells.fill) === null || _cells_fill === void 0 ? void 0 : _cells_fill.color;
|
|
1102
1390
|
let backgroundColor;
|
|
1103
1391
|
if (Array.isArray(rawBackgroundColor)) {
|
|
1104
|
-
|
|
1392
|
+
var _rawBackgroundColor_updatedColIndex;
|
|
1393
|
+
const entry = (_rawBackgroundColor_updatedColIndex = rawBackgroundColor[updatedColIndex]) !== null && _rawBackgroundColor_updatedColIndex !== void 0 ? _rawBackgroundColor_updatedColIndex : rawBackgroundColor[0];
|
|
1105
1394
|
const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1106
1395
|
backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
1107
1396
|
} else if (typeof rawBackgroundColor === 'string') {
|
|
1108
1397
|
backgroundColor = rawBackgroundColor;
|
|
1109
1398
|
}
|
|
1110
|
-
|
|
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;
|
|
1111
1401
|
const textAlign = rawTextAlign;
|
|
1112
1402
|
const style = {
|
|
1113
1403
|
...fontColor ? {
|
|
@@ -1137,35 +1427,297 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1137
1427
|
};
|
|
1138
1428
|
var _tableData_header_values;
|
|
1139
1429
|
return {
|
|
1140
|
-
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 : [],
|
|
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),
|
|
1141
1431
|
rows,
|
|
1142
1432
|
width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
|
|
1143
1433
|
height: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height,
|
|
1144
1434
|
styles
|
|
1145
1435
|
};
|
|
1146
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
|
+
};
|
|
1147
1585
|
const projectPolarToCartesian = (input)=>{
|
|
1586
|
+
var _input_layout, _input_layout1;
|
|
1148
1587
|
const projection = {
|
|
1149
1588
|
...input
|
|
1150
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;
|
|
1151
1618
|
for(let sindex = 0; sindex < input.data.length; sindex++){
|
|
1152
|
-
var
|
|
1619
|
+
var _input_layout_polar_angularaxis, _input_layout_polar, _input_layout2, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout3;
|
|
1153
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
|
+
}
|
|
1154
1625
|
series.x = [];
|
|
1155
1626
|
series.y = [];
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
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])) {
|
|
1160
1647
|
continue;
|
|
1161
1648
|
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
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
|
+
}));
|
|
1166
1685
|
}
|
|
1167
1686
|
projection.data[sindex] = series;
|
|
1168
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;
|
|
1169
1721
|
return projection;
|
|
1170
1722
|
};
|
|
1171
1723
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1271,11 +1823,11 @@ const createBins = (data, binStart, binEnd, binSize)=>{
|
|
|
1271
1823
|
]);
|
|
1272
1824
|
if (typeof binSize === 'number' && binSize > 0) {
|
|
1273
1825
|
const thresholds = [];
|
|
1274
|
-
const precision = Math.max(
|
|
1275
|
-
let th = precisionRound(minVal, precision);
|
|
1276
|
-
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)){
|
|
1277
1829
|
thresholds.push(th);
|
|
1278
|
-
th = precisionRound(th + binSize, precision);
|
|
1830
|
+
th = (0, _utilities.precisionRound)(th + binSize, precision);
|
|
1279
1831
|
}
|
|
1280
1832
|
minVal = thresholds[0];
|
|
1281
1833
|
maxVal = thresholds[thresholds.length - 1];
|
|
@@ -1321,15 +1873,6 @@ const calculateHistNorm = (histnorm, value, total, dx, dy = 1)=>{
|
|
|
1321
1873
|
return value;
|
|
1322
1874
|
}
|
|
1323
1875
|
};
|
|
1324
|
-
const getPrecision = (value)=>{
|
|
1325
|
-
var _value_toString_split_;
|
|
1326
|
-
var _value_toString_split__length;
|
|
1327
|
-
return (_value_toString_split__length = (_value_toString_split_ = value.toString().split('.')[1]) === null || _value_toString_split_ === void 0 ? void 0 : _value_toString_split_.length) !== null && _value_toString_split__length !== void 0 ? _value_toString_split__length : 0;
|
|
1328
|
-
};
|
|
1329
|
-
const precisionRound = (value, precision)=>{
|
|
1330
|
-
const factor = Math.pow(10, precision);
|
|
1331
|
-
return Math.round(value * factor) / factor;
|
|
1332
|
-
};
|
|
1333
1876
|
const getLegendShape = (series)=>{
|
|
1334
1877
|
var _series_line, _series_mode;
|
|
1335
1878
|
const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
|
|
@@ -1340,25 +1883,44 @@ const getLegendShape = (series)=>{
|
|
|
1340
1883
|
}
|
|
1341
1884
|
return 'default';
|
|
1342
1885
|
};
|
|
1343
|
-
const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
1886
|
+
const getAllupLegendsProps = (input, colorMap, colorwayType, traceInfo, isDarkTheme)=>{
|
|
1344
1887
|
const allupLegends = [];
|
|
1345
1888
|
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1346
1889
|
const toShowLegend = input.data.reduce((acc, series)=>{
|
|
1347
|
-
return acc || series.showlegend === true;
|
|
1890
|
+
return acc || series.showlegend === true || series.showlegend === undefined;
|
|
1348
1891
|
}, false);
|
|
1349
1892
|
if (toShowLegend) {
|
|
1350
1893
|
input.data.forEach((series, index)=>{
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
color
|
|
1360
|
-
|
|
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
|
+
}
|
|
1361
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
|
+
}
|
|
1362
1924
|
}
|
|
1363
1925
|
});
|
|
1364
1926
|
}
|
|
@@ -1424,28 +1986,21 @@ const getIndexFromKey = (key, pattern)=>{
|
|
|
1424
1986
|
const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1425
1987
|
return parseInt(normalizedKey, 10) - 1;
|
|
1426
1988
|
};
|
|
1427
|
-
const
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
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;
|
|
1431
2000
|
const annotations = {};
|
|
1432
2001
|
let templateRows = '1fr';
|
|
1433
2002
|
let templateColumns = '1fr';
|
|
1434
2003
|
const gridLayout = {};
|
|
1435
|
-
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1436
|
-
return {
|
|
1437
|
-
templateRows,
|
|
1438
|
-
templateColumns,
|
|
1439
|
-
layout: gridLayout
|
|
1440
|
-
};
|
|
1441
|
-
}
|
|
1442
|
-
if (!layout.xaxis || !layout.yaxis) {
|
|
1443
|
-
return {
|
|
1444
|
-
templateRows,
|
|
1445
|
-
templateColumns,
|
|
1446
|
-
layout: gridLayout
|
|
1447
|
-
};
|
|
1448
|
-
}
|
|
1449
2004
|
if (!isMultiPlot) {
|
|
1450
2005
|
return {
|
|
1451
2006
|
templateRows,
|
|
@@ -1453,144 +2008,144 @@ const getGridProperties = (layout, isMultiPlot)=>{
|
|
|
1453
2008
|
layout: gridLayout
|
|
1454
2009
|
};
|
|
1455
2010
|
}
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
gridX[index] = (_layout_key_domain = (_layout_key1 = layout[key]) === null || _layout_key1 === void 0 ? void 0 : _layout_key1.domain) !== null && _layout_key_domain !== void 0 ? _layout_key_domain : [];
|
|
1468
|
-
} else if (key.startsWith('yaxis')) {
|
|
1469
|
-
var _layout_key2, _layout_key3;
|
|
1470
|
-
const index = getIndexFromKey(key, 'yaxis');
|
|
1471
|
-
var _layout_key_anchor1;
|
|
1472
|
-
const anchor = (_layout_key_anchor1 = (_layout_key2 = layout[key]) === null || _layout_key2 === void 0 ? void 0 : _layout_key2.anchor) !== null && _layout_key_anchor1 !== void 0 ? _layout_key_anchor1 : 'x';
|
|
1473
|
-
const anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1474
|
-
if (index !== anchorIndex) {
|
|
1475
|
-
var _layout_yaxis2;
|
|
1476
|
-
if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
|
|
1477
|
-
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1478
|
-
return {
|
|
1479
|
-
templateRows,
|
|
1480
|
-
templateColumns
|
|
1481
|
-
};
|
|
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}`);
|
|
1482
2022
|
}
|
|
1483
|
-
|
|
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);
|
|
1484
2052
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
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);
|
|
1487
2070
|
}
|
|
1488
2071
|
});
|
|
1489
|
-
(
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
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
|
+
}
|
|
1502
2088
|
}
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
if (
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2091
|
+
if (domainX.length > 0) {
|
|
1506
2092
|
const uniqueXIntervals = new Map();
|
|
1507
|
-
|
|
1508
|
-
const key = `${interval
|
|
2093
|
+
domainX.forEach((interval)=>{
|
|
2094
|
+
const key = `${interval.start}-${interval.end}`;
|
|
1509
2095
|
if (!uniqueXIntervals.has(key)) {
|
|
1510
2096
|
uniqueXIntervals.set(key, interval);
|
|
1511
2097
|
}
|
|
1512
2098
|
});
|
|
1513
|
-
const
|
|
1514
|
-
templateColumns =
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
return;
|
|
1520
|
-
}
|
|
1521
|
-
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
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
|
|
1522
2105
|
const annotationProps = annotations[index];
|
|
1523
2106
|
const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1524
|
-
if (interval[0] < lastIntervalEnd) {
|
|
1525
|
-
columnNumber = 1;
|
|
1526
|
-
}
|
|
1527
|
-
lastIntervalEnd = interval[1];
|
|
1528
2107
|
const row = {
|
|
1529
2108
|
row: -1,
|
|
1530
2109
|
column: columnNumber,
|
|
1531
|
-
xAnnotation
|
|
2110
|
+
xAnnotation,
|
|
2111
|
+
xDomain: interval,
|
|
2112
|
+
yDomain: {
|
|
2113
|
+
start: 0,
|
|
2114
|
+
end: 1
|
|
2115
|
+
}
|
|
1532
2116
|
};
|
|
1533
2117
|
gridLayout[cellName] = row;
|
|
1534
|
-
columnNumber += 1;
|
|
1535
2118
|
});
|
|
1536
2119
|
}
|
|
1537
|
-
|
|
1538
|
-
var _cell_column;
|
|
1539
|
-
return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
|
|
1540
|
-
}));
|
|
1541
|
-
const columnFill = {};
|
|
1542
|
-
for(let i = 1; i <= numColumns; i++){
|
|
1543
|
-
columnFill[i] = {
|
|
1544
|
-
row: 1,
|
|
1545
|
-
fillDomain: 0
|
|
1546
|
-
};
|
|
1547
|
-
}
|
|
1548
|
-
if (gridY.length > 0) {
|
|
2120
|
+
if (domainY.length > 0) {
|
|
1549
2121
|
const uniqueYIntervals = new Map();
|
|
1550
|
-
|
|
1551
|
-
const key = `${interval
|
|
2122
|
+
domainY.forEach((interval)=>{
|
|
2123
|
+
const key = `${interval.start}-${interval.end}`;
|
|
1552
2124
|
if (!uniqueYIntervals.has(key)) {
|
|
1553
2125
|
uniqueYIntervals.set(key, interval);
|
|
1554
2126
|
}
|
|
1555
2127
|
});
|
|
1556
|
-
const
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
const
|
|
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
|
|
1563
2135
|
const annotationProps = annotations[index];
|
|
1564
2136
|
const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1565
2137
|
const cell = gridLayout[cellName];
|
|
1566
2138
|
if (cell !== undefined) {
|
|
1567
|
-
cell.row =
|
|
2139
|
+
cell.row = rowNumber;
|
|
1568
2140
|
cell.yAnnotation = yAnnotation;
|
|
2141
|
+
cell.yDomain = interval;
|
|
1569
2142
|
}
|
|
1570
|
-
columnFill[cell.column].fillDomain = interval[1];
|
|
1571
|
-
columnFill[cell.column].row += 1;
|
|
1572
2143
|
});
|
|
1573
2144
|
}
|
|
1574
|
-
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1575
|
-
const reversedGridLayout = {};
|
|
1576
|
-
// find the maximum row number
|
|
1577
|
-
const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1578
|
-
var _cell_row;
|
|
1579
|
-
return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
|
|
1580
|
-
}));
|
|
1581
|
-
// iterate over the gridLayout and reverse the row numbers
|
|
1582
|
-
Object.keys(gridLayout).forEach((key)=>{
|
|
1583
|
-
const cell = gridLayout[key];
|
|
1584
|
-
if (cell.row !== undefined) {
|
|
1585
|
-
// reverse the row number
|
|
1586
|
-
cell.row = maxRowNumber - cell.row + 1;
|
|
1587
|
-
}
|
|
1588
|
-
reversedGridLayout[key] = cell;
|
|
1589
|
-
});
|
|
1590
2145
|
return {
|
|
1591
2146
|
templateRows,
|
|
1592
2147
|
templateColumns,
|
|
1593
|
-
layout:
|
|
2148
|
+
layout: gridLayout
|
|
1594
2149
|
};
|
|
1595
2150
|
};
|
|
1596
2151
|
/**
|
|
@@ -1632,3 +2187,227 @@ const getGridProperties = (layout, isMultiPlot)=>{
|
|
|
1632
2187
|
});
|
|
1633
2188
|
return result;
|
|
1634
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
|
+
};
|