@rowsncolumns/charts 28.1.8 → 28.1.11

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.
Files changed (47) hide show
  1. package/dist/cjs/basic-chart/basic-chart.d.ts.map +1 -1
  2. package/dist/cjs/basic-chart/basic-chart.js +538 -430
  3. package/dist/cjs/basic-chart/helpers.d.ts.map +1 -1
  4. package/dist/cjs/basic-chart/helpers.js +2 -0
  5. package/dist/cjs/plotly/basic-chart/basic-chart.d.ts.map +1 -1
  6. package/dist/cjs/plotly/basic-chart/basic-chart.js +333 -184
  7. package/dist/cjs/plotly/basic-chart/helpers.d.ts.map +1 -1
  8. package/dist/cjs/plotly/basic-chart/helpers.js +2 -0
  9. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  10. package/dist/cjs/utils/bubble.d.ts +34 -1
  11. package/dist/cjs/utils/bubble.d.ts.map +1 -1
  12. package/dist/cjs/utils/bubble.js +39 -13
  13. package/dist/cjs/utils/echarts-overlays.d.ts +46 -0
  14. package/dist/cjs/utils/echarts-overlays.d.ts.map +1 -0
  15. package/dist/cjs/utils/echarts-overlays.js +134 -0
  16. package/dist/cjs/utils/hierarchy.d.ts +23 -1
  17. package/dist/cjs/utils/hierarchy.d.ts.map +1 -1
  18. package/dist/cjs/utils/hierarchy.js +179 -55
  19. package/dist/cjs/utils/overrides.d.ts.map +1 -1
  20. package/dist/cjs/utils/overrides.js +15 -3
  21. package/dist/cjs/utils/trendline.d.ts +7 -1
  22. package/dist/cjs/utils/trendline.d.ts.map +1 -1
  23. package/dist/cjs/utils/trendline.js +82 -18
  24. package/dist/esm/basic-chart/basic-chart.d.ts.map +1 -1
  25. package/dist/esm/basic-chart/basic-chart.js +381 -251
  26. package/dist/esm/basic-chart/helpers.d.ts.map +1 -1
  27. package/dist/esm/basic-chart/helpers.js +2 -0
  28. package/dist/esm/plotly/basic-chart/basic-chart.d.ts.map +1 -1
  29. package/dist/esm/plotly/basic-chart/basic-chart.js +253 -58
  30. package/dist/esm/plotly/basic-chart/helpers.d.ts.map +1 -1
  31. package/dist/esm/plotly/basic-chart/helpers.js +2 -0
  32. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  33. package/dist/esm/utils/bubble.d.ts +34 -1
  34. package/dist/esm/utils/bubble.d.ts.map +1 -1
  35. package/dist/esm/utils/bubble.js +35 -11
  36. package/dist/esm/utils/echarts-overlays.d.ts +46 -0
  37. package/dist/esm/utils/echarts-overlays.d.ts.map +1 -0
  38. package/dist/esm/utils/echarts-overlays.js +135 -0
  39. package/dist/esm/utils/hierarchy.d.ts +23 -1
  40. package/dist/esm/utils/hierarchy.d.ts.map +1 -1
  41. package/dist/esm/utils/hierarchy.js +168 -50
  42. package/dist/esm/utils/overrides.d.ts.map +1 -1
  43. package/dist/esm/utils/overrides.js +15 -3
  44. package/dist/esm/utils/trendline.d.ts +7 -1
  45. package/dist/esm/utils/trendline.d.ts.map +1 -1
  46. package/dist/esm/utils/trendline.js +67 -14
  47. package/package.json +3 -3
@@ -354,6 +354,15 @@ var sanitizeChartValue = function (value) {
354
354
  * (Excel): every range's points in sequence. A single range passes through
355
355
  * untouched so the common path renders exactly as before.
356
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
+ };
357
366
  var mergeSeriesData = function (parts) {
358
367
  var e_1, _a;
359
368
  if (parts.length === 1)
@@ -417,6 +426,11 @@ var BasicChart = function (_a) {
417
426
  // The plotted `<div>` plotly hands back on init — what `Plotly.toImage`
418
427
  // rasterises for Copy as Picture and the print preview.
419
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);
420
434
  var focusSheet = (0, spreadsheet_1.useFocusSheet)();
421
435
  // Excel selects a data series (or one data point) when it is clicked
422
436
  // inside the chart and the grid highlights its source cells. The plot
@@ -493,11 +507,11 @@ var BasicChart = function (_a) {
493
507
  * Triggers a chart update
494
508
  */
495
509
  var updateChart = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
496
- 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, hierarchyData, seriesName, 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;
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;
497
511
  var e_2, _m, e_4, _o, e_3, _p, _q, _r;
498
- 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;
499
- return tslib_1.__generator(this, function (_77) {
500
- switch (_77.label) {
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) {
501
515
  case 0:
502
516
  (0, utils_1.debug)("Updating chart", chart);
503
517
  traces = [];
@@ -522,7 +536,7 @@ var BasicChart = function (_a) {
522
536
  });
523
537
  seriesInputs = [];
524
538
  i = 0;
525
- _77.label = 1;
539
+ _82.label = 1;
526
540
  case 1:
527
541
  if (!(i < spec.series.length)) return [3 /*break*/, 5];
528
542
  seriesEntry = spec.series[i];
@@ -531,13 +545,13 @@ var BasicChart = function (_a) {
531
545
  _a = chart_spec_utils_1.coerceCalculatedLabel;
532
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)];
533
547
  case 2:
534
- resolvedLabel = _a.apply(void 0, [_77.sent()]);
535
- _77.label = 3;
548
+ resolvedLabel = _a.apply(void 0, [_82.sent()]);
549
+ _82.label = 3;
536
550
  case 3:
537
551
  xValues = (_x = perSeriesX[i]) !== null && _x !== void 0 ? _x : perSeriesX[0];
538
552
  sizeValues_1 = (_y = perSeriesSize[i]) !== null && _y !== void 0 ? _y : perSeriesSize[0];
539
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 } : {})));
540
- _77.label = 4;
554
+ _82.label = 4;
541
555
  case 4:
542
556
  i++;
543
557
  return [3 /*break*/, 1];
@@ -550,8 +564,13 @@ var BasicChart = function (_a) {
550
564
  sizeValues: sharedSizeValues,
551
565
  series: seriesInputs,
552
566
  }), categories_1 = _b.categories, preparedSeries = _b.series, sizeValues = _b.sizeValues;
