@fluentui/react-charting 5.24.24 → 5.24.26
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 +49 -1
- package/CHANGELOG.md +23 -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 +213 -47
- 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 +215 -50
- 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 +215 -49
- 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 +4 -4
- package/src/components/CommonComponents/CartesianChart.types.ts +19 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../../utilities/colors", "../GaugeChart/index", "../../utilities/utilities", "@fluentui/chart-utilities", "d3-shape", "./PlotlyColorAdapter", "d3-color"], function (require, exports, tslib_1, d3_array_1, d3_scale_1, d3_format_1, colors_1, index_1, utilities_1, chart_utilities_1, d3_shape_1, PlotlyColorAdapter_1, d3_color_1) {
|
|
1
|
+
define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../../utilities/colors", "../GaugeChart/index", "../../utilities/utilities", "@fluentui/chart-utilities", "d3-shape", "./PlotlyColorAdapter", "d3-color", "@fluentui/react"], function (require, exports, tslib_1, d3_array_1, d3_scale_1, d3_format_1, colors_1, index_1, utilities_1, chart_utilities_1, d3_shape_1, PlotlyColorAdapter_1, d3_color_1, react_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.getGridProperties = exports.isNonPlotType = exports.getValidXYRanges = exports.getNumberAtIndexOrDefault = exports.getAllupLegendsProps = exports.projectPolarToCartesian = exports.transformPlotlyJsonToFunnelChartProps = exports.transformPlotlyJsonToChartTableProps = exports.transformPlotlyJsonToGaugeProps = exports.transformPlotlyJsonToSankeyProps = exports.transformPlotlyJsonToHeatmapProps = exports.transformPlotlyJsonToGanttChartProps = exports.transformPlotlyJsonToHorizontalBarWithAxisProps = exports.transformPlotlyJsonToScatterChartProps = exports.transformPlotlyJsonToLineChartProps = exports.transformPlotlyJsonToAreaChartProps = exports.transformPlotlyJsonToVBCProps = exports.transformPlotlyJsonToGVBCProps = exports.transformPlotlyJsonToVSBCProps = exports.transformPlotlyJsonToDonutProps = exports.normalizeObjectArrayForGVBC = exports.resolveXAxisPoint = exports._getGaugeAxisColor = exports.correctYearMonth = exports.SINGLE_REPEAT = exports.NON_PLOT_KEY_PREFIX = void 0;
|
|
@@ -327,25 +327,55 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
327
327
|
// otherwise, default to colorway from template
|
|
328
328
|
var colors = (0, PlotlyColorAdapter_1.extractColor)((_b = (_a = input.layout) === null || _a === void 0 ? void 0 : _a.piecolorway) !== null && _b !== void 0 ? _b : (_e = (_d = (_c = input.layout) === null || _c === void 0 ? void 0 : _c.template) === null || _d === void 0 ? void 0 : _d.layout) === null || _e === void 0 ? void 0 : _e.colorway, colorwayType, (_g = (_f = input.layout) === null || _f === void 0 ? void 0 : _f.piecolorway) !== null && _g !== void 0 ? _g : (_h = firstData === null || firstData === void 0 ? void 0 : firstData.marker) === null || _h === void 0 ? void 0 : _h.colors, colorMap, isDarkTheme);
|
|
329
329
|
var mapLegendToDataPoint = {};
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
mapLegendToDataPoint[legend]
|
|
340
|
-
legend
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
330
|
+
if (colors) {
|
|
331
|
+
(_j = firstData.labels) === null || _j === void 0 ? void 0 : _j.forEach(function (label, index) {
|
|
332
|
+
var value = (0, exports.getNumberAtIndexOrDefault)(firstData.values, index);
|
|
333
|
+
if ((0, chart_utilities_1.isInvalidValue)(value) || value < 0) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
var legend = "".concat(label);
|
|
337
|
+
// resolve color for each legend from the extracted colors
|
|
338
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(colors, index, legend, colorMap, isDarkTheme);
|
|
339
|
+
if (!mapLegendToDataPoint[legend]) {
|
|
340
|
+
mapLegendToDataPoint[legend] = {
|
|
341
|
+
legend: legend,
|
|
342
|
+
data: value,
|
|
343
|
+
color: color,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
mapLegendToDataPoint[legend].data += value;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
// Sort labels by value descending before mapping
|
|
353
|
+
if (firstData.labels && firstData.values) {
|
|
354
|
+
var labelValuePairs = firstData.labels.map(function (label, index) { return ({
|
|
355
|
+
label: label,
|
|
356
|
+
value: (0, exports.getNumberAtIndexOrDefault)(firstData.values, index),
|
|
357
|
+
index: index,
|
|
358
|
+
}); });
|
|
359
|
+
// Filter out invalid values
|
|
360
|
+
var validPairs = labelValuePairs.filter(function (pair) { return !(0, chart_utilities_1.isInvalidValue)(pair.value); });
|
|
361
|
+
// Sort descending by value
|
|
362
|
+
validPairs.sort(function (a, b) { return b.value - a.value; });
|
|
363
|
+
validPairs.forEach(function (pair, sortedIdx) {
|
|
364
|
+
var legend = "".concat(pair.label);
|
|
365
|
+
var color = (0, PlotlyColorAdapter_1.resolveColor)(colors, sortedIdx, legend, colorMap, isDarkTheme);
|
|
366
|
+
if (!mapLegendToDataPoint[legend]) {
|
|
367
|
+
mapLegendToDataPoint[legend] = {
|
|
368
|
+
legend: legend,
|
|
369
|
+
data: pair.value,
|
|
370
|
+
color: color,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
mapLegendToDataPoint[legend].data += pair.value;
|
|
375
|
+
}
|
|
376
|
+
});
|
|
347
377
|
}
|
|
348
|
-
}
|
|
378
|
+
}
|
|
349
379
|
var width = (_l = (_k = input.layout) === null || _k === void 0 ? void 0 : _k.width) !== null && _l !== void 0 ? _l : 440;
|
|
350
380
|
var height = (_o = (_m = input.layout) === null || _m === void 0 ? void 0 : _m.height) !== null && _o !== void 0 ? _o : 220;
|
|
351
381
|
var hideLabels = firstData.textinfo
|
|
@@ -450,7 +480,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
450
480
|
});
|
|
451
481
|
});
|
|
452
482
|
var vsbcData = Object.values(mapXToDataPoints);
|
|
453
|
-
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));
|
|
483
|
+
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));
|
|
454
484
|
};
|
|
455
485
|
exports.transformPlotlyJsonToVSBCProps = transformPlotlyJsonToVSBCProps;
|
|
456
486
|
var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -517,7 +547,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
517
547
|
});
|
|
518
548
|
});
|
|
519
549
|
var gvbcData = Object.values(mapXToDataPoints);
|
|
520
|
-
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));
|
|
550
|
+
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));
|
|
521
551
|
};
|
|
522
552
|
exports.transformPlotlyJsonToGVBCProps = transformPlotlyJsonToGVBCProps;
|
|
523
553
|
var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -682,7 +712,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
682
712
|
var scatterChartProps = {
|
|
683
713
|
scatterChartData: chartData,
|
|
684
714
|
};
|
|
685
|
-
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));
|
|
715
|
+
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));
|
|
686
716
|
if (isAreaChart) {
|
|
687
717
|
return tslib_1.__assign({ data: chartProps, mode: mode }, commonProps);
|
|
688
718
|
}
|
|
@@ -733,9 +763,9 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
733
763
|
var scalingFactor = 0.01;
|
|
734
764
|
var gapFactor = 1 / (1 + scalingFactor * numberOfRows);
|
|
735
765
|
var barHeight = availableHeight / (numberOfRows * (1 + gapFactor));
|
|
736
|
-
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'
|
|
766
|
+
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'
|
|
737
767
|
? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
|
|
738
|
-
: ((_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));
|
|
768
|
+
: ((_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));
|
|
739
769
|
};
|
|
740
770
|
exports.transformPlotlyJsonToHorizontalBarWithAxisProps = transformPlotlyJsonToHorizontalBarWithAxisProps;
|
|
741
771
|
var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -782,7 +812,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
782
812
|
.filter(function (point) { return point !== null; });
|
|
783
813
|
})
|
|
784
814
|
.flat();
|
|
785
|
-
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));
|
|
815
|
+
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));
|
|
786
816
|
};
|
|
787
817
|
exports.transformPlotlyJsonToGanttChartProps = transformPlotlyJsonToGanttChartProps;
|
|
788
818
|
var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -897,7 +927,7 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
897
927
|
var rangeValuesForColorScale = Array.isArray(colorscale)
|
|
898
928
|
? colorscale.map(function (arr) { return arr[1]; })
|
|
899
929
|
: defaultRange;
|
|
900
|
-
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));
|
|
930
|
+
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));
|
|
901
931
|
};
|
|
902
932
|
exports.transformPlotlyJsonToHeatmapProps = transformPlotlyJsonToHeatmapProps;
|
|
903
933
|
var transformPlotlyJsonToSankeyProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
@@ -1532,11 +1562,11 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1532
1562
|
var binGenerator = (0, d3_array_1.bin)().domain([minVal, maxVal]);
|
|
1533
1563
|
if (typeof binSize === 'number' && binSize > 0) {
|
|
1534
1564
|
var thresholds = [];
|
|
1535
|
-
var precision = Math.max(
|
|
1536
|
-
var th = precisionRound(minVal, precision);
|
|
1537
|
-
while (th < precisionRound(maxVal + binSize, precision)) {
|
|
1565
|
+
var precision = Math.max((0, react_1.calculatePrecision)(minVal), (0, react_1.calculatePrecision)(binSize));
|
|
1566
|
+
var th = (0, react_1.precisionRound)(minVal, precision);
|
|
1567
|
+
while (th < (0, react_1.precisionRound)(maxVal + binSize, precision)) {
|
|
1538
1568
|
thresholds.push(th);
|
|
1539
|
-
th = precisionRound(th + binSize, precision);
|
|
1569
|
+
th = (0, react_1.precisionRound)(th + binSize, precision);
|
|
1540
1570
|
}
|
|
1541
1571
|
minVal = thresholds[0];
|
|
1542
1572
|
maxVal = thresholds[thresholds.length - 1];
|
|
@@ -1579,14 +1609,6 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1579
1609
|
return value;
|
|
1580
1610
|
}
|
|
1581
1611
|
};
|
|
1582
|
-
var getPrecision = function (value) {
|
|
1583
|
-
var _a, _b;
|
|
1584
|
-
return (_b = (_a = value.toString().split('.')[1]) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
1585
|
-
};
|
|
1586
|
-
var precisionRound = function (value, precision) {
|
|
1587
|
-
var factor = Math.pow(10, precision);
|
|
1588
|
-
return Math.round(value * factor) / factor;
|
|
1589
|
-
};
|
|
1590
1612
|
var getLegendShape = function (series) {
|
|
1591
1613
|
var _a, _b;
|
|
1592
1614
|
var dashType = ((_a = series.line) === null || _a === void 0 ? void 0 : _a.dash) || 'solid';
|
|
@@ -1969,7 +1991,128 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1969
1991
|
};
|
|
1970
1992
|
};
|
|
1971
1993
|
var getAxisScaleTypeProps = function (data, layout) {
|
|
1994
|
+
var _a, _b, _c;
|
|
1972
1995
|
var result = {};
|
|
1996
|
+
var axisObjects = getAxisObjects(data, layout);
|
|
1997
|
+
if (((_a = axisObjects.x) === null || _a === void 0 ? void 0 : _a.type) === 'log') {
|
|
1998
|
+
result.xScaleType = 'log';
|
|
1999
|
+
}
|
|
2000
|
+
if (((_b = axisObjects.y) === null || _b === void 0 ? void 0 : _b.type) === 'log') {
|
|
2001
|
+
result.yScaleType = 'log';
|
|
2002
|
+
}
|
|
2003
|
+
if (((_c = axisObjects.y2) === null || _c === void 0 ? void 0 : _c.type) === 'log') {
|
|
2004
|
+
result.secondaryYScaleType = 'log';
|
|
2005
|
+
}
|
|
2006
|
+
return result;
|
|
2007
|
+
};
|
|
2008
|
+
/**
|
|
2009
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/tick_value_defaults.js#L8}
|
|
2010
|
+
*/
|
|
2011
|
+
var getAxisTickProps = function (data, layout) {
|
|
2012
|
+
var props = {};
|
|
2013
|
+
var axisObjects = getAxisObjects(data, layout);
|
|
2014
|
+
Object.keys(axisObjects).forEach(function (axId) {
|
|
2015
|
+
var ax = axisObjects[axId];
|
|
2016
|
+
if (!ax) {
|
|
2017
|
+
return;
|
|
2018
|
+
}
|
|
2019
|
+
var axType = getAxisType(data, axId[0], ax);
|
|
2020
|
+
if ((!ax.tickmode || ax.tickmode === 'array') && (0, chart_utilities_1.isArrayOrTypedArray)(ax.tickvals)) {
|
|
2021
|
+
var tickValues = axType === 'date' ? ax.tickvals.map(function (v) { return new Date(v); }) : ax.tickvals;
|
|
2022
|
+
if (axId === 'x') {
|
|
2023
|
+
props.tickValues = tickValues;
|
|
2024
|
+
}
|
|
2025
|
+
else if (axId === 'y') {
|
|
2026
|
+
props.yAxisTickValues = tickValues;
|
|
2027
|
+
}
|
|
2028
|
+
return;
|
|
2029
|
+
}
|
|
2030
|
+
if ((!ax.tickmode || ax.tickmode === 'linear') && ax.dtick) {
|
|
2031
|
+
var dtick = plotlyDtick(ax.dtick, axType);
|
|
2032
|
+
var tick0 = plotlyTick0(ax.tick0, axType, dtick);
|
|
2033
|
+
if (axId === 'x') {
|
|
2034
|
+
props.xAxis = {
|
|
2035
|
+
tickStep: dtick,
|
|
2036
|
+
tick0: tick0,
|
|
2037
|
+
};
|
|
2038
|
+
}
|
|
2039
|
+
else if (axId === 'y') {
|
|
2040
|
+
props.yAxis = {
|
|
2041
|
+
tickStep: dtick,
|
|
2042
|
+
tick0: tick0,
|
|
2043
|
+
};
|
|
2044
|
+
}
|
|
2045
|
+
return;
|
|
2046
|
+
}
|
|
2047
|
+
if ((!ax.tickmode || ax.tickmode === 'auto') && typeof ax.nticks === 'number' && ax.nticks >= 0) {
|
|
2048
|
+
if (axId === 'x') {
|
|
2049
|
+
props.xAxisTickCount = ax.nticks;
|
|
2050
|
+
}
|
|
2051
|
+
else if (axId === 'y') {
|
|
2052
|
+
props.yAxisTickCount = ax.nticks;
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
});
|
|
2056
|
+
return props;
|
|
2057
|
+
};
|
|
2058
|
+
/**
|
|
2059
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L16}
|
|
2060
|
+
*/
|
|
2061
|
+
var plotlyDtick = function (dtick, axType) {
|
|
2062
|
+
var isLogAx = axType === 'log';
|
|
2063
|
+
var isDateAx = axType === 'date';
|
|
2064
|
+
var isCatAx = axType === 'category';
|
|
2065
|
+
var dtickDflt = isDateAx ? 86400000 : 1;
|
|
2066
|
+
if (!dtick) {
|
|
2067
|
+
return dtickDflt;
|
|
2068
|
+
}
|
|
2069
|
+
if ((0, chart_utilities_1.isNumber)(dtick)) {
|
|
2070
|
+
dtick = Number(dtick);
|
|
2071
|
+
if (dtick <= 0) {
|
|
2072
|
+
return dtickDflt;
|
|
2073
|
+
}
|
|
2074
|
+
if (isCatAx) {
|
|
2075
|
+
// category dtick must be positive integers
|
|
2076
|
+
return Math.max(1, Math.round(dtick));
|
|
2077
|
+
}
|
|
2078
|
+
if (isDateAx) {
|
|
2079
|
+
// date dtick must be at least 0.1ms (our current precision)
|
|
2080
|
+
return Math.max(0.1, dtick);
|
|
2081
|
+
}
|
|
2082
|
+
return dtick;
|
|
2083
|
+
}
|
|
2084
|
+
if (typeof dtick !== 'string' || !(isDateAx || isLogAx)) {
|
|
2085
|
+
return dtickDflt;
|
|
2086
|
+
}
|
|
2087
|
+
var prefix = dtick.charAt(0);
|
|
2088
|
+
var dtickNum = (0, chart_utilities_1.isNumber)(dtick.slice(1)) ? Number(dtick.slice(1)) : 0;
|
|
2089
|
+
if (dtickNum <= 0 ||
|
|
2090
|
+
!(
|
|
2091
|
+
// "M<n>" gives ticks every (integer) n months
|
|
2092
|
+
((isDateAx && prefix === 'M' && dtickNum === Math.round(dtickNum)) ||
|
|
2093
|
+
// "L<f>" gives ticks linearly spaced in data (not in position) every (float) f
|
|
2094
|
+
(isLogAx && prefix === 'L') ||
|
|
2095
|
+
// "D1" gives powers of 10 with all small digits between, "D2" gives only 2 and 5
|
|
2096
|
+
(isLogAx && prefix === 'D' && (dtickNum === 1 || dtickNum === 2))))) {
|
|
2097
|
+
return dtickDflt;
|
|
2098
|
+
}
|
|
2099
|
+
return dtick;
|
|
2100
|
+
};
|
|
2101
|
+
/**
|
|
2102
|
+
* @see {@link https://github.com/plotly/plotly.js/blob/master/src/plots/cartesian/clean_ticks.js#L70}
|
|
2103
|
+
*/
|
|
2104
|
+
var plotlyTick0 = function (tick0, axType, dtick) {
|
|
2105
|
+
if (axType === 'date') {
|
|
2106
|
+
return (0, chart_utilities_1.isDate)(tick0) ? new Date(tick0) : new Date(utilities_1.DEFAULT_DATE_STRING);
|
|
2107
|
+
}
|
|
2108
|
+
if (dtick === 'D1' || dtick === 'D2') {
|
|
2109
|
+
// D1 and D2 modes ignore tick0 entirely
|
|
2110
|
+
return undefined;
|
|
2111
|
+
}
|
|
2112
|
+
// Aside from date axes, tick0 must be numeric
|
|
2113
|
+
return (0, chart_utilities_1.isNumber)(tick0) ? Number(tick0) : 0;
|
|
2114
|
+
};
|
|
2115
|
+
var getAxisObjects = function (data, layout) {
|
|
1973
2116
|
// Traces are grouped by their xaxis property, and for each group/subplot, the adapter functions
|
|
1974
2117
|
// are called with the corresponding filtered data. As a result, all traces passed to an adapter
|
|
1975
2118
|
// function share the same xaxis.
|
|
@@ -1980,22 +2123,44 @@ define(["require", "exports", "tslib", "d3-array", "d3-scale", "d3-format", "../
|
|
|
1980
2123
|
xAxisId = axisIds.x;
|
|
1981
2124
|
yAxisIds.add(axisIds.y);
|
|
1982
2125
|
});
|
|
1983
|
-
var
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
return ((_a = layout === null || layout === void 0 ? void 0 : layout[axisKey]) === null || _a === void 0 ? void 0 : _a.type) === 'log';
|
|
1987
|
-
};
|
|
1988
|
-
if (typeof xAxisId === 'number' && isLogAxis('x', xAxisId)) {
|
|
1989
|
-
result.xScaleType = 'log';
|
|
2126
|
+
var axisObjects = {};
|
|
2127
|
+
if (typeof xAxisId === 'number') {
|
|
2128
|
+
axisObjects.x = layout === null || layout === void 0 ? void 0 : layout[(0, chart_utilities_1.getAxisKey)('x', xAxisId)];
|
|
1990
2129
|
}
|
|
1991
2130
|
var sortedYAxisIds = Array.from(yAxisIds).sort();
|
|
1992
|
-
if (sortedYAxisIds.length > 0
|
|
1993
|
-
|
|
2131
|
+
if (sortedYAxisIds.length > 0) {
|
|
2132
|
+
axisObjects.y = layout === null || layout === void 0 ? void 0 : layout[(0, chart_utilities_1.getAxisKey)('y', sortedYAxisIds[0])];
|
|
1994
2133
|
}
|
|
1995
|
-
if (sortedYAxisIds.length > 1
|
|
1996
|
-
|
|
2134
|
+
if (sortedYAxisIds.length > 1) {
|
|
2135
|
+
axisObjects.y2 = layout === null || layout === void 0 ? void 0 : layout[(0, chart_utilities_1.getAxisKey)('y', sortedYAxisIds[1])];
|
|
2136
|
+
}
|
|
2137
|
+
return axisObjects;
|
|
2138
|
+
};
|
|
2139
|
+
var getAxisType = function (data, axLetter, ax) {
|
|
2140
|
+
var values = [];
|
|
2141
|
+
data.forEach(function (series) {
|
|
2142
|
+
var _a;
|
|
2143
|
+
(_a = series[axLetter]) === null || _a === void 0 ? void 0 : _a.forEach(function (val) {
|
|
2144
|
+
if (!(0, chart_utilities_1.isInvalidValue)(val)) {
|
|
2145
|
+
values.push(val);
|
|
2146
|
+
}
|
|
2147
|
+
});
|
|
2148
|
+
});
|
|
2149
|
+
// Note: When ax.type is explicitly specified, Plotly casts the values to match that type.
|
|
2150
|
+
// Therefore, simply checking the type of the values may not be sufficient. At the moment,
|
|
2151
|
+
// we don’t always perform this casting ourselves and instead use the values as provided.
|
|
2152
|
+
if ((0, chart_utilities_1.isNumberArray)(values)) {
|
|
2153
|
+
if ((ax === null || ax === void 0 ? void 0 : ax.type) === 'log') {
|
|
2154
|
+
return 'log';
|
|
2155
|
+
}
|
|
2156
|
+
return 'linear';
|
|
2157
|
+
}
|
|
2158
|
+
if ((0, chart_utilities_1.isDateArray)(values)) {
|
|
2159
|
+
return 'date';
|
|
2160
|
+
}
|
|
2161
|
+
if ((0, chart_utilities_1.isStringArray)(values)) {
|
|
2162
|
+
return 'category';
|
|
1997
2163
|
}
|
|
1998
|
-
return result;
|
|
1999
2164
|
};
|
|
2000
2165
|
});
|
|
2001
2166
|
//# sourceMappingURL=PlotlySchemaAdapter.js.map
|