@fluentui/react-charting 5.24.36 → 5.24.37
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.json +28 -1
- package/CHANGELOG.md +13 -2
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +107 -53
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +107 -53
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +107 -53
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/package.json +2 -2
|
@@ -71,7 +71,7 @@ export declare const projectPolarToCartesian: (input: PlotlySchema) => PlotlySch
|
|
|
71
71
|
export declare function findArrayAttributes(trace: any): void;
|
|
72
72
|
export declare const getAllupLegendsProps: (input: PlotlySchema, colorMap: React.MutableRefObject<Map<string, string>>, colorwayType: ColorwayType, traceInfo: TraceInfo[], isDarkTheme?: boolean) => ILegendsProps;
|
|
73
73
|
export declare const getNumberAtIndexOrDefault: (data: PlotData["z"] | undefined, index: number) => number | undefined;
|
|
74
|
-
export declare const getValidXYRanges: (series: Partial<PlotData
|
|
74
|
+
export declare const getValidXYRanges: (series: Partial<PlotData>, resolveX?: (v: Datum) => Datum, resolveY?: (v: Datum) => Datum) => [number, number][];
|
|
75
75
|
export declare const isNonPlotType: (chartType: string) => boolean;
|
|
76
76
|
export declare const getGridProperties: (schema: PlotlySchema | undefined, isMultiPlot: boolean, validTracesInfo: TraceInfo[]) => GridProperties;
|
|
77
77
|
export {};
|
|
@@ -415,19 +415,15 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
415
415
|
var _j = getLegendProps(input.data, input.layout, isMultiPlot), legends = _j.legends, hideLegend = _j.hideLegend;
|
|
416
416
|
var colorScale = undefined;
|
|
417
417
|
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
418
|
+
var resolveXAxisValue = getAxisValueResolver(input.data, input.layout, 'x');
|
|
418
419
|
input.data.forEach(function (series, index1) {
|
|
419
420
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
420
421
|
colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
|
|
421
|
-
var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
422
422
|
// extract bar colors for each series only once
|
|
423
423
|
var extractedBarColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_d = series.marker) === null || _d === void 0 ? void 0 : _d.color, colorMap, isDarkTheme);
|
|
424
424
|
// extract line colors for each series only once
|
|
425
425
|
var extractedLineColors = (0, PlotlyColorAdapter_1.extractColor)((_g = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.template) === null || _f === void 0 ? void 0 : _f.layout) === null || _g === void 0 ? void 0 : _g.colorway, colorwayType, (_h = series.line) === null || _h === void 0 ? void 0 : _h.color, colorMap, isDarkTheme);
|
|
426
|
-
var
|
|
427
|
-
var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
|
|
428
|
-
var isXString = (0, chart_utilities_1.isStringArray)(xValues);
|
|
429
|
-
var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
|
|
430
|
-
var validXYRanges = (0, exports.getValidXYRanges)(series);
|
|
426
|
+
var validXYRanges = (0, exports.getValidXYRanges)(series, resolveXAxisValue);
|
|
431
427
|
validXYRanges.forEach(function (_a, rangeIdx) {
|
|
432
428
|
var rangeStart = _a[0], rangeEnd = _a[1];
|
|
433
429
|
var rangeXValues = series.x.slice(rangeStart, rangeEnd);
|
|
@@ -436,7 +432,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
436
432
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
437
433
|
if (!mapXToDataPoints[x]) {
|
|
438
434
|
mapXToDataPoints[x] = {
|
|
439
|
-
xAxisPoint: (
|
|
435
|
+
xAxisPoint: resolveXAxisValue(x),
|
|
440
436
|
chartData: [],
|
|
441
437
|
lineData: [],
|
|
442
438
|
};
|
|
@@ -647,8 +643,9 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
647
643
|
var xValues = [];
|
|
648
644
|
var yValues = [];
|
|
649
645
|
series.x.forEach(function (xVal, index) {
|
|
650
|
-
var
|
|
651
|
-
|
|
646
|
+
var _a;
|
|
647
|
+
var yVal = (_a = (0, exports.getNumberAtIndexOrDefault)(series.y, index)) !== null && _a !== void 0 ? _a : 0;
|
|
648
|
+
if ((0, chart_utilities_1.isInvalidValue)(xVal)) {
|
|
652
649
|
return;
|
|
653
650
|
}
|
|
654
651
|
xValues.push(xVal);
|
|
@@ -702,8 +699,27 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
702
699
|
return transformPlotlyJsonToScatterTraceProps(input, isMultiPlot, 'scatter', colorMap, colorwayType, isDarkTheme);
|
|
703
700
|
};
|
|
704
701
|
exports.transformPlotlyJsonToScatterChartProps = transformPlotlyJsonToScatterChartProps;
|
|
702
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
703
|
+
var mapColorFillBars = function (layout) {
|
|
704
|
+
if (!Array.isArray(layout === null || layout === void 0 ? void 0 : layout.shapes)) {
|
|
705
|
+
return [];
|
|
706
|
+
}
|
|
707
|
+
return layout.shapes
|
|
708
|
+
.filter(function (shape) { return shape.type === 'rect'; })
|
|
709
|
+
.map(function (shape) {
|
|
710
|
+
//colorFillbars doesn't support string dates or categories
|
|
711
|
+
if (typeof shape.x0 === 'string' || typeof shape.x1 === 'string') {
|
|
712
|
+
return null;
|
|
713
|
+
}
|
|
714
|
+
return {
|
|
715
|
+
color: shape.fillcolor,
|
|
716
|
+
data: [{ startX: shape.x0, endX: shape.x1 }],
|
|
717
|
+
applyPattern: false,
|
|
718
|
+
};
|
|
719
|
+
});
|
|
720
|
+
};
|
|
705
721
|
var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chartType, colorMap, colorwayType, isDarkTheme) {
|
|
706
|
-
var _a, _b, _c, _d, _e, _f;
|
|
722
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
707
723
|
var isScatterMarkers = [
|
|
708
724
|
'text',
|
|
709
725
|
'markers',
|
|
@@ -718,9 +734,10 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
718
734
|
var isScatterChart = chartType === 'scatter';
|
|
719
735
|
var secondaryYAxisValues = getSecondaryYAxisValues(input.data, input.layout);
|
|
720
736
|
var mode = 'tonexty';
|
|
721
|
-
var
|
|
737
|
+
var _h = getLegendProps(input.data, input.layout, isMultiPlot), legends = _h.legends, hideLegend = _h.hideLegend;
|
|
722
738
|
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
723
|
-
var
|
|
739
|
+
var resolveXAxisValue = getAxisValueResolver(input.data, input.layout, 'x');
|
|
740
|
+
var shouldWrapLabels = getAxisType(input.data, input.layout, 'x') === 'category';
|
|
724
741
|
var chartData = input.data
|
|
725
742
|
.map(function (series, index) {
|
|
726
743
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
@@ -732,11 +749,6 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
732
749
|
// extract colors for each series only once
|
|
733
750
|
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_g = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.template) === null || _f === void 0 ? void 0 : _f.layout) === null || _g === void 0 ? void 0 : _g.colorway, colorwayType, colors, colorMap, isDarkTheme);
|
|
734
751
|
var xValues = series.x;
|
|
735
|
-
var isXString = (0, chart_utilities_1.isStringArray)(xValues);
|
|
736
|
-
var isXDate = (0, chart_utilities_1.isDateArray)(xValues);
|
|
737
|
-
var isXNumber = (0, chart_utilities_1.isNumberArray)(xValues);
|
|
738
|
-
var isXYearCategory = (0, chart_utilities_1.isYearArray)(series.x); // Consider year as categorical not numeric continuous axis
|
|
739
|
-
shouldWrapLabels = shouldWrapLabels || (isXString && !isXDate);
|
|
740
752
|
var legend = legends[index];
|
|
741
753
|
// resolve color for each legend's lines from the extracted colors
|
|
742
754
|
var seriesColor = (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, index, legend, colorMap, (_k = (_j = (_h = input.layout) === null || _h === void 0 ? void 0 : _h.template) === null || _j === void 0 ? void 0 : _j.layout) === null || _k === void 0 ? void 0 : _k.colorway, isDarkTheme);
|
|
@@ -745,7 +757,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
745
757
|
// if mode contains 'text', we prioritize showing the text over curving the line
|
|
746
758
|
var lineOptions = !((_l = series.mode) === null || _l === void 0 ? void 0 : _l.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
|
|
747
759
|
var legendShape = getLegendShape(series);
|
|
748
|
-
var validXYRanges = (0, exports.getValidXYRanges)(series);
|
|
760
|
+
var validXYRanges = (0, exports.getValidXYRanges)(series, resolveXAxisValue);
|
|
749
761
|
return validXYRanges.map(function (_a, rangeIdx) {
|
|
750
762
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
751
763
|
var rangeStart = _a[0], rangeEnd = _a[1];
|
|
@@ -765,7 +777,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
765
777
|
legendShape: legendShape,
|
|
766
778
|
data: rangeXValues.map(function (x, i) {
|
|
767
779
|
var _a, _b;
|
|
768
|
-
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ x: (
|
|
780
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ x: resolveXAxisValue(x), y: rangeYValues[i] }, (Array.isArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.size)
|
|
769
781
|
? { markerSize: markerSizes[i] }
|
|
770
782
|
: typeof ((_b = series.marker) === null || _b === void 0 ? void 0 : _b.size) === 'number'
|
|
771
783
|
? { markerSize: series.marker.size }
|
|
@@ -822,8 +834,10 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
822
834
|
return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
|
|
823
835
|
}
|
|
824
836
|
else {
|
|
825
|
-
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: isScatterChart ? scatterChartProps : chartProps, roundedTicks: true, enableReflow: false }, commonProps), yMinMax), (isScatterChart
|
|
826
|
-
? tslib_1.__assign({ showYAxisLablesTooltip: true }, getAxisCategoryOrderProps(input.data, input.layout)) : {}))
|
|
837
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: isScatterChart ? scatterChartProps : chartProps, roundedTicks: true, enableReflow: false }, commonProps), yMinMax), (isScatterChart
|
|
838
|
+
? tslib_1.__assign({ showYAxisLablesTooltip: true }, getAxisCategoryOrderProps(input.data, input.layout)) : {})), (!isScatterChart && ((_g = mapColorFillBars(input.layout)) === null || _g === void 0 ? void 0 : _g.length)
|
|
839
|
+
? { colorFillBars: mapColorFillBars(input.layout) }
|
|
840
|
+
: {}));
|
|
827
841
|
}
|
|
828
842
|
};
|
|
829
843
|
var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -840,18 +854,18 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
840
854
|
return series.y
|
|
841
855
|
.map(function (yValue, i) {
|
|
842
856
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
843
|
-
if ((0, chart_utilities_1.isInvalidValue)(
|
|
857
|
+
if ((0, chart_utilities_1.isInvalidValue)(yValue)) {
|
|
844
858
|
return null;
|
|
845
859
|
}
|
|
846
860
|
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
847
861
|
var color = colorScale
|
|
848
|
-
? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((
|
|
849
|
-
? (
|
|
862
|
+
? colorScale((0, chart_utilities_1.isArrayOrTypedArray)((_a = series.marker) === null || _a === void 0 ? void 0 : _a.color)
|
|
863
|
+
? (_c = (_b = series.marker) === null || _b === void 0 ? void 0 : _b.color) === null || _c === void 0 ? void 0 : _c[i % ((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color).length]
|
|
850
864
|
: 0)
|
|
851
|
-
: (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, i, legend, colorMap, (
|
|
865
|
+
: (0, PlotlyColorAdapter_1.resolveColor)(extractedColors, i, legend, colorMap, (_g = (_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.template) === null || _f === void 0 ? void 0 : _f.layout) === null || _g === void 0 ? void 0 : _g.colorway, isDarkTheme);
|
|
852
866
|
var opacity = (0, PlotlyColorAdapter_1.getOpacity)(series, i);
|
|
853
867
|
return {
|
|
854
|
-
x: series.x[i],
|
|
868
|
+
x: (0, chart_utilities_1.isInvalidValue)((_h = series.x) === null || _h === void 0 ? void 0 : _h[i]) ? 0 : series.x[i],
|
|
855
869
|
y: yValue,
|
|
856
870
|
legend: legend,
|
|
857
871
|
color: (_j = (0, d3_color_1.rgb)(color).copy({ opacity: opacity }).formatHex8()) !== null && _j !== void 0 ? _j : color,
|
|
@@ -877,14 +891,14 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
877
891
|
var _a, _b, _c;
|
|
878
892
|
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
879
893
|
var colorScale = undefined;
|
|
894
|
+
var isXDate = getAxisType(input.data, input.layout, 'x') === 'date';
|
|
880
895
|
var chartData = input.data
|
|
881
896
|
.map(function (series, index) {
|
|
882
|
-
var _a, _b, _c, _d
|
|
897
|
+
var _a, _b, _c, _d;
|
|
883
898
|
colorScale = (0, PlotlyColorAdapter_1.createColorScale)(input.layout, series, colorScale);
|
|
884
899
|
// extract colors for each series only once
|
|
885
900
|
var extractedColors = (0, PlotlyColorAdapter_1.extractColor)((_c = (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.layout) === null || _c === void 0 ? void 0 : _c.colorway, colorwayType, (_d = series.marker) === null || _d === void 0 ? void 0 : _d.color, colorMap, isDarkTheme);
|
|
886
901
|
var legend = legends[index];
|
|
887
|
-
var isXDate = ((_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.xaxis) === null || _f === void 0 ? void 0 : _f.type) === 'date' || (0, chart_utilities_1.isDateArray)(series.x);
|
|
888
902
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
889
903
|
var convertXValueToNumber = function (value) {
|
|
890
904
|
return (0, chart_utilities_1.isInvalidValue)(value) ? 0 : isXDate ? +parseLocalDate(value) : +value;
|
|
@@ -931,9 +945,9 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
931
945
|
var yValues_1 = [];
|
|
932
946
|
var zValues_1 = [];
|
|
933
947
|
(_a = firstData.x) === null || _a === void 0 ? void 0 : _a.forEach(function (xVal, index) {
|
|
934
|
-
var _a;
|
|
935
|
-
var zVal = (0, exports.getNumberAtIndexOrDefault)(firstData.z, index);
|
|
936
|
-
if ((0, chart_utilities_1.isInvalidValue)(xVal) || (0, chart_utilities_1.isInvalidValue)((
|
|
948
|
+
var _a, _b;
|
|
949
|
+
var zVal = (_a = (0, exports.getNumberAtIndexOrDefault)(firstData.z, index)) !== null && _a !== void 0 ? _a : 0;
|
|
950
|
+
if ((0, chart_utilities_1.isInvalidValue)(xVal) || (0, chart_utilities_1.isInvalidValue)((_b = firstData.y) === null || _b === void 0 ? void 0 : _b[index])) {
|
|
937
951
|
return;
|
|
938
952
|
}
|
|
939
953
|
xValues_1.push(xVal);
|
|
@@ -1773,7 +1787,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1773
1787
|
return 1;
|
|
1774
1788
|
};
|
|
1775
1789
|
exports.getNumberAtIndexOrDefault = getNumberAtIndexOrDefault;
|
|
1776
|
-
var getValidXYRanges = function (series) {
|
|
1790
|
+
var getValidXYRanges = function (series, resolveX, resolveY) {
|
|
1777
1791
|
if (!(0, chart_utilities_1.isArrayOrTypedArray)(series.x) || !(0, chart_utilities_1.isArrayOrTypedArray)(series.y)) {
|
|
1778
1792
|
return [];
|
|
1779
1793
|
}
|
|
@@ -1781,7 +1795,10 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1781
1795
|
var start = 0;
|
|
1782
1796
|
var end = 0;
|
|
1783
1797
|
for (; end < series.x.length; end++) {
|
|
1784
|
-
if ((0, chart_utilities_1.isInvalidValue)(series.x[end]) ||
|
|
1798
|
+
if ((0, chart_utilities_1.isInvalidValue)(series.x[end]) ||
|
|
1799
|
+
(typeof resolveX === 'function' && (0, chart_utilities_1.isInvalidValue)(resolveX(series.x[end]))) ||
|
|
1800
|
+
(0, chart_utilities_1.isInvalidValue)(series.y[end]) ||
|
|
1801
|
+
(typeof resolveY === 'function' && (0, chart_utilities_1.isInvalidValue)(resolveY(series.y[end])))) {
|
|
1785
1802
|
if (end - start > 0) {
|
|
1786
1803
|
ranges.push([start, end]);
|
|
1787
1804
|
}
|
|
@@ -2094,7 +2111,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
2094
2111
|
if (!ax) {
|
|
2095
2112
|
return;
|
|
2096
2113
|
}
|
|
2097
|
-
var axType = getAxisType(data,
|
|
2114
|
+
var axType = getAxisType(data, ax);
|
|
2098
2115
|
if ((!ax.tickmode || ax.tickmode === 'array') && (0, chart_utilities_1.isArrayOrTypedArray)(ax.tickvals)) {
|
|
2099
2116
|
var tickValues = axType === 'date' ? ax.tickvals.map(function (v) { return new Date(v); }) : ax.tickvals;
|
|
2100
2117
|
if (axId === 'x') {
|
|
@@ -2201,44 +2218,81 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
2201
2218
|
xAxisId = axisIds.x;
|
|
2202
2219
|
yAxisIds.add(axisIds.y);
|
|
2203
2220
|
});
|
|
2221
|
+
var makeAxisObject = function (axLetter, axId) { return (tslib_1.__assign(tslib_1.__assign({}, layout === null || layout === void 0 ? void 0 : layout[(0, chart_utilities_1.getAxisKey)(axLetter, axId)]), { _id: "".concat(axLetter).concat(axId > 1 ? axId : '') })); };
|
|
2204
2222
|
var axisObjects = {};
|
|
2205
2223
|
if (typeof xAxisId === 'number') {
|
|
2206
|
-
axisObjects.x =
|
|
2224
|
+
axisObjects.x = makeAxisObject('x', xAxisId);
|
|
2207
2225
|
}
|
|
2208
2226
|
var sortedYAxisIds = Array.from(yAxisIds).sort();
|
|
2209
2227
|
if (sortedYAxisIds.length > 0) {
|
|
2210
|
-
axisObjects.y =
|
|
2228
|
+
axisObjects.y = makeAxisObject('y', sortedYAxisIds[0]);
|
|
2211
2229
|
}
|
|
2212
2230
|
if (sortedYAxisIds.length > 1) {
|
|
2213
|
-
axisObjects.y2 =
|
|
2231
|
+
axisObjects.y2 = makeAxisObject('y', sortedYAxisIds[1]);
|
|
2214
2232
|
}
|
|
2215
2233
|
return axisObjects;
|
|
2216
2234
|
};
|
|
2217
|
-
|
|
2235
|
+
function getAxisType(data, arg2, arg3) {
|
|
2236
|
+
var _a;
|
|
2237
|
+
var ax;
|
|
2238
|
+
if (arg2 && typeof arg2 === 'object' && '_id' in arg2) {
|
|
2239
|
+
ax = arg2;
|
|
2240
|
+
}
|
|
2241
|
+
else if (typeof arg3 === 'string') {
|
|
2242
|
+
var layout = arg2;
|
|
2243
|
+
ax = getAxisObjects(data, layout)[arg3];
|
|
2244
|
+
}
|
|
2245
|
+
if (!ax) {
|
|
2246
|
+
return 'category';
|
|
2247
|
+
}
|
|
2248
|
+
if (['linear', 'log', 'date', 'category'].includes((_a = ax.type) !== null && _a !== void 0 ? _a : '')) {
|
|
2249
|
+
return ax.type;
|
|
2250
|
+
}
|
|
2251
|
+
var axLetter = ax._id[0];
|
|
2218
2252
|
var values = [];
|
|
2219
2253
|
data.forEach(function (series) {
|
|
2220
2254
|
var _a;
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
// Therefore, simply checking the type of the values may not be sufficient. At the moment,
|
|
2229
|
-
// we don’t always perform this casting ourselves and instead use the values as provided.
|
|
2230
|
-
if ((0, chart_utilities_1.isNumberArray)(values)) {
|
|
2231
|
-
if ((ax === null || ax === void 0 ? void 0 : ax.type) === 'log') {
|
|
2232
|
-
return 'log';
|
|
2255
|
+
var axId = series["".concat(axLetter, "axis")];
|
|
2256
|
+
if (axId === ax._id || (!axId && ax._id === axLetter)) {
|
|
2257
|
+
(_a = series[axLetter]) === null || _a === void 0 ? void 0 : _a.forEach(function (val) {
|
|
2258
|
+
if (!(0, chart_utilities_1.isInvalidValue)(val)) {
|
|
2259
|
+
values.push(val);
|
|
2260
|
+
}
|
|
2261
|
+
});
|
|
2233
2262
|
}
|
|
2263
|
+
});
|
|
2264
|
+
if ((0, chart_utilities_1.isNumberArray)(values) && !(0, chart_utilities_1.isYearArray)(values)) {
|
|
2234
2265
|
return 'linear';
|
|
2235
2266
|
}
|
|
2236
2267
|
if ((0, chart_utilities_1.isDateArray)(values)) {
|
|
2237
2268
|
return 'date';
|
|
2238
2269
|
}
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2270
|
+
return 'category';
|
|
2271
|
+
}
|
|
2272
|
+
var getAxisValueResolver = function (data, layout, axisId) {
|
|
2273
|
+
var axType = getAxisType(data, layout, axisId);
|
|
2274
|
+
return function (value) {
|
|
2275
|
+
if ((0, chart_utilities_1.isInvalidValue)(value)) {
|
|
2276
|
+
return null;
|
|
2277
|
+
}
|
|
2278
|
+
switch (axType) {
|
|
2279
|
+
case 'linear':
|
|
2280
|
+
case 'log':
|
|
2281
|
+
return (0, chart_utilities_1.isNumber)(value) ? +value : null;
|
|
2282
|
+
case 'date':
|
|
2283
|
+
if ((0, chart_utilities_1.isNumber)(value)) {
|
|
2284
|
+
return new Date(+value);
|
|
2285
|
+
}
|
|
2286
|
+
if (typeof value === 'string') {
|
|
2287
|
+
return new Date(value);
|
|
2288
|
+
}
|
|
2289
|
+
return null;
|
|
2290
|
+
case 'category':
|
|
2291
|
+
return "".concat(value);
|
|
2292
|
+
default:
|
|
2293
|
+
return null;
|
|
2294
|
+
}
|
|
2295
|
+
};
|
|
2242
2296
|
};
|
|
2243
2297
|
});
|
|
2244
2298
|
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|