553
- 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
+ });
554
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; });
555
574
  palette_1 = (0, chart_styles_1.getChartPalette)(spec, [
556
575
  theme.themeColors.accent1,
557
576
  theme.themeColors.accent2,
@@ -561,7 +580,7 @@ var BasicChart = function (_a) {
561
580
  theme.themeColors.accent6,
562
581
  ]);
563
582
  isScatter_1 = spec.chartType === "scatter";
564
- scatterStyle_1 = (_1 = spec.scatterStyle) !== null && _1 !== void 0 ? _1 : (isScatter_1 ? "lineMarker" : undefined);
583
+ scatterStyle_1 = (_2 = spec.scatterStyle) !== null && _2 !== void 0 ? _2 : (isScatter_1 ? "lineMarker" : undefined);
565
584
  plotlyModeForScatterStyle_1 = function (style) {
566
585
  switch (style) {
567
586
  case "line":
@@ -582,8 +601,10 @@ var BasicChart = function (_a) {
582
601
  ? "spline"
583
602
  : "linear";
584
603
  };
585
- traces_1 = preparedSeries.map(function (entry, index) {
586
- var _a, _b, _c, _d, _e, _f;
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;
587
608
  var xValues = entry.points.map(function (point) {
588
609
  var _a, _b;
589
610
  return hasStringX_1
@@ -591,9 +612,57 @@ var BasicChart = function (_a) {
591
612
  : point.value[0];
592
613
  });
593
614
  var yValues = entry.points.map(function (point) { return point.value[1]; });
594
- var labelValuesForSeries = entry.points.map(function (point) { return point.name; });
595
- var seriesColor = (_b = (_a = spec.series[index]) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : (0, utils_1.chartPaletteColorAt)(palette_1, index);
596
- var perSeriesMarker = (_d = (_c = spec.series[index]) === null || _c === void 0 ? void 0 : _c.marker) !== null && _d !== void 0 ? _d : undefined;
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
+ };
597
666
  if (isScatter_1) {
598
667
  // Per-series marker.symbol = "none" → pure line (no markers).
599
668
  // Per-series marker.size overrides the default. Falls back to
@@ -603,9 +672,9 @@ var BasicChart = function (_a) {
603
672
  var mode = noMarkers
604
673
  ? "lines"
605
674
  : plotlyModeForScatterStyle_1(scatterStyle_1);
606
- var markerSize = (_e = perSeriesMarker === null || perSeriesMarker === void 0 ? void 0 : perSeriesMarker.size) !== null && _e !== void 0 ? _e : 6;
607
- var markerColor = (_f = perSeriesMarker === null || perSeriesMarker === void 0 ? void 0 : perSeriesMarker.color) !== null && _f !== void 0 ? _f : seriesColor;
608
- return tslib_1.__assign({ type: "scatter", mode: mode, x: xValues, y: yValues, text: labelValuesForSeries, name: entry.name, hovertemplate: "%{text}<br>X: %{x}<br>Y: %{y}<extra></extra>", line: {
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: {
609
678
  shape: lineShapeFor_1(scatterStyle_1),
610
679
  color: seriesColor,
611
680
  width: 2,
@@ -614,71 +683,114 @@ var BasicChart = function (_a) {
614
683
  : {
615
684
  marker: {
616
685
  size: markerSize,
617
- color: markerColor,
686
+ color: pointColors(markerColor),
618
687
  symbol: (0, helpers_1.mapMarkerSymbolToPlotly)(symbol),
619
688
  },
620
- }));
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
+ }
621
747
  }
622
- // Bubble — third dimension scaled into marker diameter.
623
- var rawSizes = entry.points.map(function (point) { return point.value[2]; });
624
- var scaledSizes = rawSizes.map(function (value) { return sizeScale_1(value); });
625
- return {
626
- type: "scatter",
627
- mode: "markers",
628
- x: xValues,
629
- y: yValues,
630
- text: labelValuesForSeries,
631
- customdata: rawSizes,
632
- name: entry.name,
633
- hovertemplate: "%{text}<br>X: %{x}<br>Y: %{y}<br>Size: %{customdata}<extra></extra>",
634
- marker: {
635
- size: scaledSizes,
636
- sizemode: "diameter",
637
- color: seriesColor,
638
- opacity: 0.7,
639
- },
640
- };
641
748
  });
642
749
  titleFmt = spec.titleTextFormat;
643
- xAxisFmt = (_2 = spec.categoryAxisOptions) === null || _2 === void 0 ? void 0 : _2.textFormat;
644
- yAxisFmt = (_3 = spec.valueAxisOptions) === null || _3 === void 0 ? void 0 : _3.textFormat;
645
- legendFmt = (_4 = spec.legend) === null || _4 === void 0 ? void 0 : _4.textFormat;
646
- bubbleLayout = {
647
- 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: {
648
754
  text: (0, plotly_title_1.plotlyTitleText)(title, spec.titleTextFormat),
649
755
  font: {
650
- family: (_5 = titleFmt === null || titleFmt === void 0 ? void 0 : titleFmt.fontFamily) !== null && _5 !== void 0 ? _5 : "Untitled Sans, apple-system, sans-serif",
651
- size: (_6 = titleFmt === null || titleFmt === void 0 ? void 0 : titleFmt.fontSize) !== null && _6 !== void 0 ? _6 : 16,
652
- color: (_7 = titleFmt === null || titleFmt === void 0 ? void 0 : titleFmt.color) !== null && _7 !== void 0 ? _7 : textColor,
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,
653
759
  },
654
760
  x: 0.02,
655
761
  xanchor: "left",
656
- },
657
- xaxis: {
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({
658
767
  title: {
659
- text: (_8 = spec.horizontalAxisTitle) !== null && _8 !== void 0 ? _8 : "",
660
- font: { color: (_9 = xAxisFmt === null || xAxisFmt === void 0 ? void 0 : xAxisFmt.color) !== null && _9 !== void 0 ? _9 : textColor },
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 },
661
770
  },
662
771
  gridcolor: gridColor,
663
- tickfont: tslib_1.__assign(tslib_1.__assign({ color: (_10 = xAxisFmt === null || xAxisFmt === void 0 ? void 0 : xAxisFmt.color) !== null && _10 !== void 0 ? _10 : 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 } : {})),
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 } : {})),
664
773
  type: hasStringX_1 ? "category" : "linear",
665
- },
666
- yaxis: {
774
+ }, spec.categoryAxisOptions), yaxis: applyAxisOverridesPlotly({
667
775
  title: {
668
- text: (_11 = spec.verticalAxisTitle) !== null && _11 !== void 0 ? _11 : "",
669
- font: { color: (_12 = yAxisFmt === null || yAxisFmt === void 0 ? void 0 : yAxisFmt.color) !== null && _12 !== void 0 ? _12 : textColor },
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 },
670
778
  },
671
779
  gridcolor: gridColor,
672
- tickfont: tslib_1.__assign(tslib_1.__assign({ color: (_13 = yAxisFmt === null || yAxisFmt === void 0 ? void 0 : yAxisFmt.color) !== null && _13 !== void 0 ? _13 : 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 } : {})),
673
- },
674
- legend: {
675
- font: tslib_1.__assign(tslib_1.__assign({ color: (_14 = legendFmt === null || legendFmt === void 0 ? void 0 : legendFmt.color) !== null && _14 !== void 0 ? _14 : 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 } : {})),
676
- },
677
- paper_bgcolor: bgColor,
678
- plot_bgcolor: bgColor,
679
- showlegend: preparedSeries.length > 1,
680
- margin: { l: 60, r: 20, t: 50, b: 50 },
681
- };
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 } });
682
794
  setPlotData(traces_1);
683
795
  setLayout(bubbleLayout);
684
796
  return [2 /*return*/];
@@ -695,19 +807,42 @@ var BasicChart = function (_a) {
695
807
  hiddenDimensionStrategy: spec.hiddenDimensionStrategy,
696
808
  });
697
809
  hierarchyTitleRef.current = explicitChartTitle !== null && explicitChartTitle !== void 0 ? explicitChartTitle : headerTitle;
