@rowsncolumns/charts 28.1.7 → 28.1.10
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/dist/cjs/basic-chart/basic-chart.d.ts.map +1 -1
- package/dist/cjs/basic-chart/basic-chart.js +525 -419
- package/dist/cjs/basic-chart/helpers.d.ts.map +1 -1
- package/dist/cjs/basic-chart/helpers.js +2 -0
- package/dist/cjs/plotly/basic-chart/basic-chart.d.ts.map +1 -1
- package/dist/cjs/plotly/basic-chart/basic-chart.js +351 -192
- package/dist/cjs/plotly/basic-chart/helpers.d.ts.map +1 -1
- package/dist/cjs/plotly/basic-chart/helpers.js +2 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/cjs/utils/bubble.d.ts +34 -1
- package/dist/cjs/utils/bubble.d.ts.map +1 -1
- package/dist/cjs/utils/bubble.js +39 -13
- package/dist/cjs/utils/doughnut.d.ts +19 -0
- package/dist/cjs/utils/doughnut.d.ts.map +1 -0
- package/dist/cjs/utils/doughnut.js +28 -0
- package/dist/cjs/utils/echarts-overlays.d.ts +46 -0
- package/dist/cjs/utils/echarts-overlays.d.ts.map +1 -0
- package/dist/cjs/utils/echarts-overlays.js +134 -0
- package/dist/cjs/utils/hierarchy.d.ts +23 -1
- package/dist/cjs/utils/hierarchy.d.ts.map +1 -1
- package/dist/cjs/utils/hierarchy.js +179 -55
- package/dist/cjs/utils/overrides.d.ts +9 -0
- package/dist/cjs/utils/overrides.d.ts.map +1 -1
- package/dist/cjs/utils/overrides.js +18 -3
- package/dist/cjs/utils/radar.d.ts +31 -5
- package/dist/cjs/utils/radar.d.ts.map +1 -1
- package/dist/cjs/utils/radar.js +67 -27
- package/dist/cjs/utils/trendline.d.ts +7 -1
- package/dist/cjs/utils/trendline.d.ts.map +1 -1
- package/dist/cjs/utils/trendline.js +82 -18
- package/dist/esm/basic-chart/basic-chart.d.ts.map +1 -1
- package/dist/esm/basic-chart/basic-chart.js +376 -248
- package/dist/esm/basic-chart/helpers.d.ts.map +1 -1
- package/dist/esm/basic-chart/helpers.js +2 -0
- package/dist/esm/plotly/basic-chart/basic-chart.d.ts.map +1 -1
- package/dist/esm/plotly/basic-chart/basic-chart.js +279 -69
- package/dist/esm/plotly/basic-chart/helpers.d.ts.map +1 -1
- package/dist/esm/plotly/basic-chart/helpers.js +2 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/utils/bubble.d.ts +34 -1
- package/dist/esm/utils/bubble.d.ts.map +1 -1
- package/dist/esm/utils/bubble.js +35 -11
- package/dist/esm/utils/doughnut.d.ts +19 -0
- package/dist/esm/utils/doughnut.d.ts.map +1 -0
- package/dist/esm/utils/doughnut.js +21 -0
- package/dist/esm/utils/echarts-overlays.d.ts +46 -0
- package/dist/esm/utils/echarts-overlays.d.ts.map +1 -0
- package/dist/esm/utils/echarts-overlays.js +135 -0
- package/dist/esm/utils/hierarchy.d.ts +23 -1
- package/dist/esm/utils/hierarchy.d.ts.map +1 -1
- package/dist/esm/utils/hierarchy.js +168 -50
- package/dist/esm/utils/overrides.d.ts +9 -0
- package/dist/esm/utils/overrides.d.ts.map +1 -1
- package/dist/esm/utils/overrides.js +16 -2
- package/dist/esm/utils/radar.d.ts +31 -5
- package/dist/esm/utils/radar.d.ts.map +1 -1
- package/dist/esm/utils/radar.js +44 -16
- package/dist/esm/utils/trendline.d.ts +7 -1
- package/dist/esm/utils/trendline.d.ts.map +1 -1
- package/dist/esm/utils/trendline.js +67 -14
- package/package.json +4 -4
|
@@ -21,6 +21,8 @@ var error_bars_1 = require("../../utils/error-bars");
|
|
|
21
21
|
var category_levels_1 = require("../../utils/category-levels");
|
|
22
22
|
var gradient_1 = require("../../utils/gradient");
|
|
23
23
|
var legend_layout_1 = require("../../utils/legend-layout");
|
|
24
|
+
var doughnut_1 = require("../../utils/doughnut");
|
|
25
|
+
var overrides_1 = require("../../utils/overrides");
|
|
24
26
|
var plotly_title_1 = require("../../utils/plotly-title");
|
|
25
27
|
var pie_explosion_1 = require("../../utils/pie-explosion");
|
|
26
28
|
var plotly_click_1 = require("../../utils/plotly-click");
|
|
@@ -352,6 +354,15 @@ var sanitizeChartValue = function (value) {
|
|
|
352
354
|
* (Excel): every range's points in sequence. A single range passes through
|
|
353
355
|
* untouched so the common path renders exactly as before.
|
|
354
356
|
*/
|
|
357
|
+
/**
|
|
358
|
+
* The plain value array of a series' data. (`"values" in seriesData` is
|
|
359
|
+
* true for an ARRAY too — `Array.prototype.values` — which handed the
|
|
360
|
+
* waterfall / funnel / histogram / boxplot branches that method instead
|
|
361
|
+
* of the numbers.)
|
|
362
|
+
*/
|
|
363
|
+
var seriesValuesOf = function (seriesData) {
|
|
364
|
+
return Array.isArray(seriesData) ? seriesData : seriesData.values;
|
|
365
|
+
};
|
|
355
366
|
var mergeSeriesData = function (parts) {
|
|
356
367
|
var e_1, _a;
|
|
357
368
|
if (parts.length === 1)
|
|
@@ -415,6 +426,11 @@ var BasicChart = function (_a) {
|
|
|
415
426
|
// The plotted `<div>` plotly hands back on init — what `Plotly.toImage`
|
|
416
427
|
// rasterises for Copy as Picture and the print preview.
|
|
417
428
|
var graphDivRef = (0, react_1.useRef)(null);
|
|
429
|
+
// Plotly zooms a treemap / sunburst into the clicked branch by default;
|
|
430
|
+
// Excel has no drill-down, so the click handler cancels it unless the
|
|
431
|
+
// spec opts in (`drillDown`).
|
|
432
|
+
var drillDownRef = (0, react_1.useRef)(false);
|
|
433
|
+
drillDownRef.current = Boolean(spec.drillDown);
|
|
418
434
|
var focusSheet = (0, spreadsheet_1.useFocusSheet)();
|
|
419
435
|
// Excel selects a data series (or one data point) when it is clicked
|
|
420
436
|
// inside the chart and the grid highlights its source cells. The plot
|
|
@@ -491,11 +507,11 @@ var BasicChart = function (_a) {
|
|
|
491
507
|
* Triggers a chart update
|
|
492
508
|
*/
|
|
493
509
|
var updateChart = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
494
|
-
var traces, chartType, position, isBubble, isHierarchy, textColor, bgColor, gridColor, skipHeaders_1, labels, perSeriesX, perSeriesSize, seriesInputs, i, seriesEntry, resolvedLabel, _a, xValues, sizeValues_1, sharedXValues, sharedSizeValues, _b, categories_1, preparedSeries, sizeValues, sizeScale_1, hasStringX_1, palette_1, isScatter_1, scatterStyle_1, plotlyModeForScatterStyle_1, lineShapeFor_1, traces_1, titleFmt, xAxisFmt, yAxisFmt, legendFmt, bubbleLayout, hierarchyRows, headerTitle,
|
|
510
|
+
var traces, chartType, position, isBubble, isHierarchy, textColor, bgColor, gridColor, skipHeaders_1, labels, perSeriesX, perSeriesSize, seriesInputs, i, seriesEntry, resolvedLabel, _a, xValues, sizeValues_1, sharedXValues, sharedSizeValues, _b, categories_1, preparedSeries, sizeValues, sizeScale_1, hasStringX_1, hasBubbleSecondaryAxis, palette_1, isScatter_1, scatterStyle_1, plotlyModeForScatterStyle_1, lineShapeFor_1, traces_1, titleFmt, xAxisFmt, yAxisFmt, legendFmt, bubbleLayout, hierarchyRows, headerTitle, hierarchyData_1, seriesName, hierarchyPalette, nodeColors, isSunburst, SUNBURST_ROOT_ID_1, rootTotal, hierarchyTrace, layoutForHierarchy, labels, seriesEntry, rawValues_1, locations_1, z_1, ramp_1, colorscale, geoScope, regionTrace, surfaceToken, categories, surfaceSeriesInputs, _c, _d, seriesEntry, dataLabel, _e, _f, values, e_2_1, seriesNames, surfaceTrace, surfaceLayout, categories, radarStyle, radarTraces, radarInputs, _g, _h, seriesEntry, label, values, radarAxisOptions, indicators, _loop_1, i, radarScale, variant, categories, seriesValues, volumePoints_1, hasVolume, buildVolumeTrace, volumeLayout, priceYAxisDomain, roles, xs_1, candleTrace, lineSeries, stockPalette_1, xs_2, stockTraces, isStacked, isHorizontalBarChart, lineTraceVariant, shouldAggregate, primaryDomainSource, rawPrimaryDomainValues, domainData, categoryLevels, multicategoryX, aggregateDomainValues, domainAxisData, secondaryDomainData, categoriesFor, assignCartesianData, themeColorPalette, applyTraceColor, hasSecondaryAxis, hasSecondaryCategoryAxis, valueAxisKey, categoryAxisKey, secondaryValueAxisRef, secondaryCategoryAxisRef, isPareto, isOfPie, ofPieHandled, ofPieExtras, decorateCartesianTrace, domainSources, seriesIndex, _loop_2, _j, _k, series, e_3_1, authoredTitleFmt, isPercentStackedBars, primaryAxisNumberFormat, secondaryAxisNumberFormat, _l, legendOverrides, showlegend, axisFontSize, primaryValues, leftAxisLabelDepth, leftAxisDepth, rightAxisDepth, bottomAxisTitleStandoff, legendBand, newLayout, dlOpts, doughnutSeriesOrder, doughnutRingSet, traceDataLabels, doughnutHole, seriesNumberFormats, traceNumberFormat, piePull, formattedTraces, sortedTraces;
|
|
495
511
|
var e_2, _m, e_4, _o, e_3, _p, _q, _r;
|
|
496
|
-
var _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75;
|
|
497
|
-
return tslib_1.__generator(this, function (
|
|
498
|
-
switch (
|
|
512
|
+
var _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80, _81;
|
|
513
|
+
return tslib_1.__generator(this, function (_82) {
|
|
514
|
+
switch (_82.label) {
|
|
499
515
|
case 0:
|
|
500
516
|
(0, utils_1.debug)("Updating chart", chart);
|
|
501
517
|
traces = [];
|
|
@@ -520,7 +536,7 @@ var BasicChart = function (_a) {
|
|
|
520
536
|
});
|
|
521
537
|
seriesInputs = [];
|
|
522
538
|
i = 0;
|
|
523
|
-
|
|
539
|
+
_82.label = 1;
|
|
524
540
|
case 1:
|
|
525
541
|
if (!(i < spec.series.length)) return [3 /*break*/, 5];
|
|
526
542
|
seriesEntry = spec.series[i];
|
|
@@ -529,13 +545,13 @@ var BasicChart = function (_a) {
|
|
|
529
545
|
_a = chart_spec_utils_1.coerceCalculatedLabel;
|
|
530
546
|
return [4 /*yield*/, onRequestCalculate(resolvedLabel, (_w = chart.position.sheetId) !== null && _w !== void 0 ? _w : sheetId, chart.position.overlayPosition.anchorCell.rowIndex, chart.position.overlayPosition.anchorCell.columnIndex)];
|
|
531
547
|
case 2:
|
|
532
|
-
resolvedLabel = _a.apply(void 0, [
|
|
533
|
-
|
|
548
|
+
resolvedLabel = _a.apply(void 0, [_82.sent()]);
|
|
549
|
+
_82.label = 3;
|
|
534
550
|
case 3:
|
|
535
551
|
xValues = (_x = perSeriesX[i]) !== null && _x !== void 0 ? _x : perSeriesX[0];
|
|
536
552
|
sizeValues_1 = (_y = perSeriesSize[i]) !== null && _y !== void 0 ? _y : perSeriesSize[0];
|
|
537
553
|
seriesInputs.push(tslib_1.__assign(tslib_1.__assign({ name: resolvedLabel, values: flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy, skipHeaders_1) }, (xValues ? { xValues: xValues } : {})), (sizeValues_1 ? { sizeValues: sizeValues_1 } : {})));
|
|
538
|
-
|
|
554
|
+
_82.label = 4;
|
|
539
555
|
case 4:
|
|
540
556
|
i++;
|
|
541
557
|
return [3 /*break*/, 1];
|
|
@@ -548,8 +564,13 @@ var BasicChart = function (_a) {
|
|
|
548
564
|
sizeValues: sharedSizeValues,
|
|
549
565
|
series: seriesInputs,
|
|
550
566
|
}), categories_1 = _b.categories, preparedSeries = _b.series, sizeValues = _b.sizeValues;
|
|
551
|
-
sizeScale_1 = (0, bubble_1.createBubbleSizeScale)(sizeValues
|
|
567
|
+
sizeScale_1 = (0, bubble_1.createBubbleSizeScale)(sizeValues, {
|
|
568
|
+
sizeRepresents: spec.sizeRepresents,
|
|
569
|
+
bubbleScale: spec.bubbleScale,
|
|
570
|
+
plotMinSide: Math.min((width !== null && width !== void 0 ? width : 0) - 80, (height !== null && height !== void 0 ? height : 0) - 100),
|
|
571
|
+
});
|
|
552
572
|
hasStringX_1 = categories_1.length > 0;
|
|
573
|
+
hasBubbleSecondaryAxis = ((_1 = spec.series) !== null && _1 !== void 0 ? _1 : []).some(function (seriesEntry) { return seriesEntry === null || seriesEntry === void 0 ? void 0 : seriesEntry.useSecondaryAxis; });
|
|
553
574
|
palette_1 = (0, chart_styles_1.getChartPalette)(spec, [
|
|
554
575
|
theme.themeColors.accent1,
|
|
555
576
|
theme.themeColors.accent2,
|
|
@@ -559,7 +580,7 @@ var BasicChart = function (_a) {
|
|
|
559
580
|
theme.themeColors.accent6,
|
|
560
581
|
]);
|
|
561
582
|
isScatter_1 = spec.chartType === "scatter";
|
|
562
|
-
scatterStyle_1 = (
|
|
583
|
+
scatterStyle_1 = (_2 = spec.scatterStyle) !== null && _2 !== void 0 ? _2 : (isScatter_1 ? "lineMarker" : undefined);
|
|
563
584
|
plotlyModeForScatterStyle_1 = function (style) {
|
|
564
585
|
switch (style) {
|
|
565
586
|
case "line":
|
|
@@ -580,8 +601,10 @@ var BasicChart = function (_a) {
|
|
|
580
601
|
? "spline"
|
|
581
602
|
: "linear";
|
|
582
603
|
};
|
|
583
|
-
traces_1 =
|
|
584
|
-
|
|
604
|
+
traces_1 = [];
|
|
605
|
+
preparedSeries.forEach(function (entry, index) {
|
|
606
|
+
var e_5, _a, e_6, _b;
|
|
607
|
+
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
585
608
|
var xValues = entry.points.map(function (point) {
|
|
586
609
|
var _a, _b;
|
|
587
610
|
return hasStringX_1
|
|
@@ -589,9 +612,57 @@ var BasicChart = function (_a) {
|
|
|
589
612
|
: point.value[0];
|
|
590
613
|
});
|
|
591
614
|
var yValues = entry.points.map(function (point) { return point.value[1]; });
|
|
592
|
-
var
|
|
593
|
-
var
|
|
594
|
-
var
|
|
615
|
+
var rawSizes = entry.points.map(function (point) { return point.value[2]; });
|
|
616
|
+
var seriesSpec = spec.series[index];
|
|
617
|
+
var seriesColor = (_c = seriesSpec === null || seriesSpec === void 0 ? void 0 : seriesSpec.color) !== null && _c !== void 0 ? _c : (0, utils_1.chartPaletteColorAt)(palette_1, index);
|
|
618
|
+
var perSeriesMarker = (_d = seriesSpec === null || seriesSpec === void 0 ? void 0 : seriesSpec.marker) !== null && _d !== void 0 ? _d : undefined;
|
|
619
|
+
// Per-point colours (`<c:dPt>`) key on the point's source row
|
|
620
|
+
// (`BubbleSeriesPoint.index` — points without a Y are skipped).
|
|
621
|
+
var pointColorOverrides = new Map();
|
|
622
|
+
try {
|
|
623
|
+
for (var _r = tslib_1.__values((_e = seriesSpec === null || seriesSpec === void 0 ? void 0 : seriesSpec.dataPointColors) !== null && _e !== void 0 ? _e : []), _s = _r.next(); !_s.done; _s = _r.next()) {
|
|
624
|
+
var dp = _s.value;
|
|
625
|
+
if (typeof (dp === null || dp === void 0 ? void 0 : dp.idx) === "number" && typeof (dp === null || dp === void 0 ? void 0 : dp.color) === "string") {
|
|
626
|
+
pointColorOverrides.set(dp.idx, dp.color);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
631
|
+
finally {
|
|
632
|
+
try {
|
|
633
|
+
if (_s && !_s.done && (_a = _r.return)) _a.call(_r);
|
|
634
|
+
}
|
|
635
|
+
finally { if (e_5) throw e_5.error; }
|
|
636
|
+
}
|
|
637
|
+
var pointColors = function (base) {
|
|
638
|
+
return pointColorOverrides.size
|
|
639
|
+
? entry.points.map(function (point) { var _a; return (_a = pointColorOverrides.get(point.index)) !== null && _a !== void 0 ? _a : base; })
|
|
640
|
+
: base;
|
|
641
|
+
};
|
|
642
|
+
// Hover reads the bubble label and size from `customdata`, leaving
|
|
643
|
+
// `text` to the data labels.
|
|
644
|
+
var customdata = entry.points.map(function (point) { return [point.name, point.value[2]]; });
|
|
645
|
+
var onSecondary = (seriesSpec === null || seriesSpec === void 0 ? void 0 : seriesSpec.useSecondaryAxis) ? { yaxis: "y2" } : {};
|
|
646
|
+
// This series' data labels: Y value by default, the bubble's size
|
|
647
|
+
// with `showBubbleSize`, the bubble label with `showCategoryName`.
|
|
648
|
+
var labelOpts = (0, overrides_1.resolveSeriesDataLabels)(spec.dataLabels, seriesSpec);
|
|
649
|
+
var labelText = (labelOpts === null || labelOpts === void 0 ? void 0 : labelOpts.show)
|
|
650
|
+
? entry.points.map(function (point) {
|
|
651
|
+
return (0, overrides_1.dataLabelFormatter)(labelOpts, locale)({
|
|
652
|
+
value: point.value,
|
|
653
|
+
name: point.name,
|
|
654
|
+
seriesName: entry.name,
|
|
655
|
+
data: point,
|
|
656
|
+
});
|
|
657
|
+
})
|
|
658
|
+
: undefined;
|
|
659
|
+
var labelPosition = (labelOpts === null || labelOpts === void 0 ? void 0 : labelOpts.show)
|
|
660
|
+
? (_f = (labelOpts.position && PLOTLY_DLBL_POS_POINT[labelOpts.position])) !== null && _f !== void 0 ? _f : "top center"
|
|
661
|
+
: undefined;
|
|
662
|
+
var withLabels = function (trace) {
|
|
663
|
+
return labelText
|
|
664
|
+
? tslib_1.__assign(tslib_1.__assign({}, trace), { mode: withTextMode(trace.mode), text: labelText, textposition: labelPosition }) : trace;
|
|
665
|
+
};
|
|
595
666
|
if (isScatter_1) {
|
|
596
667
|
// Per-series marker.symbol = "none" → pure line (no markers).
|
|
597
668
|
// Per-series marker.size overrides the default. Falls back to
|
|
@@ -601,9 +672,9 @@ var BasicChart = function (_a) {
|
|
|
601
672
|
var mode = noMarkers
|
|
602
673
|
? "lines"
|
|
603
674
|
: plotlyModeForScatterStyle_1(scatterStyle_1);
|
|
604
|
-
var markerSize = (
|
|
605
|
-
var markerColor = (
|
|
606
|
-
|
|
675
|
+
var markerSize = (_g = perSeriesMarker === null || perSeriesMarker === void 0 ? void 0 : perSeriesMarker.size) !== null && _g !== void 0 ? _g : 6;
|
|
676
|
+
var markerColor = (_h = perSeriesMarker === null || perSeriesMarker === void 0 ? void 0 : perSeriesMarker.color) !== null && _h !== void 0 ? _h : seriesColor;
|
|
677
|
+
traces_1.push(withLabels(tslib_1.__assign(tslib_1.__assign({ type: "scatter", mode: mode, x: xValues, y: yValues, customdata: customdata, name: entry.name, hovertemplate: "%{customdata[0]}<br>X: %{x}<br>Y: %{y}<extra></extra>", line: {
|
|
607
678
|
shape: lineShapeFor_1(scatterStyle_1),
|
|
608
679
|
color: seriesColor,
|
|
609
680
|
width: 2,
|
|
@@ -612,71 +683,114 @@ var BasicChart = function (_a) {
|
|
|
612
683
|
: {
|
|
613
684
|
marker: {
|
|
614
685
|
size: markerSize,
|
|
615
|
-
color: markerColor,
|
|
686
|
+
color: pointColors(markerColor),
|
|
616
687
|
symbol: (0, helpers_1.mapMarkerSymbolToPlotly)(symbol),
|
|
617
688
|
},
|
|
618
|
-
}));
|
|
689
|
+
})), onSecondary)));
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
// Bubble — third dimension scaled into marker diameter.
|
|
693
|
+
var scaledSizes = rawSizes.map(function (value) { return sizeScale_1(value); });
|
|
694
|
+
traces_1.push(withLabels(tslib_1.__assign({ type: "scatter", mode: "markers", x: xValues, y: yValues, customdata: customdata, name: entry.name, hovertemplate: "%{customdata[0]}<br>X: %{x}<br>Y: %{y}<br>Size: %{customdata[1]}<extra></extra>", marker: {
|
|
695
|
+
size: scaledSizes,
|
|
696
|
+
sizemode: "diameter",
|
|
697
|
+
color: pointColors(seriesColor),
|
|
698
|
+
opacity: 0.7,
|
|
699
|
+
} }, onSecondary)));
|
|
700
|
+
}
|
|
701
|
+
// Trendlines on the real (x, y) points — a regression of Y on X,
|
|
702
|
+
// not on the point index — and native error bars (#1067).
|
|
703
|
+
var numericX = entry.points.map(function (point) { return point.value[0]; });
|
|
704
|
+
try {
|
|
705
|
+
for (var _t = tslib_1.__values((_j = seriesSpec === null || seriesSpec === void 0 ? void 0 : seriesSpec.trendlines) !== null && _j !== void 0 ? _j : []), _u = _t.next(); !_u.done; _u = _t.next()) {
|
|
706
|
+
var tl = _u.value;
|
|
707
|
+
var result = (0, trendline_1.computeTrendline)(yValues, {
|
|
708
|
+
type: tl.type,
|
|
709
|
+
order: tl.order,
|
|
710
|
+
period: tl.period,
|
|
711
|
+
forecastForward: tl.forecastForward,
|
|
712
|
+
forecastBackward: tl.forecastBackward,
|
|
713
|
+
}, numericX);
|
|
714
|
+
if (!result || result.points.length < 2)
|
|
715
|
+
continue;
|
|
716
|
+
var tlName = (_k = tl.name) !== null && _k !== void 0 ? _k : "".concat(entry.name ? entry.name + " " : "").concat((_l = tl.type) !== null && _l !== void 0 ? _l : "linear", " trend");
|
|
717
|
+
traces_1.push(tslib_1.__assign({ type: "scatter", mode: "lines", name: tlName, x: result.points.map(function (p) {
|
|
718
|
+
var _a;
|
|
719
|
+
return hasStringX_1
|
|
720
|
+
? (_a = categories_1[Math.round(p.x)]) !== null && _a !== void 0 ? _a : p.x
|
|
721
|
+
: p.x;
|
|
722
|
+
}), y: result.points.map(function (p) { return p.y; }), line: { color: (_m = tl.color) !== null && _m !== void 0 ? _m : seriesColor, dash: "dash", width: 2 }, hoverinfo: "skip" }, onSecondary));
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
726
|
+
finally {
|
|
727
|
+
try {
|
|
728
|
+
if (_u && !_u.done && (_b = _t.return)) _b.call(_t);
|
|
729
|
+
}
|
|
730
|
+
finally { if (e_6) throw e_6.error; }
|
|
731
|
+
}
|
|
732
|
+
if (seriesSpec === null || seriesSpec === void 0 ? void 0 : seriesSpec.errorBars) {
|
|
733
|
+
var direction = (_o = seriesSpec.errorBars.direction) !== null && _o !== void 0 ? _o : "y";
|
|
734
|
+
// An X error bar sizes from the X values (a percentage or
|
|
735
|
+
// deviation of X).
|
|
736
|
+
var magnitudes_1 = (0, error_bars_1.computeErrorBars)(direction === "x" ? numericX : yValues, (0, error_bars_1.resolveCustomErrorBarValues)(seriesSpec.errorBars, function (range) {
|
|
737
|
+
return getSeriesValuesFromRange(range, spec.hiddenDimensionStrategy);
|
|
738
|
+
}));
|
|
739
|
+
if (magnitudes_1) {
|
|
740
|
+
var symmetric = magnitudes_1.plus.every(function (plus, i) { return plus === magnitudes_1.minus[i]; });
|
|
741
|
+
var errorConfig = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ type: "data", symmetric: symmetric, array: magnitudes_1.plus }, (symmetric ? {} : { arrayminus: magnitudes_1.minus })), { color: seriesColor }), (seriesSpec.errorBars.noEndCap ? { width: 0 } : {}));
|
|
742
|
+
var target = traces_1[traces_1.length - 1 - ((_q = (_p = seriesSpec.trendlines) === null || _p === void 0 ? void 0 : _p.length) !== null && _q !== void 0 ? _q : 0)];
|
|
743
|
+
if (target) {
|
|
744
|
+
target[direction === "x" ? "error_x" : "error_y"] = errorConfig;
|
|
745
|
+
}
|
|
746
|
+
}
|
|
619
747
|
}
|
|
620
|
-
// Bubble — third dimension scaled into marker diameter.
|
|
621
|
-
var rawSizes = entry.points.map(function (point) { return point.value[2]; });
|
|
622
|
-
var scaledSizes = rawSizes.map(function (value) { return sizeScale_1(value); });
|
|
623
|
-
return {
|
|
624
|
-
type: "scatter",
|
|
625
|
-
mode: "markers",
|
|
626
|
-
x: xValues,
|
|
627
|
-
y: yValues,
|
|
628
|
-
text: labelValuesForSeries,
|
|
629
|
-
customdata: rawSizes,
|
|
630
|
-
name: entry.name,
|
|
631
|
-
hovertemplate: "%{text}<br>X: %{x}<br>Y: %{y}<br>Size: %{customdata}<extra></extra>",
|
|
632
|
-
marker: {
|
|
633
|
-
size: scaledSizes,
|
|
634
|
-
sizemode: "diameter",
|
|
635
|
-
color: seriesColor,
|
|
636
|
-
opacity: 0.7,
|
|
637
|
-
},
|
|
638
|
-
};
|
|
639
748
|
});
|
|
640
749
|
titleFmt = spec.titleTextFormat;
|
|
641
|
-
xAxisFmt = (
|
|
642
|
-
yAxisFmt = (
|
|
643
|
-
legendFmt = (
|
|
644
|
-
bubbleLayout = {
|
|
645
|
-
title: {
|
|
750
|
+
xAxisFmt = (_3 = spec.categoryAxisOptions) === null || _3 === void 0 ? void 0 : _3.textFormat;
|
|
751
|
+
yAxisFmt = (_4 = spec.valueAxisOptions) === null || _4 === void 0 ? void 0 : _4.textFormat;
|
|
752
|
+
legendFmt = (_5 = spec.legend) === null || _5 === void 0 ? void 0 : _5.textFormat;
|
|
753
|
+
bubbleLayout = tslib_1.__assign(tslib_1.__assign({ title: {
|
|
646
754
|
text: (0, plotly_title_1.plotlyTitleText)(title, spec.titleTextFormat),
|
|
647
755
|
font: {
|
|
648
|
-
family: (
|
|
649
|
-
size: (
|
|
650
|
-
color: (
|
|
756
|
+
family: (_6 = titleFmt === null || titleFmt === void 0 ? void 0 : titleFmt.fontFamily) !== null && _6 !== void 0 ? _6 : "Untitled Sans, apple-system, sans-serif",
|
|
757
|
+
size: (_7 = titleFmt === null || titleFmt === void 0 ? void 0 : titleFmt.fontSize) !== null && _7 !== void 0 ? _7 : 16,
|
|
758
|
+
color: (_8 = titleFmt === null || titleFmt === void 0 ? void 0 : titleFmt.color) !== null && _8 !== void 0 ? _8 : textColor,
|
|
651
759
|
},
|
|
652
760
|
x: 0.02,
|
|
653
761
|
xanchor: "left",
|
|
654
|
-
},
|
|
655
|
-
|
|
762
|
+
},
|
|
763
|
+
// Axis min / max / reverse / log / visibility from the spec
|
|
764
|
+
// (`categoryAxisOptions` is the X axis, as in the echarts
|
|
765
|
+
// renderer).
|
|
766
|
+
xaxis: applyAxisOverridesPlotly({
|
|
656
767
|
title: {
|
|
657
|
-
text: (
|
|
658
|
-
font: { color: (
|
|
768
|
+
text: (_9 = spec.horizontalAxisTitle) !== null && _9 !== void 0 ? _9 : "",
|
|
769
|
+
font: { color: (_10 = xAxisFmt === null || xAxisFmt === void 0 ? void 0 : xAxisFmt.color) !== null && _10 !== void 0 ? _10 : textColor },
|
|
659
770
|
},
|
|
660
771
|
gridcolor: gridColor,
|
|
661
|
-
tickfont: tslib_1.__assign(tslib_1.__assign({ color: (
|
|
772
|
+
tickfont: tslib_1.__assign(tslib_1.__assign({ color: (_11 = xAxisFmt === null || xAxisFmt === void 0 ? void 0 : xAxisFmt.color) !== null && _11 !== void 0 ? _11 : textColor }, ((xAxisFmt === null || xAxisFmt === void 0 ? void 0 : xAxisFmt.fontFamily) ? { family: xAxisFmt.fontFamily } : {})), ((xAxisFmt === null || xAxisFmt === void 0 ? void 0 : xAxisFmt.fontSize) ? { size: xAxisFmt.fontSize } : {})),
|
|
662
773
|
type: hasStringX_1 ? "category" : "linear",
|
|
663
|
-
},
|
|
664
|
-
yaxis: {
|
|
774
|
+
}, spec.categoryAxisOptions), yaxis: applyAxisOverridesPlotly({
|
|
665
775
|
title: {
|
|
666
|
-
text: (
|
|
667
|
-
font: { color: (
|
|
776
|
+
text: (_12 = spec.verticalAxisTitle) !== null && _12 !== void 0 ? _12 : "",
|
|
777
|
+
font: { color: (_13 = yAxisFmt === null || yAxisFmt === void 0 ? void 0 : yAxisFmt.color) !== null && _13 !== void 0 ? _13 : textColor },
|
|
668
778
|
},
|
|
669
779
|
gridcolor: gridColor,
|
|
670
|
-
tickfont: tslib_1.__assign(tslib_1.__assign({ color: (
|
|
671
|
-
},
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
780
|
+
tickfont: tslib_1.__assign(tslib_1.__assign({ color: (_14 = yAxisFmt === null || yAxisFmt === void 0 ? void 0 : yAxisFmt.color) !== null && _14 !== void 0 ? _14 : textColor }, ((yAxisFmt === null || yAxisFmt === void 0 ? void 0 : yAxisFmt.fontFamily) ? { family: yAxisFmt.fontFamily } : {})), ((yAxisFmt === null || yAxisFmt === void 0 ? void 0 : yAxisFmt.fontSize) ? { size: yAxisFmt.fontSize } : {})),
|
|
781
|
+
}, spec.valueAxisOptions) }, (hasBubbleSecondaryAxis
|
|
782
|
+
? {
|
|
783
|
+
yaxis2: applyAxisOverridesPlotly({
|
|
784
|
+
overlaying: "y",
|
|
785
|
+
side: "right",
|
|
786
|
+
showgrid: false,
|
|
787
|
+
automargin: true,
|
|
788
|
+
tickfont: { color: (_15 = yAxisFmt === null || yAxisFmt === void 0 ? void 0 : yAxisFmt.color) !== null && _15 !== void 0 ? _15 : textColor },
|
|
789
|
+
}, spec.secondaryValueAxisOptions),
|
|
790
|
+
}
|
|
791
|
+
: {})), { legend: {
|
|
792
|
+
font: tslib_1.__assign(tslib_1.__assign({ color: (_16 = legendFmt === null || legendFmt === void 0 ? void 0 : legendFmt.color) !== null && _16 !== void 0 ? _16 : textColor }, ((legendFmt === null || legendFmt === void 0 ? void 0 : legendFmt.fontFamily) ? { family: legendFmt.fontFamily } : {})), ((legendFmt === null || legendFmt === void 0 ? void 0 : legendFmt.fontSize) ? { size: legendFmt.fontSize } : {})),
|
|
793
|
+
}, paper_bgcolor: bgColor, plot_bgcolor: bgColor, showlegend: preparedSeries.length > 1, margin: { l: 60, r: hasBubbleSecondaryAxis ? 60 : 20, t: 50, b: 50 } });
|
|
680
794
|
setPlotData(traces_1);
|
|
681
795
|
setLayout(bubbleLayout);
|
|
682
796
|
return [2 /*return*/];
|
|
@@ -693,19 +807,24 @@ var BasicChart = function (_a) {
|
|
|
693
807
|
hiddenDimensionStrategy: spec.hiddenDimensionStrategy,
|
|
694
808
|
});
|
|
695
809
|
hierarchyTitleRef.current = explicitChartTitle !== null && explicitChartTitle !== void 0 ? explicitChartTitle : headerTitle;
|
|
696
|
-
|
|
697
|
-
seriesName =
|
|
698
|
-
? (
|
|
699
|
-
: (
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
810
|
+
hierarchyData_1 = (0, hierarchy_1.toPlotlyHierarchy)(hierarchyRows);
|
|
811
|
+
seriesName = hierarchyData_1.labels.length === 1
|
|
812
|
+
? (_17 = hierarchyData_1.labels[0]) !== null && _17 !== void 0 ? _17 : ""
|
|
813
|
+
: (_18 = explicitChartTitle !== null && explicitChartTitle !== void 0 ? explicitChartTitle : headerTitle) !== null && _18 !== void 0 ? _18 : "";
|
|
814
|
+
hierarchyPalette = (0, chart_styles_1.getChartPalette)(spec, [
|
|
815
|
+
theme.themeColors.accent1,
|
|
816
|
+
theme.themeColors.accent2,
|
|
817
|
+
theme.themeColors.accent3,
|
|
818
|
+
theme.themeColors.accent4,
|
|
819
|
+
theme.themeColors.accent5,
|
|
820
|
+
theme.themeColors.accent6,
|
|
821
|
+
]);
|
|
822
|
+
nodeColors = (0, hierarchy_1.hierarchyNodeColors)(hierarchyData_1, hierarchyPalette);
|
|
823
|
+
isSunburst = spec.chartType === "sunburst";
|
|
824
|
+
SUNBURST_ROOT_ID_1 = "__rnc_sunburst_root__";
|
|
825
|
+
rootTotal = hierarchyData_1.values.reduce(function (sum, value, i) { return (hierarchyData_1.parents[i] === "" ? sum + value : sum); }, 0);
|
|
826
|
+
hierarchyTrace = tslib_1.__assign({ type: chartType, labels: isSunburst ? tslib_1.__spreadArray([""], tslib_1.__read(hierarchyData_1.labels), false) : hierarchyData_1.labels, ids: isSunburst ? tslib_1.__spreadArray([SUNBURST_ROOT_ID_1], tslib_1.__read(hierarchyData_1.ids), false) : hierarchyData_1.ids, parents: isSunburst
|
|
827
|
+
? tslib_1.__spreadArray([""], tslib_1.__read(hierarchyData_1.parents.map(function (parent) { return parent || SUNBURST_ROOT_ID_1; })), false) : hierarchyData_1.parents, values: isSunburst ? tslib_1.__spreadArray([rootTotal], tslib_1.__read(hierarchyData_1.values), false) : hierarchyData_1.values, marker: tslib_1.__assign({ colors: isSunburst ? tslib_1.__spreadArray(["rgba(0,0,0,0)"], tslib_1.__read(nodeColors), false) : nodeColors }, (isSunburst ? { line: { width: 1 } } : {})), name: seriesName, textinfo: "label+value", branchvalues: "total" }, (isSunburst ? {} : { textposition: "bottom left" }));
|
|
709
828
|
layoutForHierarchy = {
|
|
710
829
|
title: {
|
|
711
830
|
text: (0, plotly_title_1.plotlyTitleText)(title, spec.titleTextFormat),
|
|
@@ -745,7 +864,7 @@ var BasicChart = function (_a) {
|
|
|
745
864
|
// country-name matching and silently skips labels it can't place.
|
|
746
865
|
if ((0, region_map_1.isRegionMapSpec)(spec)) {
|
|
747
866
|
labels = flattenChartDataValues(spec.domains, getDomainValuesFromRange, spec.hiddenDimensionStrategy, false).map(function (v) { return String(v !== null && v !== void 0 ? v : "").trim(); });
|
|
748
|
-
seriesEntry = (
|
|
867
|
+
seriesEntry = (_19 = spec.series) === null || _19 === void 0 ? void 0 : _19[0];
|
|
749
868
|
rawValues_1 = seriesEntry
|
|
750
869
|
? flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); })
|
|
751
870
|
: [];
|
|
@@ -810,34 +929,34 @@ var BasicChart = function (_a) {
|
|
|
810
929
|
if (!(surfaceToken === "SURFACE" || surfaceToken === "SURFACE_3D")) return [3 /*break*/, 17];
|
|
811
930
|
categories = flattenChartDataValues(spec.domains, getDomainValuesFromRange, spec.hiddenDimensionStrategy, false).map(function (v) { return String(v !== null && v !== void 0 ? v : ""); });
|
|
812
931
|
surfaceSeriesInputs = [];
|
|
813
|
-
|
|
932
|
+
_82.label = 7;
|
|
814
933
|
case 7:
|
|
815
|
-
|
|
816
|
-
_c = tslib_1.__values((
|
|
817
|
-
|
|
934
|
+
_82.trys.push([7, 14, 15, 16]);
|
|
935
|
+
_c = tslib_1.__values((_20 = spec.series) !== null && _20 !== void 0 ? _20 : []), _d = _c.next();
|
|
936
|
+
_82.label = 8;
|
|
818
937
|
case 8:
|
|
819
938
|
if (!!_d.done) return [3 /*break*/, 13];
|
|
820
939
|
seriesEntry = _d.value;
|
|
821
940
|
if (!(!(0, utils_1.isNil)(seriesEntry.dataLabel) && (0, utils_1.isAFormula)(seriesEntry.dataLabel))) return [3 /*break*/, 10];
|
|
822
941
|
_f = chart_spec_utils_1.coerceCalculatedLabel;
|
|
823
|
-
return [4 /*yield*/, onRequestCalculate(seriesEntry.dataLabel, (
|
|
942
|
+
return [4 /*yield*/, onRequestCalculate(seriesEntry.dataLabel, (_21 = position.sheetId) !== null && _21 !== void 0 ? _21 : sheetId, position.overlayPosition.anchorCell.rowIndex, position.overlayPosition.anchorCell.columnIndex)];
|
|
824
943
|
case 9:
|
|
825
|
-
_e = _f.apply(void 0, [
|
|
944
|
+
_e = _f.apply(void 0, [_82.sent()]);
|
|
826
945
|
return [3 /*break*/, 11];
|
|
827
946
|
case 10:
|
|
828
|
-
_e = (
|
|
829
|
-
|
|
947
|
+
_e = (_22 = seriesEntry.dataLabel) !== null && _22 !== void 0 ? _22 : "";
|
|
948
|
+
_82.label = 11;
|
|
830
949
|
case 11:
|
|
831
950
|
dataLabel = _e;
|
|
832
951
|
values = flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); });
|
|
833
952
|
surfaceSeriesInputs.push({ name: dataLabel, values: values });
|
|
834
|
-
|
|
953
|
+
_82.label = 12;
|
|
835
954
|
case 12:
|
|
836
955
|
_d = _c.next();
|
|
837
956
|
return [3 /*break*/, 8];
|
|
838
957
|
case 13: return [3 /*break*/, 16];
|
|
839
958
|
case 14:
|
|
840
|
-
e_2_1 =
|
|
959
|
+
e_2_1 = _82.sent();
|
|
841
960
|
e_2 = { error: e_2_1 };
|
|
842
961
|
return [3 /*break*/, 16];
|
|
843
962
|
case 15:
|
|
@@ -865,21 +984,21 @@ var BasicChart = function (_a) {
|
|
|
865
984
|
}, paper_bgcolor: bgColor, plot_bgcolor: bgColor, showlegend: false, margin: { l: 60, r: 20, t: 50, b: 50 } }, (surfaceToken === "SURFACE"
|
|
866
985
|
? {
|
|
867
986
|
xaxis: {
|
|
868
|
-
title: { text: (
|
|
987
|
+
title: { text: (_23 = spec.horizontalAxisTitle) !== null && _23 !== void 0 ? _23 : "" },
|
|
869
988
|
automargin: true,
|
|
870
989
|
color: textColor,
|
|
871
990
|
},
|
|
872
991
|
yaxis: {
|
|
873
|
-
title: { text: (
|
|
992
|
+
title: { text: (_24 = spec.verticalAxisTitle) !== null && _24 !== void 0 ? _24 : "" },
|
|
874
993
|
automargin: true,
|
|
875
994
|
color: textColor,
|
|
876
995
|
},
|
|
877
996
|
}
|
|
878
997
|
: {
|
|
879
998
|
scene: {
|
|
880
|
-
xaxis: { title: { text: (
|
|
999
|
+
xaxis: { title: { text: (_25 = spec.horizontalAxisTitle) !== null && _25 !== void 0 ? _25 : "" } },
|
|
881
1000
|
yaxis: { title: { text: "" } },
|
|
882
|
-
zaxis: { title: { text: (
|
|
1001
|
+
zaxis: { title: { text: (_26 = spec.verticalAxisTitle) !== null && _26 !== void 0 ? _26 : "" } },
|
|
883
1002
|
},
|
|
884
1003
|
}));
|
|
885
1004
|
setPlotData([surfaceTrace]);
|
|
@@ -891,11 +1010,11 @@ var BasicChart = function (_a) {
|
|
|
891
1010
|
// theta = the category names (closed by appending the first point).
|
|
892
1011
|
if (spec.chartType === "radar") {
|
|
893
1012
|
categories = flattenChartDataValues(spec.domains, getDomainValuesFromRange, spec.hiddenDimensionStrategy, false).map(function (v) { return String(v !== null && v !== void 0 ? v : ""); });
|
|
894
|
-
radarStyle = (
|
|
1013
|
+
radarStyle = (_27 = spec.radarStyle) !== null && _27 !== void 0 ? _27 : "standard";
|
|
895
1014
|
radarTraces = [];
|
|
896
1015
|
radarInputs = [];
|
|
897
1016
|
try {
|
|
898
|
-
for (_g = tslib_1.__values((
|
|
1017
|
+
for (_g = tslib_1.__values((_28 = spec.series) !== null && _28 !== void 0 ? _28 : []), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
899
1018
|
seriesEntry = _h.value;
|
|
900
1019
|
label = seriesEntry.dataLabel && !(0, utils_1.isAFormula)(seriesEntry.dataLabel)
|
|
901
1020
|
? seriesEntry.dataLabel
|
|
@@ -911,10 +1030,11 @@ var BasicChart = function (_a) {
|
|
|
911
1030
|
}
|
|
912
1031
|
finally { if (e_4) throw e_4.error; }
|
|
913
1032
|
}
|
|
914
|
-
|
|
1033
|
+
radarAxisOptions = spec.valueAxisOptions;
|
|
1034
|
+
indicators = (0, radar_1.buildRadarIndicators)(categories, radarInputs, radarAxisOptions);
|
|
915
1035
|
_loop_1 = function (i) {
|
|
916
1036
|
var input = radarInputs[i];
|
|
917
|
-
var seriesColor = (
|
|
1037
|
+
var seriesColor = (_31 = (_30 = (_29 = spec.series) === null || _29 === void 0 ? void 0 : _29[i]) === null || _30 === void 0 ? void 0 : _30.color) !== null && _31 !== void 0 ? _31 : undefined;
|
|
918
1038
|
var r = indicators.map(function (_, idx) { var _a; return (_a = input.values[idx]) !== null && _a !== void 0 ? _a : 0; });
|
|
919
1039
|
var theta = indicators.map(function (ind) { return ind.name; });
|
|
920
1040
|
radarTraces.push(tslib_1.__assign(tslib_1.__assign({ type: "scatterpolar", r: r.length ? tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(r), false), [r[0]], false) : r, theta: theta.length ? tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(theta), false), [theta[0]], false) : theta, name: input.name, mode: radarStyle === "standard" ? "lines" : "lines+markers" }, (radarStyle === "filled" ? { fill: "toself" } : {})), (seriesColor ? { line: { color: seriesColor } } : {})));
|
|
@@ -922,7 +1042,7 @@ var BasicChart = function (_a) {
|
|
|
922
1042
|
for (i = 0; i < radarInputs.length; i++) {
|
|
923
1043
|
_loop_1(i);
|
|
924
1044
|
}
|
|
925
|
-
|
|
1045
|
+
radarScale = (_32 = indicators[0]) !== null && _32 !== void 0 ? _32 : { min: 0, max: 1 };
|
|
926
1046
|
setPlotData(radarTraces);
|
|
927
1047
|
setLayout({
|
|
928
1048
|
title: { text: (0, plotly_title_1.plotlyTitleText)(title, spec.titleTextFormat) },
|
|
@@ -932,8 +1052,8 @@ var BasicChart = function (_a) {
|
|
|
932
1052
|
showlegend: radarTraces.length > 1,
|
|
933
1053
|
polar: {
|
|
934
1054
|
radialaxis: {
|
|
935
|
-
visible:
|
|
936
|
-
range: [
|
|
1055
|
+
visible: (radarAxisOptions === null || radarAxisOptions === void 0 ? void 0 : radarAxisOptions.visible) !== false,
|
|
1056
|
+
range: [radarScale.min, radarScale.max],
|
|
937
1057
|
},
|
|
938
1058
|
},
|
|
939
1059
|
margin: { l: 50, r: 50, t: 50, b: 50 },
|
|
@@ -946,13 +1066,13 @@ var BasicChart = function (_a) {
|
|
|
946
1066
|
// V-variants additionally get a volume column sub-pane below the
|
|
947
1067
|
// price plot.
|
|
948
1068
|
if (spec.chartType === "stock") {
|
|
949
|
-
variant = ((
|
|
1069
|
+
variant = ((_33 = spec.stockVariant) !== null && _33 !== void 0 ? _33 : "HLC");
|
|
950
1070
|
categories = flattenChartDataValues(spec.domains, getDomainValuesFromRange, spec.hiddenDimensionStrategy, false).map(function (v) { return String(v !== null && v !== void 0 ? v : ""); });
|
|
951
|
-
seriesValues = ((
|
|
1071
|
+
seriesValues = ((_34 = spec.series) !== null && _34 !== void 0 ? _34 : []).map(function (seriesEntry) {
|
|
952
1072
|
return flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); });
|
|
953
1073
|
});
|
|
954
1074
|
volumePoints_1 = (0, stock_1.toVolumeSeries)(seriesValues, variant);
|
|
955
|
-
hasVolume = ((
|
|
1075
|
+
hasVolume = ((_35 = volumePoints_1 === null || volumePoints_1 === void 0 ? void 0 : volumePoints_1.length) !== null && _35 !== void 0 ? _35 : 0) > 0;
|
|
956
1076
|
buildVolumeTrace = function (xs) {
|
|
957
1077
|
return ({
|
|
958
1078
|
type: "bar",
|
|
@@ -985,25 +1105,25 @@ var BasicChart = function (_a) {
|
|
|
985
1105
|
roles = (0, stock_1.assignStockRoles)(seriesValues, variant);
|
|
986
1106
|
xs_1 = categories.length > 0
|
|
987
1107
|
? categories
|
|
988
|
-
: ((
|
|
1108
|
+
: ((_36 = roles.close) !== null && _36 !== void 0 ? _36 : []).map(function (_, i) { return i + 1; });
|
|
989
1109
|
candleTrace = {
|
|
990
1110
|
type: "candlestick",
|
|
991
1111
|
x: xs_1,
|
|
992
|
-
open: ((
|
|
993
|
-
high: ((
|
|
994
|
-
low: ((
|
|
995
|
-
close: ((
|
|
1112
|
+
open: ((_37 = roles.open) !== null && _37 !== void 0 ? _37 : []).map(function (v) { return v !== null && v !== void 0 ? v : null; }),
|
|
1113
|
+
high: ((_38 = roles.high) !== null && _38 !== void 0 ? _38 : []).map(function (v) { return v !== null && v !== void 0 ? v : null; }),
|
|
1114
|
+
low: ((_39 = roles.low) !== null && _39 !== void 0 ? _39 : []).map(function (v) { return v !== null && v !== void 0 ? v : null; }),
|
|
1115
|
+
close: ((_40 = roles.close) !== null && _40 !== void 0 ? _40 : []).map(function (v) { return v !== null && v !== void 0 ? v : null; }),
|
|
996
1116
|
increasing: { line: { color: theme.themeColors.accent1 } },
|
|
997
1117
|
decreasing: { line: { color: theme.themeColors.accent2 } },
|
|
998
1118
|
};
|
|
999
1119
|
setPlotData(hasVolume ? [candleTrace, buildVolumeTrace(xs_1)] : [candleTrace]);
|
|
1000
1120
|
setLayout(tslib_1.__assign(tslib_1.__assign({ title: { text: (0, plotly_title_1.plotlyTitleText)(title, spec.titleTextFormat) }, font: { color: textColor }, paper_bgcolor: bgColor, plot_bgcolor: bgColor, showlegend: false, xaxis: {
|
|
1001
|
-
title: { text: (
|
|
1121
|
+
title: { text: (_41 = spec.horizontalAxisTitle) !== null && _41 !== void 0 ? _41 : "" },
|
|
1002
1122
|
automargin: true,
|
|
1003
1123
|
showgrid: true,
|
|
1004
1124
|
gridcolor: gridColor,
|
|
1005
1125
|
rangeslider: { visible: false },
|
|
1006
|
-
}, yaxis: tslib_1.__assign({ title: { text: (
|
|
1126
|
+
}, yaxis: tslib_1.__assign({ title: { text: (_42 = spec.verticalAxisTitle) !== null && _42 !== void 0 ? _42 : "" }, automargin: true, showgrid: true, gridcolor: gridColor }, priceYAxisDomain) }, volumeLayout), { margin: { l: 50, r: 50, t: 50, b: 50 }, autosize: true }));
|
|
1007
1127
|
return [2 /*return*/];
|
|
1008
1128
|
}
|
|
1009
1129
|
lineSeries = (0, stock_1.toLineSeries)(seriesValues, variant);
|
|
@@ -1015,7 +1135,7 @@ var BasicChart = function (_a) {
|
|
|
1015
1135
|
]);
|
|
1016
1136
|
xs_2 = categories.length > 0
|
|
1017
1137
|
? categories
|
|
1018
|
-
: ((
|
|
1138
|
+
: ((_44 = (_43 = lineSeries[0]) === null || _43 === void 0 ? void 0 : _43.values) !== null && _44 !== void 0 ? _44 : []).map(function (_, i) { return i + 1; });
|
|
1019
1139
|
stockTraces = lineSeries.map(function (s, i) { return ({
|
|
1020
1140
|
type: "scatter",
|
|
1021
1141
|
mode: "lines",
|
|
@@ -1026,11 +1146,11 @@ var BasicChart = function (_a) {
|
|
|
1026
1146
|
}); });
|
|
1027
1147
|
setPlotData(hasVolume ? tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(stockTraces), false), [buildVolumeTrace(xs_2)], false) : stockTraces);
|
|
1028
1148
|
setLayout(tslib_1.__assign(tslib_1.__assign({ title: { text: (0, plotly_title_1.plotlyTitleText)(title, spec.titleTextFormat) }, font: { color: textColor }, paper_bgcolor: bgColor, plot_bgcolor: bgColor, showlegend: stockTraces.length > 1, xaxis: {
|
|
1029
|
-
title: { text: (
|
|
1149
|
+
title: { text: (_45 = spec.horizontalAxisTitle) !== null && _45 !== void 0 ? _45 : "" },
|
|
1030
1150
|
automargin: true,
|
|
1031
1151
|
showgrid: true,
|
|
1032
1152
|
gridcolor: gridColor,
|
|
1033
|
-
}, yaxis: tslib_1.__assign({ title: { text: (
|
|
1153
|
+
}, yaxis: tslib_1.__assign({ title: { text: (_46 = spec.verticalAxisTitle) !== null && _46 !== void 0 ? _46 : "" }, automargin: true, showgrid: true, gridcolor: gridColor }, priceYAxisDomain) }, volumeLayout), { margin: { l: 50, r: 50, t: 50, b: 50 }, autosize: true }));
|
|
1034
1154
|
return [2 /*return*/];
|
|
1035
1155
|
}
|
|
1036
1156
|
isStacked = spec.stackedType && spec.stackedType !== "UNSTACKED";
|
|
@@ -1077,12 +1197,12 @@ var BasicChart = function (_a) {
|
|
|
1077
1197
|
return extra;
|
|
1078
1198
|
};
|
|
1079
1199
|
shouldAggregate = (0, aggregation_1.shouldAggregateSeries)(spec.series);
|
|
1080
|
-
primaryDomainSource = (
|
|
1200
|
+
primaryDomainSource = (_49 = (_48 = (_47 = spec === null || spec === void 0 ? void 0 : spec.domains) === null || _47 === void 0 ? void 0 : _47[0]) === null || _48 === void 0 ? void 0 : _48.sources) === null || _49 === void 0 ? void 0 : _49[0];
|
|
1081
1201
|
rawPrimaryDomainValues = primaryDomainSource
|
|
1082
|
-
? (0, aggregation_1.sanitizeDomainValues)((
|
|
1202
|
+
? (0, aggregation_1.sanitizeDomainValues)((_50 = getDomainValuesFromRange(primaryDomainSource, spec.hiddenDimensionStrategy)) !== null && _50 !== void 0 ? _50 : [])
|
|
1083
1203
|
: [];
|
|
1084
1204
|
domainData = (0, aggregation_1.getDomainValuesForAxis)(rawPrimaryDomainValues, shouldAggregate);
|
|
1085
|
-
categoryLevels = (0, category_levels_1.resolveCategoryLevels)((
|
|
1205
|
+
categoryLevels = (0, category_levels_1.resolveCategoryLevels)((_51 = spec.categoryLevels) === null || _51 === void 0 ? void 0 : _51.map(function (level) {
|
|
1086
1206
|
return flattenChartDataValues([level], getDomainValuesFromRange, spec.hiddenDimensionStrategy, false);
|
|
1087
1207
|
}));
|
|
1088
1208
|
multicategoryX = categoryLevels
|
|
@@ -1092,7 +1212,7 @@ var BasicChart = function (_a) {
|
|
|
1092
1212
|
domainData = categoryLevels.leaf;
|
|
1093
1213
|
}
|
|
1094
1214
|
aggregateDomainValues = domainData;
|
|
1095
|
-
domainAxisData = (categoryLevels ? [] : (
|
|
1215
|
+
domainAxisData = (categoryLevels ? [] : (_52 = spec.domains) !== null && _52 !== void 0 ? _52 : []).map(function (domain, domainIndex) {
|
|
1096
1216
|
return domain.sources.flatMap(function (sheetRange, sourceIndex) {
|
|
1097
1217
|
var _a;
|
|
1098
1218
|
if (domainIndex === 0 && sourceIndex === 0) {
|
|
@@ -1136,7 +1256,7 @@ var BasicChart = function (_a) {
|
|
|
1136
1256
|
theme.themeColors.accent6,
|
|
1137
1257
|
]);
|
|
1138
1258
|
applyTraceColor = function (trace, seriesColor, options) {
|
|
1139
|
-
var
|
|
1259
|
+
var e_7, _a;
|
|
1140
1260
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
1141
1261
|
var target = trace;
|
|
1142
1262
|
var chartTypeForStyling = (_b = options === null || options === void 0 ? void 0 : options.effectiveChartType) !== null && _b !== void 0 ? _b : spec.chartType;
|
|
@@ -1158,24 +1278,25 @@ var BasicChart = function (_a) {
|
|
|
1158
1278
|
// by category index, falling back to the series color for points
|
|
1159
1279
|
// without an override.
|
|
1160
1280
|
var isPie = chartTypeForStyling === "pie";
|
|
1161
|
-
|
|
1281
|
+
var isFunnel = chartTypeForStyling === "funnel";
|
|
1282
|
+
if ((isBarOrColumn || isPie || isFunnel) &&
|
|
1162
1283
|
Array.isArray(options === null || options === void 0 ? void 0 : options.dataPointColors) &&
|
|
1163
1284
|
(options === null || options === void 0 ? void 0 : options.dataPointColors.length)) {
|
|
1164
|
-
var
|
|
1285
|
+
var overrides_2 = new Map();
|
|
1165
1286
|
try {
|
|
1166
1287
|
for (var _u = tslib_1.__values(options.dataPointColors), _v = _u.next(); !_v.done; _v = _u.next()) {
|
|
1167
1288
|
var dp = _v.value;
|
|
1168
1289
|
if (typeof dp.idx === "number" && typeof dp.color === "string") {
|
|
1169
|
-
|
|
1290
|
+
overrides_2.set(dp.idx, dp.color);
|
|
1170
1291
|
}
|
|
1171
1292
|
}
|
|
1172
1293
|
}
|
|
1173
|
-
catch (
|
|
1294
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
1174
1295
|
finally {
|
|
1175
1296
|
try {
|
|
1176
1297
|
if (_v && !_v.done && (_a = _u.return)) _a.call(_u);
|
|
1177
1298
|
}
|
|
1178
|
-
finally { if (
|
|
1299
|
+
finally { if (e_7) throw e_7.error; }
|
|
1179
1300
|
}
|
|
1180
1301
|
if (isPie) {
|
|
1181
1302
|
// Per-slice colours (`<c:dPt>`): an authored slice colour wins,
|
|
@@ -1189,7 +1310,7 @@ var BasicChart = function (_a) {
|
|
|
1189
1310
|
: 0;
|
|
1190
1311
|
target.marker = tslib_1.__assign(tslib_1.__assign({}, ((_j = target.marker) !== null && _j !== void 0 ? _j : {})), { colors: Array.from({ length: labelCount }, function (_, i) {
|
|
1191
1312
|
var _a, _b;
|
|
1192
|
-
return (_b = (_a =
|
|
1313
|
+
return (_b = (_a = overrides_2.get(i)) !== null && _a !== void 0 ? _a : seriesColor) !== null && _b !== void 0 ? _b : existing_1[i % Math.max(1, existing_1.length)];
|
|
1193
1314
|
}) });
|
|
1194
1315
|
return trace;
|
|
1195
1316
|
}
|
|
@@ -1199,7 +1320,7 @@ var BasicChart = function (_a) {
|
|
|
1199
1320
|
: Array.isArray(target.x)
|
|
1200
1321
|
? target.x
|
|
1201
1322
|
: [];
|
|
1202
|
-
var colors = yArray.map(function (_, i) { var _a; return (_a =
|
|
1323
|
+
var colors = yArray.map(function (_, i) { var _a; return (_a = overrides_2.get(i)) !== null && _a !== void 0 ? _a : fallback_1; });
|
|
1203
1324
|
target.marker = tslib_1.__assign(tslib_1.__assign({}, ((_k = target.marker) !== null && _k !== void 0 ? _k : {})), { color: colors });
|
|
1204
1325
|
return trace;
|
|
1205
1326
|
}
|
|
@@ -1261,7 +1382,7 @@ var BasicChart = function (_a) {
|
|
|
1261
1382
|
ofPieHandled = false;
|
|
1262
1383
|
ofPieExtras = null;
|
|
1263
1384
|
decorateCartesianTrace = function (trace, series, values, dataLabel) {
|
|
1264
|
-
var
|
|
1385
|
+
var e_8, _a;
|
|
1265
1386
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1266
1387
|
var target = trace;
|
|
1267
1388
|
// Secondary value axis. Plotly overlays a second value axis ("y2",
|
|
@@ -1340,37 +1461,37 @@ var BasicChart = function (_a) {
|
|
|
1340
1461
|
_loop_3(tl);
|
|
1341
1462
|
}
|
|
1342
1463
|
}
|
|
1343
|
-
catch (
|
|
1464
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
1344
1465
|
finally {
|
|
1345
1466
|
try {
|
|
1346
1467
|
if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
|
|
1347
1468
|
}
|
|
1348
|
-
finally { if (
|
|
1469
|
+
finally { if (e_8) throw e_8.error; }
|
|
1349
1470
|
}
|
|
1350
1471
|
};
|
|
1351
|
-
domainSources = (
|
|
1472
|
+
domainSources = (_55 = (_54 = (_53 = spec.domains) === null || _53 === void 0 ? void 0 : _53[0]) === null || _54 === void 0 ? void 0 : _54.sources) !== null && _55 !== void 0 ? _55 : [];
|
|
1352
1473
|
seriesIndex = 0;
|
|
1353
1474
|
_loop_2 = function (series) {
|
|
1354
|
-
var currentSeriesIndex, dataLabel,
|
|
1355
|
-
return tslib_1.__generator(this, function (
|
|
1356
|
-
switch (
|
|
1475
|
+
var currentSeriesIndex, dataLabel, _83, _84, effectiveChartType, lineLike, pieDomainLabels, piePointOffset, seriesData, seriesPlotlyType, seriesTraceStyle, rawValues, binCount, _85, labels, counts, cumulativePercents, barTrace, trace, rawValues, quartileMethod, showOutliers, showMeanMarker, usePrecomputed, trace, summary, hideOutliers, rawValues, totalIndices_1, increaseColor, trace, rawValues, trace, pieData, _86, main_1, secondary, otherTotal, total, ofPieType, secondScale, halfAngle, paletteAt_1, MAIN_DOMAIN_X, CY, SECONDARY_CX, BAR_LEFT, BAR_RIGHT, plotW, plotH, hasGeometry, r, r2, clampFrac, rx2, ry2, barHalf, shapes, connectorColor, mainCx, px, pyTop, pyBottom, tx, half, line, pieData, trace, _87, x, y, orientation_1, trace, numericValues, _88, x, y, orientation_2, trace;
|
|
1476
|
+
return tslib_1.__generator(this, function (_89) {
|
|
1477
|
+
switch (_89.label) {
|
|
1357
1478
|
case 0:
|
|
1358
1479
|
currentSeriesIndex = seriesIndex++;
|
|
1359
1480
|
if (!(!(0, utils_1.isNil)(series.dataLabel) && (0, utils_1.isAFormula)(series.dataLabel))) return [3 /*break*/, 2];
|
|
1360
|
-
|
|
1361
|
-
return [4 /*yield*/, onRequestCalculate(series.dataLabel, (
|
|
1481
|
+
_84 = chart_spec_utils_1.coerceCalculatedLabel;
|
|
1482
|
+
return [4 /*yield*/, onRequestCalculate(series.dataLabel, (_57 = position.sheetId) !== null && _57 !== void 0 ? _57 : sheetId, position.overlayPosition.anchorCell.rowIndex, position.overlayPosition.anchorCell.columnIndex)];
|
|
1362
1483
|
case 1:
|
|
1363
|
-
|
|
1484
|
+
_83 = _84.apply(void 0, [_89.sent()]);
|
|
1364
1485
|
return [3 /*break*/, 3];
|
|
1365
1486
|
case 2:
|
|
1366
|
-
|
|
1367
|
-
|
|
1487
|
+
_83 = (_58 = series.dataLabel) !== null && _58 !== void 0 ? _58 : "";
|
|
1488
|
+
_89.label = 3;
|
|
1368
1489
|
case 3:
|
|
1369
|
-
dataLabel =
|
|
1490
|
+
dataLabel = _83;
|
|
1370
1491
|
// A series with no ranges draws nothing.
|
|
1371
1492
|
if (series.sources.length === 0)
|
|
1372
1493
|
return [2 /*return*/, "continue"];
|
|
1373
|
-
effectiveChartType = (
|
|
1494
|
+
effectiveChartType = (_59 = series.seriesChartType) !== null && _59 !== void 0 ? _59 : spec.chartType;
|
|
1374
1495
|
lineLike = (0, empty_cells_1.isLineLikeChartType)(effectiveChartType);
|
|
1375
1496
|
pieDomainLabels = (spec.chartType === "pie" || spec.chartType === "doughnut") &&
|
|
1376
1497
|
(domainSources.length > 1 || series.sources.length > 1)
|
|
@@ -1403,19 +1524,17 @@ var BasicChart = function (_a) {
|
|
|
1403
1524
|
? { connectgaps: true }
|
|
1404
1525
|
: {}));
|
|
1405
1526
|
if (effectiveChartType === "histogram") {
|
|
1406
|
-
rawValues =
|
|
1407
|
-
? seriesData.values
|
|
1408
|
-
: seriesData;
|
|
1527
|
+
rawValues = seriesValuesOf(seriesData);
|
|
1409
1528
|
binCount = spec.binCount;
|
|
1410
1529
|
if (isPareto) {
|
|
1411
|
-
|
|
1530
|
+
_85 = (0, histogram_1.computePareto)((0, histogram_1.binHistogram)(rawValues, binCount)), labels = _85.labels, counts = _85.counts, cumulativePercents = _85.cumulativePercents;
|
|
1412
1531
|
barTrace = {
|
|
1413
1532
|
type: "bar",
|
|
1414
1533
|
x: labels,
|
|
1415
1534
|
y: counts,
|
|
1416
1535
|
name: dataLabel,
|
|
1417
1536
|
};
|
|
1418
|
-
applyTraceColor(barTrace, (
|
|
1537
|
+
applyTraceColor(barTrace, (_60 = series.color) !== null && _60 !== void 0 ? _60 : undefined, {
|
|
1419
1538
|
noFill: series.noFill,
|
|
1420
1539
|
dataPointColors: series.dataPointColors,
|
|
1421
1540
|
seriesIndex: currentSeriesIndex,
|
|
@@ -1436,7 +1555,7 @@ var BasicChart = function (_a) {
|
|
|
1436
1555
|
trace = tslib_1.__assign({ type: "histogram", x: rawValues.map(function (v) { return (v !== null && v !== void 0 ? v : null); }), name: dataLabel }, (typeof binCount === "number" && binCount > 0
|
|
1437
1556
|
? { nbinsx: binCount }
|
|
1438
1557
|
: {}));
|
|
1439
|
-
applyTraceColor(trace, (
|
|
1558
|
+
applyTraceColor(trace, (_61 = series.color) !== null && _61 !== void 0 ? _61 : undefined, {
|
|
1440
1559
|
noFill: series.noFill,
|
|
1441
1560
|
dataPointColors: series.dataPointColors,
|
|
1442
1561
|
seriesIndex: currentSeriesIndex,
|
|
@@ -1446,9 +1565,7 @@ var BasicChart = function (_a) {
|
|
|
1446
1565
|
}
|
|
1447
1566
|
}
|
|
1448
1567
|
else if (effectiveChartType === "boxplot") {
|
|
1449
|
-
rawValues =
|
|
1450
|
-
? seriesData.values
|
|
1451
|
-
: seriesData;
|
|
1568
|
+
rawValues = seriesValuesOf(seriesData);
|
|
1452
1569
|
quartileMethod = spec.quartileMethod;
|
|
1453
1570
|
showOutliers = spec.showOutliers;
|
|
1454
1571
|
showMeanMarker = spec.showMeanMarker === true;
|
|
@@ -1486,7 +1603,7 @@ var BasicChart = function (_a) {
|
|
|
1486
1603
|
// default and `showOutliers: true` alike).
|
|
1487
1604
|
boxpoints: "outliers" }, (showMeanMarker ? { boxmean: true } : {}));
|
|
1488
1605
|
}
|
|
1489
|
-
applyTraceColor(trace, (
|
|
1606
|
+
applyTraceColor(trace, (_62 = series.color) !== null && _62 !== void 0 ? _62 : undefined, {
|
|
1490
1607
|
noFill: series.noFill,
|
|
1491
1608
|
dataPointColors: series.dataPointColors,
|
|
1492
1609
|
seriesIndex: currentSeriesIndex,
|
|
@@ -1495,10 +1612,9 @@ var BasicChart = function (_a) {
|
|
|
1495
1612
|
traces.push(trace);
|
|
1496
1613
|
}
|
|
1497
1614
|
else if (effectiveChartType === "waterfall") {
|
|
1498
|
-
rawValues =
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
totalIndices_1 = new Set((_60 = spec.totalIndices) !== null && _60 !== void 0 ? _60 : []);
|
|
1615
|
+
rawValues = seriesValuesOf(seriesData);
|
|
1616
|
+
totalIndices_1 = new Set((_63 = spec.totalIndices) !== null && _63 !== void 0 ? _63 : []);
|
|
1617
|
+
increaseColor = (_64 = series.color) !== null && _64 !== void 0 ? _64 : (0, utils_1.chartPaletteColorAt)(themeColorPalette, currentSeriesIndex);
|
|
1502
1618
|
trace = {
|
|
1503
1619
|
type: "waterfall",
|
|
1504
1620
|
x: categoriesFor(series),
|
|
@@ -1507,26 +1623,33 @@ var BasicChart = function (_a) {
|
|
|
1507
1623
|
return totalIndices_1.has(i) ? "total" : "relative";
|
|
1508
1624
|
}),
|
|
1509
1625
|
name: dataLabel,
|
|
1626
|
+
increasing: { marker: { color: increaseColor } },
|
|
1627
|
+
decreasing: {
|
|
1628
|
+
marker: {
|
|
1629
|
+
color: (_66 = (_65 = series.negativeColor) !== null && _65 !== void 0 ? _65 : theme.themeColors.accent2) !== null && _66 !== void 0 ? _66 : increaseColor,
|
|
1630
|
+
},
|
|
1631
|
+
},
|
|
1632
|
+
totals: { marker: { color: (_67 = theme.themeColors.accent3) !== null && _67 !== void 0 ? _67 : increaseColor } },
|
|
1633
|
+
connector: {
|
|
1634
|
+
line: {
|
|
1635
|
+
color: isDarkMode ? "rgba(255,255,255,0.45)" : "#999999",
|
|
1636
|
+
width: 1,
|
|
1637
|
+
},
|
|
1638
|
+
},
|
|
1510
1639
|
};
|
|
1511
|
-
applyTraceColor(trace, (_61 = series.color) !== null && _61 !== void 0 ? _61 : undefined, {
|
|
1512
|
-
noFill: series.noFill,
|
|
1513
|
-
dataPointColors: series.dataPointColors,
|
|
1514
|
-
seriesIndex: currentSeriesIndex,
|
|
1515
|
-
effectiveChartType: effectiveChartType,
|
|
1516
|
-
});
|
|
1517
1640
|
traces.push(trace);
|
|
1518
1641
|
}
|
|
1519
1642
|
else if (effectiveChartType === "funnel") {
|
|
1520
|
-
rawValues =
|
|
1521
|
-
? seriesData.values
|
|
1522
|
-
: seriesData;
|
|
1643
|
+
rawValues = seriesValuesOf(seriesData);
|
|
1523
1644
|
trace = {
|
|
1524
1645
|
type: "funnel",
|
|
1646
|
+
orientation: "h",
|
|
1525
1647
|
y: categoriesFor(series),
|
|
1526
1648
|
x: rawValues.map(function (v) { return (v !== null && v !== void 0 ? v : null); }),
|
|
1527
1649
|
name: dataLabel,
|
|
1650
|
+
textinfo: "none",
|
|
1528
1651
|
};
|
|
1529
|
-
applyTraceColor(trace, (
|
|
1652
|
+
applyTraceColor(trace, (_68 = series.color) !== null && _68 !== void 0 ? _68 : undefined, {
|
|
1530
1653
|
noFill: series.noFill,
|
|
1531
1654
|
dataPointColors: series.dataPointColors,
|
|
1532
1655
|
seriesIndex: currentSeriesIndex,
|
|
@@ -1544,10 +1667,10 @@ var BasicChart = function (_a) {
|
|
|
1544
1667
|
return [2 /*return*/, "continue"];
|
|
1545
1668
|
ofPieHandled = true;
|
|
1546
1669
|
pieData = seriesData;
|
|
1547
|
-
|
|
1670
|
+
_86 = (0, of_pie_1.splitOfPie)(pieData.values, pieData.labels, {
|
|
1548
1671
|
splitType: spec.splitType,
|
|
1549
1672
|
splitPos: spec.splitPos,
|
|
1550
|
-
}), main_1 =
|
|
1673
|
+
}), main_1 = _86.main, secondary = _86.secondary, otherTotal = _86.otherTotal, total = _86.total;
|
|
1551
1674
|
ofPieType = (0, of_pie_1.resolveOfPieType)(spec.ofPieType);
|
|
1552
1675
|
secondScale = (0, of_pie_1.clampSecondPieSize)(spec.secondPieSize) / 100;
|
|
1553
1676
|
halfAngle = (0, of_pie_1.otherSliceHalfAngle)(otherTotal, total);
|
|
@@ -1680,7 +1803,7 @@ var BasicChart = function (_a) {
|
|
|
1680
1803
|
trace.meta = {
|
|
1681
1804
|
rncSeriesIndex: currentSeriesIndex,
|
|
1682
1805
|
};
|
|
1683
|
-
applyTraceColor(trace, (
|
|
1806
|
+
applyTraceColor(trace, (_69 = series.color) !== null && _69 !== void 0 ? _69 : undefined, {
|
|
1684
1807
|
noFill: series.noFill,
|
|
1685
1808
|
dataPointColors: series.dataPointColors,
|
|
1686
1809
|
seriesIndex: currentSeriesIndex,
|
|
@@ -1689,13 +1812,13 @@ var BasicChart = function (_a) {
|
|
|
1689
1812
|
traces.push(trace);
|
|
1690
1813
|
}
|
|
1691
1814
|
else if ("values" in seriesData && "labels" in seriesData) {
|
|
1692
|
-
|
|
1815
|
+
_87 = assignCartesianData(categoriesFor(series), seriesData.values), x = _87.x, y = _87.y, orientation_1 = _87.orientation;
|
|
1693
1816
|
trace = tslib_1.__assign(tslib_1.__assign({ type: seriesPlotlyType, x: x, y: y, orientation: orientation_1, name: dataLabel, stackgroup: isStacked ? "one" : undefined }, seriesTraceStyle), lineTraceVariant(series, effectiveChartType, seriesData.values));
|
|
1694
1817
|
// Ties the trace back to spec.series for click selection
|
|
1695
1818
|
trace.meta = {
|
|
1696
1819
|
rncSeriesIndex: currentSeriesIndex,
|
|
1697
1820
|
};
|
|
1698
|
-
applyTraceColor(trace, (
|
|
1821
|
+
applyTraceColor(trace, (_70 = series.color) !== null && _70 !== void 0 ? _70 : undefined, {
|
|
1699
1822
|
noFill: series.noFill,
|
|
1700
1823
|
dataPointColors: series.dataPointColors,
|
|
1701
1824
|
invertIfNegative: series.invertIfNegative,
|
|
@@ -1710,13 +1833,13 @@ var BasicChart = function (_a) {
|
|
|
1710
1833
|
}
|
|
1711
1834
|
else {
|
|
1712
1835
|
numericValues = seriesData;
|
|
1713
|
-
|
|
1836
|
+
_88 = assignCartesianData(categoriesFor(series), numericValues), x = _88.x, y = _88.y, orientation_2 = _88.orientation;
|
|
1714
1837
|
trace = tslib_1.__assign(tslib_1.__assign({ type: seriesPlotlyType, x: x, y: y, orientation: orientation_2, name: dataLabel, stackgroup: isStacked ? "one" : undefined }, seriesTraceStyle), lineTraceVariant(series, effectiveChartType, numericValues));
|
|
1715
1838
|
// Ties the trace back to spec.series for click selection
|
|
1716
1839
|
trace.meta = {
|
|
1717
1840
|
rncSeriesIndex: currentSeriesIndex,
|
|
1718
1841
|
};
|
|
1719
|
-
applyTraceColor(trace, (
|
|
1842
|
+
applyTraceColor(trace, (_71 = series.color) !== null && _71 !== void 0 ? _71 : undefined, {
|
|
1720
1843
|
noFill: series.noFill,
|
|
1721
1844
|
dataPointColors: series.dataPointColors,
|
|
1722
1845
|
invertIfNegative: series.invertIfNegative,
|
|
@@ -1733,24 +1856,24 @@ var BasicChart = function (_a) {
|
|
|
1733
1856
|
}
|
|
1734
1857
|
});
|
|
1735
1858
|
};
|
|
1736
|
-
|
|
1859
|
+
_82.label = 18;
|
|
1737
1860
|
case 18:
|
|
1738
|
-
|
|
1739
|
-
_j = tslib_1.__values((
|
|
1740
|
-
|
|
1861
|
+
_82.trys.push([18, 23, 24, 25]);
|
|
1862
|
+
_j = tslib_1.__values((_56 = spec.series) !== null && _56 !== void 0 ? _56 : []), _k = _j.next();
|
|
1863
|
+
_82.label = 19;
|
|
1741
1864
|
case 19:
|
|
1742
1865
|
if (!!_k.done) return [3 /*break*/, 22];
|
|
1743
1866
|
series = _k.value;
|
|
1744
1867
|
return [5 /*yield**/, _loop_2(series)];
|
|
1745
1868
|
case 20:
|
|
1746
|
-
|
|
1747
|
-
|
|
1869
|
+
_82.sent();
|
|
1870
|
+
_82.label = 21;
|
|
1748
1871
|
case 21:
|
|
1749
1872
|
_k = _j.next();
|
|
1750
1873
|
return [3 /*break*/, 19];
|
|
1751
1874
|
case 22: return [3 /*break*/, 25];
|
|
1752
1875
|
case 23:
|
|
1753
|
-
e_3_1 =
|
|
1876
|
+
e_3_1 = _82.sent();
|
|
1754
1877
|
e_3 = { error: e_3_1 };
|
|
1755
1878
|
return [3 /*break*/, 25];
|
|
1756
1879
|
case 24:
|
|
@@ -1767,13 +1890,13 @@ var BasicChart = function (_a) {
|
|
|
1767
1890
|
? undefined
|
|
1768
1891
|
: (0, axis_number_format_1.resolveValueAxisNumberFormat)({
|
|
1769
1892
|
axisOptions: spec.valueAxisOptions,
|
|
1770
|
-
series: ((
|
|
1893
|
+
series: ((_72 = spec.series) !== null && _72 !== void 0 ? _72 : []).filter(function (s) { return !s.useSecondaryAxis; }),
|
|
1771
1894
|
getFormattingFromRange: getFormattingFromRange,
|
|
1772
1895
|
hiddenDimensionStrategy: spec.hiddenDimensionStrategy,
|
|
1773
1896
|
});
|
|
1774
1897
|
secondaryAxisNumberFormat = (0, axis_number_format_1.resolveValueAxisNumberFormat)({
|
|
1775
1898
|
axisOptions: spec.secondaryValueAxisOptions,
|
|
1776
|
-
series: ((
|
|
1899
|
+
series: ((_73 = spec.series) !== null && _73 !== void 0 ? _73 : []).filter(function (s) { return s.useSecondaryAxis; }),
|
|
1777
1900
|
getFormattingFromRange: getFormattingFromRange,
|
|
1778
1901
|
hiddenDimensionStrategy: spec.hiddenDimensionStrategy,
|
|
1779
1902
|
});
|
|
@@ -1821,14 +1944,14 @@ var BasicChart = function (_a) {
|
|
|
1821
1944
|
? VALUE_AXIS_TITLE_STANDOFF
|
|
1822
1945
|
: legend_layout_1.BAND_GAP;
|
|
1823
1946
|
legendBand = (0, legend_layout_1.reservePlotlyLegendBand)({
|
|
1824
|
-
position: (
|
|
1947
|
+
position: (_74 = spec.legend) === null || _74 === void 0 ? void 0 : _74.position,
|
|
1825
1948
|
visible: showlegend !== false,
|
|
1826
1949
|
labels: (0, legend_layout_1.legendLabelsFrom)(undefined, traces.map(function (trace) { return trace === null || trace === void 0 ? void 0 : trace.name; })),
|
|
1827
|
-
legendFontSize: (
|
|
1950
|
+
legendFontSize: (_77 = (_76 = (_75 = spec.legend) === null || _75 === void 0 ? void 0 : _75.textFormat) === null || _76 === void 0 ? void 0 : _76.fontSize) !== null && _77 !== void 0 ? _77 : axisFontSize,
|
|
1828
1951
|
width: Math.max(0, (width !== null && width !== void 0 ? width : 0) - 2),
|
|
1829
1952
|
height: Math.max(0, (height !== null && height !== void 0 ? height : 0) - 2),
|
|
1830
1953
|
hasTitle: Boolean(title),
|
|
1831
|
-
titleFontSize: (
|
|
1954
|
+
titleFontSize: (_78 = authoredTitleFmt === null || authoredTitleFmt === void 0 ? void 0 : authoredTitleFmt.fontSize) !== null && _78 !== void 0 ? _78 : 16,
|
|
1832
1955
|
hasBottomAxisTitle: Boolean(spec.horizontalAxisTitle),
|
|
1833
1956
|
hasLeftAxisTitle: Boolean(spec.verticalAxisTitle),
|
|
1834
1957
|
leftAxisDepth: leftAxisDepth,
|
|
@@ -1840,7 +1963,7 @@ var BasicChart = function (_a) {
|
|
|
1840
1963
|
family: "Untitled Sans, apple-system, sans-serif",
|
|
1841
1964
|
size: 16,
|
|
1842
1965
|
color: textColor,
|
|
1843
|
-
}, authoredTitleFmt), x: 0.02, xanchor: "left" }, legendBand.title), showlegend: showlegend === undefined ? true : showlegend, legend: tslib_1.__assign(tslib_1.__assign({}, legendOverrides), ((
|
|
1966
|
+
}, authoredTitleFmt), x: 0.02, xanchor: "left" }, legendBand.title), showlegend: showlegend === undefined ? true : showlegend, legend: tslib_1.__assign(tslib_1.__assign({}, legendOverrides), ((_79 = legendBand.legend) !== null && _79 !== void 0 ? _79 : {})), margin: legendBand.margin, autosize: true }, ((spec.chartType === "bar" || spec.chartType === "column") &&
|
|
1844
1967
|
spec.stackedType
|
|
1845
1968
|
? tslib_1.__assign({ barmode: spec.stackedType === "STACKED" ||
|
|
1846
1969
|
spec.stackedType === "PERCENT_STACKED"
|
|
@@ -1853,7 +1976,7 @@ var BasicChart = function (_a) {
|
|
|
1853
1976
|
color: textColor,
|
|
1854
1977
|
}, paper_bgcolor: bgColor, plot_bgcolor: bgColor, xaxis: applyAxisOverridesPlotly({
|
|
1855
1978
|
title: {
|
|
1856
|
-
text: (
|
|
1979
|
+
text: (_80 = spec.horizontalAxisTitle) !== null && _80 !== void 0 ? _80 : "",
|
|
1857
1980
|
font: { color: textColor },
|
|
1858
1981
|
standoff: bottomAxisTitleStandoff,
|
|
1859
1982
|
},
|
|
@@ -1871,7 +1994,7 @@ var BasicChart = function (_a) {
|
|
|
1871
1994
|
isHorizontalBarChart
|
|
1872
1995
|
? spec.valueAxisOptions
|
|
1873
1996
|
: spec.categoryAxisOptions, isHorizontalBarChart ? primaryAxisNumberFormat : undefined), yaxis: applyAxisOverridesPlotly({
|
|
1874
|
-
title: tslib_1.__assign({ text: (
|
|
1997
|
+
title: tslib_1.__assign({ text: (_81 = spec.verticalAxisTitle) !== null && _81 !== void 0 ? _81 : "", font: { color: textColor } }, (isHorizontalBarChart
|
|
1875
1998
|
? {}
|
|
1876
1999
|
: { standoff: VALUE_AXIS_TITLE_STANDOFF })),
|
|
1877
2000
|
showgrid: !isHorizontalBarChart,
|
|
@@ -1907,6 +2030,21 @@ var BasicChart = function (_a) {
|
|
|
1907
2030
|
_r) : {})), (ofPieExtras
|
|
1908
2031
|
? tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ shapes: ofPieExtras.shapes }, (ofPieExtras.barmode ? { barmode: ofPieExtras.barmode } : {})), (ofPieExtras.xaxis2 ? { xaxis2: ofPieExtras.xaxis2 } : {})), (ofPieExtras.yaxis2 ? { yaxis2: ofPieExtras.yaxis2 } : {})) : {}));
|
|
1909
2032
|
dlOpts = spec.dataLabels;
|
|
2033
|
+
doughnutSeriesOrder = spec.chartType === "doughnut"
|
|
2034
|
+
? traces
|
|
2035
|
+
.filter(function (t) { return (t === null || t === void 0 ? void 0 : t.type) === "pie"; })
|
|
2036
|
+
.map(function (t) { var _a; return (_a = t === null || t === void 0 ? void 0 : t.meta) === null || _a === void 0 ? void 0 : _a.rncSeriesIndex; })
|
|
2037
|
+
.filter(function (i) { return typeof i === "number"; })
|
|
2038
|
+
.sort(function (a, b) { return a - b; })
|
|
2039
|
+
: [];
|
|
2040
|
+
doughnutRingSet = spec.chartType === "doughnut"
|
|
2041
|
+
? (0, doughnut_1.doughnutRings)((0, doughnut_1.clampDoughnutHole)(spec.doughnutHoleSize), doughnutSeriesOrder.length)
|
|
2042
|
+
: [];
|
|
2043
|
+
traceDataLabels = function (trace) {
|
|
2044
|
+
var _a, _b;
|
|
2045
|
+
var specIndex = (_a = trace === null || trace === void 0 ? void 0 : trace.meta) === null || _a === void 0 ? void 0 : _a.rncSeriesIndex;
|
|
2046
|
+
return (0, overrides_1.resolveSeriesDataLabels)(dlOpts, typeof specIndex === "number" ? (_b = spec.series) === null || _b === void 0 ? void 0 : _b[specIndex] : undefined);
|
|
2047
|
+
};
|
|
1910
2048
|
doughnutHole = spec.doughnutHoleSize;
|
|
1911
2049
|
seriesNumberFormats = (0, axis_number_format_1.resolveSeriesNumberFormats)(spec.series, getFormattingFromRange, spec.hiddenDimensionStrategy);
|
|
1912
2050
|
traceNumberFormat = function (trace) {
|
|
@@ -1920,10 +2058,20 @@ var BasicChart = function (_a) {
|
|
|
1920
2058
|
};
|
|
1921
2059
|
piePull = isOfPie ? undefined : (0, pie_explosion_1.explosionToPlotlyPull)((0, pie_explosion_1.resolveExplosion)(spec));
|
|
1922
2060
|
formattedTraces = traces.map(function (trace) {
|
|
1923
|
-
var _a;
|
|
2061
|
+
var _a, _b, _c, _d, _e;
|
|
1924
2062
|
var pattern = traceNumberFormat(trace);
|
|
1925
|
-
var next = applyDataLabelsToTracePlotly(trace,
|
|
2063
|
+
var next = applyDataLabelsToTracePlotly(trace, traceDataLabels(trace), spec.chartType, pattern, locale);
|
|
2064
|
+
if (next.type === "funnel") {
|
|
2065
|
+
// The formatted values ride on `text`; a funnel prints its own
|
|
2066
|
+
// `value` unless told to draw the text (or nothing).
|
|
2067
|
+
next = tslib_1.__assign(tslib_1.__assign({}, next), { textinfo: ((_a = traceDataLabels(trace)) === null || _a === void 0 ? void 0 : _a.show) ? "text" : "none" });
|
|
2068
|
+
}
|
|
1926
2069
|
if (next.type === "pie") {
|
|
2070
|
+
// Plotly's pie prints every slice's percentage by default; Excel
|
|
2071
|
+
// draws nothing until data labels are on (#1062).
|
|
2072
|
+
if (!((_b = traceDataLabels(trace)) === null || _b === void 0 ? void 0 : _b.show)) {
|
|
2073
|
+
next = tslib_1.__assign(tslib_1.__assign({}, next), { textinfo: "none" });
|
|
2074
|
+
}
|
|
1927
2075
|
// Hover values format like the slice's source cell.
|
|
1928
2076
|
if (pattern && !next.text) {
|
|
1929
2077
|
var values = Array.isArray(next.values) ? next.values : [];
|
|
@@ -1940,7 +2088,7 @@ var BasicChart = function (_a) {
|
|
|
1940
2088
|
}
|
|
1941
2089
|
else if (!next.hovertemplate &&
|
|
1942
2090
|
(next.type === "bar" || next.type === "scatter") &&
|
|
1943
|
-
typeof ((
|
|
2091
|
+
typeof ((_c = next.meta) === null || _c === void 0 ? void 0 : _c.rncSeriesIndex) === "number") {
|
|
1944
2092
|
// Hover values read like the series' own cells (Excel's data tip
|
|
1945
2093
|
// shows the cell text) — the series format alone, not the axis
|
|
1946
2094
|
// fallback the labels use, since that resolves to the first series
|
|
@@ -1962,9 +2110,14 @@ var BasicChart = function (_a) {
|
|
|
1962
2110
|
// (doughnutHoleSize); clamp like the echarts renderer and default
|
|
1963
2111
|
// to 0.5 when unset.
|
|
1964
2112
|
if (spec.chartType === "doughnut" && next.type === "pie") {
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
2113
|
+
var rank = doughnutSeriesOrder.indexOf((_d = next.meta) === null || _d === void 0 ? void 0 : _d.rncSeriesIndex);
|
|
2114
|
+
var ring = (_e = doughnutRingSet[rank]) !== null && _e !== void 0 ? _e : (0, doughnut_1.doughnutRings)((0, doughnut_1.clampDoughnutHole)(doughnutHole), 1)[0];
|
|
2115
|
+
// Plotly's `hole` is a fraction of the trace's own radius.
|
|
2116
|
+
next = tslib_1.__assign(tslib_1.__assign({}, next), { hole: ring.inner / ring.outer });
|
|
2117
|
+
if (doughnutRingSet.length > 1) {
|
|
2118
|
+
var half = ring.outer / 2;
|
|
2119
|
+
next = tslib_1.__assign(tslib_1.__assign({}, next), { domain: { x: [0.5 - half, 0.5 + half], y: [0.5 - half, 0.5 + half] } });
|
|
2120
|
+
}
|
|
1968
2121
|
}
|
|
1969
2122
|
return next;
|
|
1970
2123
|
});
|
|
@@ -2097,7 +2250,13 @@ var BasicChart = function (_a) {
|
|
|
2097
2250
|
} }, "Delete chart")))))) : null,
|
|
2098
2251
|
react_1.default.createElement("div", { className: "flex-1 rnc-plotly-chart-container", onPointerDownCapture: handlePointerDownCapture },
|
|
2099
2252
|
react_1.default.createElement(plot_1.Plot, { data: plotData, layout: plotLayout, config: config, onClick: handlePlotClick, onInitialized: function (_figure, graphDiv) {
|
|
2253
|
+
var _a, _b;
|
|
2100
2254
|
graphDivRef.current = graphDiv;
|
|
2255
|
+
var plotDiv = graphDiv;
|
|
2256
|
+
// Returning false from these handlers keeps the clicked branch
|
|
2257
|
+
// from becoming the new root.
|
|
2258
|
+
(_a = plotDiv.on) === null || _a === void 0 ? void 0 : _a.call(plotDiv, "plotly_treemapclick", function () { return drillDownRef.current; });
|
|
2259
|
+
(_b = plotDiv.on) === null || _b === void 0 ? void 0 : _b.call(plotDiv, "plotly_sunburstclick", function () { return drillDownRef.current; });
|
|
2101
2260
|
}, style: { width: "100%", height: "100%" } }))));
|
|
2102
2261
|
};
|
|
2103
2262
|
exports.BasicChart = BasicChart;
|