@fluentui/react-charts 9.2.2 → 9.2.3
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 +35 -2
- package/dist/index.d.ts +89 -10
- package/lib/components/AreaChart/AreaChart.js +4 -1
- package/lib/components/AreaChart/AreaChart.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
- package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ChartTable/ChartTable.js +3 -2
- package/lib/components/ChartTable/ChartTable.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.js +60 -19
- package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
- package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +175 -107
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +6 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +791 -199
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/DonutChart/DonutChart.js +2 -2
- package/lib/components/DonutChart/DonutChart.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js +2 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
- package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +29 -8
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HeatMapChart/HeatMapChart.js +175 -114
- package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
- package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +26 -6
- package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
- package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib/components/LineChart/LineChart.js +251 -78
- package/lib/components/LineChart/LineChart.js.map +1 -1
- package/lib/components/LineChart/LineChart.types.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.js +10 -3
- package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
- package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.js +56 -37
- package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js +21 -4
- package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +16 -3
- package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalBarChart/VerticalBarChart.js +27 -4
- package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +158 -46
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
- package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib/types/DataPoint.js.map +1 -1
- package/lib/utilities/utilities.js +15 -5
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js +4 -1
- package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +2 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ChartTable/ChartTable.js +3 -2
- package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.js +60 -18
- package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +13 -0
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +12 -0
- package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +171 -105
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +9 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +810 -197
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js +1 -1
- package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +2 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +28 -7
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +174 -113
- package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +25 -5
- package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.js +250 -78
- package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
- package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +12 -3
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +14 -2
- package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.js +56 -37
- package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +30 -3
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +15 -2
- package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +26 -3
- package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +157 -45
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +2 -1
- package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/lib-commonjs/utilities/utilities.js +15 -4
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +10 -10
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/* eslint-disable one-var */ /* eslint-disable vars-on-top */ /* eslint-disable no-var */ import * as React from 'react';
|
|
2
2
|
import { bin as d3Bin, extent as d3Extent, sum as d3Sum, min as d3Min, max as d3Max, range as d3Range } from 'd3-array';
|
|
3
3
|
import { scaleLinear as d3ScaleLinear } from 'd3-scale';
|
|
4
|
+
import { format as d3Format } from 'd3-format';
|
|
4
5
|
import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
|
|
5
|
-
import { findNumericMinMaxOfY } from '../../utilities/utilities';
|
|
6
|
-
import {
|
|
6
|
+
import { findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS } from '../../utilities/utilities';
|
|
7
|
+
import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue } from '@fluentui/chart-utilities';
|
|
7
8
|
import { curveCardinal as d3CurveCardinal } from 'd3-shape';
|
|
8
|
-
import { extractColor, resolveColor } from './PlotlyColorAdapter';
|
|
9
|
+
import { getOpacity, extractColor, resolveColor } from './PlotlyColorAdapter';
|
|
10
|
+
import { rgb } from 'd3-color';
|
|
9
11
|
const dashOptions = {
|
|
10
12
|
dot: {
|
|
11
13
|
strokeDasharray: '1, 5',
|
|
@@ -64,24 +66,35 @@ export const correctYearMonth = (xValues)=>{
|
|
|
64
66
|
const parsedDate = `${possiblyMonthValue} 01, ${presentYear}`;
|
|
65
67
|
return isDate(parsedDate) ? new Date(parsedDate) : null;
|
|
66
68
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
const filteredDateIndexPairs = dates.map((date, index)=>[
|
|
70
|
+
date,
|
|
71
|
+
index
|
|
72
|
+
]).filter(([date])=>date !== null);
|
|
73
|
+
for(let i = filteredDateIndexPairs.length - 1; i > 0; i--){
|
|
74
|
+
const currentDate = filteredDateIndexPairs[i][0];
|
|
75
|
+
const previousDate = filteredDateIndexPairs[i - 1][0];
|
|
76
|
+
const currentMonth = currentDate.getMonth();
|
|
77
|
+
const previousMonth = previousDate.getMonth();
|
|
78
|
+
const currentYear = currentDate.getFullYear();
|
|
79
|
+
const previousYear = previousDate.getFullYear();
|
|
72
80
|
if (previousMonth >= currentMonth) {
|
|
73
|
-
|
|
81
|
+
filteredDateIndexPairs[i - 1][0].setFullYear(currentYear - 1);
|
|
74
82
|
} else if (previousYear > currentYear) {
|
|
75
|
-
|
|
83
|
+
filteredDateIndexPairs[i - 1][0].setFullYear(currentYear);
|
|
76
84
|
}
|
|
85
|
+
dates[filteredDateIndexPairs[i - 1][1]] = filteredDateIndexPairs[i - 1][0];
|
|
77
86
|
}
|
|
78
87
|
xValues = xValues.map((month, index)=>{
|
|
88
|
+
if (dates[index] === null) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
79
91
|
return `${month} 01, ${dates[index].getFullYear()}`;
|
|
80
92
|
});
|
|
81
93
|
return xValues;
|
|
82
94
|
};
|
|
83
|
-
const usesSecondaryYScale = (series)=>{
|
|
84
|
-
|
|
95
|
+
const usesSecondaryYScale = (series, layout)=>{
|
|
96
|
+
var _layout_yaxis2, _layout_yaxis21;
|
|
97
|
+
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');
|
|
85
98
|
};
|
|
86
99
|
const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>{
|
|
87
100
|
var _layout_yaxis2, _layout_yaxis21, _layout_yaxis2_title, _layout_yaxis22;
|
|
@@ -89,7 +102,7 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
|
|
|
89
102
|
let yMinValue;
|
|
90
103
|
let yMaxValue;
|
|
91
104
|
data.forEach((series)=>{
|
|
92
|
-
if (usesSecondaryYScale(series)) {
|
|
105
|
+
if (usesSecondaryYScale(series, layout)) {
|
|
93
106
|
containsSecondaryYAxis = true;
|
|
94
107
|
const yValues = series.y;
|
|
95
108
|
if (yValues) {
|
|
@@ -123,32 +136,56 @@ export const _getGaugeAxisColor = (colorway, colorwayType, color, colorMap, isDa
|
|
|
123
136
|
const extractedColors = extractColor(colorway, colorwayType, color, colorMap, isDarkTheme);
|
|
124
137
|
return resolveColor(extractedColors, 0, '', colorMap, isDarkTheme);
|
|
125
138
|
};
|
|
126
|
-
export const
|
|
127
|
-
|
|
139
|
+
export const resolveXAxisPoint = (x, isXYearCategory, isXString, isXDate, isXNumber)=>{
|
|
140
|
+
if (x === null || x === undefined) {
|
|
141
|
+
return '';
|
|
142
|
+
}
|
|
143
|
+
if (isXYearCategory) {
|
|
144
|
+
return x.toString();
|
|
145
|
+
}
|
|
146
|
+
if (isXString) {
|
|
147
|
+
if (isXDate) {
|
|
148
|
+
const date = new Date(x);
|
|
149
|
+
return date;
|
|
150
|
+
}
|
|
151
|
+
if (isXNumber) {
|
|
152
|
+
return parseFloat(x);
|
|
153
|
+
}
|
|
154
|
+
return x;
|
|
155
|
+
}
|
|
156
|
+
return x;
|
|
157
|
+
};
|
|
158
|
+
export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
159
|
+
var _input_layout, _input_layout_template_layout, _input_layout_template, _input_layout1, _input_layout2, _firstData_marker, _firstData_labels, _input_layout3, _input_layout4, _input_layout5, _input_layout6;
|
|
128
160
|
const firstData = input.data[0];
|
|
161
|
+
var _input_layout_piecolorway, _input_layout_piecolorway1;
|
|
129
162
|
// extract colors for each series only once
|
|
130
|
-
|
|
163
|
+
// use piecolorway if available
|
|
164
|
+
// otherwise, default to colorway from template
|
|
165
|
+
const colors = extractColor((_input_layout_piecolorway = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.piecolorway) !== null && _input_layout_piecolorway !== void 0 ? _input_layout_piecolorway : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template = _input_layout1.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_input_layout_piecolorway1 = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.piecolorway) !== null && _input_layout_piecolorway1 !== void 0 ? _input_layout_piecolorway1 : firstData === null || firstData === void 0 ? void 0 : (_firstData_marker = firstData.marker) === null || _firstData_marker === void 0 ? void 0 : _firstData_marker.colors, colorMap, isDarkTheme);
|
|
131
166
|
const mapLegendToDataPoint = {};
|
|
132
167
|
(_firstData_labels = firstData.labels) === null || _firstData_labels === void 0 ? void 0 : _firstData_labels.forEach((label, index)=>{
|
|
133
|
-
|
|
168
|
+
const value = getNumberAtIndexOrDefault(firstData.values, index);
|
|
169
|
+
if (isInvalidValue(value) || value < 0) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const legend = `${label}`;
|
|
134
173
|
// resolve color for each legend from the extracted colors
|
|
135
|
-
const color = resolveColor(colors, index,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
mapLegendToDataPoint[label] = {
|
|
140
|
-
legend: label,
|
|
174
|
+
const color = resolveColor(colors, index, legend, colorMap, isDarkTheme);
|
|
175
|
+
if (!mapLegendToDataPoint[legend]) {
|
|
176
|
+
mapLegendToDataPoint[legend] = {
|
|
177
|
+
legend,
|
|
141
178
|
data: value,
|
|
142
179
|
color
|
|
143
180
|
};
|
|
144
181
|
} else {
|
|
145
|
-
mapLegendToDataPoint[
|
|
182
|
+
mapLegendToDataPoint[legend].data += value;
|
|
146
183
|
}
|
|
147
184
|
});
|
|
148
185
|
var _input_layout_width;
|
|
149
|
-
const width = (_input_layout_width = (
|
|
186
|
+
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;
|
|
150
187
|
var _input_layout_height;
|
|
151
|
-
const height = (_input_layout_height = (
|
|
188
|
+
const height = (_input_layout_height = (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 220;
|
|
152
189
|
const hideLabels = firstData.textinfo ? ![
|
|
153
190
|
'value',
|
|
154
191
|
'percent',
|
|
@@ -156,15 +193,15 @@ export const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, i
|
|
|
156
193
|
].includes(firstData.textinfo) : false;
|
|
157
194
|
const donutMarginHorizontal = hideLabels ? 0 : 80;
|
|
158
195
|
const donutMarginVertical = 40 + (hideLabels ? 0 : 40);
|
|
159
|
-
const innerRadius = firstData.hole ? firstData.hole * (Math.min(width - donutMarginHorizontal, height - donutMarginVertical) / 2) :
|
|
196
|
+
const innerRadius = firstData.hole ? firstData.hole * (Math.min(width - donutMarginHorizontal, height - donutMarginVertical) / 2) : MIN_DONUT_RADIUS;
|
|
160
197
|
const { chartTitle } = getTitles(input.layout);
|
|
161
198
|
return {
|
|
162
199
|
data: {
|
|
163
200
|
chartTitle,
|
|
164
201
|
chartData: Object.values(mapLegendToDataPoint)
|
|
165
202
|
},
|
|
166
|
-
hideLegend: ((
|
|
167
|
-
width: (
|
|
203
|
+
hideLegend: ((_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.showlegend) === false ? true : false,
|
|
204
|
+
width: (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.width,
|
|
168
205
|
height,
|
|
169
206
|
innerRadius,
|
|
170
207
|
hideLabels,
|
|
@@ -175,63 +212,84 @@ export const transformPlotlyJsonToDonutProps = (input, colorMap, colorwayType, i
|
|
|
175
212
|
roundCorners: true
|
|
176
213
|
};
|
|
177
214
|
};
|
|
178
|
-
export const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
215
|
+
export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
179
216
|
var _input_layout, _input_layout1, _vsbcData_;
|
|
180
217
|
const mapXToDataPoints = {};
|
|
181
218
|
let yMaxValue = 0;
|
|
182
219
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
183
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
220
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
221
|
+
let colorScale = undefined;
|
|
184
222
|
let yMinValue = 0;
|
|
185
223
|
input.data.forEach((series, index1)=>{
|
|
186
|
-
var
|
|
224
|
+
var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _input_layout_template_layout1, _input_layout_template1, _input_layout2, _series_line;
|
|
225
|
+
if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_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[0]) === 'number') {
|
|
226
|
+
colorScale = createColorScale(input.layout, series);
|
|
227
|
+
}
|
|
187
228
|
const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
|
|
188
229
|
// extract bar colors for each series only once
|
|
189
|
-
const extractedBarColors = extractColor((
|
|
230
|
+
const extractedBarColors = extractColor((_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, (_series_marker3 = series.marker) === null || _series_marker3 === void 0 ? void 0 : _series_marker3.color, colorMap, isDarkTheme);
|
|
190
231
|
// extract line colors for each series only once
|
|
191
|
-
const extractedLineColors = extractColor((
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
legend,
|
|
209
|
-
data: yVal,
|
|
210
|
-
color
|
|
211
|
-
});
|
|
212
|
-
yMaxValue = Math.max(yMaxValue, yVal);
|
|
213
|
-
} else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
214
|
-
var _series_line;
|
|
215
|
-
const lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
216
|
-
const lineOptions = getLineOptions(series.line);
|
|
217
|
-
const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
|
|
218
|
-
const legendShape = dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot' ? 'dottedLine' : 'default';
|
|
219
|
-
mapXToDataPoints[x].lineData.push({
|
|
220
|
-
legend,
|
|
221
|
-
legendShape,
|
|
222
|
-
y: yVal,
|
|
223
|
-
color: lineColor,
|
|
224
|
-
...lineOptions ? {
|
|
225
|
-
lineOptions
|
|
226
|
-
} : {},
|
|
227
|
-
useSecondaryYScale: usesSecondaryYScale(series)
|
|
228
|
-
});
|
|
229
|
-
if (!usesSecondaryYScale(series)) {
|
|
230
|
-
yMaxValue = Math.max(yMaxValue, yVal);
|
|
232
|
+
const extractedLineColors = extractColor((_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_template1 = _input_layout2.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
|
|
233
|
+
const xValues = series.x;
|
|
234
|
+
const isXDate = isDateArray(xValues);
|
|
235
|
+
const isXString = isStringArray(xValues);
|
|
236
|
+
const isXNumber = isNumberArray(xValues);
|
|
237
|
+
const validXYRanges = getValidXYRanges(series);
|
|
238
|
+
validXYRanges.forEach(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
239
|
+
const rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
240
|
+
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
241
|
+
rangeXValues.forEach((x, index2)=>{
|
|
242
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
243
|
+
if (!mapXToDataPoints[x]) {
|
|
244
|
+
mapXToDataPoints[x] = {
|
|
245
|
+
xAxisPoint: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber),
|
|
246
|
+
chartData: [],
|
|
247
|
+
lineData: []
|
|
248
|
+
};
|
|
231
249
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
250
|
+
const legend = legends[index1];
|
|
251
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
252
|
+
const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index2 % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedBarColors, index2, legend, colorMap, isDarkTheme);
|
|
253
|
+
const opacity = getOpacity(series, index2);
|
|
254
|
+
const yVal = rangeYValues[index2];
|
|
255
|
+
if (series.type === 'bar') {
|
|
256
|
+
var _rgb_copy_formatHex8;
|
|
257
|
+
mapXToDataPoints[x].chartData.push({
|
|
258
|
+
legend,
|
|
259
|
+
data: yVal,
|
|
260
|
+
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
261
|
+
opacity
|
|
262
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
263
|
+
});
|
|
264
|
+
if (typeof yVal === 'number') {
|
|
265
|
+
yMaxValue = Math.max(yMaxValue, yVal);
|
|
266
|
+
}
|
|
267
|
+
} else if (series.type === 'scatter' || !!fallbackVSBC) {
|
|
268
|
+
var _series_mode;
|
|
269
|
+
const lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, isDarkTheme);
|
|
270
|
+
const lineOptions = !((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('text')) ? getLineOptions(series.line) : undefined;
|
|
271
|
+
const legendShape = getLegendShape(series);
|
|
272
|
+
var _rgb_copy_formatHex81;
|
|
273
|
+
mapXToDataPoints[x].lineData.push({
|
|
274
|
+
legend: legend + (validXYRanges.length > 1 ? `.${rangeIdx + 1}` : ''),
|
|
275
|
+
legendShape,
|
|
276
|
+
y: yVal,
|
|
277
|
+
color: (_rgb_copy_formatHex81 = rgb(lineColor).copy({
|
|
278
|
+
opacity
|
|
279
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex81 !== void 0 ? _rgb_copy_formatHex81 : color,
|
|
280
|
+
lineOptions: {
|
|
281
|
+
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
282
|
+
mode: series.mode
|
|
283
|
+
},
|
|
284
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
285
|
+
});
|
|
286
|
+
if (!usesSecondaryYScale(series, input.layout) && typeof yVal === 'number') {
|
|
287
|
+
yMaxValue = Math.max(yMaxValue, yVal);
|
|
288
|
+
yMinValue = Math.min(yMinValue, yVal);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
yMaxValue = Math.max(yMaxValue, yVal);
|
|
292
|
+
});
|
|
235
293
|
});
|
|
236
294
|
});
|
|
237
295
|
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
@@ -253,19 +311,45 @@ export const transformPlotlyJsonToVSBCProps = (input, colorMap, colorwayType, is
|
|
|
253
311
|
hideTickOverlap: true,
|
|
254
312
|
barGapMax: 2,
|
|
255
313
|
hideLegend,
|
|
256
|
-
roundCorners: true
|
|
314
|
+
roundCorners: true,
|
|
315
|
+
showYAxisLables: true,
|
|
316
|
+
noOfCharsToTruncate: 20,
|
|
317
|
+
showYAxisLablesTooltip: true,
|
|
318
|
+
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
257
319
|
};
|
|
258
320
|
};
|
|
259
|
-
|
|
321
|
+
const createColorScale = (layout, series)=>{
|
|
322
|
+
var _layout_coloraxis, _series_marker, _layout_coloraxis1, _layout_coloraxis2;
|
|
323
|
+
const scale = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis = layout.coloraxis) === null || _layout_coloraxis === void 0 ? void 0 : _layout_coloraxis.colorscale;
|
|
324
|
+
const colorValues = (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color;
|
|
325
|
+
var _layout_coloraxis_cmin, _layout_coloraxis_cmax;
|
|
326
|
+
const [dMin, dMax] = [
|
|
327
|
+
(_layout_coloraxis_cmin = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis1 = layout.coloraxis) === null || _layout_coloraxis1 === void 0 ? void 0 : _layout_coloraxis1.cmin) !== null && _layout_coloraxis_cmin !== void 0 ? _layout_coloraxis_cmin : Math.min(...colorValues),
|
|
328
|
+
(_layout_coloraxis_cmax = layout === null || layout === void 0 ? void 0 : (_layout_coloraxis2 = layout.coloraxis) === null || _layout_coloraxis2 === void 0 ? void 0 : _layout_coloraxis2.cmax) !== null && _layout_coloraxis_cmax !== void 0 ? _layout_coloraxis_cmax : Math.max(...colorValues)
|
|
329
|
+
];
|
|
330
|
+
// Normalize colorscale domain to actual data domain
|
|
331
|
+
const scaleDomain = scale.map(([pos])=>dMin + pos * (dMax - dMin));
|
|
332
|
+
const scaleColors = scale.map((item)=>item[1]);
|
|
333
|
+
return d3ScaleLinear().domain(scaleDomain).range(scaleColors);
|
|
334
|
+
};
|
|
335
|
+
export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
260
336
|
var _input_layout, _input_layout1, _gvbcData_;
|
|
261
337
|
const mapXToDataPoints = {};
|
|
262
338
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, 0, 0);
|
|
263
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
339
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
340
|
+
let colorScale = undefined;
|
|
264
341
|
input.data.forEach((series, index1)=>{
|
|
265
|
-
var
|
|
342
|
+
var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _series_x;
|
|
343
|
+
if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_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[0]) === 'number') {
|
|
344
|
+
colorScale = createColorScale(input.layout, series);
|
|
345
|
+
}
|
|
266
346
|
// extract colors for each series only once
|
|
267
|
-
const extractedColors = extractColor((
|
|
347
|
+
const extractedColors = extractColor((_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, (_series_marker3 = series.marker) === null || _series_marker3 === void 0 ? void 0 : _series_marker3.color, colorMap, isDarkTheme);
|
|
268
348
|
(_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x.forEach((x, index2)=>{
|
|
349
|
+
var _series_y;
|
|
350
|
+
if (isInvalidValue(x) || isInvalidValue((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index2])) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
269
353
|
if (!mapXToDataPoints[x]) {
|
|
270
354
|
mapXToDataPoints[x] = {
|
|
271
355
|
name: x.toString(),
|
|
@@ -273,18 +357,21 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, is
|
|
|
273
357
|
};
|
|
274
358
|
}
|
|
275
359
|
if (series.type === 'bar') {
|
|
276
|
-
var
|
|
360
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
277
361
|
const legend = legends[index1];
|
|
278
|
-
// resolve color for each legend's bars from the extracted colors
|
|
279
|
-
const color = resolveColor(extractedColors,
|
|
280
|
-
|
|
362
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
363
|
+
const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index2 % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, index2, legend, colorMap, isDarkTheme);
|
|
364
|
+
const opacity = getOpacity(series, index2);
|
|
365
|
+
var _rgb_copy_formatHex8;
|
|
281
366
|
mapXToDataPoints[x].series.push({
|
|
282
367
|
key: legend,
|
|
283
|
-
data:
|
|
368
|
+
data: series.y[index2],
|
|
284
369
|
xAxisCalloutData: x,
|
|
285
|
-
color
|
|
370
|
+
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
371
|
+
opacity
|
|
372
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
286
373
|
legend,
|
|
287
|
-
useSecondaryYScale: usesSecondaryYScale(series)
|
|
374
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
288
375
|
});
|
|
289
376
|
}
|
|
290
377
|
});
|
|
@@ -305,32 +392,45 @@ export const transformPlotlyJsonToGVBCProps = (input, colorMap, colorwayType, is
|
|
|
305
392
|
hideTickOverlap: true,
|
|
306
393
|
wrapXAxisLables: typeof ((_gvbcData_ = gvbcData[0]) === null || _gvbcData_ === void 0 ? void 0 : _gvbcData_.name) === 'string',
|
|
307
394
|
hideLegend,
|
|
308
|
-
roundCorners: true
|
|
395
|
+
roundCorners: true,
|
|
396
|
+
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
309
397
|
};
|
|
310
398
|
};
|
|
311
|
-
export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
399
|
+
export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
312
400
|
var _input_layout, _input_layout1, _vbcData_;
|
|
313
401
|
const vbcData = [];
|
|
314
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
402
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
403
|
+
let colorScale = undefined;
|
|
315
404
|
input.data.forEach((series, seriesIdx)=>{
|
|
316
|
-
var
|
|
405
|
+
var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3, _series_xbins, _series_xbins1, _series_xbins2;
|
|
317
406
|
if (!series.x) {
|
|
318
407
|
return;
|
|
319
408
|
}
|
|
409
|
+
if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_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[0]) === 'number') {
|
|
410
|
+
colorScale = createColorScale(input.layout, series);
|
|
411
|
+
}
|
|
320
412
|
// extract colors for each series only once
|
|
321
|
-
const extractedColors = extractColor((
|
|
322
|
-
const
|
|
413
|
+
const extractedColors = extractColor((_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, (_series_marker3 = series.marker) === null || _series_marker3 === void 0 ? void 0 : _series_marker3.color, colorMap, isDarkTheme);
|
|
414
|
+
const xValues = [];
|
|
415
|
+
const yValues = [];
|
|
416
|
+
series.x.forEach((xVal, index)=>{
|
|
417
|
+
const yVal = getNumberAtIndexOrDefault(series.y, index);
|
|
418
|
+
if (isInvalidValue(xVal) || isInvalidValue(yVal)) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
xValues.push(xVal);
|
|
422
|
+
yValues.push(yVal);
|
|
423
|
+
});
|
|
424
|
+
const isXString = isStringArray(xValues);
|
|
323
425
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
324
426
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
325
|
-
const xBins = createBins(
|
|
427
|
+
const xBins = createBins(xValues, (_series_xbins = series.xbins) === null || _series_xbins === void 0 ? void 0 : _series_xbins.start, (_series_xbins1 = series.xbins) === null || _series_xbins1 === void 0 ? void 0 : _series_xbins1.end, (_series_xbins2 = series.xbins) === null || _series_xbins2 === void 0 ? void 0 : _series_xbins2.size);
|
|
326
428
|
const yBins = xBins.map(()=>[]);
|
|
327
429
|
let total = 0;
|
|
328
|
-
|
|
430
|
+
xValues.forEach((xVal, index)=>{
|
|
329
431
|
const binIdx = findBinIndex(xBins, xVal, isXString);
|
|
330
432
|
if (binIdx !== -1) {
|
|
331
|
-
|
|
332
|
-
var _series_y_index;
|
|
333
|
-
yBins[binIdx].push((_series_y_index = (_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[index]) !== null && _series_y_index !== void 0 ? _series_y_index : 1);
|
|
433
|
+
yBins[binIdx].push(yValues[index]);
|
|
334
434
|
}
|
|
335
435
|
});
|
|
336
436
|
const y = yBins.map((bin)=>{
|
|
@@ -339,15 +439,20 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isD
|
|
|
339
439
|
return yVal;
|
|
340
440
|
});
|
|
341
441
|
xBins.forEach((bin, index)=>{
|
|
442
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
342
443
|
const legend = legends[seriesIdx];
|
|
343
|
-
// resolve color for each legend's bars from the extracted colors
|
|
344
|
-
const color = resolveColor(extractedColors,
|
|
444
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
445
|
+
const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[index % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
446
|
+
const opacity = getOpacity(series, index);
|
|
345
447
|
const yVal = calculateHistNorm(series.histnorm, y[index], total, isXString ? bin.length : getBinSize(bin));
|
|
448
|
+
var _rgb_copy_formatHex8;
|
|
346
449
|
vbcData.push({
|
|
347
450
|
x: isXString ? bin.join(', ') : getBinCenter(bin),
|
|
348
451
|
y: yVal,
|
|
349
452
|
legend,
|
|
350
|
-
color
|
|
453
|
+
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
454
|
+
opacity
|
|
455
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
351
456
|
...isXString ? {} : {
|
|
352
457
|
xAxisCalloutData: `[${bin.x0} - ${bin.x1})`
|
|
353
458
|
}
|
|
@@ -368,56 +473,99 @@ export const transformPlotlyJsonToVBCProps = (input, colorMap, colorwayType, isD
|
|
|
368
473
|
wrapXAxisLables: typeof ((_vbcData_ = vbcData[0]) === null || _vbcData_ === void 0 ? void 0 : _vbcData_.x) === 'string',
|
|
369
474
|
maxBarWidth: 50,
|
|
370
475
|
hideLegend,
|
|
371
|
-
roundCorners: true
|
|
476
|
+
roundCorners: true,
|
|
477
|
+
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
372
478
|
};
|
|
373
479
|
};
|
|
374
|
-
export const
|
|
480
|
+
export const transformPlotlyJsonToAreaChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
481
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'area', colorMap, colorwayType, isDarkTheme);
|
|
482
|
+
};
|
|
483
|
+
export const transformPlotlyJsonToLineChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
484
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'line', colorMap, colorwayType, isDarkTheme);
|
|
485
|
+
};
|
|
486
|
+
export const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
487
|
+
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
488
|
+
};
|
|
489
|
+
const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
|
|
490
|
+
var _input_data_;
|
|
491
|
+
const isScatterMarkers = [
|
|
492
|
+
'markers',
|
|
493
|
+
'text+markers',
|
|
494
|
+
'markers+text',
|
|
495
|
+
'lines+markers',
|
|
496
|
+
'markers+line',
|
|
497
|
+
'text+lines+markers'
|
|
498
|
+
].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
|
|
499
|
+
const isAreaChart = chartType === 'area';
|
|
500
|
+
const isScatterChart = chartType === 'scatter';
|
|
375
501
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout, isAreaChart ? 0 : undefined, isAreaChart ? 0 : undefined);
|
|
376
502
|
let mode = 'tonexty';
|
|
377
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
503
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
378
504
|
const chartData = input.data.map((series, index)=>{
|
|
379
|
-
var
|
|
505
|
+
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _series_mode1;
|
|
506
|
+
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;
|
|
380
507
|
// extract colors for each series only once
|
|
381
|
-
const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType,
|
|
508
|
+
const extractedColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, colors, colorMap, isDarkTheme);
|
|
382
509
|
const xValues = series.x;
|
|
383
|
-
const
|
|
510
|
+
const isXString = isStringArray(xValues);
|
|
384
511
|
const isXDate = isDateArray(xValues);
|
|
385
512
|
const isXNumber = isNumberArray(xValues);
|
|
513
|
+
const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
|
|
386
514
|
const legend = legends[index];
|
|
387
515
|
// resolve color for each legend's lines from the extracted colors
|
|
388
516
|
const seriesColor = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
517
|
+
const seriesOpacity = getOpacity(series, index);
|
|
389
518
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
390
|
-
const lineOptions = getLineOptions(series.line);
|
|
391
|
-
const
|
|
392
|
-
const
|
|
393
|
-
return {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
519
|
+
const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) ? getLineOptions(series.line) : undefined;
|
|
520
|
+
const legendShape = getLegendShape(series);
|
|
521
|
+
const validXYRanges = getValidXYRanges(series);
|
|
522
|
+
return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
523
|
+
var _series_marker;
|
|
524
|
+
const rangeXValues = xValues.slice(rangeStart, rangeEnd);
|
|
525
|
+
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
526
|
+
const markerSizes = isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? series.marker.size.slice(rangeStart, rangeEnd) : [];
|
|
527
|
+
const textValues = Array.isArray(series.text) ? series.text.slice(rangeStart, rangeEnd) : undefined;
|
|
528
|
+
var _rgb_copy_formatHex8;
|
|
529
|
+
return {
|
|
530
|
+
legend,
|
|
531
|
+
legendShape,
|
|
532
|
+
data: rangeXValues.map((x, i)=>{
|
|
533
|
+
var _series_marker, _series_marker1;
|
|
534
|
+
return {
|
|
535
|
+
x: resolveXAxisPoint(x, isXYearCategory, isXString, isXDate, isXNumber),
|
|
536
|
+
y: rangeYValues[i],
|
|
537
|
+
...Array.isArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? {
|
|
538
|
+
markerSize: markerSizes[i]
|
|
539
|
+
} : typeof ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.size) === 'number' ? {
|
|
540
|
+
markerSize: series.marker.size
|
|
541
|
+
} : {},
|
|
542
|
+
...textValues ? {
|
|
543
|
+
text: textValues[i]
|
|
544
|
+
} : {}
|
|
545
|
+
};
|
|
546
|
+
}),
|
|
547
|
+
color: (_rgb_copy_formatHex8 = rgb(seriesColor).copy({
|
|
548
|
+
opacity: seriesOpacity
|
|
549
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : seriesColor,
|
|
550
|
+
lineOptions: {
|
|
551
|
+
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
552
|
+
mode: series.mode
|
|
553
|
+
},
|
|
554
|
+
useSecondaryYScale: usesSecondaryYScale(series, input.layout)
|
|
555
|
+
};
|
|
556
|
+
});
|
|
557
|
+
}).flat();
|
|
415
558
|
const yMinMaxValues = findNumericMinMaxOfY(chartData);
|
|
416
559
|
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
560
|
+
const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
|
|
417
561
|
const chartProps = {
|
|
418
562
|
chartTitle,
|
|
419
563
|
lineChartData: chartData
|
|
420
564
|
};
|
|
565
|
+
const scatterChartProps = {
|
|
566
|
+
chartTitle,
|
|
567
|
+
scatterChartData: chartData
|
|
568
|
+
};
|
|
421
569
|
if (isAreaChart) {
|
|
422
570
|
var _input_layout, _input_layout1;
|
|
423
571
|
var _input_layout_height;
|
|
@@ -432,13 +580,14 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, isSca
|
|
|
432
580
|
height: (_input_layout_height = (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
433
581
|
hideTickOverlap: true,
|
|
434
582
|
useUTC: false,
|
|
435
|
-
hideLegend
|
|
583
|
+
hideLegend,
|
|
584
|
+
optimizeLargeData: numDataPoints > 1000
|
|
436
585
|
};
|
|
437
586
|
} else {
|
|
438
587
|
var _input_layout2, _input_layout3;
|
|
439
588
|
var _input_layout_height1;
|
|
440
589
|
return {
|
|
441
|
-
data: chartProps,
|
|
590
|
+
data: isScatterChart ? scatterChartProps : chartProps,
|
|
442
591
|
supportNegativeData: true,
|
|
443
592
|
xAxisTitle,
|
|
444
593
|
yAxisTitle,
|
|
@@ -450,30 +599,42 @@ export const transformPlotlyJsonToScatterChartProps = (input, isAreaChart, isSca
|
|
|
450
599
|
height: (_input_layout_height1 = (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.height) !== null && _input_layout_height1 !== void 0 ? _input_layout_height1 : 350,
|
|
451
600
|
hideTickOverlap: true,
|
|
452
601
|
useUTC: false,
|
|
453
|
-
hideLegend
|
|
602
|
+
hideLegend,
|
|
603
|
+
optimizeLargeData: numDataPoints > 1000
|
|
454
604
|
};
|
|
455
605
|
}
|
|
456
606
|
};
|
|
457
|
-
export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
607
|
+
export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
458
608
|
var _input_layout, _input_layout_margin, _input_layout1, _input_layout_margin1, _input_layout2, _input_layout_yaxis2, _input_layout3, _input_layout_yaxis21, _input_layout4, _input_layout_yaxis2_title, _input_layout_yaxis22, _input_layout5, _input_layout6;
|
|
459
|
-
const { legends, hideLegend } = getLegendProps(input.data, input.layout);
|
|
609
|
+
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
610
|
+
let colorScale = undefined;
|
|
460
611
|
const chartData = input.data.map((series, index)=>{
|
|
461
|
-
var _input_layout_template_layout, _input_layout_template,
|
|
612
|
+
var _input_layout_coloraxis_colorscale, _input_layout_coloraxis, _input_layout, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout1, _series_marker3;
|
|
613
|
+
if (((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : (_input_layout_coloraxis_colorscale = _input_layout_coloraxis.colorscale) === null || _input_layout_coloraxis_colorscale === void 0 ? void 0 : _input_layout_coloraxis_colorscale.length) && isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) && ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length > 0 && typeof ((_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[0]) === 'number') {
|
|
614
|
+
colorScale = createColorScale(input.layout, series);
|
|
615
|
+
}
|
|
462
616
|
// extract colors for each series only once
|
|
463
|
-
const extractedColors = extractColor((
|
|
617
|
+
const extractedColors = extractColor((_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, (_series_marker3 = series.marker) === null || _series_marker3 === void 0 ? void 0 : _series_marker3.color, colorMap, isDarkTheme);
|
|
464
618
|
const legend = legends[index];
|
|
465
|
-
// resolve color for each legend's bars from the extracted colors
|
|
466
|
-
const color = resolveColor(extractedColors, index, legend, colorMap, isDarkTheme);
|
|
467
619
|
return series.y.map((yValue, i)=>{
|
|
620
|
+
var _series_x, _series_marker, _series_marker1, _series_marker_color, _series_marker2;
|
|
621
|
+
if (isInvalidValue((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]) || isInvalidValue(yValue)) {
|
|
622
|
+
return null;
|
|
623
|
+
}
|
|
624
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
625
|
+
const color = colorScale ? colorScale(isArrayOrTypedArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color) ? (_series_marker2 = series.marker) === null || _series_marker2 === void 0 ? void 0 : (_series_marker_color = _series_marker2.color) === null || _series_marker_color === void 0 ? void 0 : _series_marker_color[i % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedColors, i, legend, colorMap, isDarkTheme);
|
|
626
|
+
const opacity = getOpacity(series, i);
|
|
627
|
+
var _rgb_copy_formatHex8;
|
|
468
628
|
return {
|
|
469
629
|
x: series.x[i],
|
|
470
630
|
y: yValue,
|
|
471
631
|
legend,
|
|
472
|
-
color
|
|
632
|
+
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
633
|
+
opacity
|
|
634
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
473
635
|
};
|
|
474
|
-
});
|
|
475
|
-
}).
|
|
476
|
-
.reverse();
|
|
636
|
+
}).filter((point)=>point !== null);
|
|
637
|
+
}).flat();
|
|
477
638
|
var _input_layout_height;
|
|
478
639
|
const chartHeight = (_input_layout_height = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 450;
|
|
479
640
|
var _input_layout_margin_l;
|
|
@@ -500,31 +661,42 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, colorMap,
|
|
|
500
661
|
noOfCharsToTruncate: 20,
|
|
501
662
|
showYAxisLablesTooltip: true,
|
|
502
663
|
hideLegend,
|
|
503
|
-
roundCorners: true
|
|
664
|
+
roundCorners: true,
|
|
665
|
+
...getAxisCategoryOrderProps(input.data, input.layout)
|
|
504
666
|
};
|
|
505
667
|
};
|
|
506
|
-
export const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
507
|
-
var _input_layout, _input_layout1;
|
|
668
|
+
export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
669
|
+
var _input_layout, _input_layout_coloraxis, _input_layout1, _input_layout_template_layout, _input_layout_template, _input_layout2, _input_layout_template_data_histogram2d_, _input_layout_template_data_histogram2d, _input_layout_template_data, _input_layout_template1, _input_layout3, _input_layout_template_data_heatmap_, _input_layout_template_data_heatmap, _input_layout_template_data1, _input_layout_template2, _input_layout4, _input_layout5, _input_layout6;
|
|
508
670
|
const firstData = input.data[0];
|
|
509
671
|
const heatmapDataPoints = [];
|
|
510
672
|
let zMin = Number.POSITIVE_INFINITY;
|
|
511
673
|
let zMax = Number.NEGATIVE_INFINITY;
|
|
512
674
|
if (firstData.type === 'histogram2d') {
|
|
513
|
-
var _firstData_xbins, _firstData_xbins1, _firstData_xbins2, _firstData_ybins, _firstData_ybins1, _firstData_ybins2
|
|
514
|
-
const
|
|
515
|
-
const
|
|
516
|
-
const
|
|
517
|
-
const yBins = createBins(firstData.y, (_firstData_ybins = firstData.ybins) === null || _firstData_ybins === void 0 ? void 0 : _firstData_ybins.start, (_firstData_ybins1 = firstData.ybins) === null || _firstData_ybins1 === void 0 ? void 0 : _firstData_ybins1.end, (_firstData_ybins2 = firstData.ybins) === null || _firstData_ybins2 === void 0 ? void 0 : _firstData_ybins2.size);
|
|
518
|
-
const zBins = yBins.map(()=>xBins.map(()=>[]));
|
|
519
|
-
let total = 0;
|
|
675
|
+
var _firstData_x, _firstData_xbins, _firstData_xbins1, _firstData_xbins2, _firstData_ybins, _firstData_ybins1, _firstData_ybins2;
|
|
676
|
+
const xValues = [];
|
|
677
|
+
const yValues = [];
|
|
678
|
+
const zValues = [];
|
|
520
679
|
(_firstData_x = firstData.x) === null || _firstData_x === void 0 ? void 0 : _firstData_x.forEach((xVal, index)=>{
|
|
521
680
|
var _firstData_y;
|
|
681
|
+
const zVal = getNumberAtIndexOrDefault(firstData.z, index);
|
|
682
|
+
if (isInvalidValue(xVal) || isInvalidValue((_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y[index]) || isInvalidValue(zVal)) {
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
xValues.push(xVal);
|
|
686
|
+
yValues.push(firstData.y[index]);
|
|
687
|
+
zValues.push(zVal);
|
|
688
|
+
});
|
|
689
|
+
const isXString = isStringArray(xValues);
|
|
690
|
+
const isYString = isStringArray(yValues);
|
|
691
|
+
const xBins = createBins(xValues, (_firstData_xbins = firstData.xbins) === null || _firstData_xbins === void 0 ? void 0 : _firstData_xbins.start, (_firstData_xbins1 = firstData.xbins) === null || _firstData_xbins1 === void 0 ? void 0 : _firstData_xbins1.end, (_firstData_xbins2 = firstData.xbins) === null || _firstData_xbins2 === void 0 ? void 0 : _firstData_xbins2.size);
|
|
692
|
+
const yBins = createBins(yValues, (_firstData_ybins = firstData.ybins) === null || _firstData_ybins === void 0 ? void 0 : _firstData_ybins.start, (_firstData_ybins1 = firstData.ybins) === null || _firstData_ybins1 === void 0 ? void 0 : _firstData_ybins1.end, (_firstData_ybins2 = firstData.ybins) === null || _firstData_ybins2 === void 0 ? void 0 : _firstData_ybins2.size);
|
|
693
|
+
const zBins = yBins.map(()=>xBins.map(()=>[]));
|
|
694
|
+
let total = 0;
|
|
695
|
+
xValues.forEach((xVal, index)=>{
|
|
522
696
|
const xBinIdx = findBinIndex(xBins, xVal, isXString);
|
|
523
|
-
const yBinIdx = findBinIndex(yBins,
|
|
697
|
+
const yBinIdx = findBinIndex(yBins, yValues[index], isYString);
|
|
524
698
|
if (xBinIdx !== -1 && yBinIdx !== -1) {
|
|
525
|
-
|
|
526
|
-
var _firstData_z_index;
|
|
527
|
-
zBins[yBinIdx][xBinIdx].push((_firstData_z_index = (_firstData_z = firstData.z) === null || _firstData_z === void 0 ? void 0 : _firstData_z[index]) !== null && _firstData_z_index !== void 0 ? _firstData_z_index : 1);
|
|
699
|
+
zBins[yBinIdx][xBinIdx].push(zValues[index]);
|
|
528
700
|
}
|
|
529
701
|
});
|
|
530
702
|
const z = zBins.map((row)=>{
|
|
@@ -587,8 +759,23 @@ export const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
|
587
759
|
getColorFromToken(DataVizPalette.color2),
|
|
588
760
|
getColorFromToken(DataVizPalette.color3)
|
|
589
761
|
];
|
|
590
|
-
|
|
591
|
-
|
|
762
|
+
var _firstData_colorscale, _ref, _ref1, _ref2, _ref3;
|
|
763
|
+
let colorscale = (_ref3 = (_ref2 = (_ref1 = (_ref = (_firstData_colorscale = firstData === null || firstData === void 0 ? void 0 : firstData.colorscale) !== null && _firstData_colorscale !== void 0 ? _firstData_colorscale : (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.colorscale) !== null && _ref !== void 0 ? _ref : (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_coloraxis = _input_layout1.coloraxis) === null || _input_layout_coloraxis === void 0 ? void 0 : _input_layout_coloraxis.colorscale) !== null && _ref1 !== void 0 ? _ref1 : (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_template = _input_layout2.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorscale) !== null && _ref2 !== void 0 ? _ref2 : firstData.type === 'histogram2d' && ((_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : (_input_layout_template1 = _input_layout3.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_data = _input_layout_template1.data) === null || _input_layout_template_data === void 0 ? void 0 : (_input_layout_template_data_histogram2d = _input_layout_template_data.histogram2d) === null || _input_layout_template_data_histogram2d === void 0 ? void 0 : (_input_layout_template_data_histogram2d_ = _input_layout_template_data_histogram2d[0]) === null || _input_layout_template_data_histogram2d_ === void 0 ? void 0 : _input_layout_template_data_histogram2d_.colorscale)) !== null && _ref3 !== void 0 ? _ref3 : (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : (_input_layout_template2 = _input_layout4.template) === null || _input_layout_template2 === void 0 ? void 0 : (_input_layout_template_data1 = _input_layout_template2.data) === null || _input_layout_template_data1 === void 0 ? void 0 : (_input_layout_template_data_heatmap = _input_layout_template_data1.heatmap) === null || _input_layout_template_data_heatmap === void 0 ? void 0 : (_input_layout_template_data_heatmap_ = _input_layout_template_data_heatmap[0]) === null || _input_layout_template_data_heatmap_ === void 0 ? void 0 : _input_layout_template_data_heatmap_.colorscale;
|
|
764
|
+
// determine if the types diverging, sequential or sequentialminus are present in colorscale
|
|
765
|
+
if (colorscale && typeof colorscale === 'object' && ('diverging' in colorscale || 'sequential' in colorscale || 'sequentialminus' in colorscale)) {
|
|
766
|
+
const isDivergent = zMin < 0 && zMax > 0; // Data spans both positive and negative values
|
|
767
|
+
const isSequential = zMin >= 0; // Data is entirely positive
|
|
768
|
+
const isSequentialMinus = zMax <= 0; // Data is entirely negative
|
|
769
|
+
if (isDivergent) {
|
|
770
|
+
colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.diverging;
|
|
771
|
+
} else if (isSequential) {
|
|
772
|
+
colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.sequential;
|
|
773
|
+
} else if (isSequentialMinus) {
|
|
774
|
+
colorscale = colorscale === null || colorscale === void 0 ? void 0 : colorscale.sequentialminus;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
const domainValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[0] * (zMax - zMin) + zMin) : defaultDomain;
|
|
778
|
+
const rangeValuesForColorScale = Array.isArray(colorscale) ? colorscale.map((arr)=>arr[1]) : defaultRange;
|
|
592
779
|
const { chartTitle, xAxisTitle, yAxisTitle } = getTitles(input.layout);
|
|
593
780
|
var _input_layout_height;
|
|
594
781
|
return {
|
|
@@ -603,24 +790,33 @@ export const transformPlotlyJsonToHeatmapProps = (input)=>{
|
|
|
603
790
|
xAxisTitle,
|
|
604
791
|
yAxisTitle,
|
|
605
792
|
sortOrder: 'none',
|
|
606
|
-
width: (
|
|
607
|
-
height: (_input_layout_height = (
|
|
793
|
+
width: (_input_layout5 = input.layout) === null || _input_layout5 === void 0 ? void 0 : _input_layout5.width,
|
|
794
|
+
height: (_input_layout_height = (_input_layout6 = input.layout) === null || _input_layout6 === void 0 ? void 0 : _input_layout6.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
608
795
|
hideTickOverlap: true,
|
|
609
796
|
noOfCharsToTruncate: 20,
|
|
610
797
|
showYAxisLablesTooltip: true,
|
|
611
|
-
wrapXAxisLables: true
|
|
798
|
+
wrapXAxisLables: true,
|
|
799
|
+
...getAxisCategoryOrderProps([
|
|
800
|
+
firstData
|
|
801
|
+
], input.layout)
|
|
612
802
|
};
|
|
613
803
|
};
|
|
614
|
-
export const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
804
|
+
export const transformPlotlyJsonToSankeyProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
615
805
|
var _input_layout_template_layout, _input_layout_template, _input_layout, _node_label, _input_layout1, _input_layout2;
|
|
616
806
|
const { link, node } = input.data[0];
|
|
617
807
|
var _link_value;
|
|
618
|
-
const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>
|
|
808
|
+
const validLinks = ((_link_value = link === null || link === void 0 ? void 0 : link.value) !== null && _link_value !== void 0 ? _link_value : []).map((val, index)=>{
|
|
809
|
+
var _link_source, _link_target;
|
|
810
|
+
if (isInvalidValue(val) || isInvalidValue(link === null || link === void 0 ? void 0 : (_link_source = link.source) === null || _link_source === void 0 ? void 0 : _link_source[index]) || isInvalidValue(link === null || link === void 0 ? void 0 : (_link_target = link.target) === null || _link_target === void 0 ? void 0 : _link_target[index])) {
|
|
811
|
+
return null;
|
|
812
|
+
}
|
|
813
|
+
return {
|
|
619
814
|
value: val,
|
|
620
815
|
source: link === null || link === void 0 ? void 0 : link.source[index],
|
|
621
816
|
target: link === null || link === void 0 ? void 0 : link.target[index]
|
|
622
|
-
}
|
|
623
|
-
|
|
817
|
+
};
|
|
818
|
+
})// Filter out negative nodes, unequal nodes and self-references (circular links)
|
|
819
|
+
.filter((x)=>x !== null && x.source >= 0 && x.target >= 0 && x.source !== x.target);
|
|
624
820
|
const extractedNodeColors = 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);
|
|
625
821
|
const sankeyChartData = {
|
|
626
822
|
nodes: (_node_label = node.label) === null || _node_label === void 0 ? void 0 : _node_label.map((label, index)=>{
|
|
@@ -654,7 +850,7 @@ export const transformPlotlyJsonToSankeyProps = (input, colorMap, colorwayType,
|
|
|
654
850
|
height: (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 468
|
|
655
851
|
};
|
|
656
852
|
};
|
|
657
|
-
export const transformPlotlyJsonToGaugeProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
853
|
+
export const transformPlotlyJsonToGaugeProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
658
854
|
var _firstData_gauge, _input_layout_template_layout, _input_layout_template, _input_layout, _firstData_gauge_steps, _firstData_gauge1, _firstData_gauge_axis_range, _firstData_gauge_axis, _firstData_gauge2, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _firstData_gauge_axis1, _firstData_gauge3, _firstData_gauge_axis_range1, _firstData_gauge_axis2, _firstData_gauge4, _firstData_delta, _firstData_gauge_axis_range2, _firstData_gauge_axis3, _firstData_gauge5, _firstData_gauge_axis_range3, _firstData_gauge_axis4, _firstData_gauge6, _firstData_gauge_axis_range4, _firstData_gauge_axis5, _firstData_gauge7, _firstData_gauge_axis_range5, _firstData_gauge_axis6, _firstData_gauge8, _input_layout2, _input_layout3, _firstData_gauge_steps1, _firstData_gauge9;
|
|
659
855
|
const firstData = input.data[0];
|
|
660
856
|
const stepsColors = ((_firstData_gauge = firstData.gauge) === null || _firstData_gauge === void 0 ? void 0 : _firstData_gauge.steps) ? firstData.gauge.steps.map((step)=>step.color) : undefined;
|
|
@@ -729,40 +925,148 @@ export const transformPlotlyJsonToGaugeProps = (input, colorMap, colorwayType, i
|
|
|
729
925
|
const cleanText = (text)=>{
|
|
730
926
|
return text.replace(/<[^&]*?>/g, '').replace(/<[^>]*>/g, '').replace(/<br>|\\u003cbr\\u003e|<br>/gi, '').replace(/\$[^$]*\$/g, '$').trim();
|
|
731
927
|
};
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
928
|
+
const formatValue = (value, colIndex, cells)=>{
|
|
929
|
+
if (value === null || typeof value === 'boolean') {
|
|
930
|
+
return value;
|
|
931
|
+
}
|
|
932
|
+
const formatStr = Array.isArray(cells.format) ? cells.format[colIndex] : cells.format;
|
|
933
|
+
const prefix = Array.isArray(cells.prefix) ? cells.prefix[colIndex] : cells.prefix;
|
|
934
|
+
const suffix = Array.isArray(cells.suffix) ? cells.suffix[colIndex] : cells.suffix;
|
|
935
|
+
let formatted = value;
|
|
936
|
+
if (typeof value === 'number') {
|
|
937
|
+
if (typeof formatStr === 'string') {
|
|
938
|
+
try {
|
|
939
|
+
formatted = d3Format(formatStr)(value);
|
|
940
|
+
} catch {
|
|
941
|
+
formatted = formatScientificLimitWidth(value);
|
|
942
|
+
}
|
|
943
|
+
} else {
|
|
944
|
+
formatted = formatScientificLimitWidth(value);
|
|
739
945
|
}
|
|
740
|
-
|
|
741
|
-
|
|
946
|
+
}
|
|
947
|
+
return `${prefix !== null && prefix !== void 0 ? prefix : ''}${formatted}${suffix !== null && suffix !== void 0 ? suffix : ''}`;
|
|
948
|
+
};
|
|
949
|
+
export const transformPlotlyJsonToChartTableProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
950
|
+
var _tableData_cells, _input_layout_template_data, _input_layout_template, _input_layout, _input_layout_font, _input_layout1, _tableData_header, _tableData_header1, _input_layout_template_data1, _input_layout_template1, _input_layout2, _input_layout3, _input_layout4;
|
|
951
|
+
const tableData = input.data[0];
|
|
952
|
+
const normalizeHeaders = (values, header)=>{
|
|
953
|
+
const cleanedValues = Array.isArray(values[0]) ? values.map((row)=>row.map((cell)=>cleanText(cell)).filter(Boolean).join(' ')) : values.map((cell)=>cleanText(cell));
|
|
954
|
+
return cleanedValues.map((value, colIndex)=>{
|
|
955
|
+
var _header_font, _header_font1, _header_fill;
|
|
956
|
+
const fontColorRaw = header === null || header === void 0 ? void 0 : (_header_font = header.font) === null || _header_font === void 0 ? void 0 : _header_font.color;
|
|
957
|
+
let fontColor;
|
|
958
|
+
if (Array.isArray(fontColorRaw)) {
|
|
959
|
+
const colorEntry = fontColorRaw[colIndex];
|
|
960
|
+
if (Array.isArray(colorEntry)) {
|
|
961
|
+
fontColor = typeof colorEntry[0] === 'string' ? colorEntry[0] : undefined;
|
|
962
|
+
} else if (typeof colorEntry === 'string') {
|
|
963
|
+
fontColor = colorEntry;
|
|
964
|
+
}
|
|
965
|
+
} else if (typeof fontColorRaw === 'string') {
|
|
966
|
+
fontColor = fontColorRaw;
|
|
967
|
+
}
|
|
968
|
+
const fontSizeRaw = header === null || header === void 0 ? void 0 : (_header_font1 = header.font) === null || _header_font1 === void 0 ? void 0 : _header_font1.size;
|
|
969
|
+
let fontSize;
|
|
970
|
+
if (Array.isArray(fontSizeRaw)) {
|
|
971
|
+
fontSize = Array.isArray(fontSizeRaw[0]) ? fontSizeRaw[0][colIndex] : fontSizeRaw[colIndex];
|
|
972
|
+
} else if (typeof fontSizeRaw === 'number') {
|
|
973
|
+
fontSize = fontSizeRaw;
|
|
974
|
+
}
|
|
975
|
+
const updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
976
|
+
const fillColorRaw = header === null || header === void 0 ? void 0 : (_header_fill = header.fill) === null || _header_fill === void 0 ? void 0 : _header_fill.color;
|
|
977
|
+
const backgroundColor = Array.isArray(fillColorRaw) ? fillColorRaw[updatedColIndex] : fillColorRaw;
|
|
978
|
+
const textAlignRaw = header === null || header === void 0 ? void 0 : header.align;
|
|
979
|
+
const textAlign = Array.isArray(textAlignRaw) ? textAlignRaw[colIndex] : textAlignRaw;
|
|
980
|
+
const style = {
|
|
981
|
+
...typeof fontColor === 'string' ? {
|
|
982
|
+
color: fontColor
|
|
983
|
+
} : {},
|
|
984
|
+
...typeof fontSize === 'number' ? {
|
|
985
|
+
fontSize
|
|
986
|
+
} : {},
|
|
987
|
+
...typeof backgroundColor === 'string' ? {
|
|
988
|
+
backgroundColor
|
|
989
|
+
} : {},
|
|
990
|
+
...textAlign ? {
|
|
991
|
+
textAlign
|
|
992
|
+
} : {}
|
|
993
|
+
};
|
|
994
|
+
return {
|
|
995
|
+
value,
|
|
996
|
+
style
|
|
997
|
+
};
|
|
998
|
+
});
|
|
742
999
|
};
|
|
743
1000
|
var _tableData_cells_values;
|
|
744
1001
|
const columns = (_tableData_cells_values = (_tableData_cells = tableData.cells) === null || _tableData_cells === void 0 ? void 0 : _tableData_cells.values) !== null && _tableData_cells_values !== void 0 ? _tableData_cells_values : [];
|
|
745
|
-
const
|
|
746
|
-
|
|
1002
|
+
const cells = tableData.cells.font ? tableData.cells : (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_data = _input_layout_template.data) === null || _input_layout_template_data === void 0 ? void 0 : _input_layout_template_data.table[0].cells;
|
|
1003
|
+
const rows = columns[0].map((_, rowIndex)=>columns.map((col, colIndex)=>{
|
|
1004
|
+
var _cells_font, _cells_font1, _cells_fill;
|
|
1005
|
+
const cellValue = col[rowIndex];
|
|
1006
|
+
const cleanValue = typeof cellValue === 'string' ? cleanText(cellValue) : cellValue;
|
|
1007
|
+
const formattedValue = typeof cleanValue === 'string' || typeof cleanValue === 'number' ? formatValue(cleanValue, colIndex, cells) : cleanValue;
|
|
1008
|
+
const rawFontColor = cells === null || cells === void 0 ? void 0 : (_cells_font = cells.font) === null || _cells_font === void 0 ? void 0 : _cells_font.color;
|
|
1009
|
+
let fontColor;
|
|
1010
|
+
if (Array.isArray(rawFontColor)) {
|
|
1011
|
+
const entry = rawFontColor[colIndex];
|
|
1012
|
+
const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1013
|
+
fontColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
1014
|
+
} else if (typeof rawFontColor === 'string') {
|
|
1015
|
+
fontColor = rawFontColor;
|
|
1016
|
+
}
|
|
1017
|
+
const rawFontSize = cells === null || cells === void 0 ? void 0 : (_cells_font1 = cells.font) === null || _cells_font1 === void 0 ? void 0 : _cells_font1.size;
|
|
1018
|
+
let fontSize;
|
|
1019
|
+
if (Array.isArray(rawFontSize)) {
|
|
1020
|
+
const entry = rawFontSize[colIndex];
|
|
1021
|
+
const fontSizeValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1022
|
+
fontSize = typeof fontSizeValue === 'number' ? fontSizeValue : undefined;
|
|
1023
|
+
} else if (typeof rawFontSize === 'number') {
|
|
1024
|
+
fontSize = rawFontSize;
|
|
1025
|
+
}
|
|
1026
|
+
const updatedColIndex = colIndex >= 1 ? 1 : 0;
|
|
1027
|
+
const rawBackgroundColor = cells === null || cells === void 0 ? void 0 : (_cells_fill = cells.fill) === null || _cells_fill === void 0 ? void 0 : _cells_fill.color;
|
|
1028
|
+
let backgroundColor;
|
|
1029
|
+
if (Array.isArray(rawBackgroundColor)) {
|
|
1030
|
+
const entry = rawBackgroundColor[updatedColIndex];
|
|
1031
|
+
const colorValue = Array.isArray(entry) ? entry[rowIndex] : entry;
|
|
1032
|
+
backgroundColor = typeof colorValue === 'string' ? colorValue : undefined;
|
|
1033
|
+
} else if (typeof rawBackgroundColor === 'string') {
|
|
1034
|
+
backgroundColor = rawBackgroundColor;
|
|
1035
|
+
}
|
|
1036
|
+
const rawTextAlign = Array.isArray(cells === null || cells === void 0 ? void 0 : cells.align) ? cells.align[colIndex] : cells === null || cells === void 0 ? void 0 : cells.align;
|
|
1037
|
+
const textAlign = rawTextAlign;
|
|
1038
|
+
const style = {
|
|
1039
|
+
...fontColor ? {
|
|
1040
|
+
color: fontColor
|
|
1041
|
+
} : {},
|
|
1042
|
+
...typeof fontSize === 'number' ? {
|
|
1043
|
+
fontSize
|
|
1044
|
+
} : {},
|
|
1045
|
+
...backgroundColor ? {
|
|
1046
|
+
backgroundColor
|
|
1047
|
+
} : {},
|
|
1048
|
+
...textAlign ? {
|
|
1049
|
+
textAlign
|
|
1050
|
+
} : {}
|
|
1051
|
+
};
|
|
747
1052
|
return {
|
|
748
|
-
value:
|
|
1053
|
+
value: formattedValue,
|
|
1054
|
+
style
|
|
749
1055
|
};
|
|
750
1056
|
}));
|
|
751
1057
|
const styles = {
|
|
752
1058
|
root: {
|
|
753
|
-
...((
|
|
1059
|
+
...((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_font = _input_layout1.font) === null || _input_layout_font === void 0 ? void 0 : _input_layout_font.size) ? {
|
|
754
1060
|
fontSize: input.layout.font.size
|
|
755
1061
|
} : {}
|
|
756
1062
|
}
|
|
757
1063
|
};
|
|
758
1064
|
var _tableData_header_values;
|
|
759
1065
|
return {
|
|
760
|
-
headers: normalizeHeaders((_tableData_header_values = (_tableData_header = tableData.header) === null || _tableData_header === void 0 ? void 0 : _tableData_header.values) !== null && _tableData_header_values !== void 0 ? _tableData_header_values : []).
|
|
761
|
-
value
|
|
762
|
-
})),
|
|
1066
|
+
headers: normalizeHeaders((_tableData_header_values = (_tableData_header = tableData.header) === null || _tableData_header === void 0 ? void 0 : _tableData_header.values) !== null && _tableData_header_values !== void 0 ? _tableData_header_values : [], ((_tableData_header1 = tableData.header) === null || _tableData_header1 === void 0 ? void 0 : _tableData_header1.font) ? tableData.header : (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : (_input_layout_template1 = _input_layout2.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_data1 = _input_layout_template1.data) === null || _input_layout_template_data1 === void 0 ? void 0 : _input_layout_template_data1.table[0].header),
|
|
763
1067
|
rows,
|
|
764
|
-
width: (
|
|
765
|
-
height: (
|
|
1068
|
+
width: (_input_layout3 = input.layout) === null || _input_layout3 === void 0 ? void 0 : _input_layout3.width,
|
|
1069
|
+
height: (_input_layout4 = input.layout) === null || _input_layout4 === void 0 ? void 0 : _input_layout4.height,
|
|
766
1070
|
styles
|
|
767
1071
|
};
|
|
768
1072
|
};
|
|
@@ -771,14 +1075,20 @@ export const projectPolarToCartesian = (input)=>{
|
|
|
771
1075
|
...input
|
|
772
1076
|
};
|
|
773
1077
|
for(let sindex = 0; sindex < input.data.length; sindex++){
|
|
1078
|
+
var _series_r;
|
|
774
1079
|
const series = input.data[sindex];
|
|
775
1080
|
series.x = [];
|
|
776
1081
|
series.y = [];
|
|
777
|
-
|
|
1082
|
+
var _series_r_length;
|
|
1083
|
+
for(let ptindex = 0; ptindex < ((_series_r_length = (_series_r = series.r) === null || _series_r === void 0 ? void 0 : _series_r.length) !== null && _series_r_length !== void 0 ? _series_r_length : 0); ptindex++){
|
|
1084
|
+
var _series_theta, _series_r1;
|
|
1085
|
+
if (isInvalidValue((_series_theta = series.theta) === null || _series_theta === void 0 ? void 0 : _series_theta[ptindex]) || isInvalidValue((_series_r1 = series.r) === null || _series_r1 === void 0 ? void 0 : _series_r1[ptindex])) {
|
|
1086
|
+
continue;
|
|
1087
|
+
}
|
|
778
1088
|
const thetaRad = series.theta[ptindex] * Math.PI / 180;
|
|
779
1089
|
const radius = series.r[ptindex];
|
|
780
|
-
series.x
|
|
781
|
-
series.y
|
|
1090
|
+
series.x.push(radius * Math.cos(thetaRad));
|
|
1091
|
+
series.y.push(radius * Math.sin(thetaRad));
|
|
782
1092
|
}
|
|
783
1093
|
projection.data[sindex] = series;
|
|
784
1094
|
}
|
|
@@ -857,11 +1167,6 @@ function getLineOptions(line) {
|
|
|
857
1167
|
}
|
|
858
1168
|
return Object.keys(lineOptions).length > 0 ? lineOptions : undefined;
|
|
859
1169
|
}
|
|
860
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
861
|
-
const isStringArray = (arr)=>{
|
|
862
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
863
|
-
return isArrayOfType(arr, (value)=>typeof value === 'string');
|
|
864
|
-
};
|
|
865
1170
|
// TODO: Use binary search to find the appropriate bin for numeric value.
|
|
866
1171
|
const findBinIndex = (bins, value, isString)=>{
|
|
867
1172
|
if (typeof value === 'undefined' || value === null) {
|
|
@@ -956,7 +1261,46 @@ const precisionRound = (value, precision)=>{
|
|
|
956
1261
|
const factor = Math.pow(10, precision);
|
|
957
1262
|
return Math.round(value * factor) / factor;
|
|
958
1263
|
};
|
|
959
|
-
const
|
|
1264
|
+
const getLegendShape = (series)=>{
|
|
1265
|
+
var _series_line, _series_mode;
|
|
1266
|
+
const dashType = ((_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.dash) || 'solid';
|
|
1267
|
+
if (dashType === 'dot' || dashType === 'dash' || dashType === 'dashdot') {
|
|
1268
|
+
return 'dottedLine';
|
|
1269
|
+
} else if ((_series_mode = series.mode) === null || _series_mode === void 0 ? void 0 : _series_mode.includes('markers')) {
|
|
1270
|
+
return 'circle';
|
|
1271
|
+
}
|
|
1272
|
+
return 'default';
|
|
1273
|
+
};
|
|
1274
|
+
export const getAllupLegendsProps = (input, colorMap, colorwayType, isDarkTheme)=>{
|
|
1275
|
+
const allupLegends = [];
|
|
1276
|
+
// reduce on showlegend boolean propperty. reduce should return true if at least one series has showlegend true
|
|
1277
|
+
const toShowLegend = input.data.reduce((acc, series)=>{
|
|
1278
|
+
return acc || series.showlegend === true;
|
|
1279
|
+
}, false);
|
|
1280
|
+
if (toShowLegend) {
|
|
1281
|
+
input.data.forEach((series, index)=>{
|
|
1282
|
+
var _series_line, _series_marker, _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
1283
|
+
const name = series.legendgroup;
|
|
1284
|
+
const color = ((_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);
|
|
1285
|
+
const legendShape = getLegendShape(series);
|
|
1286
|
+
const resolvedColor = 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, color, colorMap, isDarkTheme);
|
|
1287
|
+
if (name !== undefined && allupLegends.some((group)=>group.title === name) === false) {
|
|
1288
|
+
allupLegends.push({
|
|
1289
|
+
title: name,
|
|
1290
|
+
color: resolvedColor,
|
|
1291
|
+
shape: legendShape
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
return {
|
|
1297
|
+
legends: allupLegends,
|
|
1298
|
+
centerLegends: true,
|
|
1299
|
+
enabledWrapLines: true,
|
|
1300
|
+
canSelectMultipleLegends: true
|
|
1301
|
+
};
|
|
1302
|
+
};
|
|
1303
|
+
const getLegendProps = (data, layout, isMultiPlot)=>{
|
|
960
1304
|
const legends = [];
|
|
961
1305
|
if (data.length === 1) {
|
|
962
1306
|
legends.push(data[0].name || '');
|
|
@@ -965,9 +1309,257 @@ const getLegendProps = (data, layout)=>{
|
|
|
965
1309
|
legends.push(series.name || `Series ${index + 1}`);
|
|
966
1310
|
});
|
|
967
1311
|
}
|
|
968
|
-
const
|
|
1312
|
+
const hideLegendsData = data.every((series)=>series.showlegend === false);
|
|
1313
|
+
const hideLegendsInferred = (layout === null || layout === void 0 ? void 0 : layout.showlegend) === false || (layout === null || layout === void 0 ? void 0 : layout.showlegend) !== true && legends.length < 2;
|
|
969
1314
|
return {
|
|
970
1315
|
legends,
|
|
971
|
-
hideLegend:
|
|
1316
|
+
hideLegend: isMultiPlot || hideLegendsInferred || hideLegendsData
|
|
972
1317
|
};
|
|
973
1318
|
};
|
|
1319
|
+
export const getNumberAtIndexOrDefault = (data, index)=>{
|
|
1320
|
+
if (isArrayOrTypedArray(data)) {
|
|
1321
|
+
if (typeof data[index] !== 'number' || !isFinite(data[index])) {
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
return data[index];
|
|
1325
|
+
}
|
|
1326
|
+
return 1;
|
|
1327
|
+
};
|
|
1328
|
+
export const getValidXYRanges = (series)=>{
|
|
1329
|
+
if (!isArrayOrTypedArray(series.x) || !isArrayOrTypedArray(series.y)) {
|
|
1330
|
+
return [];
|
|
1331
|
+
}
|
|
1332
|
+
const ranges = [];
|
|
1333
|
+
let start = 0;
|
|
1334
|
+
let end = 0;
|
|
1335
|
+
for(; end < series.x.length; end++){
|
|
1336
|
+
if (isInvalidValue(series.x[end]) || isInvalidValue(series.y[end])) {
|
|
1337
|
+
if (end - start > 0) {
|
|
1338
|
+
ranges.push([
|
|
1339
|
+
start,
|
|
1340
|
+
end
|
|
1341
|
+
]);
|
|
1342
|
+
}
|
|
1343
|
+
start = end + 1;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
if (end - start > 0) {
|
|
1347
|
+
ranges.push([
|
|
1348
|
+
start,
|
|
1349
|
+
end
|
|
1350
|
+
]);
|
|
1351
|
+
}
|
|
1352
|
+
return ranges;
|
|
1353
|
+
};
|
|
1354
|
+
const getIndexFromKey = (key, pattern)=>{
|
|
1355
|
+
const normalizedKey = key.replace(pattern, '') === '' ? '1' : key.replace(pattern, '');
|
|
1356
|
+
return parseInt(normalizedKey, 10) - 1;
|
|
1357
|
+
};
|
|
1358
|
+
export const getGridProperties = (layout, isMultiPlot)=>{
|
|
1359
|
+
var _layout_annotations;
|
|
1360
|
+
const gridX = [];
|
|
1361
|
+
const gridY = [];
|
|
1362
|
+
const annotations = {};
|
|
1363
|
+
let templateRows = '1fr';
|
|
1364
|
+
let templateColumns = '1fr';
|
|
1365
|
+
const gridLayout = {};
|
|
1366
|
+
if (layout === undefined || layout === null || Object.keys(layout).length === 0) {
|
|
1367
|
+
return {
|
|
1368
|
+
templateRows,
|
|
1369
|
+
templateColumns,
|
|
1370
|
+
layout: gridLayout
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
if (!layout.xaxis || !layout.yaxis) {
|
|
1374
|
+
return {
|
|
1375
|
+
templateRows,
|
|
1376
|
+
templateColumns,
|
|
1377
|
+
layout: gridLayout
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
if (!isMultiPlot) {
|
|
1381
|
+
return {
|
|
1382
|
+
templateRows,
|
|
1383
|
+
templateColumns,
|
|
1384
|
+
layout: gridLayout
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
Object.keys(layout).forEach((key)=>{
|
|
1388
|
+
if (key.startsWith('xaxis')) {
|
|
1389
|
+
var _layout_key, _layout_key1;
|
|
1390
|
+
const index = getIndexFromKey(key, 'xaxis');
|
|
1391
|
+
var _layout_key_anchor;
|
|
1392
|
+
const anchor = (_layout_key_anchor = (_layout_key = layout[key]) === null || _layout_key === void 0 ? void 0 : _layout_key.anchor) !== null && _layout_key_anchor !== void 0 ? _layout_key_anchor : 'y';
|
|
1393
|
+
const anchorIndex = getIndexFromKey(anchor, 'y');
|
|
1394
|
+
if (index !== anchorIndex) {
|
|
1395
|
+
throw new Error(`Invalid layout: xaxis ${index + 1} anchor should be y${anchorIndex + 1}`);
|
|
1396
|
+
}
|
|
1397
|
+
var _layout_key_domain;
|
|
1398
|
+
gridX[index] = (_layout_key_domain = (_layout_key1 = layout[key]) === null || _layout_key1 === void 0 ? void 0 : _layout_key1.domain) !== null && _layout_key_domain !== void 0 ? _layout_key_domain : [];
|
|
1399
|
+
} else if (key.startsWith('yaxis')) {
|
|
1400
|
+
var _layout_key2, _layout_key3;
|
|
1401
|
+
const index = getIndexFromKey(key, 'yaxis');
|
|
1402
|
+
var _layout_key_anchor1;
|
|
1403
|
+
const anchor = (_layout_key_anchor1 = (_layout_key2 = layout[key]) === null || _layout_key2 === void 0 ? void 0 : _layout_key2.anchor) !== null && _layout_key_anchor1 !== void 0 ? _layout_key_anchor1 : 'x';
|
|
1404
|
+
const anchorIndex = getIndexFromKey(anchor, 'x');
|
|
1405
|
+
if (index !== anchorIndex) {
|
|
1406
|
+
var _layout_yaxis2;
|
|
1407
|
+
if (index === 1 && anchorIndex === 0 || ((_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.side) === 'right') {
|
|
1408
|
+
// Special case for secondary y axis where yaxis2 can anchor to x1
|
|
1409
|
+
return {
|
|
1410
|
+
templateRows,
|
|
1411
|
+
templateColumns
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
throw new Error(`Invalid layout: yaxis ${index + 1} anchor should be x${anchorIndex + 1}`);
|
|
1415
|
+
}
|
|
1416
|
+
var _layout_key_domain1;
|
|
1417
|
+
gridY[index] = (_layout_key_domain1 = (_layout_key3 = layout[key]) === null || _layout_key3 === void 0 ? void 0 : _layout_key3.domain) !== null && _layout_key_domain1 !== void 0 ? _layout_key_domain1 : [];
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
(_layout_annotations = layout.annotations) === null || _layout_annotations === void 0 ? void 0 : _layout_annotations.forEach((annotation)=>{
|
|
1421
|
+
const xMatches = gridX.flatMap((interval, idx)=>(annotation === null || annotation === void 0 ? void 0 : annotation.x) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.x) <= interval[1] ? [
|
|
1422
|
+
idx
|
|
1423
|
+
] : []);
|
|
1424
|
+
const yMatch = gridY.findIndex((interval, yIndex)=>xMatches.includes(yIndex) && (annotation === null || annotation === void 0 ? void 0 : annotation.y) >= interval[0] && (annotation === null || annotation === void 0 ? void 0 : annotation.y) <= interval[1]);
|
|
1425
|
+
if (yMatch !== -1) {
|
|
1426
|
+
if (annotations[yMatch] === undefined) {
|
|
1427
|
+
annotations[yMatch] = {};
|
|
1428
|
+
}
|
|
1429
|
+
if ((annotation === null || annotation === void 0 ? void 0 : annotation.textangle) === 90) {
|
|
1430
|
+
annotations[yMatch].yAnnotation = annotation.text;
|
|
1431
|
+
} else {
|
|
1432
|
+
annotations[yMatch].xAnnotation = annotation.text;
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
});
|
|
1436
|
+
if (gridX.length > 0) {
|
|
1437
|
+
const uniqueXIntervals = new Map();
|
|
1438
|
+
gridX.forEach((interval)=>{
|
|
1439
|
+
const key = `${interval[0]}-${interval[1]}`;
|
|
1440
|
+
if (!uniqueXIntervals.has(key)) {
|
|
1441
|
+
uniqueXIntervals.set(key, interval);
|
|
1442
|
+
}
|
|
1443
|
+
});
|
|
1444
|
+
const minXInterval = Math.min(...Array.from(uniqueXIntervals.values()).map((interval)=>interval[1] - interval[0]));
|
|
1445
|
+
templateColumns = Array.from(uniqueXIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minXInterval}fr`).join(' ');
|
|
1446
|
+
let columnNumber = 1;
|
|
1447
|
+
let lastIntervalEnd = 0;
|
|
1448
|
+
gridX.forEach((interval, index)=>{
|
|
1449
|
+
if (interval.length === 0) {
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
1453
|
+
const annotationProps = annotations[index];
|
|
1454
|
+
const xAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.xAnnotation;
|
|
1455
|
+
if (interval[0] < lastIntervalEnd) {
|
|
1456
|
+
columnNumber = 1;
|
|
1457
|
+
}
|
|
1458
|
+
lastIntervalEnd = interval[1];
|
|
1459
|
+
const row = {
|
|
1460
|
+
row: -1,
|
|
1461
|
+
column: columnNumber,
|
|
1462
|
+
xAnnotation
|
|
1463
|
+
};
|
|
1464
|
+
gridLayout[cellName] = row;
|
|
1465
|
+
columnNumber += 1;
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
const numColumns = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1469
|
+
var _cell_column;
|
|
1470
|
+
return (_cell_column = cell.column) !== null && _cell_column !== void 0 ? _cell_column : 0;
|
|
1471
|
+
}));
|
|
1472
|
+
const columnFill = {};
|
|
1473
|
+
for(let i = 1; i <= numColumns; i++){
|
|
1474
|
+
columnFill[i] = {
|
|
1475
|
+
row: 1,
|
|
1476
|
+
fillDomain: 0
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1479
|
+
if (gridY.length > 0) {
|
|
1480
|
+
const uniqueYIntervals = new Map();
|
|
1481
|
+
gridY.forEach((interval)=>{
|
|
1482
|
+
const key = `${interval[0]}-${interval[1]}`;
|
|
1483
|
+
if (!uniqueYIntervals.has(key)) {
|
|
1484
|
+
uniqueYIntervals.set(key, interval);
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
const minYInterval = Math.min(...Array.from(uniqueYIntervals.values()).map((interval)=>interval[1] - interval[0]));
|
|
1488
|
+
templateRows = Array.from(uniqueYIntervals.values()).map((interval)=>`${(interval[1] - interval[0]) / minYInterval}fr`).join(' ');
|
|
1489
|
+
gridY.forEach((interval, index)=>{
|
|
1490
|
+
if (interval.length === 0) {
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
const cellName = `x${index === 0 ? '' : index + 1}`;
|
|
1494
|
+
const annotationProps = annotations[index];
|
|
1495
|
+
const yAnnotation = annotationProps === null || annotationProps === void 0 ? void 0 : annotationProps.yAnnotation;
|
|
1496
|
+
const cell = gridLayout[cellName];
|
|
1497
|
+
if (cell !== undefined) {
|
|
1498
|
+
cell.row = columnFill[cell.column].row;
|
|
1499
|
+
cell.yAnnotation = yAnnotation;
|
|
1500
|
+
}
|
|
1501
|
+
columnFill[cell.column].fillDomain = interval[1];
|
|
1502
|
+
columnFill[cell.column].row += 1;
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
// reverse the order of rows in grid layout from bottom-top to top-bottom as required by CSS grid
|
|
1506
|
+
const reversedGridLayout = {};
|
|
1507
|
+
// find the maximum row number
|
|
1508
|
+
const maxRowNumber = Math.max(...Object.values(gridLayout).map((cell)=>{
|
|
1509
|
+
var _cell_row;
|
|
1510
|
+
return (_cell_row = cell.row) !== null && _cell_row !== void 0 ? _cell_row : 0;
|
|
1511
|
+
}));
|
|
1512
|
+
// iterate over the gridLayout and reverse the row numbers
|
|
1513
|
+
Object.keys(gridLayout).forEach((key)=>{
|
|
1514
|
+
const cell = gridLayout[key];
|
|
1515
|
+
if (cell.row !== undefined) {
|
|
1516
|
+
// reverse the row number
|
|
1517
|
+
cell.row = maxRowNumber - cell.row + 1;
|
|
1518
|
+
}
|
|
1519
|
+
reversedGridLayout[key] = cell;
|
|
1520
|
+
});
|
|
1521
|
+
return {
|
|
1522
|
+
templateRows,
|
|
1523
|
+
templateColumns,
|
|
1524
|
+
layout: reversedGridLayout
|
|
1525
|
+
};
|
|
1526
|
+
};
|
|
1527
|
+
/**
|
|
1528
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/category_order_defaults.js#L50}
|
|
1529
|
+
*/ const getAxisCategoryOrderProps = (data, layout)=>{
|
|
1530
|
+
const result = {};
|
|
1531
|
+
const axesById = {
|
|
1532
|
+
x: layout === null || layout === void 0 ? void 0 : layout.xaxis,
|
|
1533
|
+
y: layout === null || layout === void 0 ? void 0 : layout.yaxis
|
|
1534
|
+
};
|
|
1535
|
+
Object.keys(axesById).forEach((axId)=>{
|
|
1536
|
+
const ax = axesById[axId];
|
|
1537
|
+
const axLetter = axId[0];
|
|
1538
|
+
const propName = `${axLetter}AxisCategoryOrder`;
|
|
1539
|
+
const values = [];
|
|
1540
|
+
data.forEach((series)=>{
|
|
1541
|
+
var _series_axLetter;
|
|
1542
|
+
(_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
|
|
1543
|
+
if (!isInvalidValue(val)) {
|
|
1544
|
+
values.push(val);
|
|
1545
|
+
}
|
|
1546
|
+
});
|
|
1547
|
+
});
|
|
1548
|
+
const isAxisTypeCategory = (ax === null || ax === void 0 ? void 0 : ax.type) === 'category' || isStringArray(values) && !isNumberArray(values) && !isDateArray(values);
|
|
1549
|
+
if (!isAxisTypeCategory) {
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
const isValidArray = isArrayOrTypedArray(ax === null || ax === void 0 ? void 0 : ax.categoryarray) && ax.categoryarray.length > 0;
|
|
1553
|
+
if (isValidArray && (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'array')) {
|
|
1554
|
+
result[propName] = ax.categoryarray;
|
|
1555
|
+
return;
|
|
1556
|
+
}
|
|
1557
|
+
if (!(ax === null || ax === void 0 ? void 0 : ax.categoryorder) || ax.categoryorder === 'trace' || ax.categoryorder === 'array') {
|
|
1558
|
+
const categoriesInTraceOrder = Array.from(new Set(values));
|
|
1559
|
+
result[propName] = categoriesInTraceOrder;
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
result[propName] = ax.categoryorder;
|
|
1563
|
+
});
|
|
1564
|
+
return result;
|
|
1565
|
+
};
|