698
- hierarchyData = (0, hierarchy_1.toPlotlyHierarchy)(hierarchyRows);
699
- seriesName = hierarchyData.labels.length === 1
700
- ? (_15 = hierarchyData.labels[0]) !== null && _15 !== void 0 ? _15 : ""
701
- : (_16 = explicitChartTitle !== null && explicitChartTitle !== void 0 ? explicitChartTitle : headerTitle) !== null && _16 !== void 0 ? _16 : "";
702
- hierarchyTrace = {
703
- type: chartType,
704
- labels: hierarchyData.labels,
705
- parents: hierarchyData.parents,
706
- values: hierarchyData.values,
707
- name: seriesName,
708
- textinfo: "label+value",
709
- branchvalues: "total",
710
- };
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
828
+ ? {}
829
+ : {
830
+ textposition: "bottom left",
831
+ // Excel labels a treemap's top-level categories (in a header
832
+ // strip, or not at all with parentLabelLayout "none") and its
833
+ // leaves; the levels in between are never labelled (#1072).
834
+ text: hierarchyData_1.labels.map(function () { return ""; }),
835
+ texttemplate: hierarchyData_1.ids.map(function (id, i) {
836
+ var isLeaf = !hierarchyData_1.parents.includes(id);
837
+ if (isLeaf)
838
+ return "%{label}<br>%{value}";
839
+ var isTopLevel = hierarchyData_1.depths[i] === 0;
840
+ return isTopLevel &&
841
+ spec.parentLabelLayout !== "none"
842
+ ? "%{label}"
843
+ : "%{text}";
844
+ }),
845
+ }));
711
846
  layoutForHierarchy = {
712
847
  title: {
713
848
  text: (0, plotly_title_1.plotlyTitleText)(title, spec.titleTextFormat),
@@ -747,7 +882,7 @@ var BasicChart = function (_a) {
747
882
  // country-name matching and silently skips labels it can't place.
748
883
  if ((0, region_map_1.isRegionMapSpec)(spec)) {
749
884
  labels = flattenChartDataValues(spec.domains, getDomainValuesFromRange, spec.hiddenDimensionStrategy, false).map(function (v) { return String(v !== null && v !== void 0 ? v : "").trim(); });
750
- seriesEntry = (_17 = spec.series) === null || _17 === void 0 ? void 0 : _17[0];
885
+ seriesEntry = (_19 = spec.series) === null || _19 === void 0 ? void 0 : _19[0];
751
886
  rawValues_1 = seriesEntry
752
887
  ? flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); })
753
888
  : [];
@@ -812,34 +947,34 @@ var BasicChart = function (_a) {
812
947
  if (!(surfaceToken === "SURFACE" || surfaceToken === "SURFACE_3D")) return [3 /*break*/, 17];
813
948
  categories = flattenChartDataValues(spec.domains, getDomainValuesFromRange, spec.hiddenDimensionStrategy, false).map(function (v) { return String(v !== null && v !== void 0 ? v : ""); });
814
949
  surfaceSeriesInputs = [];
815
- _77.label = 7;
950
+ _82.label = 7;
816
951
  case 7:
817
- _77.trys.push([7, 14, 15, 16]);
818
- _c = tslib_1.__values((_18 = spec.series) !== null && _18 !== void 0 ? _18 : []), _d = _c.next();
819
- _77.label = 8;
952
+ _82.trys.push([7, 14, 15, 16]);
953
+ _c = tslib_1.__values((_20 = spec.series) !== null && _20 !== void 0 ? _20 : []), _d = _c.next();
954
+ _82.label = 8;
820
955
  case 8:
821
956
  if (!!_d.done) return [3 /*break*/, 13];
822
957
  seriesEntry = _d.value;
823
958
  if (!(!(0, utils_1.isNil)(seriesEntry.dataLabel) && (0, utils_1.isAFormula)(seriesEntry.dataLabel))) return [3 /*break*/, 10];
824
959
  _f = chart_spec_utils_1.coerceCalculatedLabel;
825
- return [4 /*yield*/, onRequestCalculate(seriesEntry.dataLabel, (_19 = position.sheetId) !== null && _19 !== void 0 ? _19 : sheetId, position.overlayPosition.anchorCell.rowIndex, position.overlayPosition.anchorCell.columnIndex)];
960
+ return [4 /*yield*/, onRequestCalculate(seriesEntry.dataLabel, (_21 = position.sheetId) !== null && _21 !== void 0 ? _21 : sheetId, position.overlayPosition.anchorCell.rowIndex, position.overlayPosition.anchorCell.columnIndex)];
826
961
  case 9:
827
- _e = _f.apply(void 0, [_77.sent()]);
962
+ _e = _f.apply(void 0, [_82.sent()]);
828
963
  return [3 /*break*/, 11];
829
964
  case 10:
830
- _e = (_20 = seriesEntry.dataLabel) !== null && _20 !== void 0 ? _20 : "";
831
- _77.label = 11;
965
+ _e = (_22 = seriesEntry.dataLabel) !== null && _22 !== void 0 ? _22 : "";
966
+ _82.label = 11;
832
967
  case 11:
833
968
  dataLabel = _e;
834
969
  values = flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); });
835
970
  surfaceSeriesInputs.push({ name: dataLabel, values: values });
836
- _77.label = 12;
971
+ _82.label = 12;
837
972
  case 12:
838
973
  _d = _c.next();
839
974
  return [3 /*break*/, 8];
840
975
  case 13: return [3 /*break*/, 16];
841
976
  case 14:
842
- e_2_1 = _77.sent();
977
+ e_2_1 = _82.sent();
843
978
  e_2 = { error: e_2_1 };
844
979
  return [3 /*break*/, 16];
845
980
  case 15:
@@ -867,21 +1002,21 @@ var BasicChart = function (_a) {
867
1002
  }, paper_bgcolor: bgColor, plot_bgcolor: bgColor, showlegend: false, margin: { l: 60, r: 20, t: 50, b: 50 } }, (surfaceToken === "SURFACE"
868
1003
  ? {
869
1004
  xaxis: {
870
- title: { text: (_21 = spec.horizontalAxisTitle) !== null && _21 !== void 0 ? _21 : "" },
1005
+ title: { text: (_23 = spec.horizontalAxisTitle) !== null && _23 !== void 0 ? _23 : "" },
871
1006
  automargin: true,
872
1007
  color: textColor,
873
1008
  },
874
1009
  yaxis: {
875
- title: { text: (_22 = spec.verticalAxisTitle) !== null && _22 !== void 0 ? _22 : "" },
1010
+ title: { text: (_24 = spec.verticalAxisTitle) !== null && _24 !== void 0 ? _24 : "" },
876
1011
  automargin: true,
877
1012
  color: textColor,
878
1013
  },
879
1014
  }
880
1015
  : {
881
1016
  scene: {
882
- xaxis: { title: { text: (_23 = spec.horizontalAxisTitle) !== null && _23 !== void 0 ? _23 : "" } },
1017
+ xaxis: { title: { text: (_25 = spec.horizontalAxisTitle) !== null && _25 !== void 0 ? _25 : "" } },
883
1018
  yaxis: { title: { text: "" } },
884
- zaxis: { title: { text: (_24 = spec.verticalAxisTitle) !== null && _24 !== void 0 ? _24 : "" } },
1019
+ zaxis: { title: { text: (_26 = spec.verticalAxisTitle) !== null && _26 !== void 0 ? _26 : "" } },
885
1020
  },
886
1021
  }));
887
1022
  setPlotData([surfaceTrace]);
