@fluentui/react-charts 9.3.2 → 9.3.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 +47 -2
- package/dist/index.d.ts +151 -1
- package/lib/components/AreaChart/AreaChart.js +208 -60
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +14 -12
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.js +3 -3
- package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +2 -2
- package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +5 -6
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.js +2 -1
- package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +3 -2
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +2 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +3 -2
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js +2 -1
- package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +16 -7
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +63 -18
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +471 -207
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/Arc/Arc.js +8 -7
- package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +16 -32
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib/components/DonutChart/Pie/Pie.js +4 -4
- package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.js +3 -2
- package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +2 -1
- package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib/components/FunnelChart/FunnelChart.js +23 -45
- package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js +3 -2
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js +2 -1
- package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GaugeChart/GaugeChart.js +21 -46
- package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +3 -2
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js +2 -1
- package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +332 -114
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +3 -2
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +2 -1
- package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/Legends/Legends.js +1 -1
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +145 -97
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +3 -2
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -1
- package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +7 -11
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/types/DataPoint.js +1 -3
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/utilities.js +77 -26
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +207 -59
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +13 -12
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +3 -3
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +2 -2
- package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +5 -6
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.js +2 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +7 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +7 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +16 -7
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +65 -18
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +470 -206
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Arc/Arc.js +8 -7
- package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +16 -32
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
- package/lib-commonjs/components/DonutChart/Pie/Pie.js +4 -4
- package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +7 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/FunnelChart.js +23 -45
- package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js +7 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/GaugeChart.js +21 -46
- package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +7 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +329 -112
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +7 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js +1 -1
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +144 -96
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +7 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +6 -10
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js +1 -3
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +80 -26
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +13 -13
|
@@ -233,11 +233,12 @@ const usesSecondaryYScale = (series, layout)=>{
|
|
|
233
233
|
var _layout_yaxis2, _layout_yaxis21;
|
|
234
234
|
return series.yaxis === 'y2' && ((layout === null || layout === void 0 ? void 0 : (_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.anchor) === 'x' || (layout === null || layout === void 0 ? void 0 : (_layout_yaxis21 = layout.yaxis2) === null || _layout_yaxis21 === void 0 ? void 0 : _layout_yaxis21.side) === 'right');
|
|
235
235
|
};
|
|
236
|
-
const getSecondaryYAxisValues = (data, layout
|
|
236
|
+
const getSecondaryYAxisValues = (data, layout)=>{
|
|
237
237
|
var _layout_yaxis2, _layout_yaxis21, _layout_yaxis2_title, _layout_yaxis22;
|
|
238
238
|
let containsSecondaryYAxis = false;
|
|
239
239
|
let yMinValue;
|
|
240
240
|
let yMaxValue;
|
|
241
|
+
let allLineSeries = true;
|
|
241
242
|
data.forEach((series)=>{
|
|
242
243
|
if (usesSecondaryYScale(series, layout)) {
|
|
243
244
|
containsSecondaryYAxis = true;
|
|
@@ -246,16 +247,21 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
|
|
|
246
247
|
yMinValue = Math.min(...yValues);
|
|
247
248
|
yMaxValue = Math.max(...yValues);
|
|
248
249
|
}
|
|
250
|
+
if (series.type !== 'scatter' || (0, _chartutilities.isScatterAreaChart)(series)) {
|
|
251
|
+
allLineSeries = false;
|
|
252
|
+
}
|
|
249
253
|
}
|
|
250
254
|
});
|
|
251
255
|
if (!containsSecondaryYAxis) {
|
|
252
256
|
return {};
|
|
253
257
|
}
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
258
|
+
if (!allLineSeries) {
|
|
259
|
+
if (typeof yMinValue === 'number') {
|
|
260
|
+
yMinValue = Math.min(yMinValue, 0);
|
|
261
|
+
}
|
|
262
|
+
if (typeof yMaxValue === 'number') {
|
|
263
|
+
yMaxValue = Math.max(yMaxValue, 0);
|
|
264
|
+
}
|
|
259
265
|
}
|
|
260
266
|
if (layout === null || layout === void 0 ? void 0 : (_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.range) {
|
|
261
267
|
yMinValue = layout.yaxis2.range[0];
|
|
@@ -271,7 +277,7 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
|
|
|
271
277
|
};
|
|
272
278
|
const _getGaugeAxisColor = (colorway, colorwayType, color, colorMap, isDarkTheme)=>{
|
|
273
279
|
const extractedColors = (0, _PlotlyColorAdapter.extractColor)(colorway, colorwayType, color, colorMap, isDarkTheme);
|
|
274
|
-
return (0, _PlotlyColorAdapter.resolveColor)(extractedColors, 0, '', colorMap, isDarkTheme);
|
|
280
|
+
return (0, _PlotlyColorAdapter.resolveColor)(extractedColors, 0, '', colorMap, colorway, isDarkTheme);
|
|
275
281
|
};
|
|
276
282
|
const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNumber)=>{
|
|
277
283
|
if (x === null || x === undefined) {
|
|
@@ -408,54 +414,41 @@ const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayT
|
|
|
408
414
|
// extract colors for each series only once
|
|
409
415
|
// use piecolorway if available
|
|
410
416
|
// otherwise, default to colorway from template
|
|
411
|
-
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);
|
|
417
|
+
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, true);
|
|
412
418
|
const mapLegendToDataPoint = {};
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
419
|
+
// clear colorMap for donut chart to reassign colors as the colorMap initially gets assigned by
|
|
420
|
+
// getAllupLegendsProps function without sorting labels by value
|
|
421
|
+
colorMap.current.clear();
|
|
422
|
+
// Sort labels by value descending before mapping
|
|
423
|
+
if (firstData.labels && firstData.values) {
|
|
424
|
+
var _firstData_marker1;
|
|
425
|
+
const markerColors = ((_firstData_marker1 = firstData.marker) === null || _firstData_marker1 === void 0 ? void 0 : _firstData_marker1.colors) || undefined;
|
|
426
|
+
const hasMarkerColors = Array.isArray(markerColors) && markerColors.length >= firstData.labels.length;
|
|
427
|
+
const labelValuePairs = firstData.labels.map((label, index)=>({
|
|
428
|
+
label,
|
|
429
|
+
value: getNumberAtIndexOrDefault(firstData.values, index),
|
|
430
|
+
index,
|
|
431
|
+
color: hasMarkerColors ? markerColors[index] : undefined
|
|
432
|
+
}));
|
|
433
|
+
// Filter out invalid values
|
|
434
|
+
const validPairs = labelValuePairs.filter((pair)=>!(0, _chartutilities.isInvalidValue)(pair.value));
|
|
435
|
+
// Sort descending by value; when marker colors are present, keep color attached to the label
|
|
436
|
+
validPairs.sort((a, b)=>b.value - a.value);
|
|
437
|
+
validPairs.forEach((pair, sortedIdx)=>{
|
|
438
|
+
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1;
|
|
439
|
+
const legend = `${pair.label}`;
|
|
440
|
+
var _input_layout_piecolorway, _pair_color;
|
|
441
|
+
const color = (_pair_color = pair.color) !== null && _pair_color !== void 0 ? _pair_color : (0, _PlotlyColorAdapter.resolveColor)(colors, sortedIdx, legend, colorMap, (_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, isDarkTheme, true);
|
|
423
442
|
if (!mapLegendToDataPoint[legend]) {
|
|
424
443
|
mapLegendToDataPoint[legend] = {
|
|
425
444
|
legend,
|
|
426
|
-
data: value,
|
|
445
|
+
data: pair.value,
|
|
427
446
|
color
|
|
428
447
|
};
|
|
429
448
|
} else {
|
|
430
|
-
mapLegendToDataPoint[legend].data += value;
|
|
449
|
+
mapLegendToDataPoint[legend].data += pair.value;
|
|
431
450
|
}
|
|
432
451
|
});
|
|
433
|
-
} else {
|
|
434
|
-
// Sort labels by value descending before mapping
|
|
435
|
-
if (firstData.labels && firstData.values) {
|
|
436
|
-
const labelValuePairs = firstData.labels.map((label, index)=>({
|
|
437
|
-
label,
|
|
438
|
-
value: getNumberAtIndexOrDefault(firstData.values, index),
|
|
439
|
-
index
|
|
440
|
-
}));
|
|
441
|
-
// Filter out invalid values
|
|
442
|
-
const validPairs = labelValuePairs.filter((pair)=>!(0, _chartutilities.isInvalidValue)(pair.value));
|
|
443
|
-
// Sort descending by value
|
|
444
|
-
validPairs.sort((a, b)=>b.value - a.value);
|
|
445
|
-
validPairs.forEach((pair, sortedIdx)=>{
|
|
446
|
-
const legend = `${pair.label}`;
|
|
447
|
-
const color = (0, _PlotlyColorAdapter.resolveColor)(colors, sortedIdx, legend, colorMap, isDarkTheme);
|
|
448
|
-
if (!mapLegendToDataPoint[legend]) {
|
|
449
|
-
mapLegendToDataPoint[legend] = {
|
|
450
|
-
legend,
|
|
451
|
-
data: pair.value,
|
|
452
|
-
color
|
|
453
|
-
};
|
|
454
|
-
} else {
|
|
455
|
-
mapLegendToDataPoint[legend].data += pair.value;
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
452
|
}
|
|
460
453
|
var _input_layout_width;
|
|
461
454
|
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;
|
|
@@ -470,10 +463,25 @@ const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayT
|
|
|
470
463
|
const donutMarginVertical = 40 + (hideLabels ? 0 : 40);
|
|
471
464
|
const innerRadius = firstData.hole ? firstData.hole * (Math.min(width - donutMarginHorizontal, height - donutMarginVertical) / 2) : _utilities.MIN_DONUT_RADIUS;
|
|
472
465
|
const { chartTitle } = getTitles(input.layout);
|
|
466
|
+
// Build anticlockwise order by keeping the first item, reversing the rest
|
|
467
|
+
const legends = Object.keys(mapLegendToDataPoint);
|
|
468
|
+
const reorderedEntries = legends.length > 1 ? [
|
|
469
|
+
[
|
|
470
|
+
legends[0],
|
|
471
|
+
mapLegendToDataPoint[legends[0]]
|
|
472
|
+
],
|
|
473
|
+
...legends.slice(1).reverse().map((key)=>[
|
|
474
|
+
key,
|
|
475
|
+
mapLegendToDataPoint[key]
|
|
476
|
+
])
|
|
477
|
+
] : legends.map((key)=>[
|
|
478
|
+
key,
|
|
479
|
+
mapLegendToDataPoint[key]
|
|
480
|
+
]);
|
|
473
481
|
return {
|
|
474
482
|
data: {
|
|
475
483
|
chartTitle,
|
|
476
|
-
chartData:
|
|
484
|
+
chartData: reorderedEntries.map(([, v])=>v)
|
|
477
485
|
},
|
|
478
486
|
hideLegend: isMultiPlot || ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false,
|
|
479
487
|
width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
|
|
@@ -484,46 +492,43 @@ const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayT
|
|
|
484
492
|
'percent',
|
|
485
493
|
'label+percent'
|
|
486
494
|
].includes(firstData.textinfo) : true,
|
|
487
|
-
roundCorners: true
|
|
495
|
+
roundCorners: true,
|
|
496
|
+
order: 'sorted'
|
|
488
497
|
};
|
|
489
498
|
};
|
|
490
499
|
const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
491
|
-
var _input_layout, _input_layout1, _vsbcData_;
|
|
500
|
+
var _input_layout, _input_layout1, _input_layout2, _vsbcData_;
|
|
492
501
|
const mapXToDataPoints = {};
|
|
493
502
|
let yMaxValue = 0;
|
|
503
|
+
let yMinValue = 0;
|
|
494
504
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
495
505
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
496
506
|
let colorScale = undefined;
|
|
497
507
|
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
498
|
-
|
|
508
|
+
const resolveXValue = getAxisValueResolver(getAxisType(input.data, getAxisObjects(input.data, input.layout).x));
|
|
499
509
|
input.data.forEach((series, index1)=>{
|
|
500
510
|
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line;
|
|
501
511
|
colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
|
|
502
|
-
const isXYearCategory = (0, _chartutilities.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
503
512
|
// extract bar colors for each series only once
|
|
504
513
|
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);
|
|
505
514
|
// extract line colors for each series only once
|
|
506
515
|
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);
|
|
507
|
-
const
|
|
508
|
-
const isXDate = (0, _chartutilities.isDateArray)(xValues);
|
|
509
|
-
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
510
|
-
const isXNumber = (0, _chartutilities.isNumberArray)(xValues);
|
|
511
|
-
const validXYRanges = getValidXYRanges(series);
|
|
516
|
+
const validXYRanges = getValidXYRanges(series, resolveXValue);
|
|
512
517
|
validXYRanges.forEach(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
513
518
|
const rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
514
519
|
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
515
520
|
rangeXValues.forEach((x, index2)=>{
|
|
516
|
-
var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
521
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
517
522
|
if (!mapXToDataPoints[x]) {
|
|
518
523
|
mapXToDataPoints[x] = {
|
|
519
|
-
xAxisPoint:
|
|
524
|
+
xAxisPoint: resolveXValue(x),
|
|
520
525
|
chartData: [],
|
|
521
526
|
lineData: []
|
|
522
527
|
};
|
|
523
528
|
}
|
|
524
529
|
const legend = legends[index1];
|
|
525
530
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
526
|
-
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);
|
|
531
|
+
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, (_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, isDarkTheme);
|
|
527
532
|
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index2);
|
|
528
533
|
const yVal = rangeYValues[index2];
|
|
529
534
|
const yAxisCalloutData = getFormattedCalloutYData(yVal, yAxisTickFormat);
|
|
@@ -541,8 +546,8 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
541
546
|
yMaxValue = Math.max(yMaxValue, yVal);
|
|
542
547
|
}
|
|
543
548
|
} else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
544
|
-
var _series_mode;
|
|
545
|
-
const lineColor = (0, _PlotlyColorAdapter.resolveColor)(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
549
|
+
var _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_mode;
|
|
550
|
+
const lineColor = (0, _PlotlyColorAdapter.resolveColor)(extractedLineColors, index1, legend, colorMap, (_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, isDarkTheme);
|
|
546
551
|
const lineOptions = !((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('text')) ? getLineOptions(series.line) : undefined;
|
|
547
552
|
const legendShape = getLegendShape(series);
|
|
548
553
|
var _rgb_copy_formatHex81;
|
|
@@ -569,12 +574,75 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
569
574
|
});
|
|
570
575
|
});
|
|
571
576
|
});
|
|
577
|
+
var _input_data;
|
|
578
|
+
const xCategories = Array.from(new Set(((_input_data = input.data) !== null && _input_data !== void 0 ? _input_data : []).flatMap((trace)=>{
|
|
579
|
+
const xData = trace.x;
|
|
580
|
+
if (!xData) {
|
|
581
|
+
return [];
|
|
582
|
+
}
|
|
583
|
+
if (Array.isArray(xData)) {
|
|
584
|
+
return xData.flat().map((x)=>{
|
|
585
|
+
return x;
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
return [];
|
|
589
|
+
}).filter((x)=>x !== undefined && x !== null)));
|
|
590
|
+
var _input_layout_shapes;
|
|
591
|
+
((_input_layout_shapes = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.shapes) !== null && _input_layout_shapes !== void 0 ? _input_layout_shapes : []).filter((shape)=>shape.type === 'line').forEach((shape, shapeIdx)=>{
|
|
592
|
+
var _shape_line;
|
|
593
|
+
const lineColor = (_shape_line = shape.line) === null || _shape_line === void 0 ? void 0 : _shape_line.color;
|
|
594
|
+
const resolveX = (val)=>{
|
|
595
|
+
if (typeof val === 'number' && Array.isArray(xCategories)) {
|
|
596
|
+
if (xCategories[val] !== undefined) {
|
|
597
|
+
return xCategories[val];
|
|
598
|
+
} else {
|
|
599
|
+
return xCategories[shapeIdx];
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
return val;
|
|
603
|
+
};
|
|
604
|
+
const x0Key = resolveX(shape.x0);
|
|
605
|
+
const x1Key = resolveX(shape.x1);
|
|
606
|
+
const resolveY = (val)=>{
|
|
607
|
+
if (shape.yref === 'paper') {
|
|
608
|
+
if (val === 0) {
|
|
609
|
+
return yMinValue;
|
|
610
|
+
}
|
|
611
|
+
if (val === 1) {
|
|
612
|
+
return yMaxValue;
|
|
613
|
+
}
|
|
614
|
+
if (typeof val === 'number') {
|
|
615
|
+
return yMinValue + val * (yMaxValue - yMinValue);
|
|
616
|
+
}
|
|
617
|
+
return val;
|
|
618
|
+
}
|
|
619
|
+
return val;
|
|
620
|
+
};
|
|
621
|
+
const y0Val = resolveY(shape.y0);
|
|
622
|
+
const y1Val = resolveY(shape.y1);
|
|
623
|
+
var _rgb_formatHex8;
|
|
624
|
+
mapXToDataPoints[x0Key].lineData.push({
|
|
625
|
+
legend: `Reference_${shapeIdx}`,
|
|
626
|
+
y: y0Val,
|
|
627
|
+
color: (_rgb_formatHex8 = (0, _d3color.rgb)(lineColor).formatHex8()) !== null && _rgb_formatHex8 !== void 0 ? _rgb_formatHex8 : lineColor,
|
|
628
|
+
lineOptions: getLineOptions(shape.line),
|
|
629
|
+
useSecondaryYScale: false
|
|
630
|
+
});
|
|
631
|
+
var _rgb_formatHex81;
|
|
632
|
+
mapXToDataPoints[x1Key].lineData.push({
|
|
633
|
+
legend: `Reference_${shapeIdx}`,
|
|
634
|
+
y: y1Val,
|
|
635
|
+
color: (_rgb_formatHex81 = (0, _d3color.rgb)(lineColor).formatHex8()) !== null && _rgb_formatHex81 !== void 0 ? _rgb_formatHex81 : lineColor,
|
|
636
|
+
lineOptions: getLineOptions(shape.line),
|
|
637
|
+
useSecondaryYScale: false
|
|
638
|
+
});
|
|
639
|
+
});
|
|
572
640
|
const vsbcData = Object.values(mapXToDataPoints);
|
|
573
641
|
var _input_layout_height;
|
|
574
642
|
return {
|
|
575
643
|
data: vsbcData,
|
|
576
|
-
width: (
|
|
577
|
-
height: (_input_layout_height = (
|
|
644
|
+
width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
|
|
645
|
+
height: (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
578
646
|
barWidth: 'auto',
|
|
579
647
|
yMaxValue,
|
|
580
648
|
yMinValue,
|
|
@@ -598,7 +666,7 @@ const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
598
666
|
};
|
|
599
667
|
};
|
|
600
668
|
const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
601
|
-
var _processedInput_layout, _processedInput_layout1
|
|
669
|
+
var _processedInput_layout, _processedInput_layout1;
|
|
602
670
|
// Handle object arrays in y values by normalizing the data first
|
|
603
671
|
let processedInput = {
|
|
604
672
|
...input
|
|
@@ -627,60 +695,90 @@ const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayTy
|
|
|
627
695
|
data: processedData
|
|
628
696
|
};
|
|
629
697
|
}
|
|
630
|
-
const
|
|
631
|
-
const secondaryYAxisValues = getSecondaryYAxisValues(processedInput.data, processedInput.layout
|
|
698
|
+
const gvbcDataV2 = [];
|
|
699
|
+
const secondaryYAxisValues = getSecondaryYAxisValues(processedInput.data, processedInput.layout);
|
|
632
700
|
const { legends, hideLegend } = getLegendProps(processedInput.data, processedInput.layout, isMultiPlot);
|
|
633
701
|
let colorScale = undefined;
|
|
634
702
|
const yAxisTickFormat = getYAxisTickFormat(processedInput.data[0], processedInput.layout);
|
|
635
703
|
processedInput.data.forEach((series, index1)=>{
|
|
636
|
-
var _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout, _series_marker, _series_x;
|
|
637
704
|
colorScale = (0, _PlotlyColorAdapter.createColorScale)(processedInput.layout, series, colorScale);
|
|
638
|
-
|
|
639
|
-
const
|
|
640
|
-
(
|
|
641
|
-
var
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
705
|
+
const legend = legends[index1];
|
|
706
|
+
const legendShape = getLegendShape(series);
|
|
707
|
+
if (series.type === 'bar') {
|
|
708
|
+
var _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout, _series_marker;
|
|
709
|
+
// extract bar colors for each series only once
|
|
710
|
+
const extractedBarColors = (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);
|
|
711
|
+
gvbcDataV2.push({
|
|
712
|
+
type: 'bar',
|
|
713
|
+
legend,
|
|
714
|
+
key: legend,
|
|
715
|
+
data: series.x.map((x, xIndex)=>{
|
|
716
|
+
var _series_y, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout;
|
|
717
|
+
if ((0, _chartutilities.isInvalidValue)(x) || (0, _chartutilities.isInvalidValue)((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[xIndex])) {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
721
|
+
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[xIndex % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedBarColors, xIndex, legend, colorMap, (_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, isDarkTheme);
|
|
722
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, xIndex);
|
|
723
|
+
const yVal = series.y[xIndex];
|
|
724
|
+
var _rgb_copy_formatHex8;
|
|
725
|
+
return {
|
|
726
|
+
x: x.toString(),
|
|
727
|
+
y: yVal,
|
|
728
|
+
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
|
|
729
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
730
|
+
opacity
|
|
731
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
732
|
+
};
|
|
733
|
+
}).filter((item)=>typeof item !== 'undefined'),
|
|
734
|
+
useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout)
|
|
735
|
+
});
|
|
736
|
+
} else if (series.type === 'scatter') {
|
|
737
|
+
var _processedInput_layout_template_layout1, _processedInput_layout_template1, _processedInput_layout1, _series_line, _processedInput_layout_template_layout2, _processedInput_layout_template2, _processedInput_layout2;
|
|
738
|
+
// extract line colors for each series only once
|
|
739
|
+
const extractedLineColors = (0, _PlotlyColorAdapter.extractColor)((_processedInput_layout1 = processedInput.layout) === null || _processedInput_layout1 === void 0 ? void 0 : (_processedInput_layout_template1 = _processedInput_layout1.template) === null || _processedInput_layout_template1 === void 0 ? void 0 : (_processedInput_layout_template_layout1 = _processedInput_layout_template1.layout) === null || _processedInput_layout_template_layout1 === void 0 ? void 0 : _processedInput_layout_template_layout1.colorway, colorwayType, (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
|
|
740
|
+
const lineColor = (0, _PlotlyColorAdapter.resolveColor)(extractedLineColors, index1, legend, colorMap, (_processedInput_layout2 = processedInput.layout) === null || _processedInput_layout2 === void 0 ? void 0 : (_processedInput_layout_template2 = _processedInput_layout2.template) === null || _processedInput_layout_template2 === void 0 ? void 0 : (_processedInput_layout_template_layout2 = _processedInput_layout_template2.layout) === null || _processedInput_layout_template_layout2 === void 0 ? void 0 : _processedInput_layout_template_layout2.colorway, isDarkTheme);
|
|
741
|
+
const lineOptions = getLineOptions(series.line);
|
|
742
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index1);
|
|
743
|
+
const validXYRanges = getValidXYRanges(series);
|
|
744
|
+
validXYRanges.forEach(([rangeStart, rangeEnd])=>{
|
|
745
|
+
const rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
746
|
+
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
658
747
|
var _rgb_copy_formatHex8;
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
data: yVal,
|
|
662
|
-
xAxisCalloutData: x,
|
|
663
|
-
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
664
|
-
opacity
|
|
665
|
-
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
748
|
+
gvbcDataV2.push({
|
|
749
|
+
type: 'line',
|
|
666
750
|
legend,
|
|
667
|
-
|
|
668
|
-
|
|
751
|
+
legendShape,
|
|
752
|
+
data: rangeXValues.map((x, i)=>{
|
|
753
|
+
const yVal = rangeYValues[i];
|
|
754
|
+
return {
|
|
755
|
+
x: x.toString(),
|
|
756
|
+
y: yVal,
|
|
757
|
+
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
|
|
758
|
+
};
|
|
759
|
+
}),
|
|
760
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(lineColor).copy({
|
|
761
|
+
opacity
|
|
762
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : lineColor,
|
|
763
|
+
lineOptions: {
|
|
764
|
+
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
765
|
+
mode: series.mode
|
|
766
|
+
},
|
|
767
|
+
useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout)
|
|
669
768
|
});
|
|
670
|
-
}
|
|
671
|
-
}
|
|
769
|
+
});
|
|
770
|
+
}
|
|
672
771
|
});
|
|
673
|
-
const gvbcData = Object.values(mapXToDataPoints);
|
|
674
772
|
var _processedInput_layout_height;
|
|
675
773
|
return {
|
|
676
|
-
|
|
774
|
+
dataV2: gvbcDataV2,
|
|
677
775
|
width: (_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : _processedInput_layout.width,
|
|
678
776
|
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,
|
|
679
777
|
barWidth: 'auto',
|
|
680
778
|
mode: 'plotly',
|
|
681
779
|
...secondaryYAxisValues,
|
|
682
780
|
hideTickOverlap: true,
|
|
683
|
-
wrapXAxisLables:
|
|
781
|
+
wrapXAxisLables: true,
|
|
684
782
|
hideLegend,
|
|
685
783
|
roundCorners: true,
|
|
686
784
|
...getTitles(processedInput.layout),
|
|
@@ -708,8 +806,9 @@ const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayTyp
|
|
|
708
806
|
const xValues = [];
|
|
709
807
|
const yValues = [];
|
|
710
808
|
series.x.forEach((xVal, index)=>{
|
|
711
|
-
|
|
712
|
-
|
|
809
|
+
var _getNumberAtIndexOrDefault;
|
|
810
|
+
const yVal = (_getNumberAtIndexOrDefault = getNumberAtIndexOrDefault(series.y, index)) !== null && _getNumberAtIndexOrDefault !== void 0 ? _getNumberAtIndexOrDefault : 0;
|
|
811
|
+
if ((0, _chartutilities.isInvalidValue)(xVal)) {
|
|
713
812
|
return;
|
|
714
813
|
}
|
|
715
814
|
xValues.push(xVal);
|
|
@@ -733,10 +832,10 @@ const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayTyp
|
|
|
733
832
|
return yVal;
|
|
734
833
|
});
|
|
735
834
|
xBins.forEach((bin, index)=>{
|
|
736
|
-
var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
835
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
737
836
|
const legend = legends[seriesIdx];
|
|
738
837
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
739
|
-
const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
838
|
+
const color = colorScale ? colorScale((0, _chartutilities.isArrayOrTypedArray)((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, (_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, isDarkTheme);
|
|
740
839
|
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, index);
|
|
741
840
|
const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
742
841
|
var _rgb_copy_formatHex8;
|
|
@@ -778,8 +877,29 @@ const transformPlotlyJsonToLineChartProps = (input, isMultiPlot, colorMap, color
|
|
|
778
877
|
const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
779
878
|
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
780
879
|
};
|
|
880
|
+
const mapColorFillBars = (layout)=>{
|
|
881
|
+
if (!Array.isArray(layout === null || layout === void 0 ? void 0 : layout.shapes)) {
|
|
882
|
+
return [];
|
|
883
|
+
}
|
|
884
|
+
return layout.shapes.filter((shape)=>shape.type === 'rect').map((shape)=>{
|
|
885
|
+
//colorFillbars doesn't support string dates or categories
|
|
886
|
+
if (typeof shape.x0 === 'string' || typeof shape.x1 === 'string') {
|
|
887
|
+
return null;
|
|
888
|
+
}
|
|
889
|
+
return {
|
|
890
|
+
color: shape.fillcolor,
|
|
891
|
+
data: [
|
|
892
|
+
{
|
|
893
|
+
startX: shape.x0,
|
|
894
|
+
endX: shape.x1
|
|
895
|
+
}
|
|
896
|
+
],
|
|
897
|
+
applyPattern: false
|
|
898
|
+
};
|
|
899
|
+
});
|
|
900
|
+
};
|
|
781
901
|
const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
|
|
782
|
-
var _input_data_, _input_layout, _input_layout1;
|
|
902
|
+
var _input_data_, _chartData__data_, _chartData_, _chartData__data_1, _chartData_1, _chartData__data_2, _chartData_2, _chartData__data_3, _chartData_3, _input_layout, _input_layout1, _input_layout2;
|
|
783
903
|
const isScatterMarkers = [
|
|
784
904
|
'text',
|
|
785
905
|
'markers',
|
|
@@ -792,36 +912,34 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
792
912
|
].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
|
|
793
913
|
const isAreaChart = chartType === 'area';
|
|
794
914
|
const isScatterChart = chartType === 'scatter';
|
|
795
|
-
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout
|
|
915
|
+
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
796
916
|
let mode = 'tonexty';
|
|
797
917
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
798
918
|
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
799
|
-
|
|
919
|
+
const xAxisType = getAxisType(input.data, getAxisObjects(input.data, input.layout).x);
|
|
920
|
+
const resolveXValue = getAxisValueResolver(xAxisType);
|
|
921
|
+
const shouldWrapLabels = xAxisType === 'category';
|
|
800
922
|
const chartData = input.data.map((series, index)=>{
|
|
801
|
-
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
|
|
923
|
+
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_mode1;
|
|
802
924
|
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;
|
|
803
925
|
// extract colors for each series only once
|
|
804
926
|
const extractedColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, colors, colorMap, isDarkTheme);
|
|
805
927
|
const xValues = series.x;
|
|
806
|
-
const isXString = (0, _chartutilities.isStringArray)(xValues);
|
|
807
|
-
const isXDate = (0, _chartutilities.isDateArray)(xValues);
|
|
808
|
-
const isXNumber = (0, _chartutilities.isNumberArray)(xValues);
|
|
809
|
-
const isXYearCategory = (0, _chartutilities.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
810
|
-
shouldWrapLabels = shouldWrapLabels || isXString && !isXDate;
|
|
811
928
|
const legend = legends[index];
|
|
812
929
|
// resolve color for each legend's lines from the extracted colors
|
|
813
|
-
const seriesColor = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
930
|
+
const seriesColor = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, (_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, isDarkTheme);
|
|
814
931
|
const seriesOpacity = (0, _PlotlyColorAdapter.getOpacity)(series, index);
|
|
815
932
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
816
933
|
// if mode contains 'text', we prioritize showing the text over curving the line
|
|
817
934
|
const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
|
|
818
935
|
const legendShape = getLegendShape(series);
|
|
819
|
-
const validXYRanges = getValidXYRanges(series);
|
|
936
|
+
const validXYRanges = getValidXYRanges(series, resolveXValue);
|
|
820
937
|
return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
821
|
-
var _series_marker, _input_layout, _input_layout_polar_angularaxis, _input_layout_polar, _input_layout1, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout2;
|
|
938
|
+
var _series_marker, _series_marker1, _series_marker2, _input_layout, _input_layout_polar_angularaxis, _input_layout_polar, _input_layout1, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout2;
|
|
822
939
|
const rangeXValues = xValues.slice(rangeStart, rangeEnd);
|
|
823
940
|
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
824
941
|
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) : [];
|
|
942
|
+
const markerColors = (0, _chartutilities.isArrayOrTypedArray)((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color) ? series.marker.color.slice(rangeStart, rangeEnd) : Array.isArray((_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : _series_marker2.color) ? series.marker.color.slice(rangeStart, rangeEnd) : undefined;
|
|
825
943
|
const textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : undefined;
|
|
826
944
|
var _rgb_copy_formatHex8;
|
|
827
945
|
return {
|
|
@@ -830,13 +948,16 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
830
948
|
data: rangeXValues.map((x, i)=>{
|
|
831
949
|
var _series_marker, _series_marker1;
|
|
832
950
|
return {
|
|
833
|
-
x:
|
|
951
|
+
x: resolveXValue(x),
|
|
834
952
|
y: rangeYValues[i],
|
|
835
953
|
...Array.isArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? {
|
|
836
954
|
markerSize: markerSizes[i]
|
|
837
955
|
} : typeof ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.size) === 'number' ? {
|
|
838
956
|
markerSize: series.marker.size
|
|
839
957
|
} : {},
|
|
958
|
+
...markerColors ? {
|
|
959
|
+
markerColor: markerColors[i]
|
|
960
|
+
} : {},
|
|
840
961
|
...textValues ? {
|
|
841
962
|
text: textValues[i]
|
|
842
963
|
} : {},
|
|
@@ -855,13 +976,70 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
855
976
|
originXOffset: (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.__polarOriginX,
|
|
856
977
|
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,
|
|
857
978
|
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,
|
|
858
|
-
axisLabel: series.__axisLabel ? series.__axisLabel : {}
|
|
979
|
+
axisLabel: series.__axisLabel ? series.__axisLabel : {},
|
|
980
|
+
fill: series.fill
|
|
859
981
|
} : {}
|
|
860
982
|
},
|
|
861
983
|
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
862
984
|
};
|
|
863
985
|
});
|
|
864
986
|
}).flat();
|
|
987
|
+
const xMinValue = (_chartData_ = chartData[0]) === null || _chartData_ === void 0 ? void 0 : (_chartData__data_ = _chartData_.data[0]) === null || _chartData__data_ === void 0 ? void 0 : _chartData__data_.x;
|
|
988
|
+
const xMaxValue = (_chartData_1 = chartData[0]) === null || _chartData_1 === void 0 ? void 0 : (_chartData__data_1 = _chartData_1.data[chartData[0].data.length - 1]) === null || _chartData__data_1 === void 0 ? void 0 : _chartData__data_1.x;
|
|
989
|
+
const yMinValue = (_chartData_2 = chartData[0]) === null || _chartData_2 === void 0 ? void 0 : (_chartData__data_2 = _chartData_2.data[0]) === null || _chartData__data_2 === void 0 ? void 0 : _chartData__data_2.y;
|
|
990
|
+
const yMaxValue = (_chartData_3 = chartData[0]) === null || _chartData_3 === void 0 ? void 0 : (_chartData__data_3 = _chartData_3.data[chartData[0].data.length - 1]) === null || _chartData__data_3 === void 0 ? void 0 : _chartData__data_3.y;
|
|
991
|
+
var _input_layout_shapes;
|
|
992
|
+
const lineShape = ((_input_layout_shapes = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.shapes) !== null && _input_layout_shapes !== void 0 ? _input_layout_shapes : []).filter((shape)=>shape.type === 'line').map((shape, shapeIdx)=>{
|
|
993
|
+
var _shape_line;
|
|
994
|
+
const lineColor = (_shape_line = shape.line) === null || _shape_line === void 0 ? void 0 : _shape_line.color;
|
|
995
|
+
const resolveX = (val)=>{
|
|
996
|
+
if (shape.xref === 'paper') {
|
|
997
|
+
if (val === 0) {
|
|
998
|
+
return xMinValue;
|
|
999
|
+
}
|
|
1000
|
+
if (val === 1) {
|
|
1001
|
+
return xMaxValue;
|
|
1002
|
+
}
|
|
1003
|
+
if (typeof val === 'number' && typeof xMinValue === 'number' && typeof xMaxValue === 'number') {
|
|
1004
|
+
return xMinValue + val * (xMaxValue - xMinValue);
|
|
1005
|
+
}
|
|
1006
|
+
return val;
|
|
1007
|
+
}
|
|
1008
|
+
return val;
|
|
1009
|
+
};
|
|
1010
|
+
const resolveY = (val)=>{
|
|
1011
|
+
if (shape.yref === 'paper') {
|
|
1012
|
+
if (val === 0) {
|
|
1013
|
+
return yMinValue;
|
|
1014
|
+
}
|
|
1015
|
+
if (val === 1) {
|
|
1016
|
+
return yMaxValue;
|
|
1017
|
+
}
|
|
1018
|
+
if (typeof val === 'number') {
|
|
1019
|
+
return yMinValue + val * (yMaxValue - yMinValue);
|
|
1020
|
+
}
|
|
1021
|
+
return val;
|
|
1022
|
+
}
|
|
1023
|
+
return val;
|
|
1024
|
+
};
|
|
1025
|
+
var _rgb_formatHex8;
|
|
1026
|
+
return {
|
|
1027
|
+
legend: `Reference_${shapeIdx}`,
|
|
1028
|
+
data: [
|
|
1029
|
+
{
|
|
1030
|
+
x: resolveX(shape.x0),
|
|
1031
|
+
y: resolveY(shape.y0)
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
x: resolveX(shape.x1),
|
|
1035
|
+
y: resolveY(shape.y1)
|
|
1036
|
+
}
|
|
1037
|
+
],
|
|
1038
|
+
color: (_rgb_formatHex8 = (0, _d3color.rgb)(lineColor).formatHex8()) !== null && _rgb_formatHex8 !== void 0 ? _rgb_formatHex8 : lineColor,
|
|
1039
|
+
lineOptions: getLineOptions(shape.line),
|
|
1040
|
+
useSecondaryYScale: false
|
|
1041
|
+
};
|
|
1042
|
+
});
|
|
865
1043
|
const yMinMax = getYMinMaxValues(input.data[0], input.layout);
|
|
866
1044
|
if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
|
|
867
1045
|
const yMinMaxValues = (0, _utilities.findNumericMinMaxOfY)(chartData);
|
|
@@ -870,7 +1048,10 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
870
1048
|
}
|
|
871
1049
|
const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
|
|
872
1050
|
const chartProps = {
|
|
873
|
-
lineChartData:
|
|
1051
|
+
lineChartData: [
|
|
1052
|
+
...chartData,
|
|
1053
|
+
...lineShape
|
|
1054
|
+
]
|
|
874
1055
|
};
|
|
875
1056
|
const scatterChartProps = {
|
|
876
1057
|
scatterChartData: chartData
|
|
@@ -879,8 +1060,8 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
879
1060
|
const commonProps = {
|
|
880
1061
|
supportNegativeData: true,
|
|
881
1062
|
...secondaryYAxisValues,
|
|
882
|
-
width: (
|
|
883
|
-
height: (_input_layout_height = (
|
|
1063
|
+
width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
|
|
1064
|
+
height: (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
884
1065
|
hideTickOverlap: true,
|
|
885
1066
|
hideLegend,
|
|
886
1067
|
useUTC: false,
|
|
@@ -907,7 +1088,13 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
907
1088
|
...isScatterChart ? {
|
|
908
1089
|
showYAxisLablesTooltip: true,
|
|
909
1090
|
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
910
|
-
} : {}
|
|
1091
|
+
} : {},
|
|
1092
|
+
...!isScatterChart && (()=>{
|
|
1093
|
+
const bars = mapColorFillBars(input.layout);
|
|
1094
|
+
return bars && !bars.includes(null) ? {
|
|
1095
|
+
colorFillBars: bars
|
|
1096
|
+
} : {};
|
|
1097
|
+
})()
|
|
911
1098
|
};
|
|
912
1099
|
}
|
|
913
1100
|
};
|
|
@@ -922,16 +1109,16 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
|
|
|
922
1109
|
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);
|
|
923
1110
|
const legend = legends[index];
|
|
924
1111
|
return series.y.map((yValue, i)=>{
|
|
925
|
-
var
|
|
926
|
-
if ((0, _chartutilities.isInvalidValue)(
|
|
1112
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout, _series_x;
|
|
1113
|
+
if ((0, _chartutilities.isInvalidValue)(yValue)) {
|
|
927
1114
|
return null;
|
|
928
1115
|
}
|
|
929
1116
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
930
|
-
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);
|
|
1117
|
+
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, (_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, isDarkTheme);
|
|
931
1118
|
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, i);
|
|
932
1119
|
var _rgb_copy_formatHex8;
|
|
933
1120
|
return {
|
|
934
|
-
x: series.x[i],
|
|
1121
|
+
x: (0, _chartutilities.isInvalidValue)((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]) ? 0 : series.x[i],
|
|
935
1122
|
y: yValue,
|
|
936
1123
|
legend,
|
|
937
1124
|
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
@@ -971,46 +1158,71 @@ const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, col
|
|
|
971
1158
|
};
|
|
972
1159
|
const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
973
1160
|
var _input_layout, _input_layout1;
|
|
974
|
-
const
|
|
1161
|
+
const data = input.data.filter((series)=>series.type !== 'scatter' || series.mode !== 'markers');
|
|
1162
|
+
const { legends, hideLegend } = getLegendProps(data, input.layout, isMultiPlot);
|
|
975
1163
|
let colorScale = undefined;
|
|
976
|
-
const
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1164
|
+
const xAxisType = getAxisType(data, getAxisObjects(data, input.layout).x);
|
|
1165
|
+
const resolveXValue = getAxisValueResolver(xAxisType, parseLocalDate);
|
|
1166
|
+
const resolveGanttXValue = (value)=>{
|
|
1167
|
+
const resolvedValue = resolveXValue(value);
|
|
1168
|
+
return typeof resolvedValue === 'string' ? 0 : resolvedValue !== null && resolvedValue !== void 0 ? resolvedValue : 0;
|
|
1169
|
+
};
|
|
1170
|
+
const isXDate = xAxisType === 'date';
|
|
1171
|
+
const ganttData = [];
|
|
1172
|
+
data.forEach((series, index)=>{
|
|
981
1173
|
const legend = legends[index];
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1174
|
+
if (series.type === 'bar') {
|
|
1175
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
|
|
1176
|
+
colorScale = (0, _PlotlyColorAdapter.createColorScale)(input.layout, series, colorScale);
|
|
1177
|
+
// extract colors for each series only once
|
|
1178
|
+
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);
|
|
1179
|
+
series.y.forEach((yVal, i)=>{
|
|
1180
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout, _series_base, _series_x;
|
|
1181
|
+
if ((0, _chartutilities.isInvalidValue)(yVal)) {
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
1185
|
+
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, (_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, isDarkTheme);
|
|
1186
|
+
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, i);
|
|
1187
|
+
const base = +resolveGanttXValue((_series_base = series.base) === null || _series_base === void 0 ? void 0 : _series_base[i]);
|
|
1188
|
+
const xVal = +resolveGanttXValue((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]);
|
|
1189
|
+
var _rgb_copy_formatHex8;
|
|
1190
|
+
ganttData.push({
|
|
1191
|
+
x: {
|
|
1192
|
+
start: isXDate ? new Date(base) : base,
|
|
1193
|
+
end: isXDate ? new Date(base + xVal) : base + xVal
|
|
1194
|
+
},
|
|
1195
|
+
y: yVal,
|
|
1196
|
+
legend,
|
|
1197
|
+
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
1198
|
+
opacity
|
|
1199
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
1200
|
+
});
|
|
1201
|
+
});
|
|
1202
|
+
} else if (series.type === 'scatter' && series.mode === 'none' && series.fill === 'toself') {
|
|
1203
|
+
for(let i = 0; i < series.y.length; i += 5){
|
|
1204
|
+
if ((0, _chartutilities.isInvalidValue)(series.y[i]) || (0, _chartutilities.isInvalidValue)(series.y[i + 3])) {
|
|
1205
|
+
continue;
|
|
1206
|
+
}
|
|
1207
|
+
const x0 = resolveGanttXValue(series.x[i]);
|
|
1208
|
+
const x1 = resolveGanttXValue(series.x[i + 1]);
|
|
1209
|
+
const y0 = series.y[i];
|
|
1210
|
+
const y1 = series.y[i + 3];
|
|
1211
|
+
ganttData.push({
|
|
1212
|
+
x: {
|
|
1213
|
+
start: x0,
|
|
1214
|
+
end: x1
|
|
1215
|
+
},
|
|
1216
|
+
y: Math.round((y0 + y1) / 2),
|
|
1217
|
+
legend,
|
|
1218
|
+
color: series.fillcolor
|
|
1219
|
+
});
|
|
991
1220
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
const opacity = (0, _PlotlyColorAdapter.getOpacity)(series, i);
|
|
995
|
-
const base = convertXValueToNumber((_series_base = series.base) === null || _series_base === void 0 ? void 0 : _series_base[i]);
|
|
996
|
-
const xVal = convertXValueToNumber((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]);
|
|
997
|
-
var _rgb_copy_formatHex8;
|
|
998
|
-
return {
|
|
999
|
-
x: {
|
|
1000
|
-
start: isXDate ? new Date(base) : base,
|
|
1001
|
-
end: isXDate ? new Date(base + xVal) : base + xVal
|
|
1002
|
-
},
|
|
1003
|
-
y: yVal,
|
|
1004
|
-
legend,
|
|
1005
|
-
color: (_rgb_copy_formatHex8 = (0, _d3color.rgb)(color).copy({
|
|
1006
|
-
opacity
|
|
1007
|
-
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
1008
|
-
};
|
|
1009
|
-
}).filter((point)=>point !== null);
|
|
1010
|
-
}).flat();
|
|
1221
|
+
}
|
|
1222
|
+
});
|
|
1011
1223
|
var _input_layout_height;
|
|
1012
1224
|
return {
|
|
1013
|
-
data:
|
|
1225
|
+
data: ganttData,
|
|
1014
1226
|
showYAxisLables: true,
|
|
1015
1227
|
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,
|
|
1016
1228
|
width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
|
|
@@ -1021,9 +1233,9 @@ const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMap, colo
|
|
|
1021
1233
|
roundCorners: true,
|
|
1022
1234
|
useUTC: false,
|
|
1023
1235
|
...getTitles(input.layout),
|
|
1024
|
-
...getAxisCategoryOrderProps(
|
|
1025
|
-
...getBarProps(
|
|
1026
|
-
...getAxisTickProps(
|
|
1236
|
+
...getAxisCategoryOrderProps(data, input.layout),
|
|
1237
|
+
...getBarProps(data, input.layout, true),
|
|
1238
|
+
...getAxisTickProps(data, input.layout)
|
|
1027
1239
|
};
|
|
1028
1240
|
};
|
|
1029
1241
|
const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
@@ -1039,8 +1251,9 @@ const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwa
|
|
|
1039
1251
|
const zValues = [];
|
|
1040
1252
|
(_firstData_x = firstData.x) === null || _firstData_x === void 0 ? void 0 : _firstData_x.forEach((xVal, index)=>{
|
|
1041
1253
|
var _firstData_y;
|
|
1042
|
-
|
|
1043
|
-
|
|
1254
|
+
var _getNumberAtIndexOrDefault;
|
|
1255
|
+
const zVal = (_getNumberAtIndexOrDefault = getNumberAtIndexOrDefault(firstData.z, index)) !== null && _getNumberAtIndexOrDefault !== void 0 ? _getNumberAtIndexOrDefault : 0;
|
|
1256
|
+
if ((0, _chartutilities.isInvalidValue)(xVal) || (0, _chartutilities.isInvalidValue)((_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y[index])) {
|
|
1044
1257
|
return;
|
|
1045
1258
|
}
|
|
1046
1259
|
xValues.push(xVal);
|
|
@@ -1178,7 +1391,8 @@ const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorway
|
|
|
1178
1391
|
const extractedNodeColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, node === null || node === void 0 ? void 0 : node.color, colorMap, isDarkTheme);
|
|
1179
1392
|
const sankeyChartData = {
|
|
1180
1393
|
nodes: (_node_label = node.label) === null || _node_label === void 0 ? void 0 : _node_label.map((label, index)=>{
|
|
1181
|
-
|
|
1394
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
1395
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedNodeColors, index, label, colorMap, (_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, isDarkTheme);
|
|
1182
1396
|
return {
|
|
1183
1397
|
nodeId: index,
|
|
1184
1398
|
name: label,
|
|
@@ -1215,9 +1429,9 @@ const transformPlotlyJsonToGaugeProps = (input, isMultiPlot, colorMap, colorwayT
|
|
|
1215
1429
|
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, stepsColors, colorMap, isDarkTheme);
|
|
1216
1430
|
var _firstData_gauge_axis_range_, _firstData_value, _firstData_gauge_axis_range_1, _firstData_value1;
|
|
1217
1431
|
const segments = ((_firstData_gauge1 = firstData.gauge) === null || _firstData_gauge1 === void 0 ? void 0 : (_firstData_gauge_steps = _firstData_gauge1.steps) === null || _firstData_gauge_steps === void 0 ? void 0 : _firstData_gauge_steps.length) ? firstData.gauge.steps.map((step, index)=>{
|
|
1218
|
-
var _step_range, _step_range1;
|
|
1432
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _step_range, _step_range1;
|
|
1219
1433
|
const legend = step.name || `Segment ${index + 1}`;
|
|
1220
|
-
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
1434
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, index, legend, colorMap, (_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, isDarkTheme);
|
|
1221
1435
|
return {
|
|
1222
1436
|
legend,
|
|
1223
1437
|
size: ((_step_range = step.range) === null || _step_range === void 0 ? void 0 : _step_range[1]) - ((_step_range1 = step.range) === null || _step_range1 === void 0 ? void 0 : _step_range1[0]),
|
|
@@ -1240,16 +1454,16 @@ const transformPlotlyJsonToGaugeProps = (input, isMultiPlot, colorMap, colorwayT
|
|
|
1240
1454
|
if ((_firstData_delta = firstData.delta) === null || _firstData_delta === void 0 ? void 0 : _firstData_delta.reference) {
|
|
1241
1455
|
const diff = firstData.value - firstData.delta.reference;
|
|
1242
1456
|
if (diff >= 0) {
|
|
1243
|
-
var _input_layout_template_layout2, _input_layout_template2, _input_layout4, _firstData_delta_increasing, _firstData_delta1;
|
|
1457
|
+
var _input_layout_template_layout2, _input_layout_template2, _input_layout4, _firstData_delta_increasing, _firstData_delta1, _input_layout_template_layout3, _input_layout_template3, _input_layout5;
|
|
1244
1458
|
sublabel = `\u25B2 ${diff}`;
|
|
1245
1459
|
const extractedIncreasingDeltaColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_template2 = _input_layout4.template) === null || _input_layout_template2 === void 0 ? void 0 : (_input_layout_template_layout2 = _input_layout_template2.layout) === null || _input_layout_template_layout2 === void 0 ? void 0 : _input_layout_template_layout2.colorway, colorwayType, (_firstData_delta1 = firstData.delta) === null || _firstData_delta1 === void 0 ? void 0 : (_firstData_delta_increasing = _firstData_delta1.increasing) === null || _firstData_delta_increasing === void 0 ? void 0 : _firstData_delta_increasing.color, colorMap, isDarkTheme);
|
|
1246
|
-
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedIncreasingDeltaColors, 0, '', colorMap, isDarkTheme);
|
|
1460
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedIncreasingDeltaColors, 0, '', colorMap, (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : (_input_layout_template3 = _input_layout5.template) === null || _input_layout_template3 === void 0 ? void 0 : (_input_layout_template_layout3 = _input_layout_template3.layout) === null || _input_layout_template_layout3 === void 0 ? void 0 : _input_layout_template_layout3.colorway, isDarkTheme);
|
|
1247
1461
|
sublabelColor = color;
|
|
1248
1462
|
} else {
|
|
1249
|
-
var
|
|
1463
|
+
var _input_layout_template_layout4, _input_layout_template4, _input_layout6, _firstData_delta_decreasing, _firstData_delta2, _input_layout_template_layout5, _input_layout_template5, _input_layout7;
|
|
1250
1464
|
sublabel = `\u25BC ${Math.abs(diff)}`;
|
|
1251
|
-
const extractedDecreasingDeltaColors = (0, _PlotlyColorAdapter.extractColor)((
|
|
1252
|
-
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedDecreasingDeltaColors, 0, '', colorMap, isDarkTheme);
|
|
1465
|
+
const extractedDecreasingDeltaColors = (0, _PlotlyColorAdapter.extractColor)((_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : (_input_layout_template4 = _input_layout6.template) === null || _input_layout_template4 === void 0 ? void 0 : (_input_layout_template_layout4 = _input_layout_template4.layout) === null || _input_layout_template_layout4 === void 0 ? void 0 : _input_layout_template_layout4.colorway, colorwayType, (_firstData_delta2 = firstData.delta) === null || _firstData_delta2 === void 0 ? void 0 : (_firstData_delta_decreasing = _firstData_delta2.decreasing) === null || _firstData_delta_decreasing === void 0 ? void 0 : _firstData_delta_decreasing.color, colorMap, isDarkTheme);
|
|
1466
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedDecreasingDeltaColors, 0, '', colorMap, (_input_layout7 = input.layout) === null || _input_layout7 === void 0 ? void 0 : (_input_layout_template5 = _input_layout7.template) === null || _input_layout_template5 === void 0 ? void 0 : (_input_layout_template_layout5 = _input_layout_template5.layout) === null || _input_layout_template_layout5 === void 0 ? void 0 : _input_layout_template_layout5.colorway, isDarkTheme);
|
|
1253
1467
|
sublabelColor = color;
|
|
1254
1468
|
}
|
|
1255
1469
|
}
|
|
@@ -1502,13 +1716,13 @@ const transformPlotlyJsonToFunnelChartProps = (input, isMultiPlot, colorMap, col
|
|
|
1502
1716
|
// Assign a color per series/category and use it for all subValues of that category
|
|
1503
1717
|
const seriesColors = {};
|
|
1504
1718
|
input.data.forEach((series, seriesIdx)=>{
|
|
1505
|
-
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_marker1;
|
|
1719
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _series_marker1, _input_layout_template_layout1, _input_layout_template1, _input_layout1;
|
|
1506
1720
|
const category = series.name || `Category ${seriesIdx + 1}`;
|
|
1507
1721
|
var _series_marker_colors;
|
|
1508
1722
|
// Use the same color for this category across all stages
|
|
1509
1723
|
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);
|
|
1510
1724
|
// Always use the first color for the series/category
|
|
1511
|
-
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, 0, category, colorMap, isDarkTheme);
|
|
1725
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, 0, category, colorMap, (_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, isDarkTheme);
|
|
1512
1726
|
seriesColors[category] = color;
|
|
1513
1727
|
var _series_labels, _ref;
|
|
1514
1728
|
const labels = (_ref = (_series_labels = series.labels) !== null && _series_labels !== void 0 ? _series_labels : series.y) !== null && _ref !== void 0 ? _ref : series.stage;
|
|
@@ -1556,7 +1770,8 @@ const transformPlotlyJsonToFunnelChartProps = (input, isMultiPlot, colorMap, col
|
|
|
1556
1770
|
var _series_marker_colors;
|
|
1557
1771
|
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);
|
|
1558
1772
|
categories.forEach((label, i)=>{
|
|
1559
|
-
|
|
1773
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
1774
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(extractedColors, i, label, colorMap, (_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, isDarkTheme);
|
|
1560
1775
|
const valueNum = Number(values[i]);
|
|
1561
1776
|
if (isNaN(valueNum)) {
|
|
1562
1777
|
return;
|
|
@@ -1890,11 +2105,13 @@ const getAllupLegendsProps = (input, colorMap, colorwayType, traceInfo, isDarkTh
|
|
|
1890
2105
|
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _pieSeries_marker, _pieSeries_labels;
|
|
1891
2106
|
const pieSeries = series;
|
|
1892
2107
|
var _input_layout_piecolorway, _input_layout_piecolorway1;
|
|
1893
|
-
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);
|
|
2108
|
+
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, true);
|
|
1894
2109
|
(_pieSeries_labels = pieSeries.labels) === null || _pieSeries_labels === void 0 ? void 0 : _pieSeries_labels.forEach((label, labelIndex)=>{
|
|
2110
|
+
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1;
|
|
1895
2111
|
const legend = `${label}`;
|
|
2112
|
+
var _input_layout_piecolorway;
|
|
1896
2113
|
// resolve color for each legend from the extracted colors
|
|
1897
|
-
const color = (0, _PlotlyColorAdapter.resolveColor)(colors, labelIndex, legend, colorMap, isDarkTheme);
|
|
2114
|
+
const color = (0, _PlotlyColorAdapter.resolveColor)(colors, labelIndex, legend, colorMap, (_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, isDarkTheme, true);
|
|
1898
2115
|
if (legend !== '' && allupLegends.some((group)=>group.title === legend) === false) {
|
|
1899
2116
|
allupLegends.push({
|
|
1900
2117
|
title: legend,
|
|
@@ -1951,7 +2168,7 @@ const getNumberAtIndexOrDefault = (data, index)=>{
|
|
|
1951
2168
|
}
|
|
1952
2169
|
return 1;
|
|
1953
2170
|
};
|
|
1954
|
-
const getValidXYRanges = (series)=>{
|
|
2171
|
+
const getValidXYRanges = (series, resolveX, resolveY)=>{
|
|
1955
2172
|
if (!(0, _chartutilities.isArrayOrTypedArray)(series.x) || !(0, _chartutilities.isArrayOrTypedArray)(series.y)) {
|
|
1956
2173
|
return [];
|
|
1957
2174
|
}
|
|
@@ -1959,7 +2176,7 @@ const getValidXYRanges = (series)=>{
|
|
|
1959
2176
|
let start = 0;
|
|
1960
2177
|
let end = 0;
|
|
1961
2178
|
for(; end < series.x.length; end++){
|
|
1962
|
-
if ((0, _chartutilities.isInvalidValue)(series.x[end]) || (0, _chartutilities.isInvalidValue)(series.y[end])) {
|
|
2179
|
+
if ((0, _chartutilities.isInvalidValue)(series.x[end]) || typeof resolveX === 'function' && (0, _chartutilities.isInvalidValue)(resolveX(series.x[end])) || (0, _chartutilities.isInvalidValue)(series.y[end]) || typeof resolveY === 'function' && (0, _chartutilities.isInvalidValue)(resolveY(series.y[end]))) {
|
|
1963
2180
|
if (end - start > 0) {
|
|
1964
2181
|
ranges.push([
|
|
1965
2182
|
start,
|
|
@@ -2166,6 +2383,7 @@ const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
|
|
|
2166
2383
|
});
|
|
2167
2384
|
const isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || (0, _chartutilities.isStringArray)(values) && !(0, _chartutilities.isNumberArray)(values) && !(0, _chartutilities.isDateArray)(values);
|
|
2168
2385
|
if (!isAxisTypeCategory) {
|
|
2386
|
+
result[propName] = 'data';
|
|
2169
2387
|
return;
|
|
2170
2388
|
}
|
|
2171
2389
|
const isValidArray = (0, _chartutilities.isArrayOrTypedArray)(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
|
|
@@ -2175,7 +2393,7 @@ const getGridProperties = (schema, isMultiPlot, validTracesInfo)=>{
|
|
|
2175
2393
|
}
|
|
2176
2394
|
if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
|
|
2177
2395
|
const categoriesInTraceOrder = Array.from(new Set(values));
|
|
2178
|
-
result[propName] = categoriesInTraceOrder;
|
|
2396
|
+
result[propName] = (ax === null || ax === void 0 ? void 0 : ax.autorange) === 'reversed' ? categoriesInTraceOrder.reverse() : categoriesInTraceOrder;
|
|
2179
2397
|
return;
|
|
2180
2398
|
}
|
|
2181
2399
|
result[propName] = ax.categoryorder;
|
|
@@ -2246,13 +2464,19 @@ const getAxisScaleTypeProps = (data, layout)=>{
|
|
|
2246
2464
|
if (!ax) {
|
|
2247
2465
|
return;
|
|
2248
2466
|
}
|
|
2249
|
-
const axType = getAxisType(data,
|
|
2467
|
+
const axType = getAxisType(data, ax);
|
|
2250
2468
|
if ((!ax.tickmode || ax.tickmode === 'array') && (0, _chartutilities.isArrayOrTypedArray)(ax.tickvals)) {
|
|
2251
2469
|
const tickValues = axType === 'date' ? ax.tickvals.map((v)=>new Date(v)) : ax.tickvals;
|
|
2252
2470
|
if (axId === 'x') {
|
|
2253
2471
|
props.tickValues = tickValues;
|
|
2472
|
+
props.xAxis = {
|
|
2473
|
+
tickText: ax.ticktext
|
|
2474
|
+
};
|
|
2254
2475
|
} else if (axId === 'y') {
|
|
2255
2476
|
props.yAxisTickValues = tickValues;
|
|
2477
|
+
props.yAxis = {
|
|
2478
|
+
tickText: ax.ticktext
|
|
2479
|
+
};
|
|
2256
2480
|
}
|
|
2257
2481
|
return;
|
|
2258
2482
|
}
|
|
@@ -2262,12 +2486,12 @@ const getAxisScaleTypeProps = (data, layout)=>{
|
|
|
2262
2486
|
if (axId === 'x') {
|
|
2263
2487
|
props.xAxis = {
|
|
2264
2488
|
tickStep: dtick,
|
|
2265
|
-
tick0
|
|
2489
|
+
tick0
|
|
2266
2490
|
};
|
|
2267
2491
|
} else if (axId === 'y') {
|
|
2268
2492
|
props.yAxis = {
|
|
2269
2493
|
tickStep: dtick,
|
|
2270
|
-
tick0
|
|
2494
|
+
tick0
|
|
2271
2495
|
};
|
|
2272
2496
|
}
|
|
2273
2497
|
return;
|
|
@@ -2343,44 +2567,84 @@ const getAxisObjects = (data, layout)=>{
|
|
|
2343
2567
|
xAxisId = axisIds.x;
|
|
2344
2568
|
yAxisIds.add(axisIds.y);
|
|
2345
2569
|
});
|
|
2570
|
+
const makeAxisObject = (axLetter, axId)=>({
|
|
2571
|
+
...layout === null || layout === void 0 ? void 0 : layout[(0, _chartutilities.getAxisKey)(axLetter, axId)],
|
|
2572
|
+
_id: `${axLetter}${axId > 1 ? axId : ''}`
|
|
2573
|
+
});
|
|
2346
2574
|
const axisObjects = {};
|
|
2347
2575
|
if (typeof xAxisId === 'number') {
|
|
2348
|
-
axisObjects.x =
|
|
2576
|
+
axisObjects.x = makeAxisObject('x', xAxisId);
|
|
2349
2577
|
}
|
|
2350
2578
|
const sortedYAxisIds = Array.from(yAxisIds).sort();
|
|
2351
2579
|
if (sortedYAxisIds.length > 0) {
|
|
2352
|
-
axisObjects.y =
|
|
2580
|
+
axisObjects.y = makeAxisObject('y', sortedYAxisIds[0]);
|
|
2353
2581
|
}
|
|
2354
2582
|
if (sortedYAxisIds.length > 1) {
|
|
2355
|
-
axisObjects.y2 =
|
|
2583
|
+
axisObjects.y2 = makeAxisObject('y', sortedYAxisIds[1]);
|
|
2356
2584
|
}
|
|
2357
2585
|
return axisObjects;
|
|
2358
2586
|
};
|
|
2359
|
-
const getAxisType = (data,
|
|
2587
|
+
const getAxisType = (data, ax)=>{
|
|
2588
|
+
if (!ax) {
|
|
2589
|
+
return 'category';
|
|
2590
|
+
}
|
|
2591
|
+
var _ax_type;
|
|
2592
|
+
if ([
|
|
2593
|
+
'linear',
|
|
2594
|
+
'log',
|
|
2595
|
+
'date',
|
|
2596
|
+
'category'
|
|
2597
|
+
].includes((_ax_type = ax.type) !== null && _ax_type !== void 0 ? _ax_type : '')) {
|
|
2598
|
+
return ax.type;
|
|
2599
|
+
}
|
|
2600
|
+
const axLetter = ax._id[0];
|
|
2360
2601
|
const values = [];
|
|
2361
2602
|
data.forEach((series)=>{
|
|
2362
|
-
|
|
2363
|
-
(
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
// Therefore, simply checking the type of the values may not be sufficient. At the moment,
|
|
2371
|
-
// we don’t always perform this casting ourselves and instead use the values as provided.
|
|
2372
|
-
if ((0, _chartutilities.isNumberArray)(values)) {
|
|
2373
|
-
if ((ax === null || ax === void 0 ? void 0 : ax.type) === 'log') {
|
|
2374
|
-
return 'log';
|
|
2603
|
+
const axId = series[`${axLetter}axis`];
|
|
2604
|
+
if (axId === ax._id || !axId && ax._id === axLetter) {
|
|
2605
|
+
var _series_axLetter;
|
|
2606
|
+
(_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
|
|
2607
|
+
if (!(0, _chartutilities.isInvalidValue)(val)) {
|
|
2608
|
+
values.push(val);
|
|
2609
|
+
}
|
|
2610
|
+
});
|
|
2375
2611
|
}
|
|
2612
|
+
});
|
|
2613
|
+
if ((0, _chartutilities.isNumberArray)(values) && !(0, _chartutilities.isYearArray)(values)) {
|
|
2376
2614
|
return 'linear';
|
|
2377
2615
|
}
|
|
2378
2616
|
if ((0, _chartutilities.isDateArray)(values)) {
|
|
2379
2617
|
return 'date';
|
|
2380
2618
|
}
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2619
|
+
return 'category';
|
|
2620
|
+
};
|
|
2621
|
+
const getAxisValueResolver = (axType, dateParser)=>{
|
|
2622
|
+
const toDate = (value)=>{
|
|
2623
|
+
const date = dateParser ? dateParser(value) : new Date(value);
|
|
2624
|
+
return isNaN(date.getTime()) ? null : date;
|
|
2625
|
+
};
|
|
2626
|
+
return (value)=>{
|
|
2627
|
+
if ((0, _chartutilities.isInvalidValue)(value)) {
|
|
2628
|
+
return null;
|
|
2629
|
+
}
|
|
2630
|
+
switch(axType){
|
|
2631
|
+
case 'linear':
|
|
2632
|
+
case 'log':
|
|
2633
|
+
return (0, _chartutilities.isNumber)(value) ? +value : null;
|
|
2634
|
+
case 'date':
|
|
2635
|
+
if ((0, _chartutilities.isNumber)(value)) {
|
|
2636
|
+
return toDate(+value);
|
|
2637
|
+
}
|
|
2638
|
+
if (typeof value === 'string') {
|
|
2639
|
+
return toDate(value);
|
|
2640
|
+
}
|
|
2641
|
+
return null;
|
|
2642
|
+
case 'category':
|
|
2643
|
+
return `${value}`;
|
|
2644
|
+
default:
|
|
2645
|
+
return null;
|
|
2646
|
+
}
|
|
2647
|
+
};
|
|
2384
2648
|
};
|
|
2385
2649
|
/**
|
|
2386
2650
|
* This is experimental. Use it only with valid datetime strings to verify if they conform to the ISO 8601 format.
|