@rowsncolumns/charts 28.1.10 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAkEA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAmRrD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAgFnD,eAAO,MAAM,UAAU,GAAI,gPAkBxB,eAAe,sBA4+GjB,CAAC"}
1
+ {"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAkEA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAkSrD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAiGnD,eAAO,MAAM,UAAU,GAAI,gPAkBxB,eAAe,sBAkgHjB,CAAC"}
@@ -114,7 +114,8 @@ var isHierarchyChartSpec = function (spec) {
114
114
  };
115
115
  // Every level keeps the colour its node was given (one solid colour per
116
116
  // top-level category, like Excel — no per-level saturation ramp); thin
117
- // white gaps separate the cells.
117
+ // white gaps separate the cells. Index 0 is echarts' virtual root, 1 the
118
+ // top-level categories, 2+ the levels beneath them.
118
119
  var HIERARCHY_LEVEL_STYLES = [
119
120
  {
120
121
  itemStyle: {
@@ -122,7 +123,6 @@ var HIERARCHY_LEVEL_STYLES = [
122
123
  borderColor: "#ffffff",
123
124
  borderWidth: 0,
124
125
  },
125
- upperLabel: { show: false },
126
126
  },
127
127
  {
128
128
  itemStyle: {
@@ -132,6 +132,19 @@ var HIERARCHY_LEVEL_STYLES = [
132
132
  },
133
133
  },
134
134
  ];
135
+ /** Height of the strip a treemap category name is drawn in (Excel's "Banner"). */
136
+ var TREEMAP_BANNER_HEIGHT = 20;
137
+ /**
138
+ * Excel's treemap `parentLabelLayout`: the top-level category names are
139
+ * drawn in a banner strip (or not at all); the levels between the categories
140
+ * and the leaves are never labelled, so small groups keep their height for
141
+ * the leaf cells (rowsncolumns/spreadsheet#1072). Excel's default
142
+ * `overlapping` writes the name over the group's top-left corner, which an
143
+ * echarts treemap cannot draw (an upper label always reserves its strip and
144
+ * is dropped when the strip is too small for the text), so it draws as a
145
+ * banner.
146
+ */
147
+ var treemapBannerShown = function (layout) { return layout !== "none"; };
135
148
  /**
136
149
  * Colour a hierarchy like Excel: each top-level node takes the next
137
150
  * palette colour and every descendant inherits it (#1072).
@@ -181,13 +194,25 @@ var flattenChartDataValues = function (chartData, extractor, hiddenStrategy, ski
181
194
  });
182
195
  return values;
183
196
  };
184
- var buildHierarchyLevels = function (maxDepth) {
197
+ var buildHierarchyLevels = function (maxDepth, options) {
185
198
  if (maxDepth <= 0)
186
199
  return undefined;
187
200
  var levels = [];
188
- for (var i = 0; i < maxDepth; i++) {
201
+ // One entry per depth, the virtual root included, so every level's upper
202
+ // label is explicit: the categories' banner on level 1 only.
203
+ for (var i = 0; i <= maxDepth; i++) {
189
204
  var baseStyle = HIERARCHY_LEVEL_STYLES[Math.min(i, HIERARCHY_LEVEL_STYLES.length - 1)];
190
- levels.push(tslib_1.__assign(tslib_1.__assign({}, baseStyle), { itemStyle: tslib_1.__assign({}, baseStyle.itemStyle) }));
205
+ levels.push(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, baseStyle), { itemStyle: tslib_1.__assign({}, baseStyle.itemStyle) }), (options.treemap
206
+ ? {
207
+ upperLabel: i === 1 && options.banner
208
+ ? {
209
+ show: true,
210
+ height: TREEMAP_BANNER_HEIGHT,
211
+ padding: [0, 0, 0, 4],
212
+ }
213
+ : { show: false },
214
+ }
215
+ : {})));
191
216
  }
192
217
  return levels;
193
218
  };
@@ -387,7 +412,7 @@ var BasicChart = function (_a) {
387
412
  * Triggers a chart update
388
413
  */
389
414
  var updateChart = function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
390
- var threeDRenderKind, canRender3D, willRender3D, isRegionMap, regionSpec, geoScope, geo, labels, seriesEntry, values, _a, data, unmatched, min, max, textColor, ramp, noDataColor, borderColor, regionSeriesLabel, seriesName, chartDomains, chartSeries, legend, chartType, position, showAxis, isBubble, isHierarchy, skipHeaders_1, labelValues, perSeriesX, perSeriesSize, seriesInputs, i, seriesEntry, resolvedLabel, _b, xValues, sizeValues_1, sharedXValues, sharedSizeValues, _c, categories_1, preparedSeries, sizeValues, sizeScale_1, bubblePalette_1, bubbleItemColor_1, hasBubbleSecondaryAxis, xAxisConfig, tooltipFormatter, bubbleSeriesLabelFor_1, bubbleSeries, bubbleOverlays, hierarchyRows, headerTitle, hierarchyPalette, hierarchyData, rootName, drillDown, seriesDisplayName, hierarchyDepth, levels, sizeNumberFormat_1, tooltipFormatter, hierarchyDataLabels, hierarchySeriesLabel, isContour, categories_2, contourSeriesInputs, _d, _e, seriesEntry, dataLabel, _f, _g, values, e_1_1, seriesNames_1, contourPoints, _h, zMin, zMax, contourFormats_1, contourLabel, categories_3, threeDSeriesInputs, _j, _k, seriesEntry, dataLabel, _l, _m, values, e_2_1, seriesNames_2, threeDPalette_1, seriesColorAt_1, categoryAxisLabel, seriesAxisLabel, stackedBar3D_1, threeDFormats_1, threeDTooltipFormatter, threeDSeries, visualMap, xAxis3D, yAxis3D, categoryCount, categoryTotals_1, threeDSeriesInputs_1, threeDSeriesInputs_1_1, entry, isPercent_1, surfacePoints, _o, zMin, zMax, skipHeaders, categories, radarSeriesInputs, _p, _q, seriesEntry, label, values, radarAxisOptions_1, indicators_1, radarData, radarStyle_1, radarColors_1, radarFormats_1, radarDataLabels_1, radarSeriesLabelFor_1, radarTooltipFormatter, variant_1, categories, seriesValues, stockFormats_1, stockRoleIndex_1, stockFormatFor_1, stockDataLabels_1, stockSeriesLabelFor_1, upColor_1, downColor_1, volumePoints, hasVolume, stockGrid, baseStockXAxis, stockXAxis, volumeYAxis, volumeSeries, stockAxisPointer, candleData, lineSeries, stockColors_1, isStacked, isCircularChart, isOfPie, ofPieLayout, isHorizontalBarChart, shouldAggregate, primaryDomainSource, rawPrimaryDomainValues, aggregateDomainValues, categoryLevels, pushSeriesOverlays, sideBySideBarCount, specBarGap, specBarCategoryGap, seriesPalette, paletteColorAt, _loop_1, _r, _s, _t, specSeriesIndex, series, e_3_1, labels, seriesEntry, rawValues, _u, main_1, secondary, otherTotal, total, ofPieType_1, secondScale, halfAngle_1, hasSecondary, MAIN_CX_1, CY_1, MAIN_RADIUS_PCT_1, SECONDARY_CX_1, secondaryRadiusPct_1, BAR_LEFT_1, BAR_RIGHT, barHalfFrac_1, ofPiePalette_1, paletteAt_1, connectorColor_1, primaryDomainSource_1, rawDomainValues, labels, seriesEntry, rawValues_1, totalIndices, steps, accent_1, decreaseColor_1, totalColor_1, pointColors_1, _v, _w, dp, connectors, primaryDomainSource_2, rawDomainValues, labels_1, seriesEntry, rawValues, funnelPalette, funnelColor_1, stageColors_1, _x, _y, dp, funnelData, funnelLayout, quartileMethod, showOutliers, showMeanMarker, boxStats, boxLabels, outlierPoints, meanPoints, _z, _0, seriesEntry, label, rawValues, summary, boxIndex, lo, hi, _1, _2, outlier, boxSeries, boxColor, rawValues, _3, labels, counts, isPareto_1, cumulativePercents, pareto, histogramSeries, histogramColor, renderedSeriesCount, replaceMerge, valueAxisBase, isPareto, hasSecondaryAxis, isPercentStackedBars, primaryAxisNumberFormat, secondaryAxisNumberFormat, axisNumberFormatFor, seriesNumberFormats, seriesNumberFormatFor, tooltipConfig, finalLegend, bottomAxisNameGap, legendBand, positionedLegend, gridConfig, chartDataLabels, seriesLabelOptionFor, isDoughnut, doughnutHoleSize, doughnutSeriesOrder, doughnutRingSet, explosion, explosionOffset, barSeries, len, categoryTotals_2, barSeries_1, barSeries_1_1, s, i, raw, n, barSeries_2, barSeries_2_1, s, seriesWithLabels;
415
+ var threeDRenderKind, canRender3D, willRender3D, isRegionMap, regionSpec, geoScope, geo, labels, seriesEntry, values, _a, data, unmatched, min, max, textColor, ramp, noDataColor, borderColor, regionSeriesLabel, seriesName, chartDomains, chartSeries, legend, chartType, position, showAxis, isBubble, isHierarchy, skipHeaders_1, labelValues, perSeriesX, perSeriesSize, seriesInputs, i, seriesEntry, resolvedLabel, _b, xValues, sizeValues_1, sharedXValues, sharedSizeValues, _c, categories_1, preparedSeries, sizeValues, sizeScale_1, bubblePalette_1, bubbleItemColor_1, hasBubbleSecondaryAxis, xAxisConfig, tooltipFormatter, bubbleSeriesLabelFor_1, bubbleSeries, bubbleOverlays, hierarchyRows, headerTitle, hierarchyPalette, hierarchyData, rootName, drillDown, seriesDisplayName, hierarchyDepth, isTreemap, banner, levels, hierarchyLegend, legendShown, categoryLegendSeries, sizeNumberFormat_1, tooltipFormatter, hierarchyDataLabels, hierarchySeriesLabel, isContour, categories_2, contourSeriesInputs, _d, _e, seriesEntry, dataLabel, _f, _g, values, e_1_1, seriesNames_1, contourPoints, _h, zMin, zMax, contourFormats_1, contourLabel, categories_3, threeDSeriesInputs, _j, _k, seriesEntry, dataLabel, _l, _m, values, e_2_1, seriesNames_2, threeDPalette_1, seriesColorAt_1, categoryAxisLabel, seriesAxisLabel, stackedBar3D_1, threeDFormats_1, threeDTooltipFormatter, threeDSeries, visualMap, xAxis3D, yAxis3D, categoryCount, categoryTotals_1, threeDSeriesInputs_1, threeDSeriesInputs_1_1, entry, isPercent_1, surfacePoints, _o, zMin, zMax, skipHeaders, categories, radarSeriesInputs, _p, _q, seriesEntry, label, values, radarAxisOptions_1, indicators_1, radarData, radarStyle_1, radarColors_1, radarFormats_1, radarDataLabels_1, radarSeriesLabelFor_1, radarTooltipFormatter, variant_1, categories, seriesValues, stockFormats_1, stockRoleIndex_1, stockFormatFor_1, stockDataLabels_1, stockSeriesLabelFor_1, upColor_1, downColor_1, volumePoints, hasVolume, stockGrid, baseStockXAxis, stockXAxis, volumeYAxis, volumeSeries, stockAxisPointer, candleData, lineSeries, stockColors_1, isStacked, isCircularChart, isOfPie, ofPieLayout, isHorizontalBarChart, shouldAggregate, primaryDomainSource, rawPrimaryDomainValues, aggregateDomainValues, categoryLevels, pushSeriesOverlays, sideBySideBarCount, specBarGap, specBarCategoryGap, seriesPalette, paletteColorAt, _loop_1, _r, _s, _t, specSeriesIndex, series, e_3_1, labels, seriesEntry, rawValues, _u, main_1, secondary, otherTotal, total, ofPieType_1, secondScale, halfAngle_1, hasSecondary, MAIN_CX_1, CY_1, MAIN_RADIUS_PCT_1, SECONDARY_CX_1, secondaryRadiusPct_1, BAR_LEFT_1, BAR_RIGHT, barHalfFrac_1, ofPiePalette_1, paletteAt_1, connectorColor_1, primaryDomainSource_1, rawDomainValues, labels, seriesEntry, rawValues_1, totalIndices, steps, accent_1, decreaseColor_1, totalColor_1, pointColors_1, _v, _w, dp, connectors, primaryDomainSource_2, rawDomainValues, labels_1, seriesEntry, rawValues, funnelPalette, funnelColor_1, stageColors_1, _x, _y, dp, funnelData, funnelLayout, quartileMethod, showOutliers, showMeanMarker, boxStats, boxLabels, outlierPoints, meanPoints, _z, _0, seriesEntry, label, rawValues, summary, boxIndex, lo, hi, _1, _2, outlier, boxSeries, boxColor, rawValues, _3, labels, counts, isPareto_1, cumulativePercents, pareto, histogramSeries, histogramColor, renderedSeriesCount, replaceMerge, valueAxisBase, isPareto, hasSecondaryAxis, isPercentStackedBars, primaryAxisNumberFormat, secondaryAxisNumberFormat, axisNumberFormatFor, seriesNumberFormats, seriesNumberFormatFor, tooltipConfig, finalLegend, bottomAxisNameGap, legendBand, positionedLegend, gridConfig, chartDataLabels, seriesLabelOptionFor, isDoughnut, doughnutHoleSize, doughnutSeriesOrder, doughnutRingSet, explosion, explosionOffset, barSeries, len, categoryTotals_2, barSeries_1, barSeries_1_1, s, i, raw, n, barSeries_2, barSeries_2_1, s, seriesWithLabels;
391
416
  var e_1, _4, e_2, _5, e_4, _6, e_5, _7, e_3, _8, e_6, _9, e_7, _10, e_8, _11, e_9, _12, e_10, _13, e_11, _14;
392
417
  var _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, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128, _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144, _145, _146, _147, _148, _149;
393
418
  return tslib_1.__generator(this, function (_150) {
@@ -788,7 +813,28 @@ var BasicChart = function (_a) {
788
813
  drillDown = Boolean(spec.drillDown);
789
814
  seriesDisplayName = (_36 = (_35 = explicitChartTitle !== null && explicitChartTitle !== void 0 ? explicitChartTitle : headerTitle) !== null && _35 !== void 0 ? _35 : rootName) !== null && _36 !== void 0 ? _36 : "";
790
815
  hierarchyDepth = getHierarchyDepth(hierarchyData);
791
- levels = buildHierarchyLevels(hierarchyDepth);
816
+ isTreemap = spec.chartType === "treemap";
817
+ banner = isTreemap && treemapBannerShown(spec.parentLabelLayout);
818
+ levels = buildHierarchyLevels(hierarchyDepth, {
819
+ treemap: isTreemap,
820
+ banner: banner,
821
+ });
822
+ hierarchyLegend = (0, overrides_1.applyLegendOverrides)(tslib_1.__assign(tslib_1.__assign({}, defaultLegendConfig), { show: false }), spec.legend);
823
+ legendShown = hierarchyLegend.show !== false;
824
+ categoryLegendSeries = legendShown
825
+ ? hierarchyData.map(function (node) {
826
+ var _a, _b;
827
+ return ({
828
+ type: "bar",
829
+ id: "rnc-hierarchy-legend-".concat((_a = node.id) !== null && _a !== void 0 ? _a : node.name),
830
+ name: node.name,
831
+ data: [],
832
+ silent: true,
833
+ itemStyle: { color: (_b = node.itemStyle) === null || _b === void 0 ? void 0 : _b.color },
834
+ tooltip: { show: false },
835
+ });
836
+ })
837
+ : [];
792
838
  sizeNumberFormat_1 = (0, axis_number_format_1.resolveSourceNumberFormat)((_38 = (_37 = spec.sizeData) === null || _37 === void 0 ? void 0 : _37[0]) === null || _38 === void 0 ? void 0 : _38.sources, getFormattingFromRange, spec.hiddenDimensionStrategy);
793
839
  tooltipFormatter = function (params) {
794
840
  var _a;
@@ -813,7 +859,7 @@ var BasicChart = function (_a) {
813
859
  show: false,
814
860
  },
815
861
  ],
816
- legend: (0, overrides_1.applyLegendOverrides)(tslib_1.__assign(tslib_1.__assign({}, defaultLegendConfig), { show: false }), spec.legend),
862
+ legend: tslib_1.__assign(tslib_1.__assign({}, hierarchyLegend), { data: hierarchyData.map(function (node) { return node.name; }), selectedMode: false }),
817
863
  grid: {
818
864
  left: 0,
819
865
  right: 0,
@@ -824,25 +870,21 @@ var BasicChart = function (_a) {
824
870
  trigger: "item",
825
871
  formatter: tooltipFormatter,
826
872
  },
827
- series: [
828
- tslib_1.__assign({ type: chartType, name: seriesDisplayName, rootName: rootName || seriesDisplayName || "", data: hierarchyData, label: tslib_1.__assign(tslib_1.__assign({ show: true, formatter: "{b}" }, (spec.chartType === "treemap"
829
- ? { position: "insideBottomLeft" }
830
- : {})), (hierarchySeriesLabel !== null && hierarchySeriesLabel !== void 0 ? hierarchySeriesLabel : {})), upperLabel: spec.chartType === "treemap"
831
- ? {
832
- show: true,
833
- padding: [0, 0, 0, 4],
834
- }
835
- : undefined, levels: levels,
873
+ series: tslib_1.__spreadArray([
874
+ tslib_1.__assign({ type: chartType, name: seriesDisplayName, rootName: rootName || seriesDisplayName || "", data: hierarchyData, label: tslib_1.__assign(tslib_1.__assign({ show: true, formatter: "{b}" }, (isTreemap ? { position: "insideBottomLeft" } : {})), (hierarchySeriesLabel !== null && hierarchySeriesLabel !== void 0 ? hierarchySeriesLabel : {})),
875
+ // Only `levels[1]` (the categories) may carry a banner; see
876
+ // buildHierarchyLevels.
877
+ upperLabel: isTreemap ? { show: false } : undefined, levels: levels,
836
878
  // Excel has no drill-down on either chart: zooming into a
837
879
  // branch on click (and the treemap breadcrumb) is opt-in.
838
880
  nodeClick: drillDown
839
881
  ? spec.chartType === "treemap"
840
882
  ? "zoomToNode"
841
883
  : "rootToNode"
842
- : false }, (spec.chartType === "treemap"
884
+ : false }, (isTreemap
843
885
  ? { breadcrumb: { show: drillDown } }
844
- : { radius: tslib_1.__spreadArray([], tslib_1.__read(SUNBURST_RADIUS), false) })),
845
- ],
886
+ : { radius: tslib_1.__spreadArray([], tslib_1.__read(SUNBURST_RADIUS), false) }))
887
+ ], tslib_1.__read(categoryLegendSeries), false),
846
888
  }, {
847
889
  replaceMerge: [
848
890
  "series",
@@ -854,7 +896,7 @@ var BasicChart = function (_a) {
854
896
  ],
855
897
  });
856
898
  previousChartType.current = spec.chartType;
857
- previousSeriesCount.current = 1;
899
+ previousSeriesCount.current = 1 + categoryLegendSeries.length;
858
900
  return [2 /*return*/];
859
901
  }
860
902
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../../plotly/basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAoCA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AA6ZxD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAmGnD,eAAO,MAAM,UAAU,GAAI,gPAkBxB,eAAe,sBAgkFjB,CAAC"}
1
+ {"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../../plotly/basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAoCA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AA6ZxD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAmGnD,eAAO,MAAM,UAAU,GAAI,gPAkBxB,eAAe,sBAilFjB,CAAC"}
@@ -824,7 +824,25 @@ var BasicChart = function (_a) {
824
824
  SUNBURST_ROOT_ID_1 = "__rnc_sunburst_root__";
825
825
  rootTotal = hierarchyData_1.values.reduce(function (sum, value, i) { return (hierarchyData_1.parents[i] === "" ? sum + value : sum); }, 0);
826
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" }));
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
+ }));
828
846
  layoutForHierarchy = {
829
847
  title: {
830
848
  text: (0, plotly_title_1.plotlyTitleText)(title, spec.titleTextFormat),
@@ -1 +1 @@
1
- {"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../../utils/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAWrD,oEAAoE;AACpE,eAAO,MAAM,4BAA4B,GAAI,KAAK,GAAG,oCASpD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,qBAAqB,EAC7B,MAAM,GAAG,KACR,qBA6CF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,GAAG,EACT,MAAM,GAAG,EACT,sBAAsB,MAAM,EAC5B,SAAS,MAAM,QA4BhB,CAAC;AAgBF,eAAO,MAAM,kBAAkB,GAAI,MAAM,GAAG,EAAE,SAAS,MAAM,MAAM,QAAQ,GAAG,WA+C7E,CAAC;AAgCF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,EACvC,YAAY,CAAC,GAAG,IAAI,GAAG,SAAS,EAChC,QAAQ;IAAE,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KACnD,CAAC,GAAG,IAAI,GAAG,SAA6C,CAAC;AAE5D,eAAO,MAAM,sBAAsB,GACjC,MAAM,GAAG,EACT,aAAa,MAAM,EACnB,SAAS,MAAM;;;iCA7F0D,GAAG;aA0G7E,CAAC"}
1
+ {"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../../utils/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAWrD,oEAAoE;AACpE,eAAO,MAAM,4BAA4B,GAAI,KAAK,GAAG,oCASpD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,qBAAqB,EAC7B,MAAM,GAAG,KACR,qBA6CF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,GAAG,EACT,MAAM,GAAG,EACT,sBAAsB,MAAM,EAC5B,SAAS,MAAM,QA4BhB,CAAC;AAgBF,eAAO,MAAM,kBAAkB,GAAI,MAAM,GAAG,EAAE,SAAS,MAAM,MAAM,QAAQ,GAAG,WAoD7E,CAAC;AAgCF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,EACvC,YAAY,CAAC,GAAG,IAAI,GAAG,SAAS,EAChC,QAAQ;IAAE,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KACnD,CAAC,GAAG,IAAI,GAAG,SAA6C,CAAC;AAE5D,eAAO,MAAM,sBAAsB,GACjC,MAAM,GAAG,EACT,aAAa,MAAM,EACnB,SAAS,MAAM;;;iCAlG0D,GAAG;aA+G7E,CAAC"}
@@ -135,10 +135,15 @@ var dataLabelFormatter = function (opts, locale) { return function (params) {
135
135
  if (opts.showPercent && params.percent !== undefined) {
136
136
  parts.push("".concat(params.percent, "%"));
137
137
  }
138
+ // The value shows by default unless another field was asked for instead:
139
+ // an importer records only the flags that are ON, so `<c:showVal val="0"/>`
140
+ // + `<c:showBubbleSize val="1"/>` arrives as `{ showBubbleSize: true }` and
141
+ // must label the bubble with its size alone (#1068 / #1079).
138
142
  var showVal = opts.showValue !== false &&
139
143
  !opts.showCategoryName &&
140
144
  !opts.showPercent &&
141
- !opts.showSeriesName
145
+ !opts.showSeriesName &&
146
+ !opts.showBubbleSize
142
147
  ? true
143
148
  : !!opts.showValue;
144
149
  // A scatter / bubble point's value is its [x, y, size] tuple: the label's
@@ -1 +1 @@
1
- {"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAkEA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAmRrD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAgFnD,eAAO,MAAM,UAAU,GAAI,gPAkBxB,eAAe,sBA4+GjB,CAAC"}
1
+ {"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAkEA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAkSrD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAiGnD,eAAO,MAAM,UAAU,GAAI,gPAkBxB,eAAe,sBAkgHjB,CAAC"}
@@ -104,7 +104,8 @@ const isBubbleChartSpec = (spec) => BUBBLE_CHART_TYPES.has(spec.chartType);
104
104
  const isHierarchyChartSpec = (spec) => HIERARCHY_CHART_TYPES.has(spec.chartType);
105
105
  // Every level keeps the colour its node was given (one solid colour per
106
106
  // top-level category, like Excel — no per-level saturation ramp); thin
107
- // white gaps separate the cells.
107
+ // white gaps separate the cells. Index 0 is echarts' virtual root, 1 the
108
+ // top-level categories, 2+ the levels beneath them.
108
109
  const HIERARCHY_LEVEL_STYLES = [
109
110
  {
110
111
  itemStyle: {
@@ -112,7 +113,6 @@ const HIERARCHY_LEVEL_STYLES = [
112
113
  borderColor: "#ffffff",
113
114
  borderWidth: 0,
114
115
  },
115
- upperLabel: { show: false },
116
116
  },
117
117
  {
118
118
  itemStyle: {
@@ -122,6 +122,19 @@ const HIERARCHY_LEVEL_STYLES = [
122
122
  },
123
123
  },
124
124
  ];
125
+ /** Height of the strip a treemap category name is drawn in (Excel's "Banner"). */
126
+ const TREEMAP_BANNER_HEIGHT = 20;
127
+ /**
128
+ * Excel's treemap `parentLabelLayout`: the top-level category names are
129
+ * drawn in a banner strip (or not at all); the levels between the categories
130
+ * and the leaves are never labelled, so small groups keep their height for
131
+ * the leaf cells (rowsncolumns/spreadsheet#1072). Excel's default
132
+ * `overlapping` writes the name over the group's top-left corner, which an
133
+ * echarts treemap cannot draw (an upper label always reserves its strip and
134
+ * is dropped when the strip is too small for the text), so it draws as a
135
+ * banner.
136
+ */
137
+ const treemapBannerShown = (layout) => layout !== "none";
125
138
  /**
126
139
  * Colour a hierarchy like Excel: each top-level node takes the next
127
140
  * palette colour and every descendant inherits it (#1072).
@@ -170,17 +183,30 @@ const flattenChartDataValues = (chartData, extractor, hiddenStrategy, skipFirstR
170
183
  });
171
184
  return values;
172
185
  };
173
- const buildHierarchyLevels = (maxDepth) => {
186
+ const buildHierarchyLevels = (maxDepth, options) => {
174
187
  if (maxDepth <= 0)
175
188
  return undefined;
176
189
  const levels = [];
177
- for (let i = 0; i < maxDepth; i++) {
190
+ // One entry per depth, the virtual root included, so every level's upper
191
+ // label is explicit: the categories' banner on level 1 only.
192
+ for (let i = 0; i <= maxDepth; i++) {
178
193
  const baseStyle = HIERARCHY_LEVEL_STYLES[Math.min(i, HIERARCHY_LEVEL_STYLES.length - 1)];
179
194
  levels.push({
180
195
  ...baseStyle,
181
196
  itemStyle: {
182
197
  ...baseStyle.itemStyle,
183
198
  },
199
+ ...(options.treemap
200
+ ? {
201
+ upperLabel: i === 1 && options.banner
202
+ ? {
203
+ show: true,
204
+ height: TREEMAP_BANNER_HEIGHT,
205
+ padding: [0, 0, 0, 4],
206
+ }
207
+ : { show: false },
208
+ }
209
+ : {}),
184
210
  });
185
211
  }
186
212
  return levels;
@@ -813,7 +839,30 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
813
839
  const drillDown = Boolean(spec.drillDown);
814
840
  const seriesDisplayName = explicitChartTitle ?? headerTitle ?? rootName ?? "";
815
841
  const hierarchyDepth = getHierarchyDepth(hierarchyData);
816
- const levels = buildHierarchyLevels(hierarchyDepth);
842
+ const isTreemap = spec.chartType === "treemap";
843
+ const banner = isTreemap && treemapBannerShown(spec.parentLabelLayout);
844
+ const levels = buildHierarchyLevels(hierarchyDepth, {
845
+ treemap: isTreemap,
846
+ banner,
847
+ });
848
+ // Excel lists the top-level categories with their colours in the
849
+ // legend. An echarts legend cannot address treemap nodes, so each
850
+ // category gets a data-less placeholder series carrying its name and
851
+ // colour; `selectedMode: false` keeps the swatches from toggling
852
+ // anything.
853
+ const hierarchyLegend = applyLegendOverrides({ ...defaultLegendConfig, show: false }, spec.legend);
854
+ const legendShown = hierarchyLegend.show !== false;
855
+ const categoryLegendSeries = legendShown
856
+ ? hierarchyData.map((node) => ({
857
+ type: "bar",
858
+ id: `rnc-hierarchy-legend-${node.id ?? node.name}`,
859
+ name: node.name,
860
+ data: [],
861
+ silent: true,
862
+ itemStyle: { color: node.itemStyle?.color },
863
+ tooltip: { show: false },
864
+ }))
865
+ : [];
817
866
  // Sizes format like the cells they were read from (Excel's "Linked
818
867
  // to source"), unless the data labels carry their own pattern.
819
868
  const sizeNumberFormat = resolveSourceNumberFormat(spec.sizeData?.[0]
@@ -843,7 +892,11 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
843
892
  show: false,
844
893
  },
845
894
  ],
846
- legend: applyLegendOverrides({ ...defaultLegendConfig, show: false }, spec.legend),
895
+ legend: {
896
+ ...hierarchyLegend,
897
+ data: hierarchyData.map((node) => node.name),
898
+ selectedMode: false,
899
+ },
847
900
  grid: {
848
901
  left: 0,
849
902
  right: 0,
@@ -863,17 +916,12 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
863
916
  label: {
864
917
  show: true,
865
918
  formatter: "{b}",
866
- ...(spec.chartType === "treemap"
867
- ? { position: "insideBottomLeft" }
868
- : {}),
919
+ ...(isTreemap ? { position: "insideBottomLeft" } : {}),
869
920
  ...(hierarchySeriesLabel ?? {}),
870
921
  },
871
- upperLabel: spec.chartType === "treemap"
872
- ? {
873
- show: true,
874
- padding: [0, 0, 0, 4],
875
- }
876
- : undefined,
922
+ // Only `levels[1]` (the categories) may carry a banner; see
923
+ // buildHierarchyLevels.
924
+ upperLabel: isTreemap ? { show: false } : undefined,
877
925
  levels,
878
926
  // Excel has no drill-down on either chart: zooming into a
879
927
  // branch on click (and the treemap breadcrumb) is opt-in.
@@ -882,10 +930,11 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
882
930
  ? "zoomToNode"
883
931
  : "rootToNode"
884
932
  : false,
885
- ...(spec.chartType === "treemap"
933
+ ...(isTreemap
886
934
  ? { breadcrumb: { show: drillDown } }
887
935
  : { radius: [...SUNBURST_RADIUS] }),
888
936
  },
937
+ ...categoryLegendSeries,
889
938
  ],
890
939
  }, {
891
940
  replaceMerge: [
@@ -898,7 +947,7 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
898
947
  ],
899
948
  });
900
949
  previousChartType.current = spec.chartType;
901
- previousSeriesCount.current = 1;
950
+ previousSeriesCount.current = 1 + categoryLegendSeries.length;
902
951
  return;
903
952
  }
904
953
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../../plotly/basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAoCA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AA6ZxD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAmGnD,eAAO,MAAM,UAAU,GAAI,gPAkBxB,eAAe,sBAgkFjB,CAAC"}
1
+ {"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../../plotly/basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAoCA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AA6ZxD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAmGnD,eAAO,MAAM,UAAU,GAAI,gPAkBxB,eAAe,sBAilFjB,CAAC"}
@@ -853,7 +853,25 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
853
853
  name: seriesName,
854
854
  textinfo: "label+value",
855
855
  branchvalues: "total",
856
- ...(isSunburst ? {} : { textposition: "bottom left" }),
856
+ ...(isSunburst
857
+ ? {}
858
+ : {
859
+ textposition: "bottom left",
860
+ // Excel labels a treemap's top-level categories (in a header
861
+ // strip, or not at all with parentLabelLayout "none") and its
862
+ // leaves; the levels in between are never labelled (#1072).
863
+ text: hierarchyData.labels.map(() => ""),
864
+ texttemplate: hierarchyData.ids.map((id, i) => {
865
+ const isLeaf = !hierarchyData.parents.includes(id);
866
+ if (isLeaf)
867
+ return "%{label}<br>%{value}";
868
+ const isTopLevel = hierarchyData.depths[i] === 0;
869
+ return isTopLevel &&
870
+ spec.parentLabelLayout !== "none"
871
+ ? "%{label}"
872
+ : "%{text}";
873
+ }),
874
+ }),
857
875
  };
858
876
  const layoutForHierarchy = {
859
877
  title: {
@@ -1 +1 @@
1
- {"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../../utils/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAWrD,oEAAoE;AACpE,eAAO,MAAM,4BAA4B,GAAI,KAAK,GAAG,oCASpD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,qBAAqB,EAC7B,MAAM,GAAG,KACR,qBA6CF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,GAAG,EACT,MAAM,GAAG,EACT,sBAAsB,MAAM,EAC5B,SAAS,MAAM,QA4BhB,CAAC;AAgBF,eAAO,MAAM,kBAAkB,GAAI,MAAM,GAAG,EAAE,SAAS,MAAM,MAAM,QAAQ,GAAG,WA+C7E,CAAC;AAgCF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,EACvC,YAAY,CAAC,GAAG,IAAI,GAAG,SAAS,EAChC,QAAQ;IAAE,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KACnD,CAAC,GAAG,IAAI,GAAG,SAA6C,CAAC;AAE5D,eAAO,MAAM,sBAAsB,GACjC,MAAM,GAAG,EACT,aAAa,MAAM,EACnB,SAAS,MAAM;;;iCA7F0D,GAAG;aA0G7E,CAAC"}
1
+ {"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../../utils/overrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAWrD,oEAAoE;AACpE,eAAO,MAAM,4BAA4B,GAAI,KAAK,GAAG,oCASpD,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,qBAAqB,EAC7B,MAAM,GAAG,KACR,qBA6CF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,MAAM,GAAG,EACT,MAAM,GAAG,EACT,sBAAsB,MAAM,EAC5B,SAAS,MAAM,QA4BhB,CAAC;AAgBF,eAAO,MAAM,kBAAkB,GAAI,MAAM,GAAG,EAAE,SAAS,MAAM,MAAM,QAAQ,GAAG,WAoD7E,CAAC;AAgCF;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,EACvC,YAAY,CAAC,GAAG,IAAI,GAAG,SAAS,EAChC,QAAQ;IAAE,UAAU,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KACnD,CAAC,GAAG,IAAI,GAAG,SAA6C,CAAC;AAE5D,eAAO,MAAM,sBAAsB,GACjC,MAAM,GAAG,EACT,aAAa,MAAM,EACnB,SAAS,MAAM;;;iCAlG0D,GAAG;aA+G7E,CAAC"}
@@ -126,10 +126,15 @@ export const dataLabelFormatter = (opts, locale) => (params) => {
126
126
  if (opts.showPercent && params.percent !== undefined) {
127
127
  parts.push(`${params.percent}%`);
128
128
  }
129
+ // The value shows by default unless another field was asked for instead:
130
+ // an importer records only the flags that are ON, so `<c:showVal val="0"/>`
131
+ // + `<c:showBubbleSize val="1"/>` arrives as `{ showBubbleSize: true }` and
132
+ // must label the bubble with its size alone (#1068 / #1079).
129
133
  const showVal = opts.showValue !== false &&
130
134
  !opts.showCategoryName &&
131
135
  !opts.showPercent &&
132
- !opts.showSeriesName
136
+ !opts.showSeriesName &&
137
+ !opts.showBubbleSize
133
138
  ? true
134
139
  : !!opts.showValue;
135
140
  // A scatter / bubble point's value is its [x, y, size] tuple: the label's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowsncolumns/charts",
3
- "version": "28.1.10",
3
+ "version": "28.1.11",
4
4
  "author": "Vinay M",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "main": "./dist/cjs/index.js",
@@ -70,7 +70,7 @@
70
70
  "@rowsncolumns/common-types": ">=5.3.2",
71
71
  "@rowsncolumns/grid": ">=13.2.35",
72
72
  "@rowsncolumns/icons": ">=7.2.33",
73
- "@rowsncolumns/spreadsheet": ">=10.4.8",
73
+ "@rowsncolumns/spreadsheet": ">=10.4.9",
74
74
  "@rowsncolumns/spreadsheet-state": ">=29.1.8",
75
75
  "@rowsncolumns/toolkit": ">=24.5.10",
76
76
  "@rowsncolumns/ui": ">=16.0.4",