@@ -893,11 +1028,11 @@ var BasicChart = function (_a) {
893
1028
  // theta = the category names (closed by appending the first point).
894
1029
  if (spec.chartType === "radar") {
895
1030
  categories = flattenChartDataValues(spec.domains, getDomainValuesFromRange, spec.hiddenDimensionStrategy, false).map(function (v) { return String(v !== null && v !== void 0 ? v : ""); });
896
- radarStyle = (_25 = spec.radarStyle) !== null && _25 !== void 0 ? _25 : "standard";
1031
+ radarStyle = (_27 = spec.radarStyle) !== null && _27 !== void 0 ? _27 : "standard";
897
1032
  radarTraces = [];
898
1033
  radarInputs = [];
899
1034
  try {
900
- for (_g = tslib_1.__values((_26 = spec.series) !== null && _26 !== void 0 ? _26 : []), _h = _g.next(); !_h.done; _h = _g.next()) {
1035
+ for (_g = tslib_1.__values((_28 = spec.series) !== null && _28 !== void 0 ? _28 : []), _h = _g.next(); !_h.done; _h = _g.next()) {
901
1036
  seriesEntry = _h.value;
902
1037
  label = seriesEntry.dataLabel && !(0, utils_1.isAFormula)(seriesEntry.dataLabel)
903
1038
  ? seriesEntry.dataLabel
@@ -917,7 +1052,7 @@ var BasicChart = function (_a) {
917
1052
  indicators = (0, radar_1.buildRadarIndicators)(categories, radarInputs, radarAxisOptions);
918
1053
  _loop_1 = function (i) {
919
1054
  var input = radarInputs[i];
920
- var seriesColor = (_29 = (_28 = (_27 = spec.series) === null || _27 === void 0 ? void 0 : _27[i]) === null || _28 === void 0 ? void 0 : _28.color) !== null && _29 !== void 0 ? _29 : undefined;
1055
+ 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;
921
1056
  var r = indicators.map(function (_, idx) { var _a; return (_a = input.values[idx]) !== null && _a !== void 0 ? _a : 0; });
922
1057
  var theta = indicators.map(function (ind) { return ind.name; });
923
1058
  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 } } : {})));
@@ -925,7 +1060,7 @@ var BasicChart = function (_a) {
925
1060
  for (i = 0; i < radarInputs.length; i++) {
926
1061
  _loop_1(i);
927
1062
  }
928
- radarScale = (_30 = indicators[0]) !== null && _30 !== void 0 ? _30 : { min: 0, max: 1 };
1063
+ radarScale = (_32 = indicators[0]) !== null && _32 !== void 0 ? _32 : { min: 0, max: 1 };
929
1064
  setPlotData(radarTraces);
930
1065
  setLayout({
931
1066
  title: { text: (0, plotly_title_1.plotlyTitleText)(title, spec.titleTextFormat) },
@@ -949,13 +1084,13 @@ var BasicChart = function (_a) {
949
1084
  // V-variants additionally get a volume column sub-pane below the
950
1085
  // price plot.
951
1086
  if (spec.chartType === "stock") {
952
- variant = ((_31 = spec.stockVariant) !== null && _31 !== void 0 ? _31 : "HLC");
1087
+ variant = ((_33 = spec.stockVariant) !== null && _33 !== void 0 ? _33 : "HLC");
953
1088
  categories = flattenChartDataValues(spec.domains, getDomainValuesFromRange, spec.hiddenDimensionStrategy, false).map(function (v) { return String(v !== null && v !== void 0 ? v : ""); });
954
- seriesValues = ((_32 = spec.series) !== null && _32 !== void 0 ? _32 : []).map(function (seriesEntry) {
1089
+ seriesValues = ((_34 = spec.series) !== null && _34 !== void 0 ? _34 : []).map(function (seriesEntry) {
955
1090
  return flattenChartDataValues([seriesEntry], getSeriesValuesFromRange, spec.hiddenDimensionStrategy).map(function (v) { return (typeof v === "number" ? v : Number(v)); });
956
1091
  });
957
1092
  volumePoints_1 = (0, stock_1.toVolumeSeries)(seriesValues, variant);
958
- hasVolume = ((_33 = volumePoints_1 === null || volumePoints_1 === void 0 ? void 0 : volumePoints_1.length) !== null && _33 !== void 0 ? _33 : 0) > 0;
1093
+ hasVolume = ((_35 = volumePoints_1 === null || volumePoints_1 === void 0 ? void 0 : volumePoints_1.length) !== null && _35 !== void 0 ? _35 : 0) > 0;
959
1094
  buildVolumeTrace = function (xs) {
960
1095
  return ({
961
1096
  type: "bar",
@@ -988,25 +1123,25 @@ var BasicChart = function (_a) {
988
1123
  roles = (0, stock_1.assignStockRoles)(seriesValues, variant);
989
1124
  xs_1 = categories.length > 0
990
1125
  ? categories
991
- : ((_34 = roles.close) !== null && _34 !== void 0 ? _34 : []).map(function (_, i) { return i + 1; });
1126
+ : ((_36 = roles.close) !== null && _36 !== void 0 ? _36 : []).map(function (_, i) { return i + 1; });
992
1127
  candleTrace = {
993
1128
  type: "candlestick",
994
1129
  x: xs_1,
995
- open: ((_35 = roles.open) !== null && _35 !== void 0 ? _35 : []).map(function (v) { return v !== null && v !== void 0 ? v : null; }),
996
- high: ((_36 = roles.high) !== null && _36 !== void 0 ? _36 : []).map(function (v) { return v !== null && v !== void 0 ? v : null; }),
997
- low: ((_37 = roles.low) !== null && _37 !== void 0 ? _37 : []).map(function (v) { return v !== null && v !== void 0 ? v : null; }),
998
- close: ((_38 = roles.close) !== null && _38 !== void 0 ? _38 : []).map(function (v) { return v !== null && v !== void 0 ? v : null; }),
1130
+ open: ((_37 = roles.open) !== null && _37 !== void 0 ? _37 : []).map(function (v) { return v !== null && v !== void 0 ? v : null; }),
1131
+ high: ((_38 = roles.high) !== null && _38 !== void 0 ? _38 : []).map(function (v) { return v !== null && v !== void 0 ? v : null; }),
1132
+ low: ((_39 = roles.low) !== null && _39 !== void 0 ? _39 : []).map(function (v) { return v !== null && v !== void 0 ? v : null; }),
1133
+ close: ((_40 = roles.close) !== null && _40 !== void 0 ? _40 : []).map(function (v) { return v !== null && v !== void 0 ? v : null; }),
999
1134
  increasing: { line: { color: theme.themeColors.accent1 } },
1000
1135
  decreasing: { line: { color: theme.themeColors.accent2 } },
1001
1136
  };
1002
1137
  setPlotData(hasVolume ? [candleTrace, buildVolumeTrace(xs_1)] : [candleTrace]);
1003
1138
  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: {
1004
- title: { text: (_39 = spec.horizontalAxisTitle) !== null && _39 !== void 0 ? _39 : "" },
1139
+ title: { text: (_41 = spec.horizontalAxisTitle) !== null && _41 !== void 0 ? _41 : "" },
1005
1140
  automargin: true,
1006
1141
  showgrid: true,
1007
1142
  gridcolor: gridColor,
1008
1143
  rangeslider: { visible: false },
1009
- }, yaxis: tslib_1.__assign({ title: { text: (_40 = spec.verticalAxisTitle) !== null && _40 !== void 0 ? _40 : "" }, automargin: true, showgrid: true, gridcolor: gridColor }, priceYAxisDomain) }, volumeLayout), { margin: { l: 50, r: 50, t: 50, b: 50 }, autosize: true }));
1144
+ }, 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 }));
1010
1145
  return [2 /*return*/];
1011
1146
  }
1012
1147
  lineSeries = (0, stock_1.toLineSeries)(seriesValues, variant);
@@ -1018,7 +1153,7 @@ var BasicChart = function (_a) {
1018
1153
  ]);
1019
1154
  xs_2 = categories.length > 0
1020
1155
  ? categories
1021
- : ((_42 = (_41 = lineSeries[0]) === null || _41 === void 0 ? void 0 : _41.values) !== null && _42 !== void 0 ? _42 : []).map(function (_, i) { return i + 1; });
1156
+ : ((_44 = (_43 = lineSeries[0]) === null || _43 === void 0 ? void 0 : _43.values) !== null && _44 !== void 0 ? _44 : []).map(function (_, i) { return i + 1; });
1022
1157
  stockTraces = lineSeries.map(function (s, i) { return ({
1023
1158
  type: "scatter",
1024
1159
  mode: "lines",
@@ -1029,11 +1164,11 @@ var BasicChart = function (_a) {
1029
1164
  }); });
1030
1165
  setPlotData(hasVolume ? tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(stockTraces), false), [buildVolumeTrace(xs_2)], false) : stockTraces);
1031
1166
  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: {
1032
- title: { text: (_43 = spec.horizontalAxisTitle) !== null && _43 !== void 0 ? _43 : "" },
1167
+ title: { text: (_45 = spec.horizontalAxisTitle) !== null && _45 !== void 0 ? _45 : "" },
1033
1168
  automargin: true,
1034
1169
  showgrid: true,
1035
1170
  gridcolor: gridColor,
1036
- }, yaxis: tslib_1.__assign({ title: { text: (_44 = spec.verticalAxisTitle) !== null && _44 !== void 0 ? _44 : "" }, automargin: true, showgrid: true, gridcolor: gridColor }, priceYAxisDomain) }, volumeLayout), { margin: { l: 50, r: 50, t: 50, b: 50 }, autosize: true }));
1171
+ }, 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 }));
1037
1172
  return [2 /*return*/];
1038
1173
  }
1039
1174
  isStacked = spec.stackedType && spec.stackedType !== "UNSTACKED";
