@fluentui/react-charting 5.24.24 → 5.24.25
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 +16 -1
- package/CHANGELOG.md +11 -2
- package/dist/react-charting.d.ts +55 -1
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +9 -0
- package/lib/components/CommonComponents/CartesianChart.base.js +10 -5
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +16 -1
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +165 -29
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types/IDataPoint.d.ts +37 -0
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/utilities/utilities.d.ts +7 -3
- package/lib/utilities/utilities.js +131 -17
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +10 -5
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +16 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +167 -32
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/index.d.ts +1 -1
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/types/IDataPoint.d.ts +37 -0
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +7 -3
- package/lib-amd/utilities/utilities.js +132 -16
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +10 -5
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +16 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +167 -31
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/index.d.ts +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/IDataPoint.d.ts +37 -0
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +7 -3
- package/lib-commonjs/utilities/utilities.js +132 -16
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +1 -1
- package/src/components/CommonComponents/CartesianChart.types.ts +19 -0
|
@@ -13,6 +13,7 @@ var chart_utilities_1 = require("@fluentui/chart-utilities");
|
|
|
13
13
|
var d3_shape_1 = require("d3-shape");
|
|
14
14
|
var PlotlyColorAdapter_1 = require("./PlotlyColorAdapter");
|
|
15
15
|
var d3_color_1 = require("d3-color");
|
|
16
|
+
var react_1 = require("@fluentui/react");
|
|
16
17
|
exports.NON_PLOT_KEY_PREFIX = 'nonplot_';
|
|
17
18
|
exports.SINGLE_REPEAT = 'repeat(1, 1fr)';
|
|
18
19
|
var dashOptions = {
|
|
@@ -460,7 +461,7 @@ var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
460
461
|
});
|
|
461
462
|
});
|
|
462
463
|
var vsbcData = Object.values(mapXToDataPoints);
|
|
463
|
-
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: vsbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: typeof ((_d = vsbcData[0]) === null || _d === void 0 ? void 0 : _d.xAxisPoint) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getBarProps(input.data, input.layout));
|
|
464
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: vsbcData, width: (_a = input.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barWidth: 'auto', yMaxValue: yMaxValue, yMinValue: yMinValue, mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, supportNegativeData: true, barGapMax: 2, showYAxisLables: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: typeof ((_d = vsbcData[0]) === null || _d === void 0 ? void 0 : _d.xAxisPoint) === 'string' }), getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getYMinMaxValues(input.data[0], input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getBarProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout));
|
|
464
465
|
};
|
|
465
466
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
466
467
|
var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -527,7 +528,7 @@ var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, col
|
|
|
527
528
|
});
|
|
528
529
|
});
|
|
529
530
|
var gvbcData = Object.values(mapXToDataPoints);
|
|
530
|
-
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: gvbcData, width: (_a = processedInput.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = processedInput.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, wrapXAxisLables: typeof ((_d = gvbcData[0]) === null || _d === void 0 ? void 0 : _d.name) === 'string' }), getTitles(processedInput.layout)), getAxisCategoryOrderProps(processedInput.data, processedInput.layout)), getYMinMaxValues(processedInput.data[0], processedInput.layout)), getXAxisTickFormat(processedInput.data[0], processedInput.layout)), yAxisTickFormat), getBarProps(processedInput.data, processedInput.layout));
|
|
531
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: gvbcData, width: (_a = processedInput.layout) === null || _a === void 0 ? void 0 : _a.width, height: (_c = (_b = processedInput.layout) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 350, barwidth: 'auto', mode: 'plotly' }, secondaryYAxisValues), { hideTickOverlap: true, hideLegend: hideLegend, roundCorners: true, wrapXAxisLables: typeof ((_d = gvbcData[0]) === null || _d === void 0 ? void 0 : _d.name) === 'string' }), getTitles(processedInput.layout)), getAxisCategoryOrderProps(processedInput.data, processedInput.layout)), getYMinMaxValues(processedInput.data[0], processedInput.layout)), getXAxisTickFormat(processedInput.data[0], processedInput.layout)), yAxisTickFormat), getBarProps(processedInput.data, processedInput.layout)), getAxisTickProps(processedInput.data, processedInput.layout));
|
|
531
532
|
};
|
|
532
533
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
533
534
|
var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -692,7 +693,7 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
692
693
|
var scatterChartProps = {
|
|
693
694
|
scatterChartData: chartData,
|
|
694
695
|
};
|
|
695
|
-
var commonProps = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ supportNegativeData: true }, secondaryYAxisValues), { width: (_b = input.layout) === null || _b === void 0 ? void 0 : _b.width, height: (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getAxisScaleTypeProps(input.data, input.layout));
|
|
696
|
+
var commonProps = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ supportNegativeData: true }, secondaryYAxisValues), { width: (_b = input.layout) === null || _b === void 0 ? void 0 : _b.width, height: (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 350, hideTickOverlap: true, hideLegend: hideLegend, useUTC: false, optimizeLargeData: numDataPoints > 1000 }), getTitles(input.layout)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat), getAxisScaleTypeProps(input.data, input.layout)), getAxisTickProps(input.data, input.layout));
|
|
696
697
|
if (isAreaChart) {
|
|
697
698
|
return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
|
|
698
699
|
}
|
|
@@ -743,9 +744,9 @@ var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, isMultiPl
|
|
|
743
744
|
var scalingFactor = 0.01;
|
|
744
745
|
var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
745
746
|
var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
746
|
-
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: chartData, secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
|
|
747
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: chartData, secondaryYAxistitle: typeof ((_k = (_j = input.layout) === null || _j === void 0 ? void 0 : _j.yaxis2) === null || _k === void 0 ? void 0 : _k.title) === 'string'
|
|
747
748
|
? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
|
|
748
|
-
: ((_q = (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.yaxis2) === null || _p === void 0 ? void 0 : _p.title) === null || _q === void 0 ? void 0 : _q.text) || '', barHeight: barHeight, showYAxisLables: true, height: chartHeight, width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true));
|
|
749
|
+
: ((_q = (_p = (_o = input.layout) === null || _o === void 0 ? void 0 : _o.yaxis2) === null || _p === void 0 ? void 0 : _p.title) === null || _q === void 0 ? void 0 : _q.text) || '', barHeight: barHeight, showYAxisLables: true, height: chartHeight, width: (_r = input.layout) === null || _r === void 0 ? void 0 : _r.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true)), getAxisTickProps(input.data, input.layout));
|
|
749
750
|
};
|
|
750
751
|
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
751
752
|
var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -792,7 +793,7 @@ var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMa
|
|
|
792
793
|
.filter(function (point) { return point !== null; });
|
|
793
794
|
})
|
|
794
795
|
.flat();
|
|
795
|
-
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: chartData, showYAxisLables: true, height: (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 350, width: (_c = input.layout) === null || _c === void 0 ? void 0 : _c.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true, useUTC: false }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true));
|
|
796
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: chartData, showYAxisLables: true, height: (_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 350, width: (_c = input.layout) === null || _c === void 0 ? void 0 : _c.width, hideTickOverlap: true, hideLegend: hideLegend, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, roundCorners: true, useUTC: false }, getTitles(input.layout)), getAxisCategoryOrderProps(input.data, input.layout)), getBarProps(input.data, input.layout, true)), getAxisTickProps(input.data, input.layout));
|
|
796
797
|
};
|
|
797
798
|
exports.transformPlotlyJsonToGanttChartProps = transformPlotlyJsonToGanttChartProps;
|
|
798
799
|
var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -907,7 +908,7 @@ var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap,
|
|
|
907
908
|
var rangeValuesForColorScale = Array.isArray(colorscale)
|
|
908
909
|
? colorscale.map(function (arr) { return arr[1]; })
|
|
909
910
|
: defaultRange;
|
|
910
|
-
return tslib_1.__assign(tslib_1.__assign({ data: [heatmapData], domainValuesForColorScale: domainValuesForColorScale, rangeValuesForColorScale: rangeValuesForColorScale, hideLegend: true, showYAxisLables: true, sortOrder: 'none', width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width, height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350, hideTickOverlap: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: true }, getTitles(input.layout)), getAxisCategoryOrderProps([firstData], input.layout));
|
|
911
|
+
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ data: [heatmapData], domainValuesForColorScale: domainValuesForColorScale, rangeValuesForColorScale: rangeValuesForColorScale, hideLegend: true, showYAxisLables: true, sortOrder: 'none', width: (_6 = input.layout) === null || _6 === void 0 ? void 0 : _6.width, height: (_8 = (_7 = input.layout) === null || _7 === void 0 ? void 0 : _7.height) !== null && _8 !== void 0 ? _8 : 350, hideTickOverlap: true, noOfCharsToTruncate: 20, showYAxisLablesTooltip: true, wrapXAxisLables: true }, getTitles(input.layout)), getAxisCategoryOrderProps([firstData], input.layout)), getAxisTickProps(input.data, input.layout));
|
|
911
912
|
};
|
|
912
913
|
exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
|
|
913
914
|
var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -1542,11 +1543,11 @@ var createBins = function (data, binStart, binEnd, binSize) {
|
|
|
1542
1543
|
var binGenerator = (0, d3_array_1.bin)().domain([minVal, maxVal]);
|
|
1543
1544
|
if (typeof binSize === 'number' && binSize > 0) {
|
|
1544
1545
|
var thresholds = [];
|
|
1545
|
-
var precision = Math.max(
|
|
1546
|
-
var th = precisionRound(minVal, precision);
|
|
1547
|
-
while (th < precisionRound(maxVal + binSize, precision)) {
|
|
1546
|
+
var precision = Math.max((0, react_1.calculatePrecision)(minVal), (0, react_1.calculatePrecision)(binSize));
|
|
1547
|
+
var th = (0, react_1.precisionRound)(minVal, precision);
|
|
1548
|
+
while (th < (0, react_1.precisionRound)(maxVal + binSize, precision)) {
|
|
1548
1549
|
thresholds.push(th);
|
|
1549
|
-
th = precisionRound(th + binSize, precision);
|
|
1550
|
+
th = (0, react_1.precisionRound)(th + binSize, precision);
|
|
1550
1551
|
}
|
|
1551
1552
|
minVal = thresholds[0];
|
|
1552
1553
|
maxVal = thresholds[thresholds.length - 1];
|
|
@@ -1589,14 +1590,6 @@ var calculateHistNorm = function (histnorm, value, total, dx, dy) {
|
|
|
1589
1590
|
return value;
|
|
1590
1591
|
}
|
|
1591
1592
|
};
|
|
1592
|
-
var getPrecision = function (value) {
|
|
1593
|
-
var _a, _b;
|
|
1594
|
-
return (_b = (_a = value.toString().split('.')[1]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
1595
|
-
};
|
|
1596
|
-
var precisionRound = function (value, precision) {
|
|
1597
|
-
var factor = Math.pow(10, precision);
|
|
1598
|
-
return Math.round(value * factor) / factor;
|
|
1599
|
-
};
|
|
1600
1593
|
var getLegendShape = function (series) {
|
|
1601
1594
|
var _a, _b;
|
|
1602
1595
|
var dashType = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.dash) || 'solid';
|
|
@@ -1979,7 +1972,128 @@ var getBarProps = function (data, layout, isHorizontal) {
|
|
|
1979
1972
|
};
|
|
1980
1973
|
};
|
|
1981
1974
|
var getAxisScaleTypeProps = function (data, layout) {
|
|
1975
|
+
var _a, _b, _c;
|
|
1982
1976
|
var result = {};
|
|
1977
|
+
var axisObjects = getAxisObjects(data, layout);
|
|
1978
|
+
if (((_a = axisObjects.x) === null || _a === void 0 ? void 0 : _a.type) === 'log') {
|
|
1979
|
+
result.xScaleType = 'log';
|
|
1980
|
+
}
|
|
1981
|
+
if (((_b = axisObjects.y) === null || _b === void 0 ? void 0 : _b.type) === 'log') {
|
|
1982
|
+
result.yScaleType = 'log';
|
|
1983
|
+
}
|
|
1984
|
+
if (((_c = axisObjects.y2) === null || _c === void 0 ? void 0 : _c.type) === 'log') {
|
|
1985
|
+
result.secondaryYScaleType = 'log';
|
|
1986
|
+
}
|
|
1987
|
+
return result;
|
|
1988
|
+
};
|
|
1989
|
+
/**
|
|
1990
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/tick_value_defaults.js#L8}
|
|
1991
|
+
*/
|
|
1992
|
+
var getAxisTickProps = function (data, layout) {
|
|
1993
|
+
var props = {};
|
|
1994
|
+
var axisObjects = getAxisObjects(data, layout);
|
|
1995
|
+
Object.keys(axisObjects).forEach(function (axId) {
|
|
1996
|
+
var ax = axisObjects[axId];
|
|
1997
|
+
if (!ax) {
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
var axType = getAxisType(data, axId[0], ax);
|
|
2001
|
+
if ((!ax.tickmode || ax.tickmode === 'array') && (0, chart_utilities_1.isArrayOrTypedArray)(ax.tickvals)) {
|
|
2002
|
+
var tickValues = axType === 'date' ? ax.tickvals.map(function (v) { return new Date(v); }) : ax.tickvals;
|
|
2003
|
+
if (axId === 'x') {
|
|
2004
|
+
props.tickValues = tickValues;
|
|
2005
|
+
}
|
|
2006
|
+
else if (axId === 'y') {
|
|
2007
|
+
props.yAxisTickValues = tickValues;
|
|
2008
|
+
}
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
if ((!ax.tickmode || ax.tickmode === 'linear') && ax.dtick) {
|
|
2012
|
+
var dtick = plotlyDtick(ax.dtick, axType);
|
|
2013
|
+
var tick0 = plotlyTick0(ax.tick0, axType, dtick);
|
|
2014
|
+
if (axId === 'x') {
|
|
2015
|
+
props.xAxis = {
|
|
2016
|
+
tickStep: dtick,
|
|
2017
|
+
tick0: tick0,
|
|
2018
|
+
};
|
|
2019
|
+
}
|
|
2020
|
+
else if (axId === 'y') {
|
|
2021
|
+
props.yAxis = {
|
|
2022
|
+
tickStep: dtick,
|
|
2023
|
+
tick0: tick0,
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
2026
|
+
return;
|
|
2027
|
+
}
|
|
2028
|
+
if ((!ax.tickmode || ax.tickmode === 'auto') && typeof ax.nticks === 'number' && ax.nticks >= 0) {
|
|
2029
|
+
if (axId === 'x') {
|
|
2030
|
+
props.xAxisTickCount = ax.nticks;
|
|
2031
|
+
}
|
|
2032
|
+
else if (axId === 'y') {
|
|
2033
|
+
props.yAxisTickCount = ax.nticks;
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
});
|
|
2037
|
+
return props;
|
|
2038
|
+
};
|
|
2039
|
+
/**
|
|
2040
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L16}
|
|
2041
|
+
*/
|
|
2042
|
+
var plotlyDtick = function (dtick, axType) {
|
|
2043
|
+
var isLogAx = axType === 'log';
|
|
2044
|
+
var isDateAx = axType === 'date';
|
|
2045
|
+
var isCatAx = axType === 'category';
|
|
2046
|
+
var dtickDflt = isDateAx ? 86400000 : 1;
|
|
2047
|
+
if (!dtick) {
|
|
2048
|
+
return dtickDflt;
|
|
2049
|
+
}
|
|
2050
|
+
if ((0, chart_utilities_1.isNumber)(dtick)) {
|
|
2051
|
+
dtick = Number(dtick);
|
|
2052
|
+
if (dtick <= 0) {
|
|
2053
|
+
return dtickDflt;
|
|
2054
|
+
}
|
|
2055
|
+
if (isCatAx) {
|
|
2056
|
+
// category dtick must be positive integers
|
|
2057
|
+
return Math.max(1, Math.round(dtick));
|
|
2058
|
+
}
|
|
2059
|
+
if (isDateAx) {
|
|
2060
|
+
// date dtick must be at least 0.1ms (our current precision)
|
|
2061
|
+
return Math.max(0.1, dtick);
|
|
2062
|
+
}
|
|
2063
|
+
return dtick;
|
|
2064
|
+
}
|
|
2065
|
+
if (typeof dtick !== 'string' || !(isDateAx || isLogAx)) {
|
|
2066
|
+
return dtickDflt;
|
|
2067
|
+
}
|
|
2068
|
+
var prefix = dtick.charAt(0);
|
|
2069
|
+
var dtickNum = (0, chart_utilities_1.isNumber)(dtick.slice(1)) ? Number(dtick.slice(1)) : 0;
|
|
2070
|
+
if (dtickNum <= 0 ||
|
|
2071
|
+
!(
|
|
2072
|
+
// "M<n>" gives ticks every (integer) n months
|
|
2073
|
+
((isDateAx && prefix === 'M' && dtickNum === Math.round(dtickNum)) ||
|
|
2074
|
+
// "L<f>" gives ticks linearly spaced in data (not in position) every (float) f
|
|
2075
|
+
(isLogAx && prefix === 'L') ||
|
|
2076
|
+
// "D1" gives powers of 10 with all small digits between, "D2" gives only 2 and 5
|
|
2077
|
+
(isLogAx && prefix === 'D' && (dtickNum === 1 || dtickNum === 2))))) {
|
|
2078
|
+
return dtickDflt;
|
|
2079
|
+
}
|
|
2080
|
+
return dtick;
|
|
2081
|
+
};
|
|
2082
|
+
/**
|
|
2083
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L70}
|
|
2084
|
+
*/
|
|
2085
|
+
var plotlyTick0 = function (tick0, axType, dtick) {
|
|
2086
|
+
if (axType === 'date') {
|
|
2087
|
+
return (0, chart_utilities_1.isDate)(tick0) ? new Date(tick0) : new Date(utilities_1.DEFAULT_DATE_STRING);
|
|
2088
|
+
}
|
|
2089
|
+
if (dtick === 'D1' || dtick === 'D2') {
|
|
2090
|
+
// D1 and D2 modes ignore tick0 entirely
|
|
2091
|
+
return undefined;
|
|
2092
|
+
}
|
|
2093
|
+
// Aside from date axes, tick0 must be numeric
|
|
2094
|
+
return (0, chart_utilities_1.isNumber)(tick0) ? Number(tick0) : 0;
|
|
2095
|
+
};
|
|
2096
|
+
var getAxisObjects = function (data, layout) {
|
|
1983
2097
|
// Traces are grouped by their xaxis property, and for each group/subplot, the adapter functions
|
|
1984
2098
|
// are called with the corresponding filtered data. As a result, all traces passed to an adapter
|
|
1985
2099
|
// function share the same xaxis.
|
|
@@ -1990,21 +2104,43 @@ var getAxisScaleTypeProps = function (data, layout) {
|
|
|
1990
2104
|
xAxisId = axisIds.x;
|
|
1991
2105
|
yAxisIds.add(axisIds.y);
|
|
1992
2106
|
});
|
|
1993
|
-
var
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
return ((_a = layout === null || layout === void 0 ? void 0 : layout[axisKey]) === null || _a === void 0 ? void 0 : _a.type) === 'log';
|
|
1997
|
-
};
|
|
1998
|
-
if (typeof xAxisId === 'number' && isLogAxis('x', xAxisId)) {
|
|
1999
|
-
result.xScaleType = 'log';
|
|
2107
|
+
var axisObjects = {};
|
|
2108
|
+
if (typeof xAxisId === 'number') {
|
|
2109
|
+
axisObjects.x = layout === null || layout === void 0 ? void 0 : layout[(0, chart_utilities_1.getAxisKey)('x', xAxisId)];
|
|
2000
2110
|
}
|
|
2001
2111
|
var sortedYAxisIds = Array.from(yAxisIds).sort();
|
|
2002
|
-
if (sortedYAxisIds.length > 0
|
|
2003
|
-
|
|
2112
|
+
if (sortedYAxisIds.length > 0) {
|
|
2113
|
+
axisObjects.y = layout === null || layout === void 0 ? void 0 : layout[(0, chart_utilities_1.getAxisKey)('y', sortedYAxisIds[0])];
|
|
2004
2114
|
}
|
|
2005
|
-
if (sortedYAxisIds.length > 1
|
|
2006
|
-
|
|
2115
|
+
if (sortedYAxisIds.length > 1) {
|
|
2116
|
+
axisObjects.y2 = layout === null || layout === void 0 ? void 0 : layout[(0, chart_utilities_1.getAxisKey)('y', sortedYAxisIds[1])];
|
|
2117
|
+
}
|
|
2118
|
+
return axisObjects;
|
|
2119
|
+
};
|
|
2120
|
+
var getAxisType = function (data, axLetter, ax) {
|
|
2121
|
+
var values = [];
|
|
2122
|
+
data.forEach(function (series) {
|
|
2123
|
+
var _a;
|
|
2124
|
+
(_a = series[axLetter]) === null || _a === void 0 ? void 0 : _a.forEach(function (val) {
|
|
2125
|
+
if (!(0, chart_utilities_1.isInvalidValue)(val)) {
|
|
2126
|
+
values.push(val);
|
|
2127
|
+
}
|
|
2128
|
+
});
|
|
2129
|
+
});
|
|
2130
|
+
// Note: When ax.type is explicitly specified, Plotly casts the values to match that type.
|
|
2131
|
+
// Therefore, simply checking the type of the values may not be sufficient. At the moment,
|
|
2132
|
+
// we don’t always perform this casting ourselves and instead use the values as provided.
|
|
2133
|
+
if ((0, chart_utilities_1.isNumberArray)(values)) {
|
|
2134
|
+
if ((ax === null || ax === void 0 ? void 0 : ax.type) === 'log') {
|
|
2135
|
+
return 'log';
|
|
2136
|
+
}
|
|
2137
|
+
return 'linear';
|
|
2138
|
+
}
|
|
2139
|
+
if ((0, chart_utilities_1.isDateArray)(values)) {
|
|
2140
|
+
return 'date';
|
|
2141
|
+
}
|
|
2142
|
+
if ((0, chart_utilities_1.isStringArray)(values)) {
|
|
2143
|
+
return 'category';
|
|
2007
2144
|
}
|
|
2008
|
-
return result;
|
|
2009
2145
|
};
|
|
2010
2146
|
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|