@fluentui/react-charting 5.24.11 → 5.24.13
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 +61 -1
- package/CHANGELOG.md +25 -2
- package/bundle-size/GanttChart.fixture.js +7 -0
- package/dist/react-charting.d.ts +128 -3
- package/dist/react-charting.js +1 -1
- package/dist/react-charting.min.js +1 -1
- package/etc/react-charting.api.md +44 -2
- package/lib/GanttChart.d.ts +1 -0
- package/lib/GanttChart.js +2 -0
- package/lib/GanttChart.js.map +1 -0
- package/lib/components/CommonComponents/CartesianChart.base.js +2 -1
- package/lib/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib/components/CommonComponents/CartesianChart.types.d.ts +3 -3
- package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib/components/DeclarativeChart/DeclarativeChart.js +22 -4
- package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +23 -0
- package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +2 -0
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +173 -63
- package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib/components/GanttChart/GanttChart.base.d.ts +3 -0
- package/lib/components/GanttChart/GanttChart.base.js +329 -0
- package/lib/components/GanttChart/GanttChart.base.js.map +1 -0
- package/lib/components/GanttChart/GanttChart.d.ts +7 -0
- package/lib/components/GanttChart/GanttChart.js +10 -0
- package/lib/components/GanttChart/GanttChart.js.map +1 -0
- package/lib/components/GanttChart/GanttChart.styles.d.ts +2 -0
- package/lib/components/GanttChart/GanttChart.styles.js +4 -0
- package/lib/components/GanttChart/GanttChart.styles.js.map +1 -0
- package/lib/components/GanttChart/GanttChart.types.d.ts +67 -0
- package/lib/components/GanttChart/GanttChart.types.js +2 -0
- package/lib/components/GanttChart/GanttChart.types.js.map +1 -0
- package/lib/components/GanttChart/index.d.ts +2 -0
- package/lib/components/GanttChart/index.js +3 -0
- package/lib/components/GanttChart/index.js.map +1 -0
- package/lib/components/LineChart/LineChart.base.d.ts +1 -0
- package/lib/components/LineChart/LineChart.base.js +34 -11
- package/lib/components/LineChart/LineChart.base.js.map +1 -1
- package/lib/components/ScatterChart/ScatterChart.base.js +37 -23
- package/lib/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/IDataPoint.d.ts +49 -0
- package/lib/types/IDataPoint.js.map +1 -1
- package/lib/utilities/scatterpolar-utils.d.ts +22 -0
- package/lib/utilities/scatterpolar-utils.js +38 -0
- package/lib/utilities/scatterpolar-utils.js.map +1 -0
- package/lib/utilities/test-data.d.ts +4 -1
- package/lib/utilities/test-data.js +213 -0
- package/lib/utilities/test-data.js.map +1 -1
- package/lib/utilities/utilities.d.ts +14 -6
- package/lib/utilities/utilities.js +25 -9
- package/lib/utilities/utilities.js.map +1 -1
- package/lib-amd/GanttChart.d.ts +1 -0
- package/lib-amd/GanttChart.js +6 -0
- package/lib-amd/GanttChart.js.map +1 -0
- package/lib-amd/components/CommonComponents/CartesianChart.base.js +2 -1
- package/lib-amd/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-amd/components/CommonComponents/CartesianChart.types.d.ts +3 -3
- package/lib-amd/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js +22 -5
- package/lib-amd/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
- package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js +25 -2
- package/lib-amd/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +2 -0
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js +173 -62
- package/lib-amd/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-amd/components/GanttChart/GanttChart.base.d.ts +3 -0
- package/lib-amd/components/GanttChart/GanttChart.base.js +325 -0
- package/lib-amd/components/GanttChart/GanttChart.base.js.map +1 -0
- package/lib-amd/components/GanttChart/GanttChart.d.ts +7 -0
- package/lib-amd/components/GanttChart/GanttChart.js +12 -0
- package/lib-amd/components/GanttChart/GanttChart.js.map +1 -0
- package/lib-amd/components/GanttChart/GanttChart.styles.d.ts +2 -0
- package/lib-amd/components/GanttChart/GanttChart.styles.js +10 -0
- package/lib-amd/components/GanttChart/GanttChart.styles.js.map +1 -0
- package/lib-amd/components/GanttChart/GanttChart.types.d.ts +67 -0
- package/lib-amd/components/GanttChart/GanttChart.types.js +5 -0
- package/lib-amd/components/GanttChart/GanttChart.types.js.map +1 -0
- package/lib-amd/components/GanttChart/index.d.ts +2 -0
- package/lib-amd/components/GanttChart/index.js +7 -0
- package/lib-amd/components/GanttChart/index.js.map +1 -0
- package/lib-amd/components/LineChart/LineChart.base.d.ts +1 -0
- package/lib-amd/components/LineChart/LineChart.base.js +33 -11
- package/lib-amd/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-amd/components/ScatterChart/ScatterChart.base.js +36 -23
- package/lib-amd/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-amd/index.d.ts +3 -1
- package/lib-amd/index.js +3 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/types/IDataPoint.d.ts +49 -0
- package/lib-amd/types/IDataPoint.js.map +1 -1
- package/lib-amd/utilities/scatterpolar-utils.d.ts +22 -0
- package/lib-amd/utilities/scatterpolar-utils.js +43 -0
- package/lib-amd/utilities/scatterpolar-utils.js.map +1 -0
- package/lib-amd/utilities/test-data.d.ts +4 -1
- package/lib-amd/utilities/test-data.js +214 -2
- package/lib-amd/utilities/test-data.js.map +1 -1
- package/lib-amd/utilities/utilities.d.ts +14 -6
- package/lib-amd/utilities/utilities.js +27 -9
- package/lib-amd/utilities/utilities.js.map +1 -1
- package/lib-commonjs/GanttChart.d.ts +1 -0
- package/lib-commonjs/GanttChart.js +5 -0
- package/lib-commonjs/GanttChart.js.map +1 -0
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js +2 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.base.js.map +1 -1
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.d.ts +3 -3
- package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +23 -5
- package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.d.ts +2 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +25 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.d.ts +2 -0
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +173 -62
- package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
- package/lib-commonjs/components/GanttChart/GanttChart.base.d.ts +3 -0
- package/lib-commonjs/components/GanttChart/GanttChart.base.js +332 -0
- package/lib-commonjs/components/GanttChart/GanttChart.base.js.map +1 -0
- package/lib-commonjs/components/GanttChart/GanttChart.d.ts +7 -0
- package/lib-commonjs/components/GanttChart/GanttChart.js +13 -0
- package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -0
- package/lib-commonjs/components/GanttChart/GanttChart.styles.d.ts +2 -0
- package/lib-commonjs/components/GanttChart/GanttChart.styles.js +8 -0
- package/lib-commonjs/components/GanttChart/GanttChart.styles.js.map +1 -0
- package/lib-commonjs/components/GanttChart/GanttChart.types.d.ts +67 -0
- package/lib-commonjs/components/GanttChart/GanttChart.types.js +3 -0
- package/lib-commonjs/components/GanttChart/GanttChart.types.js.map +1 -0
- package/lib-commonjs/components/GanttChart/index.d.ts +2 -0
- package/lib-commonjs/components/GanttChart/index.js +6 -0
- package/lib-commonjs/components/GanttChart/index.js.map +1 -0
- package/lib-commonjs/components/LineChart/LineChart.base.d.ts +1 -0
- package/lib-commonjs/components/LineChart/LineChart.base.js +33 -10
- package/lib-commonjs/components/LineChart/LineChart.base.js.map +1 -1
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js +36 -22
- package/lib-commonjs/components/ScatterChart/ScatterChart.base.js.map +1 -1
- package/lib-commonjs/index.d.ts +3 -1
- package/lib-commonjs/index.js +3 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types/IDataPoint.d.ts +49 -0
- package/lib-commonjs/types/IDataPoint.js.map +1 -1
- package/lib-commonjs/utilities/scatterpolar-utils.d.ts +22 -0
- package/lib-commonjs/utilities/scatterpolar-utils.js +42 -0
- package/lib-commonjs/utilities/scatterpolar-utils.js.map +1 -0
- package/lib-commonjs/utilities/test-data.d.ts +4 -1
- package/lib-commonjs/utilities/test-data.js +214 -1
- package/lib-commonjs/utilities/test-data.js.map +1 -1
- package/lib-commonjs/utilities/utilities.d.ts +14 -6
- package/lib-commonjs/utilities/utilities.js +28 -10
- package/lib-commonjs/utilities/utilities.js.map +1 -1
- package/package.json +2 -2
- package/src/components/CommonComponents/CartesianChart.types.ts +5 -2
- package/src/components/GanttChart/GanttChart.types.ts +83 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
1
|
+
import { __assign, __spreadArray } from "tslib";
|
|
2
2
|
import { bin as d3Bin, extent as d3Extent, sum as d3Sum, min as d3Min, max as d3Max, range as d3Range, } from 'd3-array';
|
|
3
3
|
import { scaleLinear as d3ScaleLinear } from 'd3-scale';
|
|
4
4
|
import { format as d3Format } from 'd3-format';
|
|
@@ -7,7 +7,7 @@ import { GaugeChartVariant } from '../GaugeChart/index';
|
|
|
7
7
|
import { findNumericMinMaxOfY, formatScientificLimitWidth, MIN_DONUT_RADIUS } from '../../utilities/utilities';
|
|
8
8
|
import { isArrayOrTypedArray, isDate, isDateArray, isNumberArray, isStringArray, isYearArray, isInvalidValue, formatToLocaleString, } from '@fluentui/chart-utilities';
|
|
9
9
|
import { curveCardinal as d3CurveCardinal } from 'd3-shape';
|
|
10
|
-
import { getOpacity, extractColor, resolveColor } from './PlotlyColorAdapter';
|
|
10
|
+
import { getOpacity, extractColor, resolveColor, createColorScale } from './PlotlyColorAdapter';
|
|
11
11
|
import { rgb } from 'd3-color';
|
|
12
12
|
export var NON_PLOT_KEY_PREFIX = 'nonplot_';
|
|
13
13
|
export var SINGLE_REPEAT = 'repeat(1, 1fr)';
|
|
@@ -265,18 +265,13 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
265
265
|
var colorScale = undefined;
|
|
266
266
|
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
267
267
|
input.data.forEach(function (series, index1) {
|
|
268
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
269
|
-
|
|
270
|
-
isArrayOrTypedArray((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
|
|
271
|
-
((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
|
|
272
|
-
typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
|
|
273
|
-
colorScale = createColorScale(input.layout, series);
|
|
274
|
-
}
|
|
268
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
269
|
+
colorScale = createColorScale(input.layout, series, colorScale);
|
|
275
270
|
var isXYearCategory = isYearArray(series.x); // Consider year as categorical not numeric continuous axis
|
|
276
271
|
// extract bar colors for each series only once
|
|
277
|
-
var extractedBarColors = extractColor((
|
|
272
|
+
var extractedBarColors = 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);
|
|
278
273
|
// extract line colors for each series only once
|
|
279
|
-
var extractedLineColors = extractColor((
|
|
274
|
+
var extractedLineColors = 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);
|
|
280
275
|
var xValues = series.x;
|
|
281
276
|
var isXDate = isDateArray(xValues);
|
|
282
277
|
var isXString = isStringArray(xValues);
|
|
@@ -340,22 +335,6 @@ export var transformPlotlyJsonToVSBCProps = function (input, isMultiPlot, colorM
|
|
|
340
335
|
var vsbcData = Object.values(mapXToDataPoints);
|
|
341
336
|
return __assign(__assign(__assign(__assign(__assign(__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)), getXAxisTickFormat(input.data[0], input.layout)), yAxisTickFormat);
|
|
342
337
|
};
|
|
343
|
-
var createColorScale = function (layout, series) {
|
|
344
|
-
var _a, _b, _c, _d, _e, _f;
|
|
345
|
-
var scale = (_a = layout === null || layout === void 0 ? void 0 : layout.coloraxis) === null || _a === void 0 ? void 0 : _a.colorscale;
|
|
346
|
-
var colorValues = (_b = series.marker) === null || _b === void 0 ? void 0 : _b.color;
|
|
347
|
-
var _g = [
|
|
348
|
-
(_d = (_c = layout === null || layout === void 0 ? void 0 : layout.coloraxis) === null || _c === void 0 ? void 0 : _c.cmin) !== null && _d !== void 0 ? _d : Math.min.apply(Math, colorValues),
|
|
349
|
-
(_f = (_e = layout === null || layout === void 0 ? void 0 : layout.coloraxis) === null || _e === void 0 ? void 0 : _e.cmax) !== null && _f !== void 0 ? _f : Math.max.apply(Math, colorValues),
|
|
350
|
-
], dMin = _g[0], dMax = _g[1];
|
|
351
|
-
// Normalize colorscale domain to actual data domain
|
|
352
|
-
var scaleDomain = scale.map(function (_a) {
|
|
353
|
-
var pos = _a[0];
|
|
354
|
-
return dMin + pos * (dMax - dMin);
|
|
355
|
-
});
|
|
356
|
-
var scaleColors = scale.map(function (item) { return item[1]; });
|
|
357
|
-
return d3ScaleLinear().domain(scaleDomain).range(scaleColors);
|
|
358
|
-
};
|
|
359
338
|
export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
360
339
|
var _a, _b, _c, _d;
|
|
361
340
|
var mapXToDataPoints = {};
|
|
@@ -364,16 +343,11 @@ export var transformPlotlyJsonToGVBCProps = function (input, isMultiPlot, colorM
|
|
|
364
343
|
var colorScale = undefined;
|
|
365
344
|
var yAxisTickFormat = getYAxisTickFormat(input.data[0], input.layout);
|
|
366
345
|
input.data.forEach(function (series, index1) {
|
|
367
|
-
var _a, _b, _c, _d, _e
|
|
368
|
-
|
|
369
|
-
isArrayOrTypedArray((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
|
|
370
|
-
((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
|
|
371
|
-
typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
|
|
372
|
-
colorScale = createColorScale(input.layout, series);
|
|
373
|
-
}
|
|
346
|
+
var _a, _b, _c, _d, _e;
|
|
347
|
+
colorScale = createColorScale(input.layout, series, colorScale);
|
|
374
348
|
// extract colors for each series only once
|
|
375
|
-
var extractedColors = extractColor((
|
|
376
|
-
(
|
|
349
|
+
var extractedColors = 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);
|
|
350
|
+
(_e = series.x) === null || _e === void 0 ? void 0 : _e.forEach(function (x, xIndex) {
|
|
377
351
|
var _a, _b, _c, _d, _e, _f;
|
|
378
352
|
if (isInvalidValue(x) || isInvalidValue((_a = series.y) === null || _a === void 0 ? void 0 : _a[xIndex])) {
|
|
379
353
|
return;
|
|
@@ -412,18 +386,13 @@ export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMa
|
|
|
412
386
|
var _e = getLegendProps(input.data, input.layout, isMultiPlot), legends = _e.legends, hideLegend = _e.hideLegend;
|
|
413
387
|
var colorScale = undefined;
|
|
414
388
|
input.data.forEach(function (series, seriesIdx) {
|
|
415
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
389
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
416
390
|
if (!series.x) {
|
|
417
391
|
return;
|
|
418
392
|
}
|
|
419
|
-
|
|
420
|
-
isArrayOrTypedArray((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
|
|
421
|
-
((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
|
|
422
|
-
typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
|
|
423
|
-
colorScale = createColorScale(input.layout, series);
|
|
424
|
-
}
|
|
393
|
+
colorScale = createColorScale(input.layout, series, colorScale);
|
|
425
394
|
// extract colors for each series only once
|
|
426
|
-
var extractedColors = extractColor((
|
|
395
|
+
var extractedColors = 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);
|
|
427
396
|
var xValues = [];
|
|
428
397
|
var yValues = [];
|
|
429
398
|
series.x.forEach(function (xVal, index) {
|
|
@@ -437,7 +406,7 @@ export var transformPlotlyJsonToVBCProps = function (input, isMultiPlot, colorMa
|
|
|
437
406
|
var isXString = isStringArray(xValues);
|
|
438
407
|
// TODO: In case of a single bin, add an empty bin of the same size to prevent the
|
|
439
408
|
// default bar width from being used and ensure the bar spans the full intended range.
|
|
440
|
-
var xBins = createBins(xValues, (
|
|
409
|
+
var xBins = createBins(xValues, (_e = series.xbins) === null || _e === void 0 ? void 0 : _e.start, (_f = series.xbins) === null || _f === void 0 ? void 0 : _f.end, (_g = series.xbins) === null || _g === void 0 ? void 0 : _g.size);
|
|
441
410
|
var yBins = xBins.map(function () { return []; });
|
|
442
411
|
var total = 0;
|
|
443
412
|
xValues.forEach(function (xVal, index) {
|
|
@@ -515,11 +484,11 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
515
484
|
var seriesOpacity = getOpacity(series, index);
|
|
516
485
|
mode = series.fill === 'tozeroy' ? 'tozeroy' : 'tonexty';
|
|
517
486
|
// if mode contains 'text', we prioritize showing the text over curving the line
|
|
518
|
-
var lineOptions = !((_h = series.mode) === null || _h === void 0 ? void 0 : _h.includes('text')) ? getLineOptions(series.line) : undefined;
|
|
487
|
+
var lineOptions = !((_h = series.mode) === null || _h === void 0 ? void 0 : _h.includes('text')) && series.type !== 'scatterpolar' ? getLineOptions(series.line) : undefined;
|
|
519
488
|
var legendShape = getLegendShape(series);
|
|
520
489
|
var validXYRanges = getValidXYRanges(series);
|
|
521
490
|
return validXYRanges.map(function (_a, rangeIdx) {
|
|
522
|
-
var _b, _c;
|
|
491
|
+
var _b, _c, _d;
|
|
523
492
|
var rangeStart = _a[0], rangeEnd = _a[1];
|
|
524
493
|
var rangeXValues = xValues.slice(rangeStart, rangeEnd);
|
|
525
494
|
var rangeYValues = series.y.slice(rangeStart, rangeEnd);
|
|
@@ -539,7 +508,10 @@ var transformPlotlyJsonToScatterTraceProps = function (input, isMultiPlot, chart
|
|
|
539
508
|
: {})), (textValues ? { text: textValues[i] } : {})), { yAxisCalloutData: getFormattedCalloutYData(rangeYValues[i], yAxisTickFormat) }));
|
|
540
509
|
}),
|
|
541
510
|
color: (_c = rgb(seriesColor).copy({ opacity: seriesOpacity }).formatHex8()) !== null && _c !== void 0 ? _c : seriesColor,
|
|
542
|
-
lineOptions: __assign(__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.mode
|
|
511
|
+
lineOptions: __assign(__assign({}, (lineOptions !== null && lineOptions !== void 0 ? lineOptions : {})), { mode: series.type !== 'scatterpolar' ? series.mode : 'scatterpolar',
|
|
512
|
+
// originXOffset is not typed on Layout, but may be present in input.layout as a part of projection of
|
|
513
|
+
// scatter polar coordingates to cartesian coordinates
|
|
514
|
+
originXOffset: (_d = input.layout) === null || _d === void 0 ? void 0 : _d.__polarOriginX }),
|
|
543
515
|
useSecondaryYScale: usesSecondaryYScale(series, input.layout),
|
|
544
516
|
};
|
|
545
517
|
});
|
|
@@ -572,15 +544,10 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, is
|
|
|
572
544
|
var colorScale = undefined;
|
|
573
545
|
var chartData = input.data
|
|
574
546
|
.map(function (series, index) {
|
|
575
|
-
var _a, _b, _c, _d
|
|
576
|
-
|
|
577
|
-
isArrayOrTypedArray((_d = series.marker) === null || _d === void 0 ? void 0 : _d.color) &&
|
|
578
|
-
((_e = series.marker) === null || _e === void 0 ? void 0 : _e.color).length > 0 &&
|
|
579
|
-
typeof ((_g = (_f = series.marker) === null || _f === void 0 ? void 0 : _f.color) === null || _g === void 0 ? void 0 : _g[0]) === 'number') {
|
|
580
|
-
colorScale = createColorScale(input.layout, series);
|
|
581
|
-
}
|
|
547
|
+
var _a, _b, _c, _d;
|
|
548
|
+
colorScale = createColorScale(input.layout, series, colorScale);
|
|
582
549
|
// extract colors for each series only once
|
|
583
|
-
var extractedColors = extractColor((
|
|
550
|
+
var extractedColors = 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);
|
|
584
551
|
var legend = legends[index];
|
|
585
552
|
return series.y
|
|
586
553
|
.map(function (yValue, i) {
|
|
@@ -617,6 +584,52 @@ export var transformPlotlyJsonToHorizontalBarWithAxisProps = function (input, is
|
|
|
617
584
|
? (_m = (_l = input.layout) === null || _l === void 0 ? void 0 : _l.yaxis2) === null || _m === void 0 ? void 0 : _m.title
|
|
618
585
|
: ((_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));
|
|
619
586
|
};
|
|
587
|
+
export var transformPlotlyJsonToGanttChartProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
588
|
+
var _a, _b, _c;
|
|
589
|
+
var _d = getLegendProps(input.data, input.layout, isMultiPlot), legends = _d.legends, hideLegend = _d.hideLegend;
|
|
590
|
+
var colorScale = undefined;
|
|
591
|
+
var chartData = input.data
|
|
592
|
+
.map(function (series, index) {
|
|
593
|
+
var _a, _b, _c, _d, _e, _f;
|
|
594
|
+
colorScale = createColorScale(input.layout, series, colorScale);
|
|
595
|
+
// extract colors for each series only once
|
|
596
|
+
var extractedColors = 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);
|
|
597
|
+
var legend = legends[index];
|
|
598
|
+
var isXDate = ((_f = (_e = input.layout) === null || _e === void 0 ? void 0 : _e.xaxis) === null || _f === void 0 ? void 0 : _f.type) === 'date' || isDateArray(series.x);
|
|
599
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
600
|
+
var convertXValueToNumber = function (value) {
|
|
601
|
+
return isInvalidValue(value) ? 0 : isXDate ? new Date(value).getTime() : value;
|
|
602
|
+
};
|
|
603
|
+
return series.y
|
|
604
|
+
.map(function (yVal, i) {
|
|
605
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
606
|
+
if (isInvalidValue(yVal)) {
|
|
607
|
+
return null;
|
|
608
|
+
}
|
|
609
|
+
// resolve color for each legend's bars from the colorscale or extracted colors
|
|
610
|
+
var color = colorScale
|
|
611
|
+
? colorScale(isArrayOrTypedArray((_a = series.marker) === null || _a === void 0 ? void 0 : _a.color)
|
|
612
|
+
? (_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]
|
|
613
|
+
: 0)
|
|
614
|
+
: resolveColor(extractedColors, i, legend, colorMap, isDarkTheme);
|
|
615
|
+
var opacity = getOpacity(series, i);
|
|
616
|
+
var base = convertXValueToNumber((_e = series.base) === null || _e === void 0 ? void 0 : _e[i]);
|
|
617
|
+
var xVal = convertXValueToNumber((_f = series.x) === null || _f === void 0 ? void 0 : _f[i]);
|
|
618
|
+
return {
|
|
619
|
+
x: {
|
|
620
|
+
start: isXDate ? new Date(base) : base,
|
|
621
|
+
end: isXDate ? new Date(base + xVal) : base + xVal,
|
|
622
|
+
},
|
|
623
|
+
y: yVal,
|
|
624
|
+
legend: legend,
|
|
625
|
+
color: (_g = rgb(color).copy({ opacity: opacity }).formatHex8()) !== null && _g !== void 0 ? _g : color,
|
|
626
|
+
};
|
|
627
|
+
})
|
|
628
|
+
.filter(function (point) { return point !== null; });
|
|
629
|
+
})
|
|
630
|
+
.flat();
|
|
631
|
+
return __assign(__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));
|
|
632
|
+
};
|
|
620
633
|
export var transformPlotlyJsonToHeatmapProps = function (input, isMultiPlot, colorMap, colorwayType, isDarkTheme) {
|
|
621
634
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
622
635
|
var firstData = input.data[0];
|
|
@@ -1104,23 +1117,120 @@ export var transformPlotlyJsonToFunnelChartProps = function (input, isMultiPlot,
|
|
|
1104
1117
|
};
|
|
1105
1118
|
};
|
|
1106
1119
|
export var projectPolarToCartesian = function (input) {
|
|
1107
|
-
var _a, _b
|
|
1120
|
+
var _a, _b;
|
|
1108
1121
|
var projection = __assign({}, input);
|
|
1122
|
+
// 1. Find the global min and max radius across all series
|
|
1123
|
+
var minRadius = 0;
|
|
1124
|
+
var maxRadius = 0;
|
|
1109
1125
|
for (var sindex = 0; sindex < input.data.length; sindex++) {
|
|
1126
|
+
var rVals = input.data[sindex].r;
|
|
1127
|
+
if (rVals && isArrayOrTypedArray(rVals)) {
|
|
1128
|
+
for (var ptindex = 0; ptindex < rVals.length; ptindex++) {
|
|
1129
|
+
if (!isInvalidValue(rVals[ptindex])) {
|
|
1130
|
+
minRadius = Math.min(minRadius, rVals[ptindex]);
|
|
1131
|
+
maxRadius = Math.max(maxRadius, rVals[ptindex]);
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
// 2. If there are negative radii, compute the shift
|
|
1137
|
+
var radiusShift = minRadius < 0 ? -minRadius : 0;
|
|
1138
|
+
// 3. Project all points and create a perfect square domain
|
|
1139
|
+
var allX = [];
|
|
1140
|
+
var allY = [];
|
|
1141
|
+
var originX = null;
|
|
1142
|
+
var _loop_1 = function (sindex) {
|
|
1110
1143
|
var series = input.data[sindex];
|
|
1144
|
+
// If scatterpolar, set text to theta values as strings
|
|
1145
|
+
if (series.type === 'scatterpolar' && Array.isArray(series.theta)) {
|
|
1146
|
+
series.text = series.theta.map(function (v) { return String(v); });
|
|
1147
|
+
}
|
|
1111
1148
|
series.x = [];
|
|
1112
1149
|
series.y = [];
|
|
1113
|
-
|
|
1114
|
-
|
|
1150
|
+
var thetas = series.theta;
|
|
1151
|
+
var rVals = series.r;
|
|
1152
|
+
// Skip if rVals or thetas are not arrays
|
|
1153
|
+
if (!isArrayOrTypedArray(rVals) || !isArrayOrTypedArray(thetas)) {
|
|
1154
|
+
projection.data[sindex] = series;
|
|
1155
|
+
return "continue";
|
|
1156
|
+
}
|
|
1157
|
+
// Compute tick positions if categorical
|
|
1158
|
+
var uniqueTheta = [];
|
|
1159
|
+
var categorical = false;
|
|
1160
|
+
if (!isNumberArray(thetas)) {
|
|
1161
|
+
uniqueTheta = Array.from(new Set(thetas));
|
|
1162
|
+
categorical = true;
|
|
1163
|
+
}
|
|
1164
|
+
for (var ptindex = 0; ptindex < rVals.length; ptindex++) {
|
|
1165
|
+
if (isInvalidValue(thetas === null || thetas === void 0 ? void 0 : thetas[ptindex]) || isInvalidValue(rVals === null || rVals === void 0 ? void 0 : rVals[ptindex])) {
|
|
1115
1166
|
continue;
|
|
1116
1167
|
}
|
|
1117
|
-
|
|
1118
|
-
var
|
|
1119
|
-
|
|
1120
|
-
|
|
1168
|
+
// 4. Map theta to angle in radians
|
|
1169
|
+
var thetaRad = void 0;
|
|
1170
|
+
if (categorical) {
|
|
1171
|
+
var idx = uniqueTheta.indexOf(thetas[ptindex]);
|
|
1172
|
+
var step = (2 * Math.PI) / uniqueTheta.length;
|
|
1173
|
+
thetaRad = idx * step;
|
|
1174
|
+
}
|
|
1175
|
+
else {
|
|
1176
|
+
thetaRad = (thetas[ptindex] * Math.PI) / 180;
|
|
1177
|
+
}
|
|
1178
|
+
// 5. Shift only the polar origin (not the cartesian)
|
|
1179
|
+
var rawRadius = rVals[ptindex];
|
|
1180
|
+
var polarRadius = rawRadius + radiusShift; // Only for projection
|
|
1181
|
+
// 6. Calculate cartesian coordinates (with shifted polar origin)
|
|
1182
|
+
var x = polarRadius * Math.cos(thetaRad);
|
|
1183
|
+
var y = polarRadius * Math.sin(thetaRad);
|
|
1184
|
+
// Calculate the cartesian coordinates of the original polar origin (0,0)
|
|
1185
|
+
// This is the point that should be mapped to (0,0) in cartesian coordinates
|
|
1186
|
+
if (sindex === 0 && ptindex === 0) {
|
|
1187
|
+
// For polar origin (r=0, θ=0), cartesian coordinates are (0,0)
|
|
1188
|
+
// But since we shifted the radius by radiusShift, the cartesian origin is at (radiusShift, 0)
|
|
1189
|
+
originX = radiusShift;
|
|
1190
|
+
}
|
|
1191
|
+
series.x.push(x);
|
|
1192
|
+
series.y.push(y);
|
|
1193
|
+
allX.push(x);
|
|
1194
|
+
allY.push(y);
|
|
1195
|
+
}
|
|
1196
|
+
// Map text to each data point for downstream chart rendering
|
|
1197
|
+
if (series.x && series.y) {
|
|
1198
|
+
series.data = series.x.map(function (xVal, idx) { return (__assign({ x: xVal, y: series.y[idx] }, (series.text ? { text: series.text[idx] } : {}))); });
|
|
1121
1199
|
}
|
|
1122
1200
|
projection.data[sindex] = series;
|
|
1201
|
+
};
|
|
1202
|
+
for (var sindex = 0; sindex < input.data.length; sindex++) {
|
|
1203
|
+
_loop_1(sindex);
|
|
1204
|
+
}
|
|
1205
|
+
// 7. Recenter all cartesian coordinates
|
|
1206
|
+
if (originX !== null) {
|
|
1207
|
+
for (var sindex = 0; sindex < projection.data.length; sindex++) {
|
|
1208
|
+
var series = projection.data[sindex];
|
|
1209
|
+
if (series.x && series.y) {
|
|
1210
|
+
series.x = series.x.map(function (v) { return v - originX; });
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
// Also recenter allX for normalization
|
|
1214
|
+
for (var i = 0; i < allX.length; i++) {
|
|
1215
|
+
allX[i] = allX[i] - originX;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
// 8. Find the maximum absolute value among all x and y
|
|
1219
|
+
var maxAbs = Math.max.apply(Math, __spreadArray(__spreadArray([], allX.map(Math.abs), false), allY.map(Math.abs), false));
|
|
1220
|
+
maxAbs = maxAbs === 0 ? 1 : maxAbs;
|
|
1221
|
+
// 9. Rescale all points so that the largest |x| or |y| is 0.5
|
|
1222
|
+
for (var sindex = 0; sindex < projection.data.length; sindex++) {
|
|
1223
|
+
var series = projection.data[sindex];
|
|
1224
|
+
if (series.x && series.y) {
|
|
1225
|
+
series.x = series.x.map(function (v) { return v / (2 * maxAbs); });
|
|
1226
|
+
series.y = series.y.map(function (v) { return v / (2 * maxAbs); });
|
|
1227
|
+
}
|
|
1123
1228
|
}
|
|
1229
|
+
// 10. Customize layout for perfect square with absolute positioning
|
|
1230
|
+
var size = ((_a = input.layout) === null || _a === void 0 ? void 0 : _a.width) || ((_b = input.layout) === null || _b === void 0 ? void 0 : _b.height) || 500;
|
|
1231
|
+
projection.layout = __assign(__assign({}, projection.layout), { width: size, height: size });
|
|
1232
|
+
// Attach originX as custom properties
|
|
1233
|
+
projection.layout.__polarOriginX = originX !== null && originX !== void 0 ? originX : undefined;
|
|
1124
1234
|
return projection;
|
|
1125
1235
|
};
|
|
1126
1236
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|