@@ -1080,12 +1215,12 @@ var BasicChart = function (_a) {
1080
1215
  return extra;
1081
1216
  };
1082
1217
  shouldAggregate = (0, aggregation_1.shouldAggregateSeries)(spec.series);
1083
- primaryDomainSource = (_47 = (_46 = (_45 = spec === null || spec === void 0 ? void 0 : spec.domains) === null || _45 === void 0 ? void 0 : _45[0]) === null || _46 === void 0 ? void 0 : _46.sources) === null || _47 === void 0 ? void 0 : _47[0];
1218
+ 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];
1084
1219
  rawPrimaryDomainValues = primaryDomainSource
1085
- ? (0, aggregation_1.sanitizeDomainValues)((_48 = getDomainValuesFromRange(primaryDomainSource, spec.hiddenDimensionStrategy)) !== null && _48 !== void 0 ? _48 : [])
1220
+ ? (0, aggregation_1.sanitizeDomainValues)((_50 = getDomainValuesFromRange(primaryDomainSource, spec.hiddenDimensionStrategy)) !== null && _50 !== void 0 ? _50 : [])
1086
1221
  : [];
1087
1222
  domainData = (0, aggregation_1.getDomainValuesForAxis)(rawPrimaryDomainValues, shouldAggregate);
1088
- categoryLevels = (0, category_levels_1.resolveCategoryLevels)((_49 = spec.categoryLevels) === null || _49 === void 0 ? void 0 : _49.map(function (level) {
1223
+ categoryLevels = (0, category_levels_1.resolveCategoryLevels)((_51 = spec.categoryLevels) === null || _51 === void 0 ? void 0 : _51.map(function (level) {
1089
1224
  return flattenChartDataValues([level], getDomainValuesFromRange, spec.hiddenDimensionStrategy, false);
1090
1225
  }));
1091
1226
  multicategoryX = categoryLevels
@@ -1095,7 +1230,7 @@ var BasicChart = function (_a) {
1095
1230
  domainData = categoryLevels.leaf;
1096
1231
  }
1097
1232
  aggregateDomainValues = domainData;
1098
- domainAxisData = (categoryLevels ? [] : (_50 = spec.domains) !== null && _50 !== void 0 ? _50 : []).map(function (domain, domainIndex) {
1233
+ domainAxisData = (categoryLevels ? [] : (_52 = spec.domains) !== null && _52 !== void 0 ? _52 : []).map(function (domain, domainIndex) {
1099
1234
  return domain.sources.flatMap(function (sheetRange, sourceIndex) {
1100
1235
  var _a;
1101
1236
  if (domainIndex === 0 && sourceIndex === 0) {
@@ -1139,7 +1274,7 @@ var BasicChart = function (_a) {
1139
1274
  theme.themeColors.accent6,
1140
1275
  ]);
1141
1276
  applyTraceColor = function (trace, seriesColor, options) {
1142
- var e_5, _a;
1277
+ var e_7, _a;
1143
1278
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
1144
1279
  var target = trace;
1145
1280
  var chartTypeForStyling = (_b = options === null || options === void 0 ? void 0 : options.effectiveChartType) !== null && _b !== void 0 ? _b : spec.chartType;
@@ -1161,7 +1296,8 @@ var BasicChart = function (_a) {
1161
1296
  // by category index, falling back to the series color for points
1162
1297
  // without an override.
1163
1298
  var isPie = chartTypeForStyling === "pie";
1164
- if ((isBarOrColumn || isPie) &&
1299
+ var isFunnel = chartTypeForStyling === "funnel";
1300
+ if ((isBarOrColumn || isPie || isFunnel) &&
1165
1301
  Array.isArray(options === null || options === void 0 ? void 0 : options.dataPointColors) &&
1166
1302
  (options === null || options === void 0 ? void 0 : options.dataPointColors.length)) {
1167
1303
  var overrides_2 = new Map();
@@ -1173,12 +1309,12 @@ var BasicChart = function (_a) {
1173
1309
  }
1174
1310
  }
1175
1311
  }
1176
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1312
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
1177
1313
  finally {
1178
1314
  try {
1179
1315
  if (_v && !_v.done && (_a = _u.return)) _a.call(_u);
1180
1316
  }
1181
- finally { if (e_5) throw e_5.error; }
1317
+ finally { if (e_7) throw e_7.error; }
1182
1318
  }
1183
1319
  if (isPie) {
1184
1320
  // Per-slice colours (`<c:dPt>`): an authored slice colour wins,
@@ -1264,7 +1400,7 @@ var BasicChart = function (_a) {
1264
1400
  ofPieHandled = false;
1265
1401
  ofPieExtras = null;
1266
1402
  decorateCartesianTrace = function (trace, series, values, dataLabel) {
1267
- var e_6, _a;
1403
+ var e_8, _a;
1268
1404
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1269
1405
  var target = trace;
1270
1406
  // Secondary value axis. Plotly overlays a second value axis ("y2",
@@ -1343,37 +1479,37 @@ var BasicChart = function (_a) {
1343
1479
  _loop_3(tl);
1344
1480
  }
1345
1481
  }
1346
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1482
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
1347
1483
  finally {
1348
1484
  try {
1349
1485
  if (_o && !_o.done && (_a = _m.return)) _a.call(_m);
1350
1486
  }
1351
- finally { if (e_6) throw e_6.error; }
1487
+ finally { if (e_8) throw e_8.error; }
1352
1488
  }
1353
1489
  };
1354
- domainSources = (_53 = (_52 = (_51 = spec.domains) === null || _51 === void 0 ? void 0 : _51[0]) === null || _52 === void 0 ? void 0 : _52.sources) !== null && _53 !== void 0 ? _53 : [];
1490
+ 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 : [];
1355
1491
  seriesIndex = 0;
1356
1492
  _loop_2 = function (series) {
1357
- var currentSeriesIndex, dataLabel, _78, _79, effectiveChartType, lineLike, pieDomainLabels, piePointOffset, seriesData, seriesPlotlyType, seriesTraceStyle, rawValues, binCount, _80, labels, counts, cumulativePercents, barTrace, trace, rawValues, quartileMethod, showOutliers, showMeanMarker, usePrecomputed, trace, summary, hideOutliers, rawValues, totalIndices_1, trace, rawValues, trace, pieData, _81, 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, _82, x, y, orientation_1, trace, numericValues, _83, x, y, orientation_2, trace;
1358
- return tslib_1.__generator(this, function (_84) {
1359
- switch (_84.label) {
1493
+ 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;
1494
+ return tslib_1.__generator(this, function (_89) {
1495
+ switch (_89.label) {
1360
1496
  case 0:
1361
1497
  currentSeriesIndex = seriesIndex++;
1362
1498
  if (!(!(0, utils_1.isNil)(series.dataLabel) && (0, utils_1.isAFormula)(series.dataLabel))) return [3 /*break*/, 2];
1363
- _79 = chart_spec_utils_1.coerceCalculatedLabel;
1364
- return [4 /*yield*/, onRequestCalculate(series.dataLabel, (_55 = position.sheetId) !== null && _55 !== void 0 ? _55 : sheetId, position.overlayPosition.anchorCell.rowIndex, position.overlayPosition.anchorCell.columnIndex)];
1499
+ _84 = chart_spec_utils_1.coerceCalculatedLabel;
1500
+ return [4 /*yield*/, onRequestCalculate(series.dataLabel, (_57 = position.sheetId) !== null && _57 !== void 0 ? _57 : sheetId, position.overlayPosition.anchorCell.rowIndex, position.overlayPosition.anchorCell.columnIndex)];
1365
1501
  case 1:
1366
- _78 = _79.apply(void 0, [_84.sent()]);
1502
+ _83 = _84.apply(void 0, [_89.sent()]);
1367
1503
  return [3 /*break*/, 3];
1368
1504
  case 2:
1369
- _78 = (_56 = series.dataLabel) !== null && _56 !== void 0 ? _56 : "";
1370
- _84.label = 3;
1505
+ _83 = (_58 = series.dataLabel) !== null && _58 !== void 0 ? _58 : "";
1506
+ _89.label = 3;
1371
1507
  case 3:
1372
- dataLabel = _78;
1508
+ dataLabel = _83;
1373
1509
  // A series with no ranges draws nothing.
1374
1510
  if (series.sources.length === 0)
1375
1511
  return [2 /*return*/, "continue"];
1376
- effectiveChartType = (_57 = series.seriesChartType) !== null && _57 !== void 0 ? _57 : spec.chartType;
1512
+ effectiveChartType = (_59 = series.seriesChartType) !== null && _59 !== void 0 ? _59 : spec.chartType;
1377
1513
  lineLike = (0, empty_cells_1.isLineLikeChartType)(effectiveChartType);
1378
1514
  pieDomainLabels = (spec.chartType === "pie" || spec.chartType === "doughnut") &&
1379
1515
  (domainSources.length > 1 || series.sources.length > 1)
@@ -1406,19 +1542,17 @@ var BasicChart = function (_a) {
1406
1542
  ? { connectgaps: true }
1407
1543
  : {}));
1408
1544
  if (effectiveChartType === "histogram") {
1409
- rawValues = "values" in seriesData
1410
- ? seriesData.values
1411
- : seriesData;
1545
+ rawValues = seriesValuesOf(seriesData);
1412
1546
  binCount = spec.binCount;
1413
1547
  if (isPareto) {
1414
- _80 = (0, histogram_1.computePareto)((0, histogram_1.binHistogram)(rawValues, binCount)), labels = _80.labels, counts = _80.counts, cumulativePercents = _80.cumulativePercents;
1548
+ _85 = (0, histogram_1.computePareto)((0, histogram_1.binHistogram)(rawValues, binCount)), labels = _85.labels, counts = _85.counts, cumulativePercents = _85.cumulativePercents;
1415
1549
  barTrace = {
1416
1550
  type: "bar",
1417
1551
  x: labels,
1418
1552
  y: counts,
1419
1553
  name: dataLabel,
1420
1554
  };
1421
- applyTraceColor(barTrace, (_58 = series.color) !== null && _58 !== void 0 ? _58 : undefined, {
1555
+ applyTraceColor(barTrace, (_60 = series.color) !== null && _60 !== void 0 ? _60 : undefined, {
1422
1556
  noFill: series.noFill,
1423
1557
  dataPointColors: series.dataPointColors,
1424
1558
  seriesIndex: currentSeriesIndex,
@@ -1439,7 +1573,7 @@ var BasicChart = function (_a) {
1439
1573
  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
1440
1574
  ? { nbinsx: binCount }
1441
1575
  : {}));
1442
- applyTraceColor(trace, (_59 = series.color) !== null && _59 !== void 0 ? _59 : undefined, {
1576
+ applyTraceColor(trace, (_61 = series.color) !== null && _61 !== void 0 ? _61 : undefined, {
1443
1577
  noFill: series.noFill,
1444
1578
  dataPointColors: series.dataPointColors,
1445
1579
  seriesIndex: currentSeriesIndex,
@@ -1449,9 +1583,7 @@ var BasicChart = function (_a) {
1449
1583
  }
1450
1584
  }
1451
1585
  else if (effectiveChartType === "boxplot") {
1452
- rawValues = "values" in seriesData
1453
- ? seriesData.values
1454
- : seriesData;
1586
+ rawValues = seriesValuesOf(seriesData);
1455
1587
  quartileMethod = spec.quartileMethod;
1456
1588
  showOutliers = spec.showOutliers;
1457
1589
  showMeanMarker = spec.showMeanMarker === true;
@@ -1489,7 +1621,7 @@ var BasicChart = function (_a) {
1489
1621
  // default and `showOutliers: true` alike).
1490
1622
  boxpoints: "outliers" }, (showMeanMarker ? { boxmean: true } : {}));
1491
1623
  }
1492
- applyTraceColor(trace, (_60 = series.color) !== null && _60 !== void 0 ? _60 : undefined, {
1624
+ applyTraceColor(trace, (_62 = series.color) !== null && _62 !== void 0 ? _62 : undefined, {
1493
1625
  noFill: series.noFill,
1494
1626
  dataPointColors: series.dataPointColors,
1495
1627
  seriesIndex: currentSeriesIndex,
@@ -1498,10 +1630,9 @@ var BasicChart = function (_a) {
1498
1630
  traces.push(trace);
1499
1631
  }
1500
1632
  else if (effectiveChartType === "waterfall") {
1501
- rawValues = "values" in seriesData
1502
- ? seriesData.values
1503
- : seriesData;
1504
- totalIndices_1 = new Set((_61 = spec.totalIndices) !== null && _61 !== void 0 ? _61 : []);
1633
+ rawValues = seriesValuesOf(seriesData);
1634
+ totalIndices_1 = new Set((_63 = spec.totalIndices) !== null && _63 !== void 0 ? _63 : []);
1635
+ increaseColor = (_64 = series.color) !== null && _64 !== void 0 ? _64 : (0, utils_1.chartPaletteColorAt)(themeColorPalette, currentSeriesIndex);
1505
1636
  trace = {
1506
1637
  type: "waterfall",
1507
1638
  x: categoriesFor(series),
@@ -1510,26 +1641,33 @@ var BasicChart = function (_a) {
1510
1641
  return totalIndices_1.has(i) ? "total" : "relative";
1511
1642
  }),
1512
1643
  name: dataLabel,
1644
+ increasing: { marker: { color: increaseColor } },
1645
+ decreasing: {
1646
+ marker: {
1647
+ color: (_66 = (_65 = series.negativeColor) !== null && _65 !== void 0 ? _65 : theme.themeColors.accent2) !== null && _66 !== void 0 ? _66 : increaseColor,
1648
+ },
1649
+ },
1650
+ totals: { marker: { color: (_67 = theme.themeColors.accent3) !== null && _67 !== void 0 ? _67 : increaseColor } },
1651
+ connector: {
1652
+ line: {
1653
+ color: isDarkMode ? "rgba(255,255,255,0.45)" : "#999999",
1654
+ width: 1,
1655
+ },
1656
+ },
1513
1657
  };
1514
- applyTraceColor(trace, (_62 = series.color) !== null && _62 !== void 0 ? _62 : undefined, {
1515
- noFill: series.noFill,
1516
- dataPointColors: series.dataPointColors,
1517
- seriesIndex: currentSeriesIndex,
1518
- effectiveChartType: effectiveChartType,
1519
- });
1520
1658
  traces.push(trace);
1521
1659
  }
1522
1660
  else if (effectiveChartType === "funnel") {
1523
- rawValues = "values" in seriesData
1524
- ? seriesData.values
1525
- : seriesData;
1661
+ rawValues = seriesValuesOf(seriesData);
1526
1662
  trace = {
1527
1663
  type: "funnel",
1664
+ orientation: "h",
1528
1665
  y: categoriesFor(series),
1529
1666
  x: rawValues.map(function (v) { return (v !== null && v !== void 0 ? v : null); }),
1530
1667
  name: dataLabel,
1668
+ textinfo: "none",
1531
1669
  };
1532
- applyTraceColor(trace, (_63 = series.color) !== null && _63 !== void 0 ? _63 : undefined, {
1670
+ applyTraceColor(trace, (_68 = series.color) !== null && _68 !== void 0 ? _68 : undefined, {
1533
1671
  noFill: series.noFill,
1534
1672
  dataPointColors: series.dataPointColors,
1535
1673
  seriesIndex: currentSeriesIndex,
@@ -1547,10 +1685,10 @@ var BasicChart = function (_a) {
1547
1685
  return [2 /*return*/, "continue"];
1548
1686
  ofPieHandled = true;
1549
1687
  pieData = seriesData;
1550
- _81 = (0, of_pie_1.splitOfPie)(pieData.values, pieData.labels, {
1688
+ _86 = (0, of_pie_1.splitOfPie)(pieData.values, pieData.labels, {
1551
1689
  splitType: spec.splitType,
1552
1690
  splitPos: spec.splitPos,
1553
- }), main_1 = _81.main, secondary = _81.secondary, otherTotal = _81.otherTotal, total = _81.total;
1691
+ }), main_1 = _86.main, secondary = _86.secondary, otherTotal = _86.otherTotal, total = _86.total;
1554
1692
  ofPieType = (0, of_pie_1.resolveOfPieType)(spec.ofPieType);
1555
1693
  secondScale = (0, of_pie_1.clampSecondPieSize)(spec.secondPieSize) / 100;
1556
1694
  halfAngle = (0, of_pie_1.otherSliceHalfAngle)(otherTotal, total);
@@ -1683,7 +1821,7 @@ var BasicChart = function (_a) {
1683
1821
  trace.meta = {
1684
1822
  rncSeriesIndex: currentSeriesIndex,
1685
1823
  };
1686
- applyTraceColor(trace, (_64 = series.color) !== null && _64 !== void 0 ? _64 : undefined, {
1824
+ applyTraceColor(trace, (_69 = series.color) !== null && _69 !== void 0 ? _69 : undefined, {
1687
1825
  noFill: series.noFill,
1688
1826
  dataPointColors: series.dataPointColors,
1689
1827
  seriesIndex: currentSeriesIndex,
@@ -1692,13 +1830,13 @@ var BasicChart = function (_a) {
1692
1830
  traces.push(trace);
1693
1831
  }
1694
1832
  else if ("values" in seriesData && "labels" in seriesData) {
1695
- _82 = assignCartesianData(categoriesFor(series), seriesData.values), x = _82.x, y = _82.y, orientation_1 = _82.orientation;
1833
+ _87 = assignCartesianData(categoriesFor(series), seriesData.values), x = _87.x, y = _87.y, orientation_1 = _87.orientation;
1696
1834
  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));
1697
1835
  // Ties the trace back to spec.series for click selection
1698
1836
  trace.meta = {
1699
1837
  rncSeriesIndex: currentSeriesIndex,
1700
1838
  };
1701
- applyTraceColor(trace, (_65 = series.color) !== null && _65 !== void 0 ? _65 : undefined, {
1839
+ applyTraceColor(trace, (_70 = series.color) !== null && _70 !== void 0 ? _70 : undefined, {
1702
1840
  noFill: series.noFill,
1703
1841
  dataPointColors: series.dataPointColors,
1704
1842
  invertIfNegative: series.invertIfNegative,
@@ -1713,13 +1851,13 @@ var BasicChart = function (_a) {
1713
1851
  }
1714
1852
  else {
1715
1853
  numericValues = seriesData;
1716
- _83 = assignCartesianData(categoriesFor(series), numericValues), x = _83.x, y = _83.y, orientation_2 = _83.orientation;
1854
+ _88 = assignCartesianData(categoriesFor(series), numericValues), x = _88.x, y = _88.y, orientation_2 = _88.orientation;
1717
1855
  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));
1718
1856
  // Ties the trace back to spec.series for click selection
1719
1857
  trace.meta = {
1720
1858
  rncSeriesIndex: currentSeriesIndex,
1721
1859
  };
1722
- applyTraceColor(trace, (_66 = series.color) !== null && _66 !== void 0 ? _66 : undefined, {
1860
+ applyTraceColor(trace, (_71 = series.color) !== null && _71 !== void 0 ? _71 : undefined, {
1723
1861
  noFill: series.noFill,
1724
1862
  dataPointColors: series.dataPointColors,
1725
1863
  invertIfNegative: series.invertIfNegative,
@@ -1736,24 +1874,24 @@ var BasicChart = function (_a) {
1736
1874
  }
1737
1875
  });
1738
1876
  };
1739
- _77.label = 18;
1877
+ _82.label = 18;
1740
1878
  case 18:
1741
- _77.trys.push([18, 23, 24, 25]);
1742
- _j = tslib_1.__values((_54 = spec.series) !== null && _54 !== void 0 ? _54 : []), _k = _j.next();
1743
- _77.label = 19;
1879
+ _82.trys.push([18, 23, 24, 25]);
1880
+ _j = tslib_1.__values((_56 = spec.series) !== null && _56 !== void 0 ? _56 : []), _k = _j.next();
1881
+ _82.label = 19;
1744
1882
  case 19:
1745
1883
  if (!!_k.done) return [3 /*break*/, 22];
1746
1884
  series = _k.value;
1747
1885
  return [5 /*yield**/, _loop_2(series)];
1748
1886
  case 20:
1749
- _77.sent();
1750
- _77.label = 21;
1887
+ _82.sent();
1888
+ _82.label = 21;
1751
1889
  case 21:
1752
1890
  _k = _j.next();
1753
1891
  return [3 /*break*/, 19];
1754
1892
  case 22: return [3 /*break*/, 25];
1755
1893
  case 23:
1756
- e_3_1 = _77.sent();
1894
+ e_3_1 = _82.sent();
1757
1895
  e_3 = { error: e_3_1 };
1758
1896
  return [3 /*break*/, 25];
1759
1897
  case 24:
@@ -1770,13 +1908,13 @@ var BasicChart = function (_a) {
1770
1908
  ? undefined
1771
1909
  : (0, axis_number_format_1.resolveValueAxisNumberFormat)({
1772
1910
  axisOptions: spec.valueAxisOptions,
1773
- series: ((_67 = spec.series) !== null && _67 !== void 0 ? _67 : []).filter(function (s) { return !s.useSecondaryAxis; }),
1911
+ series: ((_72 = spec.series) !== null && _72 !== void 0 ? _72 : []).filter(function (s) { return !s.useSecondaryAxis; }),
1774
1912
  getFormattingFromRange: getFormattingFromRange,
1775
1913
  hiddenDimensionStrategy: spec.hiddenDimensionStrategy,
1776
1914
  });
1777
1915
  secondaryAxisNumberFormat = (0, axis_number_format_1.resolveValueAxisNumberFormat)({
1778
1916
  axisOptions: spec.secondaryValueAxisOptions,
1779
- series: ((_68 = spec.series) !== null && _68 !== void 0 ? _68 : []).filter(function (s) { return s.useSecondaryAxis; }),
1917
+ series: ((_73 = spec.series) !== null && _73 !== void 0 ? _73 : []).filter(function (s) { return s.useSecondaryAxis; }),
1780
1918
  getFormattingFromRange: getFormattingFromRange,
1781
1919
  hiddenDimensionStrategy: spec.hiddenDimensionStrategy,
1782
1920
  });
@@ -1824,14 +1962,14 @@ var BasicChart = function (_a) {
1824
1962
  ? VALUE_AXIS_TITLE_STANDOFF
1825
1963
  : legend_layout_1.BAND_GAP;
1826
1964
  legendBand = (0, legend_layout_1.reservePlotlyLegendBand)({
1827
- position: (_69 = spec.legend) === null || _69 === void 0 ? void 0 : _69.position,
1965
+ position: (_74 = spec.legend) === null || _74 === void 0 ? void 0 : _74.position,
1828
1966
  visible: showlegend !== false,
1829
1967
  labels: (0, legend_layout_1.legendLabelsFrom)(undefined, traces.map(function (trace) { return trace === null || trace === void 0 ? void 0 : trace.name; })),
1830
- legendFontSize: (_72 = (_71 = (_70 = spec.legend) === null || _70 === void 0 ? void 0 : _70.textFormat) === null || _71 === void 0 ? void 0 : _71.fontSize) !== null && _72 !== void 0 ? _72 : axisFontSize,
1968
+ 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,
1831
1969
  width: Math.max(0, (width !== null && width !== void 0 ? width : 0) - 2),
1832
1970
  height: Math.max(0, (height !== null && height !== void 0 ? height : 0) - 2),
1833
1971
  hasTitle: Boolean(title),
1834
- titleFontSize: (_73 = authoredTitleFmt === null || authoredTitleFmt === void 0 ? void 0 : authoredTitleFmt.fontSize) !== null && _73 !== void 0 ? _73 : 16,
1972
+ titleFontSize: (_78 = authoredTitleFmt === null || authoredTitleFmt === void 0 ? void 0 : authoredTitleFmt.fontSize) !== null && _78 !== void 0 ? _78 : 16,
1835
1973
  hasBottomAxisTitle: Boolean(spec.horizontalAxisTitle),
1836
1974
  hasLeftAxisTitle: Boolean(spec.verticalAxisTitle),
1837
1975
  leftAxisDepth: leftAxisDepth,
@@ -1843,7 +1981,7 @@ var BasicChart = function (_a) {
1843
1981
  family: "Untitled Sans, apple-system, sans-serif",
1844
1982
  size: 16,
1845
1983
  color: textColor,
1846
- }, authoredTitleFmt), x: 0.02, xanchor: "left" }, legendBand.title), showlegend: showlegend === undefined ? true : showlegend, legend: tslib_1.__assign(tslib_1.__assign({}, legendOverrides), ((_74 = legendBand.legend) !== null && _74 !== void 0 ? _74 : {})), margin: legendBand.margin, autosize: true }, ((spec.chartType === "bar" || spec.chartType === "column") &&
1984
+ }, 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") &&
1847
1985
  spec.stackedType
1848
1986
  ? tslib_1.__assign({ barmode: spec.stackedType === "STACKED" ||
1849
1987
  spec.stackedType === "PERCENT_STACKED"
@@ -1856,7 +1994,7 @@ var BasicChart = function (_a) {
1856
1994
  color: textColor,
1857
1995
  }, paper_bgcolor: bgColor, plot_bgcolor: bgColor, xaxis: applyAxisOverridesPlotly({
1858
1996
  title: {
1859
- text: (_75 = spec.horizontalAxisTitle) !== null && _75 !== void 0 ? _75 : "",
1997
+ text: (_80 = spec.horizontalAxisTitle) !== null && _80 !== void 0 ? _80 : "",
1860
1998
  font: { color: textColor },
1861
1999
  standoff: bottomAxisTitleStandoff,
1862
2000
  },
@@ -1874,7 +2012,7 @@ var BasicChart = function (_a) {
1874
2012
  isHorizontalBarChart
1875
2013
  ? spec.valueAxisOptions
1876
2014
  : spec.categoryAxisOptions, isHorizontalBarChart ? primaryAxisNumberFormat : undefined), yaxis: applyAxisOverridesPlotly({
1877
- title: tslib_1.__assign({ text: (_76 = spec.verticalAxisTitle) !== null && _76 !== void 0 ? _76 : "", font: { color: textColor } }, (isHorizontalBarChart
2015
+ title: tslib_1.__assign({ text: (_81 = spec.verticalAxisTitle) !== null && _81 !== void 0 ? _81 : "", font: { color: textColor } }, (isHorizontalBarChart
1878
2016
  ? {}
1879
2017
  : { standoff: VALUE_AXIS_TITLE_STANDOFF })),
1880
2018
  showgrid: !isHorizontalBarChart,
@@ -1938,13 +2076,18 @@ var BasicChart = function (_a) {
1938
2076
  };
1939
2077
  piePull = isOfPie ? undefined : (0, pie_explosion_1.explosionToPlotlyPull)((0, pie_explosion_1.resolveExplosion)(spec));
1940
2078
  formattedTraces = traces.map(function (trace) {
1941
- var _a, _b, _c, _d;
2079
+ var _a, _b, _c, _d, _e;
1942
2080
  var pattern = traceNumberFormat(trace);
1943
2081
  var next = applyDataLabelsToTracePlotly(trace, traceDataLabels(trace), spec.chartType, pattern, locale);
2082
+ if (next.type === "funnel") {
2083
+ // The formatted values ride on `text`; a funnel prints its own
2084
+ // `value` unless told to draw the text (or nothing).
2085
+ next = tslib_1.__assign(tslib_1.__assign({}, next), { textinfo: ((_a = traceDataLabels(trace)) === null || _a === void 0 ? void 0 : _a.show) ? "text" : "none" });
2086
+ }
1944
2087
  if (next.type === "pie") {
1945
2088
  // Plotly's pie prints every slice's percentage by default; Excel
1946
2089
  // draws nothing until data labels are on (#1062).
1947
- if (!((_a = traceDataLabels(trace)) === null || _a === void 0 ? void 0 : _a.show)) {
2090
+ if (!((_b = traceDataLabels(trace)) === null || _b === void 0 ? void 0 : _b.show)) {
1948
2091
  next = tslib_1.__assign(tslib_1.__assign({}, next), { textinfo: "none" });
1949
2092
  }
1950
2093
  // Hover values format like the slice's source cell.
@@ -1963,7 +2106,7 @@ var BasicChart = function (_a) {
1963
2106
  }
1964
2107
  else if (!next.hovertemplate &&
1965
2108
  (next.type === "bar" || next.type === "scatter") &&
1966
- typeof ((_b = next.meta) === null || _b === void 0 ? void 0 : _b.rncSeriesIndex) === "number") {
2109
+ typeof ((_c = next.meta) === null || _c === void 0 ? void 0 : _c.rncSeriesIndex) === "number") {
1967
2110
  // Hover values read like the series' own cells (Excel's data tip
1968
2111
  // shows the cell text) — the series format alone, not the axis
1969
2112
  // fallback the labels use, since that resolves to the first series
@@ -1985,8 +2128,8 @@ var BasicChart = function (_a) {
1985
2128
  // (doughnutHoleSize); clamp like the echarts renderer and default
1986
2129
  // to 0.5 when unset.
1987
2130
  if (spec.chartType === "doughnut" && next.type === "pie") {
1988
- var rank = doughnutSeriesOrder.indexOf((_c = next.meta) === null || _c === void 0 ? void 0 : _c.rncSeriesIndex);
1989
- var ring = (_d = doughnutRingSet[rank]) !== null && _d !== void 0 ? _d : (0, doughnut_1.doughnutRings)((0, doughnut_1.clampDoughnutHole)(doughnutHole), 1)[0];
2131
+ var rank = doughnutSeriesOrder.indexOf((_d = next.meta) === null || _d === void 0 ? void 0 : _d.rncSeriesIndex);
2132
+ var ring = (_e = doughnutRingSet[rank]) !== null && _e !== void 0 ? _e : (0, doughnut_1.doughnutRings)((0, doughnut_1.clampDoughnutHole)(doughnutHole), 1)[0];
1990
2133
  // Plotly's `hole` is a fraction of the trace's own radius.
1991
2134
  next = tslib_1.__assign(tslib_1.__assign({}, next), { hole: ring.inner / ring.outer });
1992
2135
  if (doughnutRingSet.length > 1) {
@@ -2125,7 +2268,13 @@ var BasicChart = function (_a) {
2125
2268
  } }, "Delete chart")))))) : null,
2126
2269
  react_1.default.createElement("div", { className: "flex-1 rnc-plotly-chart-container", onPointerDownCapture: handlePointerDownCapture },
2127
2270
  react_1.default.createElement(plot_1.Plot, { data: plotData, layout: plotLayout, config: config, onClick: handlePlotClick, onInitialized: function (_figure, graphDiv) {
2271
+ var _a, _b;
2128
2272
  graphDivRef.current = graphDiv;
2273
+ var plotDiv = graphDiv;
2274
+ // Returning false from these handlers keeps the clicked branch
2275
+ // from becoming the new root.
2276
+ (_a = plotDiv.on) === null || _a === void 0 ? void 0 : _a.call(plotDiv, "plotly_treemapclick", function () { return drillDownRef.current; });
2277
+ (_b = plotDiv.on) === null || _b === void 0 ? void 0 : _b.call(plotDiv, "plotly_sunburstclick", function () { return drillDownRef.current; });
2129
2278
  }, style: { width: "100%", height: "100%" } }))));
2130
2279
  };
2131
2280
  exports.BasicChart = BasicChart;