@fluentui/react-charts 0.0.0-nightly-20250826-2140.1 → 0.0.0-nightly-20250828-0408.1
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 +48 -15
- package/dist/index.d.ts +15 -1
- package/lib/components/AreaChart/AreaChart.js +4 -1
- 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 +87 -6
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +24 -24
- package/lib/components/CommonComponents/CartesianChart.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 +42 -16
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +20 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +502 -259
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.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/GroupedVerticalBarChart/GroupedVerticalBarChart.js +23 -4
- 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/HeatMapChart/HeatMapChart.js +175 -114
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +26 -6
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +128 -82
- 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/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 +86 -59
- 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 +27 -7
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +8 -14
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +27 -4
- 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 +61 -44
- 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/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/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 +32 -37
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
- 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 +87 -6
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +24 -24
- package/lib-commonjs/components/CommonComponents/CartesianChart.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 +41 -15
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +23 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +509 -257
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.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/GroupedVerticalBarChart/GroupedVerticalBarChart.js +22 -3
- 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/HeatMapChart/HeatMapChart.js +174 -113
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +127 -81
- 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/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 +85 -58
- 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 +37 -5
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +7 -13
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +26 -3
- 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 +60 -43
- 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/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/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 +28 -40
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +12 -12
|
@@ -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,9 @@ _export(exports, {
|
|
|
30
36
|
getValidXYRanges: function() {
|
|
31
37
|
return getValidXYRanges;
|
|
32
38
|
},
|
|
39
|
+
isNonPlotType: function() {
|
|
40
|
+
return isNonPlotType;
|
|
41
|
+
},
|
|
33
42
|
projectPolarToCartesian: function() {
|
|
34
43
|
return projectPolarToCartesian;
|
|
35
44
|
},
|
|
@@ -84,6 +93,8 @@ const _chartutilities = require("@fluentui/chart-utilities");
|
|
|
84
93
|
const _d3shape = require("d3-shape");
|
|
85
94
|
const _PlotlyColorAdapter = require("./PlotlyColorAdapter");
|
|
86
95
|
const _d3color = require("d3-color");
|
|
96
|
+
const NON_PLOT_KEY_PREFIX = 'nonplot_';
|
|
97
|
+
const SINGLE_REPEAT = 'repeat(1, 1fr)';
|
|
87
98
|
const dashOptions = {
|
|
88
99
|
dot: {
|
|
89
100
|
strokeDasharray: '1, 5',
|
|
@@ -132,6 +143,47 @@ function getTitles(layout) {
|
|
|
132
143
|
};
|
|
133
144
|
return titles;
|
|
134
145
|
}
|
|
146
|
+
const getXAxisTickFormat = (series, layout)=>{
|
|
147
|
+
const xAxis = getXAxisProperties(series, layout);
|
|
148
|
+
if (xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat) {
|
|
149
|
+
return {
|
|
150
|
+
tickFormat: xAxis === null || xAxis === void 0 ? void 0 : xAxis.tickformat
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return {};
|
|
154
|
+
};
|
|
155
|
+
const getYAxisTickFormat = (series, layout)=>{
|
|
156
|
+
const yAxis = getYAxisProperties(series, layout);
|
|
157
|
+
if (yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat) {
|
|
158
|
+
return {
|
|
159
|
+
yAxisTickFormat: (0, _d3format.format)(yAxis === null || yAxis === void 0 ? void 0 : yAxis.tickformat)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return {};
|
|
163
|
+
};
|
|
164
|
+
const getYMinMaxValues = (series, layout)=>{
|
|
165
|
+
var _getYAxisProperties;
|
|
166
|
+
const range = (_getYAxisProperties = getYAxisProperties(series, layout)) === null || _getYAxisProperties === void 0 ? void 0 : _getYAxisProperties.range;
|
|
167
|
+
if (range && range.length === 2) {
|
|
168
|
+
return {
|
|
169
|
+
yMinValue: range[0],
|
|
170
|
+
yMaxValue: range[1]
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
return {};
|
|
174
|
+
};
|
|
175
|
+
const getYAxisProperties = (series, layout)=>{
|
|
176
|
+
return layout === null || layout === void 0 ? void 0 : layout.yaxis;
|
|
177
|
+
};
|
|
178
|
+
const getXAxisProperties = (series, layout)=>{
|
|
179
|
+
return layout === null || layout === void 0 ? void 0 : layout.xaxis;
|
|
180
|
+
};
|
|
181
|
+
const getFormattedCalloutYData = (yVal, yAxisFormat)=>{
|
|
182
|
+
if (typeof (yAxisFormat === null || yAxisFormat === void 0 ? void 0 : yAxisFormat.yAxisTickFormat) === 'function' && typeof yVal === 'number') {
|
|
183
|
+
return yAxisFormat.yAxisTickFormat(yVal);
|
|
184
|
+
}
|
|
185
|
+
return (0, _chartutilities.formatToLocaleString)(yVal);
|
|
186
|
+
};
|
|
135
187
|
const correctYearMonth = (xValues)=>{
|
|
136
188
|
const presentYear = new Date().getFullYear();
|
|
137
189
|
if (xValues.length > 0 && Array.isArray(xValues[0])) {
|
|
@@ -275,7 +327,7 @@ const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayT
|
|
|
275
327
|
chartTitle,
|
|
276
328
|
chartData: Object.values(mapLegendToDataPoint)
|
|
277
329
|
},
|
|
278
|
-
hideLegend: ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false
|
|
330
|
+
hideLegend: isMultiPlot || ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false,
|
|
279
331
|
width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
|
|
280
332
|
height,
|
|
281
333
|
innerRadius,
|
|
@@ -294,17 +346,16 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
294
346
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
295
347
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
296
348
|
let colorScale = undefined;
|
|
349
|
+
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
297
350
|
let yMinValue = 0;
|
|
298
351
|
input.data.forEach((series, index1)=>{
|
|
299
|
-
var
|
|
300
|
-
|
|
301
|
-
colorScale = createColorScale(input.layout, series);
|
|
302
|
-
}
|
|
352
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line;
|
|
353
|
+
colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
|
|
303
354
|
const isXYearCategory = (0, _chartutilities.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
304
355
|
// extract bar colors for each series only once
|
|
305
|
-
const extractedBarColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
356
|
+
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
357
|
// extract line colors for each series only once
|
|
307
|
-
const extractedLineColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
358
|
+
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
359
|
const xValues = series.x;
|
|
309
360
|
const isXDate = (0, _chartutilities.isDateArray)(xValues);
|
|
310
361
|
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
@@ -327,6 +378,7 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
327
378
|
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
379
|
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
|
|
329
380
|
const yVal = rangeYValues[index2];
|
|
381
|
+
const yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
|
|
330
382
|
if (series.type === 'bar') {
|
|
331
383
|
var _rgb_copy_formatHex8;
|
|
332
384
|
mapXToDataPoints[x].chartData.push({
|
|
@@ -334,7 +386,8 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
334
386
|
data: yVal,
|
|
335
387
|
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
336
388
|
opacity
|
|
337
|
-
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
389
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
390
|
+
yAxisCalloutData
|
|
338
391
|
});
|
|
339
392
|
if (typeof yVal === 'number') {
|
|
340
393
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -356,7 +409,8 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
356
409
|
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
357
410
|
mode: series.mode
|
|
358
411
|
},
|
|
359
|
-
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
412
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
413
|
+
yAxisCalloutData
|
|
360
414
|
});
|
|
361
415
|
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
362
416
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
@@ -367,7 +421,6 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
367
421
|
});
|
|
368
422
|
});
|
|
369
423
|
});
|
|
370
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
371
424
|
const vsbcData = Object.values(mapXToDataPoints);
|
|
372
425
|
var _input_layout_height;
|
|
373
426
|
return {
|
|
@@ -377,9 +430,6 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
377
430
|
barWidth: 'auto',
|
|
378
431
|
yMaxValue,
|
|
379
432
|
yMinValue,
|
|
380
|
-
chartTitle,
|
|
381
|
-
xAxisTitle,
|
|
382
|
-
yAxisTitle,
|
|
383
433
|
mode: 'plotly',
|
|
384
434
|
...secondaryYAxisValues,
|
|
385
435
|
wrapXAxisLables: typeof ((_vsbcData_ = vsbcData[0]) === null || _vsbcData_ === void 0 ? void 0 : _vsbcData_.xAxisPoint) === 'string',
|
|
@@ -389,36 +439,27 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
389
439
|
roundCorners: true,
|
|
390
440
|
showYAxisLables: true,
|
|
391
441
|
noOfCharsToTruncate: 20,
|
|
392
|
-
showYAxisLablesTooltip: true
|
|
442
|
+
showYAxisLablesTooltip: true,
|
|
443
|
+
...getTitles(input.layout),
|
|
444
|
+
...getXAxisTickFormat(input.data[0], input.layout),
|
|
445
|
+
...yAxisTickFormat,
|
|
446
|
+
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
447
|
+
...getBarProps(input.data, input.layout),
|
|
448
|
+
...getYMinMaxValues(input.data[0], input.layout)
|
|
393
449
|
};
|
|
394
450
|
};
|
|
395
|
-
const createColorScale = (layout, series)=>{
|
|
396
|
-
var _layout_coloraxis, _series_marker, _layout_coloraxis1, _layout_coloraxis2;
|
|
397
|
-
const scale = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis = layout.coloraxis) === null || _layout_coloraxis === void 0 ? void 0 : _layout_coloraxis.colorscale;
|
|
398
|
-
const colorValues = (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color;
|
|
399
|
-
var _layout_coloraxis_cmin, _layout_coloraxis_cmax;
|
|
400
|
-
const [dMin, dMax] = [
|
|
401
|
-
(_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),
|
|
402
|
-
(_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)
|
|
403
|
-
];
|
|
404
|
-
// Normalize colorscale domain to actual data domain
|
|
405
|
-
const scaleDomain = scale.map(([pos])=>dMin + pos * (dMax - dMin));
|
|
406
|
-
const scaleColors = scale.map((item)=>item[1]);
|
|
407
|
-
return (0, _d3scale.scaleLinear)().domain(scaleDomain).range(scaleColors);
|
|
408
|
-
};
|
|
409
451
|
const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
410
452
|
var _input_layout, _input_layout1, _gvbcData_;
|
|
411
453
|
const mapXToDataPoints = {};
|
|
412
454
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
413
455
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
414
456
|
let colorScale = undefined;
|
|
457
|
+
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
415
458
|
input.data.forEach((series, index1)=>{
|
|
416
|
-
var
|
|
417
|
-
|
|
418
|
-
colorScale = createColorScale(input.layout, series);
|
|
419
|
-
}
|
|
459
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_x;
|
|
460
|
+
colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
|
|
420
461
|
// extract colors for each series only once
|
|
421
|
-
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
462
|
+
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);
|
|
422
463
|
(_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
|
|
423
464
|
var _series_y;
|
|
424
465
|
if ((0, _chartutilities.isInvalidValue)(x) || (0, _chartutilities.isInvalidValue)((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2])) {
|
|
@@ -434,23 +475,24 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
434
475
|
var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
435
476
|
const legend = legends[index1];
|
|
436
477
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
437
|
-
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,
|
|
478
|
+
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);
|
|
438
479
|
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
|
|
480
|
+
const yVal = series.y[index2];
|
|
439
481
|
var _rgb_copy_formatHex8;
|
|
440
482
|
mapXToDataPoints[x].series.push({
|
|
441
483
|
key: legend,
|
|
442
|
-
data:
|
|
484
|
+
data: yVal,
|
|
443
485
|
xAxisCalloutData: x,
|
|
444
486
|
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
445
487
|
opacity
|
|
446
488
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
447
489
|
legend,
|
|
448
|
-
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
490
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
491
|
+
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
|
|
449
492
|
});
|
|
450
493
|
}
|
|
451
494
|
});
|
|
452
495
|
});
|
|
453
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
454
496
|
const gvbcData = Object.values(mapXToDataPoints);
|
|
455
497
|
var _input_layout_height;
|
|
456
498
|
return {
|
|
@@ -458,15 +500,18 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
458
500
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
459
501
|
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,
|
|
460
502
|
barWidth: 'auto',
|
|
461
|
-
chartTitle,
|
|
462
|
-
xAxisTitle,
|
|
463
|
-
yAxisTitle,
|
|
464
503
|
mode: 'plotly',
|
|
465
504
|
...secondaryYAxisValues,
|
|
466
505
|
hideTickOverlap: true,
|
|
467
506
|
wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
|
|
468
507
|
hideLegend,
|
|
469
|
-
roundCorners: true
|
|
508
|
+
roundCorners: true,
|
|
509
|
+
...getTitles(input.layout),
|
|
510
|
+
...getYMinMaxValues(input.data[0], input.layout),
|
|
511
|
+
...getXAxisTickFormat(input.data[0], input.layout),
|
|
512
|
+
...yAxisTickFormat,
|
|
513
|
+
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
514
|
+
...getBarProps(input.data, input.layout)
|
|
470
515
|
};
|
|
471
516
|
};
|
|
472
517
|
const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -475,15 +520,13 @@ const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayTyp
|
|
|
475
520
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
476
521
|
let colorScale = undefined;
|
|
477
522
|
input.data.forEach((series, seriesIdx)=>{
|
|
478
|
-
var
|
|
523
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_xbins, _series_xbins1, _series_xbins2;
|
|
479
524
|
if (!series.x) {
|
|
480
525
|
return;
|
|
481
526
|
}
|
|
482
|
-
|
|
483
|
-
colorScale = createColorScale(input.layout, series);
|
|
484
|
-
}
|
|
527
|
+
colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
|
|
485
528
|
// extract colors for each series only once
|
|
486
|
-
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
529
|
+
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);
|
|
487
530
|
const xValues = [];
|
|
488
531
|
const yValues = [];
|
|
489
532
|
series.x.forEach((xVal, index)=>{
|
|
@@ -532,21 +575,20 @@ const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayTyp
|
|
|
532
575
|
});
|
|
533
576
|
});
|
|
534
577
|
});
|
|
535
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
536
578
|
var _input_layout_height;
|
|
537
579
|
return {
|
|
538
580
|
data: vbcData,
|
|
539
581
|
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
540
582
|
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,
|
|
541
|
-
chartTitle,
|
|
542
|
-
xAxisTitle,
|
|
543
|
-
yAxisTitle,
|
|
544
583
|
mode: 'histogram',
|
|
545
584
|
hideTickOverlap: true,
|
|
546
585
|
wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
|
|
547
586
|
maxBarWidth: 50,
|
|
548
587
|
hideLegend,
|
|
549
|
-
roundCorners: true
|
|
588
|
+
roundCorners: true,
|
|
589
|
+
...getTitles(input.layout),
|
|
590
|
+
...getYMinMaxValues(input.data[0], input.layout),
|
|
591
|
+
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
550
592
|
};
|
|
551
593
|
};
|
|
552
594
|
const transformPlotlyJsonToAreaChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -559,19 +601,23 @@ const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, colorMap, co
|
|
|
559
601
|
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
560
602
|
};
|
|
561
603
|
const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
|
|
562
|
-
var _input_data_;
|
|
604
|
+
var _input_data_, _input_layout, _input_layout1;
|
|
563
605
|
const isScatterMarkers = [
|
|
606
|
+
'text',
|
|
607
|
+
'markers',
|
|
564
608
|
'text+markers',
|
|
565
609
|
'markers+text',
|
|
566
610
|
'lines+markers',
|
|
567
611
|
'markers+line',
|
|
568
|
-
'text+lines+markers'
|
|
612
|
+
'text+lines+markers',
|
|
613
|
+
'lines+markers+text'
|
|
569
614
|
].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
|
|
570
615
|
const isAreaChart = chartType === 'area';
|
|
571
616
|
const isScatterChart = chartType === 'scatter';
|
|
572
617
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
573
618
|
let mode = 'tonexty';
|
|
574
619
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
620
|
+
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
575
621
|
const chartData = input.data.map((series, index)=>{
|
|
576
622
|
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
|
|
577
623
|
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;
|
|
@@ -587,11 +633,12 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
587
633
|
const seriesColor = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
588
634
|
const seriesOpacity = (0, _PlotlyColorAdapter.getOpacity)(series, index);
|
|
589
635
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
590
|
-
|
|
636
|
+
// if mode contains 'text', we prioritize showing the text over curving the line
|
|
637
|
+
const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
|
|
591
638
|
const legendShape = getLegendShape(series);
|
|
592
639
|
const validXYRanges = getValidXYRanges(series);
|
|
593
640
|
return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
594
|
-
var _series_marker;
|
|
641
|
+
var _series_marker, _input_layout, _input_layout_polar_angularaxis, _input_layout_polar, _input_layout1, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout2;
|
|
595
642
|
const rangeXValues = xValues.slice(rangeStart, rangeEnd);
|
|
596
643
|
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
597
644
|
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) : [];
|
|
@@ -612,7 +659,8 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
612
659
|
} : {},
|
|
613
660
|
...textValues ? {
|
|
614
661
|
text: textValues[i]
|
|
615
|
-
} : {}
|
|
662
|
+
} : {},
|
|
663
|
+
yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat)
|
|
616
664
|
};
|
|
617
665
|
}),
|
|
618
666
|
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(seriesColor).copy({
|
|
@@ -620,58 +668,59 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
620
668
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
|
|
621
669
|
lineOptions: {
|
|
622
670
|
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
623
|
-
mode: series.mode
|
|
671
|
+
mode: series.type !== 'scatterpolar' ? series.mode : 'scatterpolar',
|
|
672
|
+
// originXOffset is not typed on Layout, but may be present in input.layout as a part of projection of
|
|
673
|
+
// scatter polar coordingates to cartesian coordinates
|
|
674
|
+
...series.type === 'scatterpolar' ? {
|
|
675
|
+
originXOffset: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.__polarOriginX,
|
|
676
|
+
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,
|
|
677
|
+
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,
|
|
678
|
+
axisLabel: series.__axisLabel ? series.__axisLabel : {}
|
|
679
|
+
} : {}
|
|
624
680
|
},
|
|
625
681
|
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
626
682
|
};
|
|
627
683
|
});
|
|
628
684
|
}).flat();
|
|
629
|
-
const
|
|
630
|
-
|
|
685
|
+
const yMinMax = getYMinMaxValues(input.data[0], input.layout);
|
|
686
|
+
if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
|
|
687
|
+
const yMinMaxValues = (0, _utilities.findNumericMinMaxOfY)(chartData);
|
|
688
|
+
yMinMax.yMinValue = yMinMaxValues.startValue;
|
|
689
|
+
yMinMax.yMaxValue = yMinMaxValues.endValue;
|
|
690
|
+
}
|
|
631
691
|
const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
|
|
632
692
|
const chartProps = {
|
|
633
|
-
chartTitle,
|
|
634
693
|
lineChartData: chartData
|
|
635
694
|
};
|
|
636
695
|
const scatterChartProps = {
|
|
637
|
-
chartTitle,
|
|
638
696
|
scatterChartData: chartData
|
|
639
697
|
};
|
|
698
|
+
var _input_layout_height;
|
|
699
|
+
const commonProps = {
|
|
700
|
+
supportNegativeData: true,
|
|
701
|
+
...secondaryYAxisValues,
|
|
702
|
+
width: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.width,
|
|
703
|
+
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,
|
|
704
|
+
hideTickOverlap: true,
|
|
705
|
+
hideLegend,
|
|
706
|
+
useUTC: false,
|
|
707
|
+
optimizeLargeData: numDataPoints > 1000,
|
|
708
|
+
...getTitles(input.layout),
|
|
709
|
+
...getXAxisTickFormat(input.data[0], input.layout),
|
|
710
|
+
...yAxisTickFormat
|
|
711
|
+
};
|
|
640
712
|
if (isAreaChart) {
|
|
641
|
-
var _input_layout, _input_layout1;
|
|
642
|
-
var _input_layout_height;
|
|
643
713
|
return {
|
|
644
714
|
data: chartProps,
|
|
645
|
-
supportNegativeData: true,
|
|
646
|
-
xAxisTitle,
|
|
647
|
-
yAxisTitle,
|
|
648
|
-
...secondaryYAxisValues,
|
|
649
715
|
mode,
|
|
650
|
-
|
|
651
|
-
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,
|
|
652
|
-
hideTickOverlap: true,
|
|
653
|
-
useUTC: false,
|
|
654
|
-
hideLegend,
|
|
655
|
-
optimizeLargeData: numDataPoints > 1000
|
|
716
|
+
...commonProps
|
|
656
717
|
};
|
|
657
718
|
} else {
|
|
658
|
-
var _input_layout2, _input_layout3;
|
|
659
|
-
var _input_layout_height1;
|
|
660
719
|
return {
|
|
661
720
|
data: isScatterChart ? scatterChartProps : chartProps,
|
|
662
|
-
supportNegativeData: true,
|
|
663
|
-
xAxisTitle,
|
|
664
|
-
yAxisTitle,
|
|
665
|
-
...secondaryYAxisValues,
|
|
666
721
|
roundedTicks: true,
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
width: (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.width,
|
|
670
|
-
height: (_input_layout_height1 = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.height) !== null && _input_layout_height1 !== void 0 ? _input_layout_height1 : 350,
|
|
671
|
-
hideTickOverlap: true,
|
|
672
|
-
useUTC: false,
|
|
673
|
-
hideLegend,
|
|
674
|
-
optimizeLargeData: numDataPoints > 1000
|
|
722
|
+
...commonProps,
|
|
723
|
+
...yMinMax
|
|
675
724
|
};
|
|
676
725
|
}
|
|
677
726
|
};
|
|
@@ -680,12 +729,10 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
|
|
|
680
729
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
681
730
|
let colorScale = undefined;
|
|
682
731
|
const chartData = input.data.map((series, index)=>{
|
|
683
|
-
var
|
|
684
|
-
|
|
685
|
-
colorScale = createColorScale(input.layout, series);
|
|
686
|
-
}
|
|
732
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
|
|
733
|
+
colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
|
|
687
734
|
// extract colors for each series only once
|
|
688
|
-
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
735
|
+
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);
|
|
689
736
|
const legend = legends[index];
|
|
690
737
|
return series.y.map((yValue, i)=>{
|
|
691
738
|
var _series_x, _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
@@ -705,8 +752,7 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
|
|
|
705
752
|
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
706
753
|
};
|
|
707
754
|
}).filter((point)=>point !== null);
|
|
708
|
-
}).
|
|
709
|
-
.reverse();
|
|
755
|
+
}).flat();
|
|
710
756
|
var _input_layout_height;
|
|
711
757
|
const chartHeight = (_input_layout_height = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 450;
|
|
712
758
|
var _input_layout_margin_l;
|
|
@@ -718,12 +764,8 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
|
|
|
718
764
|
const scalingFactor = 0.01;
|
|
719
765
|
const gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
720
766
|
const barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
721
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
722
767
|
return {
|
|
723
768
|
data: chartData,
|
|
724
|
-
chartTitle,
|
|
725
|
-
xAxisTitle,
|
|
726
|
-
yAxisTitle,
|
|
727
769
|
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) || '',
|
|
728
770
|
barHeight,
|
|
729
771
|
showYAxisLables: true,
|
|
@@ -733,7 +775,10 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
|
|
|
733
775
|
noOfCharsToTruncate: 20,
|
|
734
776
|
showYAxisLablesTooltip: true,
|
|
735
777
|
hideLegend,
|
|
736
|
-
roundCorners: true
|
|
778
|
+
roundCorners: true,
|
|
779
|
+
...getTitles(input.layout),
|
|
780
|
+
...getAxisCategoryOrderProps(input.data, input.layout),
|
|
781
|
+
...getBarProps(input.data, input.layout, true)
|
|
737
782
|
};
|
|
738
783
|
};
|
|
739
784
|
const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -846,7 +891,6 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
|
|
|
846
891
|
}
|
|
847
892
|
const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
|
|
848
893
|
const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
|
|
849
|
-
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
850
894
|
var _input_layout_height;
|
|
851
895
|
return {
|
|
852
896
|
data: [
|
|
@@ -856,16 +900,17 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
|
|
|
856
900
|
rangeValuesForColorScale,
|
|
857
901
|
hideLegend: true,
|
|
858
902
|
showYAxisLables: true,
|
|
859
|
-
chartTitle,
|
|
860
|
-
xAxisTitle,
|
|
861
|
-
yAxisTitle,
|
|
862
903
|
sortOrder: 'none',
|
|
863
904
|
width: (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.width,
|
|
864
905
|
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,
|
|
865
906
|
hideTickOverlap: true,
|
|
866
907
|
noOfCharsToTruncate: 20,
|
|
867
908
|
showYAxisLablesTooltip: true,
|
|
868
|
-
wrapXAxisLables: true
|
|
909
|
+
wrapXAxisLables: true,
|
|
910
|
+
...getTitles(input.layout),
|
|
911
|
+
...getAxisCategoryOrderProps([
|
|
912
|
+
firstData
|
|
913
|
+
], input.layout)
|
|
869
914
|
};
|
|
870
915
|
};
|
|
871
916
|
const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -1014,7 +1059,7 @@ const formatValue = (value, colIndex, cells)=>{
|
|
|
1014
1059
|
return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
|
|
1015
1060
|
};
|
|
1016
1061
|
const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
1017
|
-
var _tableData_cells, _input_layout_template_data, _input_layout_template, _input_layout, _input_layout_font, _input_layout1, _tableData_header,
|
|
1062
|
+
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;
|
|
1018
1063
|
const tableData = input.data[0];
|
|
1019
1064
|
const normalizeHeaders = (values, header)=>{
|
|
1020
1065
|
const cleanedValues = Array.isArray(values[0]) ? values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' ')) : values.map((cell)=>cleanText(cell));
|
|
@@ -1023,7 +1068,8 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1023
1068
|
const fontColorRaw = header === null || header === void 0 ? void 0 : (_header_font = header.font) === null || _header_font === void 0 ? void 0 : _header_font.color;
|
|
1024
1069
|
let fontColor;
|
|
1025
1070
|
if (Array.isArray(fontColorRaw)) {
|
|
1026
|
-
|
|
1071
|
+
var _fontColorRaw_colIndex;
|
|
1072
|
+
const colorEntry = (_fontColorRaw_colIndex = fontColorRaw[colIndex]) !== null && _fontColorRaw_colIndex !== void 0 ? _fontColorRaw_colIndex : fontColorRaw[0];
|
|
1027
1073
|
if (Array.isArray(colorEntry)) {
|
|
1028
1074
|
fontColor = typeof colorEntry[0] === 'string' ? colorEntry[0] : undefined;
|
|
1029
1075
|
} else if (typeof colorEntry === 'string') {
|
|
@@ -1035,15 +1081,20 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1035
1081
|
const fontSizeRaw = header === null || header === void 0 ? void 0 : (_header_font1 = header.font) === null || _header_font1 === void 0 ? void 0 : _header_font1.size;
|
|
1036
1082
|
let fontSize;
|
|
1037
1083
|
if (Array.isArray(fontSizeRaw)) {
|
|
1038
|
-
|
|
1084
|
+
var _fontSizeRaw_colIndex;
|
|
1085
|
+
const fontSizeEntry = (_fontSizeRaw_colIndex = fontSizeRaw[colIndex]) !== null && _fontSizeRaw_colIndex !== void 0 ? _fontSizeRaw_colIndex : fontSizeRaw[0];
|
|
1086
|
+
var _fontSizeRaw__colIndex;
|
|
1087
|
+
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;
|
|
1039
1088
|
} else if (typeof fontSizeRaw === 'number') {
|
|
1040
1089
|
fontSize = fontSizeRaw;
|
|
1041
1090
|
}
|
|
1042
1091
|
const updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
1043
1092
|
const fillColorRaw = header === null || header === void 0 ? void 0 : (_header_fill = header.fill) === null || _header_fill === void 0 ? void 0 : _header_fill.color;
|
|
1044
|
-
|
|
1093
|
+
var _fillColorRaw_updatedColIndex;
|
|
1094
|
+
const backgroundColor = Array.isArray(fillColorRaw) ? (_fillColorRaw_updatedColIndex = fillColorRaw[updatedColIndex]) !== null && _fillColorRaw_updatedColIndex !== void 0 ? _fillColorRaw_updatedColIndex : fillColorRaw[0] : fillColorRaw;
|
|
1045
1095
|
const textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
|
|
1046
|
-
|
|
1096
|
+
var _textAlignRaw_colIndex;
|
|
1097
|
+
const textAlign = Array.isArray(textAlignRaw) ? (_textAlignRaw_colIndex = textAlignRaw[colIndex]) !== null && _textAlignRaw_colIndex !== void 0 ? _textAlignRaw_colIndex : textAlignRaw[0] : textAlignRaw;
|
|
1047
1098
|
const style = {
|
|
1048
1099
|
...typeof fontColor === 'string' ? {
|
|
1049
1100
|
color: fontColor
|
|
@@ -1066,7 +1117,7 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1066
1117
|
};
|
|
1067
1118
|
var _tableData_cells_values;
|
|
1068
1119
|
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 : [];
|
|
1069
|
-
const cells = tableData.cells.
|
|
1120
|
+
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;
|
|
1070
1121
|
const rows = columns[0].map((_, rowIndex)=>columns.map((col, colIndex)=>{
|
|
1071
1122
|
var _cells_font, _cells_font1, _cells_fill;
|
|
1072
1123
|
const cellValue = col[rowIndex];
|
|
@@ -1075,7 +1126,8 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1075
1126
|
const rawFontColor = cells === null || cells === void 0 ? void 0 : (_cells_font = cells.font) === null || _cells_font === void 0 ? void 0 : _cells_font.color;
|
|
1076
1127
|
let fontColor;
|
|
1077
1128
|
if (Array.isArray(rawFontColor)) {
|
|
1078
|
-
|
|
1129
|
+
var _rawFontColor_colIndex;
|
|
1130
|
+
const entry = (_rawFontColor_colIndex = rawFontColor[colIndex]) !== null && _rawFontColor_colIndex !== void 0 ? _rawFontColor_colIndex : rawFontColor[0];
|
|
1079
1131
|
const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1080
1132
|
fontColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
1081
1133
|
} else if (typeof rawFontColor === 'string') {
|
|
@@ -1084,7 +1136,8 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1084
1136
|
const rawFontSize = cells === null || cells === void 0 ? void 0 : (_cells_font1 = cells.font) === null || _cells_font1 === void 0 ? void 0 : _cells_font1.size;
|
|
1085
1137
|
let fontSize;
|
|
1086
1138
|
if (Array.isArray(rawFontSize)) {
|
|
1087
|
-
|
|
1139
|
+
var _rawFontSize_colIndex;
|
|
1140
|
+
const entry = (_rawFontSize_colIndex = rawFontSize[colIndex]) !== null && _rawFontSize_colIndex !== void 0 ? _rawFontSize_colIndex : rawFontSize[0];
|
|
1088
1141
|
const fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1089
1142
|
fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
|
|
1090
1143
|
} else if (typeof rawFontSize === 'number') {
|
|
@@ -1094,13 +1147,15 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1094
1147
|
const rawBackgroundColor = cells === null || cells === void 0 ? void 0 : (_cells_fill = cells.fill) === null || _cells_fill === void 0 ? void 0 : _cells_fill.color;
|
|
1095
1148
|
let backgroundColor;
|
|
1096
1149
|
if (Array.isArray(rawBackgroundColor)) {
|
|
1097
|
-
|
|
1150
|
+
var _rawBackgroundColor_updatedColIndex;
|
|
1151
|
+
const entry = (_rawBackgroundColor_updatedColIndex = rawBackgroundColor[updatedColIndex]) !== null && _rawBackgroundColor_updatedColIndex !== void 0 ? _rawBackgroundColor_updatedColIndex : rawBackgroundColor[0];
|
|
1098
1152
|
const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1099
1153
|
backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
1100
1154
|
} else if (typeof rawBackgroundColor === 'string') {
|
|
1101
1155
|
backgroundColor = rawBackgroundColor;
|
|
1102
1156
|
}
|
|
1103
|
-
|
|
1157
|
+
var _cells_align_colIndex;
|
|
1158
|
+
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;
|
|
1104
1159
|
const textAlign = rawTextAlign;
|
|
1105
1160
|
const style = {
|
|
1106
1161
|
...fontColor ? {
|
|
@@ -1130,7 +1185,7 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1130
1185
|
};
|
|
1131
1186
|
var _tableData_header_values;
|
|
1132
1187
|
return {
|
|
1133
|
-
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 : [],
|
|
1188
|
+
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),
|
|
1134
1189
|
rows,
|
|
1135
1190
|
width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
|
|
1136
1191
|
height: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height,
|
|
@@ -1138,27 +1193,141 @@ const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colo
|
|
|
1138
1193
|
};
|
|
1139
1194
|
};
|
|
1140
1195
|
const projectPolarToCartesian = (input)=>{
|
|
1196
|
+
var _input_layout, _input_layout1;
|
|
1141
1197
|
const projection = {
|
|
1142
1198
|
...input
|
|
1143
1199
|
};
|
|
1200
|
+
// Find the global min and max radius across all series
|
|
1201
|
+
let minRadius = 0;
|
|
1202
|
+
let maxRadius = 0;
|
|
1203
|
+
for(let sindex = 0; sindex < input.data.length; sindex++){
|
|
1204
|
+
const rVals = input.data[sindex].r;
|
|
1205
|
+
if (rVals && (0, _chartutilities.isArrayOrTypedArray)(rVals)) {
|
|
1206
|
+
for(let ptindex = 0; ptindex < rVals.length; ptindex++){
|
|
1207
|
+
if (!(0, _chartutilities.isInvalidValue)(rVals[ptindex])) {
|
|
1208
|
+
minRadius = Math.min(minRadius, rVals[ptindex]);
|
|
1209
|
+
maxRadius = Math.max(maxRadius, rVals[ptindex]);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
// If there are negative radii, compute the shift
|
|
1215
|
+
const radiusShift = minRadius < 0 ? -minRadius : 0;
|
|
1216
|
+
// Collect all unique theta values from all scatterpolar series for equal spacing
|
|
1217
|
+
const allThetaValues = new Set();
|
|
1144
1218
|
for(let sindex = 0; sindex < input.data.length; sindex++){
|
|
1145
|
-
var _series_r;
|
|
1146
1219
|
const series = input.data[sindex];
|
|
1220
|
+
if (series.theta && (0, _chartutilities.isArrayOrTypedArray)(series.theta)) {
|
|
1221
|
+
series.theta.forEach((theta)=>allThetaValues.add(String(theta)));
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
// Project all points and create a perfect square domain
|
|
1225
|
+
const allX = [];
|
|
1226
|
+
const allY = [];
|
|
1227
|
+
let originX = null;
|
|
1228
|
+
for(let sindex = 0; sindex < input.data.length; sindex++){
|
|
1229
|
+
var _input_layout_polar_angularaxis, _input_layout_polar, _input_layout2, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout3;
|
|
1230
|
+
const series = input.data[sindex];
|
|
1231
|
+
// If scatterpolar, set __axisLabel to all unique theta values for equal spacing
|
|
1232
|
+
if ((0, _chartutilities.isArrayOrTypedArray)(series.theta)) {
|
|
1233
|
+
series.__axisLabel = Array.from(allThetaValues);
|
|
1234
|
+
}
|
|
1147
1235
|
series.x = [];
|
|
1148
1236
|
series.y = [];
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1237
|
+
const thetas = series.theta;
|
|
1238
|
+
const rVals = series.r;
|
|
1239
|
+
// Skip if rVals or thetas are not arrays
|
|
1240
|
+
if (!(0, _chartutilities.isArrayOrTypedArray)(rVals) || !(0, _chartutilities.isArrayOrTypedArray)(thetas)) {
|
|
1241
|
+
projection.data[sindex] = series;
|
|
1242
|
+
continue;
|
|
1243
|
+
}
|
|
1244
|
+
// retrieve polar axis settings
|
|
1245
|
+
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;
|
|
1246
|
+
var _input_layout_polar_angularaxis_rotation;
|
|
1247
|
+
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;
|
|
1248
|
+
// Compute tick positions if categorical
|
|
1249
|
+
let uniqueTheta = [];
|
|
1250
|
+
let categorical = false;
|
|
1251
|
+
if (!(0, _chartutilities.isNumberArray)(thetas)) {
|
|
1252
|
+
uniqueTheta = Array.from(new Set(thetas));
|
|
1253
|
+
categorical = true;
|
|
1254
|
+
}
|
|
1255
|
+
for(let ptindex = 0; ptindex < rVals.length; ptindex++){
|
|
1256
|
+
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])) {
|
|
1153
1257
|
continue;
|
|
1154
1258
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1259
|
+
// Map theta to angle in radians
|
|
1260
|
+
let thetaRad;
|
|
1261
|
+
if (categorical) {
|
|
1262
|
+
const idx = uniqueTheta.indexOf(thetas[ptindex]);
|
|
1263
|
+
const step = 2 * Math.PI / uniqueTheta.length;
|
|
1264
|
+
thetaRad = startAngleInRad + dirMultiplier * idx * step;
|
|
1265
|
+
} else {
|
|
1266
|
+
thetaRad = startAngleInRad + dirMultiplier * (thetas[ptindex] * Math.PI / 180);
|
|
1267
|
+
}
|
|
1268
|
+
// Shift only the polar origin (not the cartesian)
|
|
1269
|
+
const rawRadius = rVals[ptindex];
|
|
1270
|
+
const polarRadius = rawRadius + radiusShift; // Only for projection
|
|
1271
|
+
// Calculate cartesian coordinates (with shifted polar origin)
|
|
1272
|
+
const x = polarRadius * Math.cos(thetaRad);
|
|
1273
|
+
const y = polarRadius * Math.sin(thetaRad);
|
|
1274
|
+
// Calculate the cartesian coordinates of the original polar origin (0,0)
|
|
1275
|
+
// This is the point that should be mapped to (0,0) in cartesian coordinates
|
|
1276
|
+
if (sindex === 0 && ptindex === 0) {
|
|
1277
|
+
// For polar origin (r=0, θ=0), cartesian coordinates are (0,0)
|
|
1278
|
+
// But since we shifted the radius by radiusShift, the cartesian origin is at (radiusShift, 0)
|
|
1279
|
+
originX = radiusShift;
|
|
1280
|
+
}
|
|
1281
|
+
series.x.push(x);
|
|
1282
|
+
series.y.push(y);
|
|
1283
|
+
allX.push(x);
|
|
1284
|
+
allY.push(y);
|
|
1285
|
+
}
|
|
1286
|
+
// Map text to each data point for downstream chart rendering
|
|
1287
|
+
if (series.x && series.y) {
|
|
1288
|
+
series.data = series.x.map((xVal, idx)=>({
|
|
1289
|
+
x: xVal,
|
|
1290
|
+
y: series.y[idx],
|
|
1291
|
+
...series.text ? {
|
|
1292
|
+
text: series.text[idx]
|
|
1293
|
+
} : {}
|
|
1294
|
+
}));
|
|
1159
1295
|
}
|
|
1160
1296
|
projection.data[sindex] = series;
|
|
1161
1297
|
}
|
|
1298
|
+
// 7. Recenter all cartesian coordinates
|
|
1299
|
+
if (originX !== null) {
|
|
1300
|
+
for(let sindex = 0; sindex < projection.data.length; sindex++){
|
|
1301
|
+
const series = projection.data[sindex];
|
|
1302
|
+
if (series.x && series.y) {
|
|
1303
|
+
series.x = series.x.map((v)=>v - originX);
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
// Also recenter allX for normalization
|
|
1307
|
+
for(let i = 0; i < allX.length; i++){
|
|
1308
|
+
allX[i] = allX[i] - originX;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
// 8. Find the maximum absolute value among all x and y
|
|
1312
|
+
let maxAbs = Math.max(...allX.map(Math.abs), ...allY.map(Math.abs));
|
|
1313
|
+
maxAbs = maxAbs === 0 ? 1 : maxAbs;
|
|
1314
|
+
// 9. Rescale all points so that the largest |x| or |y| is 0.5
|
|
1315
|
+
for(let sindex = 0; sindex < projection.data.length; sindex++){
|
|
1316
|
+
const series = projection.data[sindex];
|
|
1317
|
+
if (series.x && series.y) {
|
|
1318
|
+
series.x = series.x.map((v)=>v / (2 * maxAbs));
|
|
1319
|
+
series.y = series.y.map((v)=>v / (2 * maxAbs));
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
// 10. Customize layout for perfect square with absolute positioning
|
|
1323
|
+
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;
|
|
1324
|
+
projection.layout = {
|
|
1325
|
+
...projection.layout,
|
|
1326
|
+
width: size,
|
|
1327
|
+
height: size
|
|
1328
|
+
};
|
|
1329
|
+
// Attach originX as custom properties
|
|
1330
|
+
projection.layout.__polarOriginX = originX !== null && originX !== void 0 ? originX : undefined;
|
|
1162
1331
|
return projection;
|
|
1163
1332
|
};
|
|
1164
1333
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1333,25 +1502,44 @@ const getLegendShape = (series)=>{
|
|
|
1333
1502
|
}
|
|
1334
1503
|
return 'default';
|
|
1335
1504
|
};
|
|
1336
|
-
const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
1505
|
+
const getAllupLegendsProps = (input, colorMap, colorwayType, traceInfo, isDarkTheme)=>{
|
|
1337
1506
|
const allupLegends = [];
|
|
1338
1507
|
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1339
1508
|
const toShowLegend = input.data.reduce((acc, series)=>{
|
|
1340
|
-
return acc || series.showlegend === true;
|
|
1509
|
+
return acc || series.showlegend === true || series.showlegend === undefined;
|
|
1341
1510
|
}, false);
|
|
1342
1511
|
if (toShowLegend) {
|
|
1343
1512
|
input.data.forEach((series, index)=>{
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
color
|
|
1353
|
-
|
|
1513
|
+
if (traceInfo[index].type === 'donut') {
|
|
1514
|
+
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _pieSeries_marker, _pieSeries_labels;
|
|
1515
|
+
const pieSeries = series;
|
|
1516
|
+
var _input_layout_piecolorway, _input_layout_piecolorway1;
|
|
1517
|
+
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);
|
|
1518
|
+
(_pieSeries_labels = pieSeries.labels) === null || _pieSeries_labels === void 0 ? void 0 : _pieSeries_labels.forEach((label, labelIndex)=>{
|
|
1519
|
+
const legend = `${label}`;
|
|
1520
|
+
// resolve color for each legend from the extracted colors
|
|
1521
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(colors, labelIndex, legend, colorMap, isDarkTheme);
|
|
1522
|
+
if (legend !== '' && allupLegends.some((group)=>group.title === legend) === false) {
|
|
1523
|
+
allupLegends.push({
|
|
1524
|
+
title: legend,
|
|
1525
|
+
color
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1354
1528
|
});
|
|
1529
|
+
} else if (isNonPlotType(traceInfo[index].type) === false) {
|
|
1530
|
+
var _plotSeries_line, _plotSeries_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout3;
|
|
1531
|
+
const plotSeries = series;
|
|
1532
|
+
const name = plotSeries.legendgroup;
|
|
1533
|
+
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);
|
|
1534
|
+
const legendShape = getLegendShape(plotSeries);
|
|
1535
|
+
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);
|
|
1536
|
+
if (name !== undefined && name !== '' && allupLegends.some((group)=>group.title === name) === false) {
|
|
1537
|
+
allupLegends.push({
|
|
1538
|
+
title: name,
|
|
1539
|
+
color: resolvedColor,
|
|
1540
|
+
shape: legendShape
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1355
1543
|
}
|
|
1356
1544
|
});
|
|
1357
1545
|
}
|
|
@@ -1417,28 +1605,21 @@ const getIndexFromKey = (key, pattern)=>{
|
|
|
1417
1605
|
const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1418
1606
|
return parseInt(normalizedKey, 10) - 1;
|
|
1419
1607
|
};
|
|
1420
|
-
const
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1608
|
+
const isNonPlotType = (chartType)=>{
|
|
1609
|
+
return [
|
|
1610
|
+
'donut',
|
|
1611
|
+
'sankey',
|
|
1612
|
+
'pie'
|
|
1613
|
+
].includes(chartType);
|
|
1614
|
+
};
|
|
1615
|
+
const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
|
|
1616
|
+
const domainX = [];
|
|
1617
|
+
const domainY = [];
|
|
1618
|
+
let cartesianDomains = 0;
|
|
1424
1619
|
const annotations = {};
|
|
1425
1620
|
let templateRows = '1fr';
|
|
1426
1621
|
let templateColumns = '1fr';
|
|
1427
1622
|
const gridLayout = {};
|
|
1428
|
-
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1429
|
-
return {
|
|
1430
|
-
templateRows,
|
|
1431
|
-
templateColumns,
|
|
1432
|
-
layout: gridLayout
|
|
1433
|
-
};
|
|
1434
|
-
}
|
|
1435
|
-
if (!layout.xaxis || !layout.yaxis) {
|
|
1436
|
-
return {
|
|
1437
|
-
templateRows,
|
|
1438
|
-
templateColumns,
|
|
1439
|
-
layout: gridLayout
|
|
1440
|
-
};
|
|
1441
|
-
}
|
|
1442
1623
|
if (!isMultiPlot) {
|
|
1443
1624
|
return {
|
|
1444
1625
|
templateRows,
|
|
@@ -1446,143 +1627,214 @@ const getGridProperties = (layout, isMultiPlot)=>{
|
|
|
1446
1627
|
layout: gridLayout
|
|
1447
1628
|
};
|
|
1448
1629
|
}
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
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 : [];
|
|
1461
|
-
} else if (key.startsWith('yaxis')) {
|
|
1462
|
-
var _layout_key2, _layout_key3;
|
|
1463
|
-
const index = getIndexFromKey(key, 'yaxis');
|
|
1464
|
-
var _layout_key_anchor1;
|
|
1465
|
-
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';
|
|
1466
|
-
const anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1467
|
-
if (index !== anchorIndex) {
|
|
1468
|
-
var _layout_yaxis2;
|
|
1469
|
-
if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
|
|
1470
|
-
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1471
|
-
return {
|
|
1472
|
-
templateRows,
|
|
1473
|
-
templateColumns
|
|
1474
|
-
};
|
|
1630
|
+
const layout = schema === null || schema === void 0 ? void 0 : schema.layout;
|
|
1631
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
1632
|
+
Object.keys(layout !== null && layout !== void 0 ? layout : {}).forEach((key)=>{
|
|
1633
|
+
if (key.startsWith('xaxis')) {
|
|
1634
|
+
var _layout_key;
|
|
1635
|
+
const index = getIndexFromKey(key, 'xaxis');
|
|
1636
|
+
var _layout_key_anchor;
|
|
1637
|
+
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';
|
|
1638
|
+
const anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1639
|
+
if (index !== anchorIndex) {
|
|
1640
|
+
throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
|
|
1475
1641
|
}
|
|
1476
|
-
|
|
1642
|
+
const xAxisLayout = layout[key];
|
|
1643
|
+
const domainXInfo = {
|
|
1644
|
+
start: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[0] : 0,
|
|
1645
|
+
end: (xAxisLayout === null || xAxisLayout === void 0 ? void 0 : xAxisLayout.domain) ? xAxisLayout.domain[1] : 1
|
|
1646
|
+
};
|
|
1647
|
+
domainX.push(domainXInfo);
|
|
1648
|
+
} else if (key.startsWith('yaxis')) {
|
|
1649
|
+
var _layout_key1;
|
|
1650
|
+
const index = getIndexFromKey(key, 'yaxis');
|
|
1651
|
+
var _layout_key_anchor1;
|
|
1652
|
+
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';
|
|
1653
|
+
const anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1654
|
+
if (index !== anchorIndex) {
|
|
1655
|
+
var _layout_yaxis2;
|
|
1656
|
+
if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
|
|
1657
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1658
|
+
return {
|
|
1659
|
+
templateRows,
|
|
1660
|
+
templateColumns
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
|
|
1664
|
+
}
|
|
1665
|
+
const yAxisLayout = layout[key];
|
|
1666
|
+
const domainYInfo = {
|
|
1667
|
+
start: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[0] : 0,
|
|
1668
|
+
end: (yAxisLayout === null || yAxisLayout === void 0 ? void 0 : yAxisLayout.domain) ? yAxisLayout.domain[1] : 1
|
|
1669
|
+
};
|
|
1670
|
+
domainY.push(domainYInfo);
|
|
1477
1671
|
}
|
|
1478
|
-
|
|
1479
|
-
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
cartesianDomains = domainX.length; // Assuming that the number of x and y axes is the same
|
|
1675
|
+
validTracesInfo.forEach((trace, index)=>{
|
|
1676
|
+
if (isNonPlotType(trace.type)) {
|
|
1677
|
+
var _schema_data, _series_domain, _series_domain1, _series_domain2, _series_domain3;
|
|
1678
|
+
const series = schema === null || schema === void 0 ? void 0 : (_schema_data = schema.data) === null || _schema_data === void 0 ? void 0 : _schema_data[index];
|
|
1679
|
+
const domainXInfo = {
|
|
1680
|
+
start: ((_series_domain = series.domain) === null || _series_domain === void 0 ? void 0 : _series_domain.x) ? series.domain.x[0] : 0,
|
|
1681
|
+
end: ((_series_domain1 = series.domain) === null || _series_domain1 === void 0 ? void 0 : _series_domain1.x) ? series.domain.x[1] : 1
|
|
1682
|
+
};
|
|
1683
|
+
const domainYInfo = {
|
|
1684
|
+
start: ((_series_domain2 = series.domain) === null || _series_domain2 === void 0 ? void 0 : _series_domain2.y) ? series.domain.y[0] : 0,
|
|
1685
|
+
end: ((_series_domain3 = series.domain) === null || _series_domain3 === void 0 ? void 0 : _series_domain3.y) ? series.domain.y[1] : 1
|
|
1686
|
+
};
|
|
1687
|
+
domainX.push(domainXInfo);
|
|
1688
|
+
domainY.push(domainYInfo);
|
|
1480
1689
|
}
|
|
1481
1690
|
});
|
|
1482
|
-
(
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1691
|
+
if (layout !== undefined && layout !== null && Object.keys(layout).length > 0) {
|
|
1692
|
+
var _layout_annotations;
|
|
1693
|
+
(_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
|
|
1694
|
+
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 ? [
|
|
1695
|
+
idx
|
|
1696
|
+
] : []);
|
|
1697
|
+
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);
|
|
1698
|
+
if (yMatch !== -1) {
|
|
1699
|
+
if (annotations[yMatch] === undefined) {
|
|
1700
|
+
annotations[yMatch] = {};
|
|
1701
|
+
}
|
|
1702
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1703
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1704
|
+
} else {
|
|
1705
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1706
|
+
}
|
|
1495
1707
|
}
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
if (
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
if (domainX.length > 0) {
|
|
1499
1711
|
const uniqueXIntervals = new Map();
|
|
1500
|
-
|
|
1501
|
-
const key = `${interval
|
|
1712
|
+
domainX.forEach((interval)=>{
|
|
1713
|
+
const key = `${interval.start}-${interval.end}`;
|
|
1502
1714
|
if (!uniqueXIntervals.has(key)) {
|
|
1503
1715
|
uniqueXIntervals.set(key, interval);
|
|
1504
1716
|
}
|
|
1505
1717
|
});
|
|
1506
|
-
const
|
|
1507
|
-
templateColumns =
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
return;
|
|
1513
|
-
}
|
|
1514
|
-
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
1718
|
+
const sortedXStart = Array.from(uniqueXIntervals.values()).map((interval)=>interval.start).sort();
|
|
1719
|
+
templateColumns = `repeat(${sortedXStart.length}, 1fr)`;
|
|
1720
|
+
domainX.forEach((interval, index)=>{
|
|
1721
|
+
const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
|
|
1722
|
+
const columnIndex = sortedXStart.findIndex((start)=>start === interval.start);
|
|
1723
|
+
const columnNumber = columnIndex + 1; // Column numbers are 1-based
|
|
1515
1724
|
const annotationProps = annotations[index];
|
|
1516
1725
|
const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1517
|
-
if (interval[0] < lastIntervalEnd) {
|
|
1518
|
-
columnNumber = 1;
|
|
1519
|
-
}
|
|
1520
|
-
lastIntervalEnd = interval[1];
|
|
1521
1726
|
const row = {
|
|
1522
1727
|
row: -1,
|
|
1523
1728
|
column: columnNumber,
|
|
1524
|
-
xAnnotation
|
|
1729
|
+
xAnnotation,
|
|
1730
|
+
xDomain: interval,
|
|
1731
|
+
yDomain: {
|
|
1732
|
+
start: 0,
|
|
1733
|
+
end: 1
|
|
1734
|
+
}
|
|
1525
1735
|
};
|
|
1526
1736
|
gridLayout[cellName] = row;
|
|
1527
|
-
columnNumber += 1;
|
|
1528
1737
|
});
|
|
1529
1738
|
}
|
|
1530
|
-
|
|
1531
|
-
var _cell_column;
|
|
1532
|
-
return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
|
|
1533
|
-
}));
|
|
1534
|
-
const columnFill = {};
|
|
1535
|
-
for(let i = 1; i <= numColumns; i++){
|
|
1536
|
-
columnFill[i] = {
|
|
1537
|
-
row: 1,
|
|
1538
|
-
fillDomain: 0
|
|
1539
|
-
};
|
|
1540
|
-
}
|
|
1541
|
-
if (gridY.length > 0) {
|
|
1739
|
+
if (domainY.length > 0) {
|
|
1542
1740
|
const uniqueYIntervals = new Map();
|
|
1543
|
-
|
|
1544
|
-
const key = `${interval
|
|
1741
|
+
domainY.forEach((interval)=>{
|
|
1742
|
+
const key = `${interval.start}-${interval.end}`;
|
|
1545
1743
|
if (!uniqueYIntervals.has(key)) {
|
|
1546
1744
|
uniqueYIntervals.set(key, interval);
|
|
1547
1745
|
}
|
|
1548
1746
|
});
|
|
1549
|
-
const
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
const
|
|
1747
|
+
const sortedYStart = Array.from(uniqueYIntervals.values()).map((interval)=>interval.start).sort();
|
|
1748
|
+
const numberOfRows = sortedYStart.length;
|
|
1749
|
+
templateRows = `repeat(${numberOfRows}, 1fr)`;
|
|
1750
|
+
domainY.forEach((interval, index)=>{
|
|
1751
|
+
const cellName = index >= cartesianDomains ? `${NON_PLOT_KEY_PREFIX}${index - cartesianDomains + 1}` : `x${index === 0 ? '' : index + 1}`;
|
|
1752
|
+
const rowIndex = sortedYStart.findIndex((start)=>start === interval.start);
|
|
1753
|
+
const rowNumber = numberOfRows - rowIndex; // Rows are 1-based and we need to reverse the order for CSS grid
|
|
1556
1754
|
const annotationProps = annotations[index];
|
|
1557
1755
|
const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1558
1756
|
const cell = gridLayout[cellName];
|
|
1559
1757
|
if (cell !== undefined) {
|
|
1560
|
-
cell.row =
|
|
1758
|
+
cell.row = rowNumber;
|
|
1561
1759
|
cell.yAnnotation = yAnnotation;
|
|
1760
|
+
cell.yDomain = interval;
|
|
1562
1761
|
}
|
|
1563
|
-
columnFill[cell.column].fillDomain = interval[1];
|
|
1564
|
-
columnFill[cell.column].row += 1;
|
|
1565
1762
|
});
|
|
1566
1763
|
}
|
|
1567
|
-
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1568
|
-
const reversedGridLayout = {};
|
|
1569
|
-
// find the maximum row number
|
|
1570
|
-
const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1571
|
-
var _cell_row;
|
|
1572
|
-
return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
|
|
1573
|
-
}));
|
|
1574
|
-
// iterate over the gridLayout and reverse the row numbers
|
|
1575
|
-
Object.keys(gridLayout).forEach((key)=>{
|
|
1576
|
-
const cell = gridLayout[key];
|
|
1577
|
-
if (cell.row !== undefined) {
|
|
1578
|
-
// reverse the row number
|
|
1579
|
-
cell.row = maxRowNumber - cell.row + 1;
|
|
1580
|
-
}
|
|
1581
|
-
reversedGridLayout[key] = cell;
|
|
1582
|
-
});
|
|
1583
1764
|
return {
|
|
1584
1765
|
templateRows,
|
|
1585
1766
|
templateColumns,
|
|
1586
|
-
layout:
|
|
1767
|
+
layout: gridLayout
|
|
1768
|
+
};
|
|
1769
|
+
};
|
|
1770
|
+
/**
|
|
1771
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/category_order_defaults.js#L50}
|
|
1772
|
+
*/ const getAxisCategoryOrderProps = (data, layout)=>{
|
|
1773
|
+
const result = {};
|
|
1774
|
+
const axesById = {
|
|
1775
|
+
x: layout === null || layout === void 0 ? void 0 : layout.xaxis,
|
|
1776
|
+
y: layout === null || layout === void 0 ? void 0 : layout.yaxis
|
|
1777
|
+
};
|
|
1778
|
+
Object.keys(axesById).forEach((axId)=>{
|
|
1779
|
+
const ax = axesById[axId];
|
|
1780
|
+
const axLetter = axId[0];
|
|
1781
|
+
const propName = `${axLetter}AxisCategoryOrder`;
|
|
1782
|
+
const values = [];
|
|
1783
|
+
data.forEach((series)=>{
|
|
1784
|
+
var _series_axLetter;
|
|
1785
|
+
(_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
|
|
1786
|
+
if (!(0, _chartutilities.isInvalidValue)(val)) {
|
|
1787
|
+
values.push(val);
|
|
1788
|
+
}
|
|
1789
|
+
});
|
|
1790
|
+
});
|
|
1791
|
+
const isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || (0, _chartutilities.isStringArray)(values) && !(0, _chartutilities.isNumberArray)(values) && !(0, _chartutilities.isDateArray)(values);
|
|
1792
|
+
if (!isAxisTypeCategory) {
|
|
1793
|
+
return;
|
|
1794
|
+
}
|
|
1795
|
+
const isValidArray = (0, _chartutilities.isArrayOrTypedArray)(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
|
|
1796
|
+
if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
|
|
1797
|
+
result[propName] = ax.categoryarray;
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1800
|
+
if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
|
|
1801
|
+
const categoriesInTraceOrder = Array.from(new Set(values));
|
|
1802
|
+
result[propName] = categoriesInTraceOrder;
|
|
1803
|
+
return;
|
|
1804
|
+
}
|
|
1805
|
+
result[propName] = ax.categoryorder;
|
|
1806
|
+
});
|
|
1807
|
+
return result;
|
|
1808
|
+
};
|
|
1809
|
+
const getBarProps = (data, layout, isHorizontal)=>{
|
|
1810
|
+
let padding;
|
|
1811
|
+
if (typeof (layout === null || layout === void 0 ? void 0 : layout.bargap) === 'number') {
|
|
1812
|
+
padding = layout.bargap;
|
|
1813
|
+
}
|
|
1814
|
+
const plotlyBarWidths = data.map((series)=>{
|
|
1815
|
+
if (series.type === 'bar' && ((0, _chartutilities.isArrayOrTypedArray)(series.width) || typeof series.width === 'number')) {
|
|
1816
|
+
return series.width;
|
|
1817
|
+
}
|
|
1818
|
+
return [];
|
|
1819
|
+
}).flat();
|
|
1820
|
+
const maxPlotlyBarWidth = (0, _d3array.max)(plotlyBarWidths);
|
|
1821
|
+
if (typeof maxPlotlyBarWidth === 'number') {
|
|
1822
|
+
padding = 1 - maxPlotlyBarWidth;
|
|
1823
|
+
padding = Math.max(0, Math.min(padding, 1));
|
|
1824
|
+
}
|
|
1825
|
+
if (typeof padding === 'undefined') {
|
|
1826
|
+
return {};
|
|
1827
|
+
}
|
|
1828
|
+
if (isHorizontal) {
|
|
1829
|
+
return {
|
|
1830
|
+
maxBarHeight: 1000,
|
|
1831
|
+
yAxisPadding: padding
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
return {
|
|
1835
|
+
barWidth: 'auto',
|
|
1836
|
+
maxBarWidth: 1000,
|
|
1837
|
+
xAxisInnerPadding: padding,
|
|
1838
|
+
xAxisOuterPadding: padding / 2
|
|
1587
1839
|
};
|
|
1588
1840
|
};
|