@fluentui/react-charts 0.0.0-nightly-20251015-0406.1 → 0.0.0-nightly-20251017-0406.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -15
- package/dist/index.d.ts +130 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +1 -2
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +249 -103
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +332 -114
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib/components/Legends/Legends.js +1 -1
- package/lib/components/Legends/Legends.js.map +1 -1
- package/lib/types/DataPoint.js +1 -3
- package/lib/types/DataPoint.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +1 -2
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +248 -102
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +329 -112
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
- package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
- package/lib-commonjs/components/Legends/Legends.js +1 -1
- package/lib-commonjs/components/Legends/Legends.js.map +1 -1
- package/lib-commonjs/types/DataPoint.js +1 -3
- package/lib-commonjs/types/DataPoint.js.map +1 -1
- package/package.json +13 -13
|
@@ -5,7 +5,7 @@ import { scaleLinear as d3ScaleLinear } from 'd3-scale';
|
|
|
5
5
|
import { format as d3Format } from 'd3-format';
|
|
6
6
|
import { DataVizPalette, getColorFromToken } from '../../utilities/colors';
|
|
7
7
|
import { DEFAULT_DATE_STRING, findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS, calculatePrecision, precisionRound } from '../../utilities/utilities';
|
|
8
|
-
import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, formatToLocaleString, isNumber, isObjectArray, getAxisIds, getAxisKey } from '@fluentui/chart-utilities';
|
|
8
|
+
import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, formatToLocaleString, isNumber, isObjectArray, getAxisIds, getAxisKey, isScatterAreaChart } from '@fluentui/chart-utilities';
|
|
9
9
|
import { curveCardinal as d3CurveCardinal } from 'd3-shape';
|
|
10
10
|
import { getOpacity, extractColor, resolveColor, createColorScale } from './PlotlyColorAdapter';
|
|
11
11
|
import { rgb } from 'd3-color';
|
|
@@ -140,11 +140,12 @@ const usesSecondaryYScale = (series, layout)=>{
|
|
|
140
140
|
var _layout_yaxis2, _layout_yaxis21;
|
|
141
141
|
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');
|
|
142
142
|
};
|
|
143
|
-
const getSecondaryYAxisValues = (data, layout
|
|
143
|
+
const getSecondaryYAxisValues = (data, layout)=>{
|
|
144
144
|
var _layout_yaxis2, _layout_yaxis21, _layout_yaxis2_title, _layout_yaxis22;
|
|
145
145
|
let containsSecondaryYAxis = false;
|
|
146
146
|
let yMinValue;
|
|
147
147
|
let yMaxValue;
|
|
148
|
+
let allLineSeries = true;
|
|
148
149
|
data.forEach((series)=>{
|
|
149
150
|
if (usesSecondaryYScale(series, layout)) {
|
|
150
151
|
containsSecondaryYAxis = true;
|
|
@@ -153,16 +154,21 @@ const getSecondaryYAxisValues = (data, layout, maxAllowedMinY, minAllowedMaxY)=>
|
|
|
153
154
|
yMinValue = Math.min(...yValues);
|
|
154
155
|
yMaxValue = Math.max(...yValues);
|
|
155
156
|
}
|
|
157
|
+
if (series.type !== 'scatter' || isScatterAreaChart(series)) {
|
|
158
|
+
allLineSeries = false;
|
|
159
|
+
}
|
|
156
160
|
}
|
|
157
161
|
});
|
|
158
162
|
if (!containsSecondaryYAxis) {
|
|
159
163
|
return {};
|
|
160
164
|
}
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
if (!allLineSeries) {
|
|
166
|
+
if (typeof yMinValue === 'number') {
|
|
167
|
+
yMinValue = Math.min(yMinValue, 0);
|
|
168
|
+
}
|
|
169
|
+
if (typeof yMaxValue === 'number') {
|
|
170
|
+
yMaxValue = Math.max(yMaxValue, 0);
|
|
171
|
+
}
|
|
166
172
|
}
|
|
167
173
|
if (layout === null || layout === void 0 ? void 0 : (_layout_yaxis2 = layout.yaxis2) === null || _layout_yaxis2 === void 0 ? void 0 : _layout_yaxis2.range) {
|
|
168
174
|
yMinValue = layout.yaxis2.range[0];
|
|
@@ -403,27 +409,23 @@ export const transformPlotlyJsonToDonutProps = (input, isMultiPlot, colorMap, co
|
|
|
403
409
|
};
|
|
404
410
|
};
|
|
405
411
|
export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme, fallbackVSBC)=>{
|
|
406
|
-
var _input_layout, _input_layout1, _vsbcData_;
|
|
412
|
+
var _input_data_, _input_layout, _input_layout1, _input_layout2, _vsbcData_;
|
|
407
413
|
const mapXToDataPoints = {};
|
|
408
414
|
let yMaxValue = 0;
|
|
415
|
+
let yMinValue = 0;
|
|
409
416
|
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
410
417
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
411
418
|
let colorScale = undefined;
|
|
412
419
|
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
413
|
-
|
|
420
|
+
const resolveXAxisValue = getAxisValueResolver(input.data, input.layout, 'x');
|
|
414
421
|
input.data.forEach((series, index1)=>{
|
|
415
422
|
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_line;
|
|
416
423
|
colorScale = createColorScale(input.layout, series, colorScale);
|
|
417
|
-
const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
|
|
418
424
|
// extract bar colors for each series only once
|
|
419
425
|
const extractedBarColors = extractColor((_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : (_input_layout_template = _input_layout.template) === null || _input_layout_template === void 0 ? void 0 : (_input_layout_template_layout = _input_layout_template.layout) === null || _input_layout_template_layout === void 0 ? void 0 : _input_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
420
426
|
// extract line colors for each series only once
|
|
421
427
|
const extractedLineColors = extractColor((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, colorwayType, (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
|
|
422
|
-
const
|
|
423
|
-
const isXDate = isDateArray(xValues);
|
|
424
|
-
const isXString = isStringArray(xValues);
|
|
425
|
-
const isXNumber = isNumberArray(xValues);
|
|
426
|
-
const validXYRanges = getValidXYRanges(series);
|
|
428
|
+
const validXYRanges = getValidXYRanges(series, resolveXAxisValue);
|
|
427
429
|
validXYRanges.forEach(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
428
430
|
const rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
429
431
|
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
@@ -431,7 +433,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
431
433
|
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout;
|
|
432
434
|
if (!mapXToDataPoints[x]) {
|
|
433
435
|
mapXToDataPoints[x] = {
|
|
434
|
-
xAxisPoint:
|
|
436
|
+
xAxisPoint: resolveXAxisValue(x),
|
|
435
437
|
chartData: [],
|
|
436
438
|
lineData: []
|
|
437
439
|
};
|
|
@@ -484,12 +486,59 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
484
486
|
});
|
|
485
487
|
});
|
|
486
488
|
});
|
|
489
|
+
var _input_data__x;
|
|
490
|
+
const xCategories = (_input_data__x = (_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.x) !== null && _input_data__x !== void 0 ? _input_data__x : [];
|
|
491
|
+
var _input_layout_shapes;
|
|
492
|
+
((_input_layout_shapes = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.shapes) !== null && _input_layout_shapes !== void 0 ? _input_layout_shapes : []).filter((shape)=>shape.type === 'line').forEach((shape, shapeIdx)=>{
|
|
493
|
+
var _shape_line;
|
|
494
|
+
const lineColor = (_shape_line = shape.line) === null || _shape_line === void 0 ? void 0 : _shape_line.color;
|
|
495
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
496
|
+
const resolveX = (val)=>{
|
|
497
|
+
if (typeof val === 'number' && Array.isArray(xCategories) && xCategories[val] !== undefined) {
|
|
498
|
+
return xCategories[val];
|
|
499
|
+
}
|
|
500
|
+
return val;
|
|
501
|
+
};
|
|
502
|
+
const x0Key = resolveX(shape.x0);
|
|
503
|
+
const x1Key = resolveX(shape.x1);
|
|
504
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
505
|
+
const resolveY = (val)=>{
|
|
506
|
+
if (shape.yref === 'paper') {
|
|
507
|
+
if (val === 0) {
|
|
508
|
+
return yMinValue;
|
|
509
|
+
}
|
|
510
|
+
if (val === 1) {
|
|
511
|
+
return yMaxValue;
|
|
512
|
+
}
|
|
513
|
+
return yMinValue + val * (yMaxValue - yMinValue);
|
|
514
|
+
}
|
|
515
|
+
return val;
|
|
516
|
+
};
|
|
517
|
+
const y0Val = resolveY(shape.y0);
|
|
518
|
+
const y1Val = resolveY(shape.y1);
|
|
519
|
+
var _rgb_formatHex8;
|
|
520
|
+
mapXToDataPoints[x0Key].lineData.push({
|
|
521
|
+
legend: `Reference_${shapeIdx}`,
|
|
522
|
+
y: y0Val,
|
|
523
|
+
color: (_rgb_formatHex8 = rgb(lineColor).formatHex8()) !== null && _rgb_formatHex8 !== void 0 ? _rgb_formatHex8 : lineColor,
|
|
524
|
+
lineOptions: getLineOptions(shape.line),
|
|
525
|
+
useSecondaryYScale: false
|
|
526
|
+
});
|
|
527
|
+
var _rgb_formatHex81;
|
|
528
|
+
mapXToDataPoints[x1Key].lineData.push({
|
|
529
|
+
legend: `Reference_${shapeIdx}`,
|
|
530
|
+
y: y1Val,
|
|
531
|
+
color: (_rgb_formatHex81 = rgb(lineColor).formatHex8()) !== null && _rgb_formatHex81 !== void 0 ? _rgb_formatHex81 : lineColor,
|
|
532
|
+
lineOptions: getLineOptions(shape.line),
|
|
533
|
+
useSecondaryYScale: false
|
|
534
|
+
});
|
|
535
|
+
});
|
|
487
536
|
const vsbcData = Object.values(mapXToDataPoints);
|
|
488
537
|
var _input_layout_height;
|
|
489
538
|
return {
|
|
490
539
|
data: vsbcData,
|
|
491
|
-
width: (
|
|
492
|
-
height: (_input_layout_height = (
|
|
540
|
+
width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
|
|
541
|
+
height: (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
493
542
|
barWidth: 'auto',
|
|
494
543
|
yMaxValue,
|
|
495
544
|
yMinValue,
|
|
@@ -513,7 +562,7 @@ export const transformPlotlyJsonToVSBCProps = (input, isMultiPlot, colorMap, col
|
|
|
513
562
|
};
|
|
514
563
|
};
|
|
515
564
|
export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, colorwayType, isDarkTheme)=>{
|
|
516
|
-
var _processedInput_layout, _processedInput_layout1
|
|
565
|
+
var _processedInput_layout, _processedInput_layout1;
|
|
517
566
|
// Handle object arrays in y values by normalizing the data first
|
|
518
567
|
let processedInput = {
|
|
519
568
|
...input
|
|
@@ -542,60 +591,90 @@ export const transformPlotlyJsonToGVBCProps = (input, isMultiPlot, colorMap, col
|
|
|
542
591
|
data: processedData
|
|
543
592
|
};
|
|
544
593
|
}
|
|
545
|
-
const
|
|
546
|
-
const secondaryYAxisValues = getSecondaryYAxisValues(processedInput.data, processedInput.layout
|
|
594
|
+
const gvbcDataV2 = [];
|
|
595
|
+
const secondaryYAxisValues = getSecondaryYAxisValues(processedInput.data, processedInput.layout);
|
|
547
596
|
const { legends, hideLegend } = getLegendProps(processedInput.data, processedInput.layout, isMultiPlot);
|
|
548
597
|
let colorScale = undefined;
|
|
549
598
|
const yAxisTickFormat = getYAxisTickFormat(processedInput.data[0], processedInput.layout);
|
|
550
599
|
processedInput.data.forEach((series, index1)=>{
|
|
551
|
-
var _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout, _series_marker, _series_x;
|
|
552
600
|
colorScale = createColorScale(processedInput.layout, series, colorScale);
|
|
553
|
-
|
|
554
|
-
const
|
|
555
|
-
(
|
|
556
|
-
var
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
601
|
+
const legend = legends[index1];
|
|
602
|
+
const legendShape = getLegendShape(series);
|
|
603
|
+
if (series.type === 'bar') {
|
|
604
|
+
var _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout, _series_marker;
|
|
605
|
+
// extract bar colors for each series only once
|
|
606
|
+
const extractedBarColors = extractColor((_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : (_processedInput_layout_template = _processedInput_layout.template) === null || _processedInput_layout_template === void 0 ? void 0 : (_processedInput_layout_template_layout = _processedInput_layout_template.layout) === null || _processedInput_layout_template_layout === void 0 ? void 0 : _processedInput_layout_template_layout.colorway, colorwayType, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
607
|
+
gvbcDataV2.push({
|
|
608
|
+
type: 'bar',
|
|
609
|
+
legend,
|
|
610
|
+
key: legend,
|
|
611
|
+
data: series.x.map((x, xIndex)=>{
|
|
612
|
+
var _series_y, _series_marker, _series_marker1, _series_marker_color, _series_marker2, _processedInput_layout_template_layout, _processedInput_layout_template, _processedInput_layout;
|
|
613
|
+
if (isInvalidValue(x) || isInvalidValue((_series_y = series.y) === null || _series_y === void 0 ? void 0 : _series_y[xIndex])) {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
617
|
+
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[xIndex % ((_series_marker1 = series.marker) === null || _series_marker1 === void 0 ? void 0 : _series_marker1.color).length] : 0) : resolveColor(extractedBarColors, xIndex, legend, colorMap, (_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : (_processedInput_layout_template = _processedInput_layout.template) === null || _processedInput_layout_template === void 0 ? void 0 : (_processedInput_layout_template_layout = _processedInput_layout_template.layout) === null || _processedInput_layout_template_layout === void 0 ? void 0 : _processedInput_layout_template_layout.colorway, isDarkTheme);
|
|
618
|
+
const opacity = getOpacity(series, xIndex);
|
|
619
|
+
const yVal = series.y[xIndex];
|
|
620
|
+
var _rgb_copy_formatHex8;
|
|
621
|
+
return {
|
|
622
|
+
x: x.toString(),
|
|
623
|
+
y: yVal,
|
|
624
|
+
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat),
|
|
625
|
+
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
626
|
+
opacity
|
|
627
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color
|
|
628
|
+
};
|
|
629
|
+
}).filter((item)=>typeof item !== 'undefined'),
|
|
630
|
+
useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout)
|
|
631
|
+
});
|
|
632
|
+
} else if (series.type === 'scatter') {
|
|
633
|
+
var _processedInput_layout_template_layout1, _processedInput_layout_template1, _processedInput_layout1, _series_line, _processedInput_layout_template_layout2, _processedInput_layout_template2, _processedInput_layout2;
|
|
634
|
+
// extract line colors for each series only once
|
|
635
|
+
const extractedLineColors = extractColor((_processedInput_layout1 = processedInput.layout) === null || _processedInput_layout1 === void 0 ? void 0 : (_processedInput_layout_template1 = _processedInput_layout1.template) === null || _processedInput_layout_template1 === void 0 ? void 0 : (_processedInput_layout_template_layout1 = _processedInput_layout_template1.layout) === null || _processedInput_layout_template_layout1 === void 0 ? void 0 : _processedInput_layout_template_layout1.colorway, colorwayType, (_series_line = series.line) === null || _series_line === void 0 ? void 0 : _series_line.color, colorMap, isDarkTheme);
|
|
636
|
+
const lineColor = resolveColor(extractedLineColors, index1, legend, colorMap, (_processedInput_layout2 = processedInput.layout) === null || _processedInput_layout2 === void 0 ? void 0 : (_processedInput_layout_template2 = _processedInput_layout2.template) === null || _processedInput_layout_template2 === void 0 ? void 0 : (_processedInput_layout_template_layout2 = _processedInput_layout_template2.layout) === null || _processedInput_layout_template_layout2 === void 0 ? void 0 : _processedInput_layout_template_layout2.colorway, isDarkTheme);
|
|
637
|
+
const lineOptions = getLineOptions(series.line);
|
|
638
|
+
const opacity = getOpacity(series, index1);
|
|
639
|
+
const validXYRanges = getValidXYRanges(series);
|
|
640
|
+
validXYRanges.forEach(([rangeStart, rangeEnd])=>{
|
|
641
|
+
const rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
642
|
+
const rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
573
643
|
var _rgb_copy_formatHex8;
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
data: yVal,
|
|
577
|
-
xAxisCalloutData: x,
|
|
578
|
-
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
579
|
-
opacity
|
|
580
|
-
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : color,
|
|
644
|
+
gvbcDataV2.push({
|
|
645
|
+
type: 'line',
|
|
581
646
|
legend,
|
|
582
|
-
|
|
583
|
-
|
|
647
|
+
legendShape,
|
|
648
|
+
data: rangeXValues.map((x, i)=>{
|
|
649
|
+
const yVal = rangeYValues[i];
|
|
650
|
+
return {
|
|
651
|
+
x: x.toString(),
|
|
652
|
+
y: yVal,
|
|
653
|
+
yAxisCalloutData: getFormattedCalloutYData(yVal, yAxisTickFormat)
|
|
654
|
+
};
|
|
655
|
+
}),
|
|
656
|
+
color: (_rgb_copy_formatHex8 = rgb(lineColor).copy({
|
|
657
|
+
opacity
|
|
658
|
+
}).formatHex8()) !== null && _rgb_copy_formatHex8 !== void 0 ? _rgb_copy_formatHex8 : lineColor,
|
|
659
|
+
lineOptions: {
|
|
660
|
+
...lineOptions !== null && lineOptions !== void 0 ? lineOptions : {},
|
|
661
|
+
mode: series.mode
|
|
662
|
+
},
|
|
663
|
+
useSecondaryYScale: usesSecondaryYScale(series, processedInput.layout)
|
|
584
664
|
});
|
|
585
|
-
}
|
|
586
|
-
}
|
|
665
|
+
});
|
|
666
|
+
}
|
|
587
667
|
});
|
|
588
|
-
const gvbcData = Object.values(mapXToDataPoints);
|
|
589
668
|
var _processedInput_layout_height;
|
|
590
669
|
return {
|
|
591
|
-
|
|
670
|
+
dataV2: gvbcDataV2,
|
|
592
671
|
width: (_processedInput_layout = processedInput.layout) === null || _processedInput_layout === void 0 ? void 0 : _processedInput_layout.width,
|
|
593
672
|
height: (_processedInput_layout_height = (_processedInput_layout1 = processedInput.layout) === null || _processedInput_layout1 === void 0 ? void 0 : _processedInput_layout1.height) !== null && _processedInput_layout_height !== void 0 ? _processedInput_layout_height : 350,
|
|
594
673
|
barWidth: 'auto',
|
|
595
674
|
mode: 'plotly',
|
|
596
675
|
...secondaryYAxisValues,
|
|
597
676
|
hideTickOverlap: true,
|
|
598
|
-
wrapXAxisLables:
|
|
677
|
+
wrapXAxisLables: true,
|
|
599
678
|
hideLegend,
|
|
600
679
|
roundCorners: true,
|
|
601
680
|
...getTitles(processedInput.layout),
|
|
@@ -623,8 +702,9 @@ export const transformPlotlyJsonToVBCProps = (input, isMultiPlot, colorMap, colo
|
|
|
623
702
|
const xValues = [];
|
|
624
703
|
const yValues = [];
|
|
625
704
|
series.x.forEach((xVal, index)=>{
|
|
626
|
-
|
|
627
|
-
|
|
705
|
+
var _getNumberAtIndexOrDefault;
|
|
706
|
+
const yVal = (_getNumberAtIndexOrDefault = getNumberAtIndexOrDefault(series.y, index)) !== null && _getNumberAtIndexOrDefault !== void 0 ? _getNumberAtIndexOrDefault : 0;
|
|
707
|
+
if (isInvalidValue(xVal)) {
|
|
628
708
|
return;
|
|
629
709
|
}
|
|
630
710
|
xValues.push(xVal);
|
|
@@ -694,7 +774,7 @@ export const transformPlotlyJsonToScatterChartProps = (input, isMultiPlot, color
|
|
|
694
774
|
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
695
775
|
};
|
|
696
776
|
const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme)=>{
|
|
697
|
-
var _input_data_, _input_layout, _input_layout1;
|
|
777
|
+
var _input_data_, _input_layout, _input_layout1, _input_layout2;
|
|
698
778
|
const isScatterMarkers = [
|
|
699
779
|
'text',
|
|
700
780
|
'markers',
|
|
@@ -707,22 +787,18 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
707
787
|
].includes((_input_data_ = input.data[0]) === null || _input_data_ === void 0 ? void 0 : _input_data_.mode);
|
|
708
788
|
const isAreaChart = chartType === 'area';
|
|
709
789
|
const isScatterChart = chartType === 'scatter';
|
|
710
|
-
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout
|
|
790
|
+
const secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
711
791
|
let mode = 'tonexty';
|
|
712
792
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
713
793
|
const yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
714
|
-
|
|
794
|
+
const resolveXAxisValue = getAxisValueResolver(input.data, input.layout, 'x');
|
|
795
|
+
const shouldWrapLabels = getAxisType(input.data, input.layout, 'x') === 'category';
|
|
715
796
|
const chartData = input.data.map((series, index)=>{
|
|
716
797
|
var _series_mode, _series_line, _series_marker, _series_line1, _input_layout_template_layout, _input_layout_template, _input_layout, _input_layout_template_layout1, _input_layout_template1, _input_layout1, _series_mode1;
|
|
717
798
|
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;
|
|
718
799
|
// extract colors for each series only once
|
|
719
800
|
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);
|
|
720
801
|
const xValues = series.x;
|
|
721
|
-
const isXString = isStringArray(xValues);
|
|
722
|
-
const isXDate = isDateArray(xValues);
|
|
723
|
-
const isXNumber = isNumberArray(xValues);
|
|
724
|
-
const isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
|
|
725
|
-
shouldWrapLabels = shouldWrapLabels || isXString && !isXDate;
|
|
726
802
|
const legend = legends[index];
|
|
727
803
|
// resolve color for each legend's lines from the extracted colors
|
|
728
804
|
const seriesColor = resolveColor(extractedColors, index, legend, colorMap, (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_template1 = _input_layout1.template) === null || _input_layout_template1 === void 0 ? void 0 : (_input_layout_template_layout1 = _input_layout_template1.layout) === null || _input_layout_template_layout1 === void 0 ? void 0 : _input_layout_template_layout1.colorway, isDarkTheme);
|
|
@@ -731,7 +807,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
731
807
|
// if mode contains 'text', we prioritize showing the text over curving the line
|
|
732
808
|
const lineOptions = !((_series_mode1 = series.mode) === null || _series_mode1 === void 0 ? void 0 : _series_mode1.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
|
|
733
809
|
const legendShape = getLegendShape(series);
|
|
734
|
-
const validXYRanges = getValidXYRanges(series);
|
|
810
|
+
const validXYRanges = getValidXYRanges(series, resolveXAxisValue);
|
|
735
811
|
return validXYRanges.map(([rangeStart, rangeEnd], rangeIdx)=>{
|
|
736
812
|
var _series_marker, _series_marker1, _series_marker2, _input_layout, _input_layout_polar_angularaxis, _input_layout_polar, _input_layout1, _input_layout_polar_angularaxis1, _input_layout_polar1, _input_layout2;
|
|
737
813
|
const rangeXValues = xValues.slice(rangeStart, rangeEnd);
|
|
@@ -746,7 +822,7 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
746
822
|
data: rangeXValues.map((x, i)=>{
|
|
747
823
|
var _series_marker, _series_marker1;
|
|
748
824
|
return {
|
|
749
|
-
x:
|
|
825
|
+
x: resolveXAxisValue(x),
|
|
750
826
|
y: rangeYValues[i],
|
|
751
827
|
...Array.isArray((_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.size) ? {
|
|
752
828
|
markerSize: markerSizes[i]
|
|
@@ -782,6 +858,28 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
782
858
|
};
|
|
783
859
|
});
|
|
784
860
|
}).flat();
|
|
861
|
+
var _input_layout_shapes;
|
|
862
|
+
const lineShape = ((_input_layout_shapes = (_input_layout = input.layout) === null || _input_layout === void 0 ? void 0 : _input_layout.shapes) !== null && _input_layout_shapes !== void 0 ? _input_layout_shapes : []).filter((shape)=>shape.type === 'line').map((shape, shapeIdx)=>{
|
|
863
|
+
var _shape_line;
|
|
864
|
+
const lineColor = (_shape_line = shape.line) === null || _shape_line === void 0 ? void 0 : _shape_line.color;
|
|
865
|
+
var _rgb_formatHex8;
|
|
866
|
+
return {
|
|
867
|
+
legend: `Reference_${shapeIdx}`,
|
|
868
|
+
data: [
|
|
869
|
+
{
|
|
870
|
+
x: shape.x0,
|
|
871
|
+
y: shape.y0
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
x: shape.x1,
|
|
875
|
+
y: shape.y1
|
|
876
|
+
}
|
|
877
|
+
],
|
|
878
|
+
color: (_rgb_formatHex8 = rgb(lineColor).formatHex8()) !== null && _rgb_formatHex8 !== void 0 ? _rgb_formatHex8 : lineColor,
|
|
879
|
+
lineOptions: getLineOptions(shape.line),
|
|
880
|
+
useSecondaryYScale: false
|
|
881
|
+
};
|
|
882
|
+
});
|
|
785
883
|
const yMinMax = getYMinMaxValues(input.data[0], input.layout);
|
|
786
884
|
if (yMinMax.yMinValue === undefined && yMinMax.yMaxValue === undefined) {
|
|
787
885
|
const yMinMaxValues = findNumericMinMaxOfY(chartData);
|
|
@@ -790,7 +888,10 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
790
888
|
}
|
|
791
889
|
const numDataPoints = chartData.reduce((total, lineChartPoints)=>total + lineChartPoints.data.length, 0);
|
|
792
890
|
const chartProps = {
|
|
793
|
-
lineChartData:
|
|
891
|
+
lineChartData: [
|
|
892
|
+
...chartData,
|
|
893
|
+
...lineShape
|
|
894
|
+
]
|
|
794
895
|
};
|
|
795
896
|
const scatterChartProps = {
|
|
796
897
|
scatterChartData: chartData
|
|
@@ -799,8 +900,8 @@ const transformPlotlyJsonToScatterTraceProps = (input, isMultiPlot, chartType, c
|
|
|
799
900
|
const commonProps = {
|
|
800
901
|
supportNegativeData: true,
|
|
801
902
|
...secondaryYAxisValues,
|
|
802
|
-
width: (
|
|
803
|
-
height: (_input_layout_height = (
|
|
903
|
+
width: (_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : _input_layout1.width,
|
|
904
|
+
height: (_input_layout_height = (_input_layout2 = input.layout) === null || _input_layout2 === void 0 ? void 0 : _input_layout2.height) !== null && _input_layout_height !== void 0 ? _input_layout_height : 350,
|
|
804
905
|
hideTickOverlap: true,
|
|
805
906
|
hideLegend,
|
|
806
907
|
useUTC: false,
|
|
@@ -842,8 +943,8 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
|
|
|
842
943
|
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, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
843
944
|
const legend = legends[index];
|
|
844
945
|
return series.y.map((yValue, i)=>{
|
|
845
|
-
var
|
|
846
|
-
if (isInvalidValue(
|
|
946
|
+
var _series_marker, _series_marker1, _series_marker_color, _series_marker2, _input_layout_template_layout, _input_layout_template, _input_layout, _series_x;
|
|
947
|
+
if (isInvalidValue(yValue)) {
|
|
847
948
|
return null;
|
|
848
949
|
}
|
|
849
950
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
@@ -851,7 +952,7 @@ export const transformPlotlyJsonToHorizontalBarWithAxisProps = (input, isMultiPl
|
|
|
851
952
|
const opacity = getOpacity(series, i);
|
|
852
953
|
var _rgb_copy_formatHex8;
|
|
853
954
|
return {
|
|
854
|
-
x: series.x[i],
|
|
955
|
+
x: isInvalidValue((_series_x = series.x) === null || _series_x === void 0 ? void 0 : _series_x[i]) ? 0 : series.x[i],
|
|
855
956
|
y: yValue,
|
|
856
957
|
legend,
|
|
857
958
|
color: (_rgb_copy_formatHex8 = rgb(color).copy({
|
|
@@ -893,13 +994,13 @@ export const transformPlotlyJsonToGanttChartProps = (input, isMultiPlot, colorMa
|
|
|
893
994
|
var _input_layout, _input_layout1;
|
|
894
995
|
const { legends, hideLegend } = getLegendProps(input.data, input.layout, isMultiPlot);
|
|
895
996
|
let colorScale = undefined;
|
|
997
|
+
const isXDate = getAxisType(input.data, input.layout, 'x') === 'date';
|
|
896
998
|
const chartData = input.data.map((series, index)=>{
|
|
897
|
-
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker
|
|
999
|
+
var _input_layout_template_layout, _input_layout_template, _input_layout, _series_marker;
|
|
898
1000
|
colorScale = createColorScale(input.layout, series, colorScale);
|
|
899
1001
|
// extract colors for each series only once
|
|
900
1002
|
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, (_series_marker = series.marker) === null || _series_marker === void 0 ? void 0 : _series_marker.color, colorMap, isDarkTheme);
|
|
901
1003
|
const legend = legends[index];
|
|
902
|
-
const isXDate = ((_input_layout1 = input.layout) === null || _input_layout1 === void 0 ? void 0 : (_input_layout_xaxis = _input_layout1.xaxis) === null || _input_layout_xaxis === void 0 ? void 0 : _input_layout_xaxis.type) === 'date' || isDateArray(series.x);
|
|
903
1004
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
904
1005
|
const convertXValueToNumber = (value)=>{
|
|
905
1006
|
return isInvalidValue(value) ? 0 : isXDate ? +parseLocalDate(value) : +value;
|
|
@@ -959,8 +1060,9 @@ export const transformPlotlyJsonToHeatmapProps = (input, isMultiPlot, colorMap,
|
|
|
959
1060
|
const zValues = [];
|
|
960
1061
|
(_firstData_x = firstData.x) === null || _firstData_x === void 0 ? void 0 : _firstData_x.forEach((xVal, index)=>{
|
|
961
1062
|
var _firstData_y;
|
|
962
|
-
|
|
963
|
-
|
|
1063
|
+
var _getNumberAtIndexOrDefault;
|
|
1064
|
+
const zVal = (_getNumberAtIndexOrDefault = getNumberAtIndexOrDefault(firstData.z, index)) !== null && _getNumberAtIndexOrDefault !== void 0 ? _getNumberAtIndexOrDefault : 0;
|
|
1065
|
+
if (isInvalidValue(xVal) || isInvalidValue((_firstData_y = firstData.y) === null || _firstData_y === void 0 ? void 0 : _firstData_y[index])) {
|
|
964
1066
|
return;
|
|
965
1067
|
}
|
|
966
1068
|
xValues.push(xVal);
|
|
@@ -1881,7 +1983,7 @@ export const getNumberAtIndexOrDefault = (data, index)=>{
|
|
|
1881
1983
|
}
|
|
1882
1984
|
return 1;
|
|
1883
1985
|
};
|
|
1884
|
-
export const getValidXYRanges = (series)=>{
|
|
1986
|
+
export const getValidXYRanges = (series, resolveX, resolveY)=>{
|
|
1885
1987
|
if (!isArrayOrTypedArray(series.x) || !isArrayOrTypedArray(series.y)) {
|
|
1886
1988
|
return [];
|
|
1887
1989
|
}
|
|
@@ -1889,7 +1991,7 @@ export const getValidXYRanges = (series)=>{
|
|
|
1889
1991
|
let start = 0;
|
|
1890
1992
|
let end = 0;
|
|
1891
1993
|
for(; end < series.x.length; end++){
|
|
1892
|
-
if (isInvalidValue(series.x[end]) || isInvalidValue(series.y[end])) {
|
|
1994
|
+
if (isInvalidValue(series.x[end]) || typeof resolveX === 'function' && isInvalidValue(resolveX(series.x[end])) || isInvalidValue(series.y[end]) || typeof resolveY === 'function' && isInvalidValue(resolveY(series.y[end]))) {
|
|
1893
1995
|
if (end - start > 0) {
|
|
1894
1996
|
ranges.push([
|
|
1895
1997
|
start,
|
|
@@ -2177,7 +2279,7 @@ const getAxisScaleTypeProps = (data, layout)=>{
|
|
|
2177
2279
|
if (!ax) {
|
|
2178
2280
|
return;
|
|
2179
2281
|
}
|
|
2180
|
-
const axType = getAxisType(data,
|
|
2282
|
+
const axType = getAxisType(data, ax);
|
|
2181
2283
|
if ((!ax.tickmode || ax.tickmode === 'array') && isArrayOrTypedArray(ax.tickvals)) {
|
|
2182
2284
|
const tickValues = axType === 'date' ? ax.tickvals.map((v)=>new Date(v)) : ax.tickvals;
|
|
2183
2285
|
if (axId === 'x') {
|
|
@@ -2193,12 +2295,12 @@ const getAxisScaleTypeProps = (data, layout)=>{
|
|
|
2193
2295
|
if (axId === 'x') {
|
|
2194
2296
|
props.xAxis = {
|
|
2195
2297
|
tickStep: dtick,
|
|
2196
|
-
tick0
|
|
2298
|
+
tick0
|
|
2197
2299
|
};
|
|
2198
2300
|
} else if (axId === 'y') {
|
|
2199
2301
|
props.yAxis = {
|
|
2200
2302
|
tickStep: dtick,
|
|
2201
|
-
tick0
|
|
2303
|
+
tick0
|
|
2202
2304
|
};
|
|
2203
2305
|
}
|
|
2204
2306
|
return;
|
|
@@ -2275,44 +2377,88 @@ const getAxisObjects = (data, layout)=>{
|
|
|
2275
2377
|
xAxisId = axisIds.x;
|
|
2276
2378
|
yAxisIds.add(axisIds.y);
|
|
2277
2379
|
});
|
|
2380
|
+
const makeAxisObject = (axLetter, axId)=>({
|
|
2381
|
+
...layout === null || layout === void 0 ? void 0 : layout[getAxisKey(axLetter, axId)],
|
|
2382
|
+
_id: `${axLetter}${axId > 1 ? axId : ''}`
|
|
2383
|
+
});
|
|
2278
2384
|
const axisObjects = {};
|
|
2279
2385
|
if (typeof xAxisId === 'number') {
|
|
2280
|
-
axisObjects.x =
|
|
2386
|
+
axisObjects.x = makeAxisObject('x', xAxisId);
|
|
2281
2387
|
}
|
|
2282
2388
|
const sortedYAxisIds = Array.from(yAxisIds).sort();
|
|
2283
2389
|
if (sortedYAxisIds.length > 0) {
|
|
2284
|
-
axisObjects.y =
|
|
2390
|
+
axisObjects.y = makeAxisObject('y', sortedYAxisIds[0]);
|
|
2285
2391
|
}
|
|
2286
2392
|
if (sortedYAxisIds.length > 1) {
|
|
2287
|
-
axisObjects.y2 =
|
|
2393
|
+
axisObjects.y2 = makeAxisObject('y', sortedYAxisIds[1]);
|
|
2288
2394
|
}
|
|
2289
2395
|
return axisObjects;
|
|
2290
2396
|
};
|
|
2291
|
-
|
|
2397
|
+
function getAxisType(data, arg2, arg3) {
|
|
2398
|
+
let ax;
|
|
2399
|
+
if (arg2 && typeof arg2 === 'object' && '_id' in arg2) {
|
|
2400
|
+
ax = arg2;
|
|
2401
|
+
} else if (typeof arg3 === 'string') {
|
|
2402
|
+
const layout = arg2;
|
|
2403
|
+
ax = getAxisObjects(data, layout)[arg3];
|
|
2404
|
+
}
|
|
2405
|
+
if (!ax) {
|
|
2406
|
+
return 'category';
|
|
2407
|
+
}
|
|
2408
|
+
var _ax_type;
|
|
2409
|
+
if ([
|
|
2410
|
+
'linear',
|
|
2411
|
+
'log',
|
|
2412
|
+
'date',
|
|
2413
|
+
'category'
|
|
2414
|
+
].includes((_ax_type = ax.type) !== null && _ax_type !== void 0 ? _ax_type : '')) {
|
|
2415
|
+
return ax.type;
|
|
2416
|
+
}
|
|
2417
|
+
const axLetter = ax._id[0];
|
|
2292
2418
|
const values = [];
|
|
2293
2419
|
data.forEach((series)=>{
|
|
2294
|
-
|
|
2295
|
-
(
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
// Therefore, simply checking the type of the values may not be sufficient. At the moment,
|
|
2303
|
-
// we don’t always perform this casting ourselves and instead use the values as provided.
|
|
2304
|
-
if (isNumberArray(values)) {
|
|
2305
|
-
if ((ax === null || ax === void 0 ? void 0 : ax.type) === 'log') {
|
|
2306
|
-
return 'log';
|
|
2420
|
+
const axId = series[`${axLetter}axis`];
|
|
2421
|
+
if (axId === ax._id || !axId && ax._id === axLetter) {
|
|
2422
|
+
var _series_axLetter;
|
|
2423
|
+
(_series_axLetter = series[axLetter]) === null || _series_axLetter === void 0 ? void 0 : _series_axLetter.forEach((val)=>{
|
|
2424
|
+
if (!isInvalidValue(val)) {
|
|
2425
|
+
values.push(val);
|
|
2426
|
+
}
|
|
2427
|
+
});
|
|
2307
2428
|
}
|
|
2429
|
+
});
|
|
2430
|
+
if (isNumberArray(values) && !isYearArray(values)) {
|
|
2308
2431
|
return 'linear';
|
|
2309
2432
|
}
|
|
2310
2433
|
if (isDateArray(values)) {
|
|
2311
2434
|
return 'date';
|
|
2312
2435
|
}
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2436
|
+
return 'category';
|
|
2437
|
+
}
|
|
2438
|
+
const getAxisValueResolver = (data, layout, axisId)=>{
|
|
2439
|
+
const axType = getAxisType(data, layout, axisId);
|
|
2440
|
+
return (value)=>{
|
|
2441
|
+
if (isInvalidValue(value)) {
|
|
2442
|
+
return null;
|
|
2443
|
+
}
|
|
2444
|
+
switch(axType){
|
|
2445
|
+
case 'linear':
|
|
2446
|
+
case 'log':
|
|
2447
|
+
return isNumber(value) ? +value : null;
|
|
2448
|
+
case 'date':
|
|
2449
|
+
if (isNumber(value)) {
|
|
2450
|
+
return new Date(+value);
|
|
2451
|
+
}
|
|
2452
|
+
if (typeof value === 'string') {
|
|
2453
|
+
return new Date(value);
|
|
2454
|
+
}
|
|
2455
|
+
return null;
|
|
2456
|
+
case 'category':
|
|
2457
|
+
return `${value}`;
|
|
2458
|
+
default:
|
|
2459
|
+
return null;
|
|
2460
|
+
}
|
|
2461
|
+
};
|
|
2316
2462
|
};
|
|
2317
2463
|
/**
|
|
2318
2464
|
* This is experimental. Use it only with valid datetime strings to verify if they conform to the ISO 8601 format.
|