@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
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../plotly/basic-chart/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,eAAO,MAAM,qBAAqB,GAChC,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,KACvC,MAmEF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC;;;;;;;;;CAgBzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,MAAM,GAAG,SAAS,GAAG,IAAI,KAChC,MAAM,GAAG,SA0BX,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,YAejE,CAAC"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../plotly/basic-chart/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,eAAO,MAAM,qBAAqB,GAChC,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,KACvC,MAmEF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC;;;;;;;;;CAgBzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,MAAM,GAAG,SAAS,GAAG,IAAI,KAChC,MAAM,GAAG,SA0BX,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,YAiBjE,CAAC"}
@@ -107,6 +107,8 @@ var showXAxis = function (type) {
107
107
  type === "column" ||
108
108
  type === "bubble" ||
109
109
  type === "histogram" ||
110
+ // A waterfall's steps are categories (Opening, Sales, …) (#1070).
111
+ type === "waterfall" ||
110
112
  // Stock is line-derived on a category x-axis. Radar is polar and
111
113
  // does not use the cartesian x-axis.
112
114
  type === "stock") {
@@ -1 +1 @@
1
- {"root":["../../config.ts","../../echarts-gl.d.ts","../../geo-modules.d.ts","../../index.ts","../../plotly-dist.d.ts","../../types.ts","../../vitest.config.ts","../../atoms/editing-chart.atom.ts","../../atoms/pivot-chart.atom.ts","../../basic-chart/basic-chart.tsx","../../basic-chart/helpers.ts","../../basic-chart/index.tsx","../../components/dialogs/chart-editor-dialog.tsx","../../components/dialogs/pivot-chart-dialog.tsx","../../components/editors/chart-editor.tsx","../../components/editors/chart-range-input.tsx","../../hooks/use-chart-editor.ts","../../hooks/use-charts.ts","../../hooks/use-on-create-chart.ts","../../hooks/use-on-delete-chart.ts","../../hooks/use-on-move-chart-to-sheet.ts","../../hooks/use-on-move-chart.ts","../../hooks/use-on-resize-chart.ts","../../hooks/use-on-update-chart.ts","../../interface/create-chart.ts","../../interface/delete-chart.ts","../../interface/move-chart-to-sheet.ts","../../interface/move-chart.ts","../../interface/resize-chart.ts","../../interface/shift-chart-ranges.ts","../../interface/update-chart.ts","../../plotly/plot.ts","../../plotly/basic-chart/basic-chart.tsx","../../plotly/basic-chart/helpers.ts","../../plotly/basic-chart/index.tsx","../../utils/aggregation.ts","../../utils/axis-number-format.ts","../../utils/bar-layout.ts","../../utils/boxplot.ts","../../utils/bubble.ts","../../utils/category-levels.ts","../../utils/chart-image.ts","../../utils/chart-orientation.ts","../../utils/chart-spec-utils.ts","../../utils/chart-styles.ts","../../utils/doughnut.ts","../../utils/echarts-gl-loader.ts","../../utils/empty-cells.ts","../../utils/error-bars.ts","../../utils/gradient.ts","../../utils/hierarchy.ts","../../utils/histogram.ts","../../utils/legend-layout.ts","../../utils/of-pie.ts","../../utils/overrides.ts","../../utils/pie-explosion.ts","../../utils/plotly-click.ts","../../utils/plotly-surface.ts","../../utils/plotly-title.ts","../../utils/radar.ts","../../utils/region-map-loader.ts","../../utils/region-map.ts","../../utils/series-click.ts","../../utils/stock.ts","../../utils/three-d.ts","../../utils/trendline.ts","../../utils/waterfall.ts","../../utils/webgl.ts"],"version":"5.8.3"}
1
+ {"root":["../../config.ts","../../echarts-gl.d.ts","../../geo-modules.d.ts","../../index.ts","../../plotly-dist.d.ts","../../types.ts","../../vitest.config.ts","../../atoms/editing-chart.atom.ts","../../atoms/pivot-chart.atom.ts","../../basic-chart/basic-chart.tsx","../../basic-chart/helpers.ts","../../basic-chart/index.tsx","../../components/dialogs/chart-editor-dialog.tsx","../../components/dialogs/pivot-chart-dialog.tsx","../../components/editors/chart-editor.tsx","../../components/editors/chart-range-input.tsx","../../hooks/use-chart-editor.ts","../../hooks/use-charts.ts","../../hooks/use-on-create-chart.ts","../../hooks/use-on-delete-chart.ts","../../hooks/use-on-move-chart-to-sheet.ts","../../hooks/use-on-move-chart.ts","../../hooks/use-on-resize-chart.ts","../../hooks/use-on-update-chart.ts","../../interface/create-chart.ts","../../interface/delete-chart.ts","../../interface/move-chart-to-sheet.ts","../../interface/move-chart.ts","../../interface/resize-chart.ts","../../interface/shift-chart-ranges.ts","../../interface/update-chart.ts","../../plotly/plot.ts","../../plotly/basic-chart/basic-chart.tsx","../../plotly/basic-chart/helpers.ts","../../plotly/basic-chart/index.tsx","../../utils/aggregation.ts","../../utils/axis-number-format.ts","../../utils/bar-layout.ts","../../utils/boxplot.ts","../../utils/bubble.ts","../../utils/category-levels.ts","../../utils/chart-image.ts","../../utils/chart-orientation.ts","../../utils/chart-spec-utils.ts","../../utils/chart-styles.ts","../../utils/doughnut.ts","../../utils/echarts-gl-loader.ts","../../utils/echarts-overlays.ts","../../utils/empty-cells.ts","../../utils/error-bars.ts","../../utils/gradient.ts","../../utils/hierarchy.ts","../../utils/histogram.ts","../../utils/legend-layout.ts","../../utils/of-pie.ts","../../utils/overrides.ts","../../utils/pie-explosion.ts","../../utils/plotly-click.ts","../../utils/plotly-surface.ts","../../utils/plotly-title.ts","../../utils/radar.ts","../../utils/region-map-loader.ts","../../utils/region-map.ts","../../utils/series-click.ts","../../utils/stock.ts","../../utils/three-d.ts","../../utils/trendline.ts","../../utils/waterfall.ts","../../utils/webgl.ts"],"version":"5.8.3"}
@@ -1,6 +1,33 @@
1
1
  export declare const toLabelString: (value: unknown) => string;
2
2
  export declare const toNumericValue: (value: unknown) => number | null;
3
- export declare const createBubbleSizeScale: (values: number[]) => (value: number) => number;
3
+ export type BubbleSizeOptions = {
4
+ /**
5
+ * Whether a size value sets the bubble's area (Excel's default,
6
+ * diameter ∝ √value) or its width (diameter ∝ value).
7
+ */
8
+ sizeRepresents?: "area" | "width" | null;
9
+ /** Percent of the default size, 0-300 (Excel's `<c:bubbleScale>`). */
10
+ bubbleScale?: number | null;
11
+ /**
12
+ * The plot area's smaller side in pixels — the largest bubble's
13
+ * diameter is a fraction of it, so bubbles grow with the chart.
14
+ */
15
+ plotMinSide?: number | null;
16
+ };
17
+ /** The largest bubble's diameter at bubbleScale 100: a quarter of the plot area's smaller side. */
18
+ export declare const BUBBLE_MAX_DIAMETER_FRACTION = 0.25;
19
+ /**
20
+ * Pixel diameter per size value, scaled from ZERO like Excel: the largest
21
+ * absolute value gets the maximum diameter and every other bubble's area
22
+ * (or width) is its share of that value. Scaling from the minimum value
23
+ * instead made the ratio between bubbles depend on the spread of the
24
+ * data (100 and 101 drew as the smallest and largest bubble), and a
25
+ * linear diameter made the perceived area grow with the square of the
26
+ * value (rowsncolumns/spreadsheet#1068).
27
+ */
28
+ export declare const createBubbleSizeScale: (values: number[], options?: BubbleSizeOptions) => (value: number) => number;
29
+ /** The diameter of the largest bubble for these options. */
30
+ export declare const bubbleMaxDiameter: (options?: BubbleSizeOptions) => number;
4
31
  export type BubbleSeriesInput = {
5
32
  name?: string | null;
6
33
  values: (string | number | boolean | null | undefined)[];
@@ -23,6 +50,12 @@ export type BubbleSeriesPoint = {
23
50
  value: [number, number, number];
24
51
  name: string;
25
52
  xLabel?: string;
53
+ /**
54
+ * The point's row in the source ranges. Points with no Y are skipped,
55
+ * so this is not the point's position in the series — per-point
56
+ * colours (`dataPointColors[].idx`) key on it.
57
+ */
58
+ index: number;
26
59
  };
27
60
  export type PreparedBubbleSeries = {
28
61
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"bubble.d.ts","sourceRoot":"","sources":["../../../utils/bubble.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,MACU,CAAC;AAE1D,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,MAAM,GAAG,IAYxD,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,EAAE,aAQrC,MAAM,WAOtB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GA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AAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,EAAE,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;;OAKG;IACH,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;IAC1D,WAAW,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;IAC9D;;OAEG;IACH,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;IAC7D,MAAM,EAAE,iBAAiB,EAAE,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAwCF,eAAO,MAAM,uBAAuB,GAAI,+CAKrC,uBAAuB,KAAG,kBAuF5B,CAAC"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareBubbleSeriesData = exports.createBubbleSizeScale = exports.toNumericValue = exports.toLabelString = void 0;
4
- var tslib_1 = require("tslib");
3
+ exports.prepareBubbleSeriesData = exports.bubbleMaxDiameter = exports.createBubbleSizeScale = exports.BUBBLE_MAX_DIAMETER_FRACTION = exports.toNumericValue = exports.toLabelString = void 0;
5
4
  var toLabelString = function (value) {
6
5
  return value === null || value === undefined ? "" : "".concat(value);
7
6
  };
@@ -20,23 +19,49 @@ var toNumericValue = function (value) {
20
19
  return null;
21
20
  };
22
21
  exports.toNumericValue = toNumericValue;
23
- var createBubbleSizeScale = function (values) {
22
+ /** The largest bubble's diameter at bubbleScale 100: a quarter of the plot area's smaller side. */
23
+ exports.BUBBLE_MAX_DIAMETER_FRACTION = 0.25;
24
+ /** Fallback plot side when the chart has no measured size yet. */
25
+ var DEFAULT_PLOT_MIN_SIDE = 240;
26
+ /** A positive size never collapses below this diameter. */
27
+ var MIN_BUBBLE_DIAMETER = 2;
28
+ /**
29
+ * Pixel diameter per size value, scaled from ZERO like Excel: the largest
30
+ * absolute value gets the maximum diameter and every other bubble's area
31
+ * (or width) is its share of that value. Scaling from the minimum value
32
+ * instead made the ratio between bubbles depend on the spread of the
33
+ * data (100 and 101 drew as the smallest and largest bubble), and a
34
+ * linear diameter made the perceived area grow with the square of the
35
+ * value (rowsncolumns/spreadsheet#1068).
36
+ */
37
+ var createBubbleSizeScale = function (values, options) {
38
+ if (options === void 0) { options = {}; }
39
+ var maxDiameter = (0, exports.bubbleMaxDiameter)(options);
24
40
  var valid = values.filter(function (value) { return Number.isFinite(value); });
25
- if (valid.length === 0) {
26
- return function () { return 24; };
27
- }
28
- var min = Math.min.apply(Math, tslib_1.__spreadArray([], tslib_1.__read(valid), false));
29
- var max = Math.max.apply(Math, tslib_1.__spreadArray([], tslib_1.__read(valid), false));
30
- var range = max - min || 1;
41
+ var maxAbs = valid.reduce(function (max, value) { return Math.max(max, Math.abs(value)); }, 0);
42
+ var byWidth = options.sizeRepresents === "width";
31
43
  return function (value) {
32
- if (!Number.isFinite(value)) {
33
- return 24;
44
+ if (!Number.isFinite(value) || maxAbs === 0) {
45
+ return maxDiameter;
34
46
  }
35
- var ratio = (value - min) / range;
36
- return 12 + ratio * 42;
47
+ var share = Math.abs(value) / maxAbs;
48
+ var diameter = maxDiameter * (byWidth ? share : Math.sqrt(share));
49
+ return share > 0 ? Math.max(MIN_BUBBLE_DIAMETER, diameter) : 0;
37
50
  };
38
51
  };
39
52
  exports.createBubbleSizeScale = createBubbleSizeScale;
53
+ /** The diameter of the largest bubble for these options. */
54
+ var bubbleMaxDiameter = function (options) {
55
+ if (options === void 0) { options = {}; }
56
+ var plotMinSide = typeof options.plotMinSide === "number" && options.plotMinSide > 0
57
+ ? options.plotMinSide
58
+ : DEFAULT_PLOT_MIN_SIDE;
59
+ var scale = typeof options.bubbleScale === "number" && Number.isFinite(options.bubbleScale)
60
+ ? Math.min(300, Math.max(0, options.bubbleScale)) / 100
61
+ : 1;
62
+ return plotMinSide * exports.BUBBLE_MAX_DIAMETER_FRACTION * scale;
63
+ };
64
+ exports.bubbleMaxDiameter = bubbleMaxDiameter;
40
65
  /**
41
66
  * Build the X-coordinate index for a series. Numeric values map to
42
67
  * their own coordinate; string values become categorical (deduped into
@@ -123,6 +148,7 @@ var prepareBubbleSeriesData = function (_a) {
123
148
  value: [coordinate.coordinate, y, sizeValue],
124
149
  name: label,
125
150
  xLabel: coordinateLabel,
151
+ index: i,
126
152
  });
127
153
  }
128
154
  var name = serie.name && serie.name.trim()
@@ -0,0 +1,46 @@
1
+ type OverlaySeriesSpec = {
2
+ color?: string | null;
3
+ useSecondaryAxis?: boolean | null;
4
+ trendlines?: Array<{
5
+ type?: any;
6
+ order?: number | null;
7
+ period?: number | null;
8
+ name?: string | null;
9
+ color?: string | null;
10
+ forecastForward?: number | null;
11
+ forecastBackward?: number | null;
12
+ }> | null;
13
+ errorBars?: {
14
+ direction?: "x" | "y" | null;
15
+ barType?: "both" | "plus" | "minus" | null;
16
+ valueType?: any;
17
+ value?: number | null;
18
+ noEndCap?: boolean | null;
19
+ plusRange?: any;
20
+ minusRange?: any;
21
+ } | null;
22
+ };
23
+ export type EchartsOverlayOptions<TRange = unknown> = {
24
+ series: OverlaySeriesSpec;
25
+ /** The series' values (Y on an XY chart), index-aligned with `xValues`. */
26
+ values: (number | null | undefined)[];
27
+ /**
28
+ * Scatter / bubble: the real X coordinate per point. Omitted for a
29
+ * category chart, where the point index is the category coordinate.
30
+ */
31
+ xValues?: (number | null | undefined)[] | null;
32
+ /** Horizontal bar: the category index is the y coordinate. */
33
+ horizontal?: boolean;
34
+ dataLabel: string;
35
+ /** The data series' own colour — overlays default to it. */
36
+ seriesColor: string;
37
+ /** Reads a custom error bar's plus / minus range. */
38
+ resolveRange: (range: TRange) => unknown[] | null | undefined;
39
+ };
40
+ /**
41
+ * Build the overlay series for one data series. Returns an empty array
42
+ * when the series has neither trendlines nor error bars.
43
+ */
44
+ export declare const buildEchartsOverlaySeries: <TRange = unknown>({ series, values, xValues, horizontal, dataLabel, seriesColor, resolveRange, }: EchartsOverlayOptions<TRange>) => any[];
45
+ export {};
46
+ //# sourceMappingURL=echarts-overlays.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"echarts-overlays.d.ts","sourceRoot":"","sources":["../../../utils/echarts-overlays.ts"],"names":[],"mappings":"AAkBA,KAAK,iBAAiB,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAClC,UAAU,CAAC,EACP,KAAK,CAAC;QACJ,IAAI,CAAC,EAAE,GAAG,CAAC;QACX,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAChC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAClC,CAAC,GACF,IAAI,CAAC;IACT,SAAS,CAAC,EAAE;QACV,SAAS,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;QAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;QAC3C,SAAS,CAAC,EAAE,GAAG,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;QAC1B,SAAS,CAAC,EAAE,GAAG,CAAC;QAChB,UAAU,CAAC,EAAE,GAAG,CAAC;KAClB,GAAG,IAAI,CAAC;CACV,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,MAAM,GAAG,OAAO,IAAI;IACpD,MAAM,EAAE,iBAAiB,CAAC;IAC1B,2EAA2E;IAC3E,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC;IAC/C,8DAA8D;IAC9D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;CAC/D,CAAC;AAIF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,GAAI,MAAM,GAAG,OAAO,EAAE,gFAQzD,qBAAqB,CAAC,MAAM,CAAC,KAAG,GAAG,EA4HrC,CAAC"}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildEchartsOverlaySeries = void 0;
4
+ var tslib_1 = require("tslib");
5
+ /**
6
+ * Trendline and error-bar overlay series for the echarts renderer.
7
+ *
8
+ * One data series may carry trendlines (`<c:trendline>`) and error bars
9
+ * (`<c:errBars>`); both are drawn as extra echarts series appended after
10
+ * the data series. The same builder serves every cartesian layout:
11
+ *
12
+ * - category charts (line / column / area): the point index is the
13
+ * category coordinate, values sit on the value axis;
14
+ * - horizontal bars: the same, with the axes swapped — the category
15
+ * index is the y coordinate (rowsncolumns/spreadsheet#1061 drew the
16
+ * overlays on the swapped axes, outside the plot);
17
+ * - scatter / bubble: real (x, y) coordinates per point, and the
18
+ * trendline is a regression of Y on X (#1067).
19
+ */
20
+ var error_bars_1 = require("./error-bars");
21
+ var trendline_1 = require("./trendline");
22
+ var ERROR_BAR_CAP_HALF = 5;
23
+ /**
24
+ * Build the overlay series for one data series. Returns an empty array
25
+ * when the series has neither trendlines nor error bars.
26
+ */
27
+ var buildEchartsOverlaySeries = function (_a) {
28
+ var e_1, _b;
29
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l;
30
+ var series = _a.series, values = _a.values, xValues = _a.xValues, _m = _a.horizontal, horizontal = _m === void 0 ? false : _m, dataLabel = _a.dataLabel, seriesColor = _a.seriesColor, resolveRange = _a.resolveRange;
31
+ if (values.length === 0)
32
+ return [];
33
+ var overlays = [];
34
+ var isXY = Array.isArray(xValues);
35
+ var useSecondary = series.useSecondaryAxis ? { yAxisIndex: 1 } : {};
36
+ try {
37
+ // Trendlines — one overlay line series per spec.
38
+ for (var _o = tslib_1.__values((_c = series.trendlines) !== null && _c !== void 0 ? _c : []), _p = _o.next(); !_p.done; _p = _o.next()) {
39
+ var tl = _p.value;
40
+ var result = (0, trendline_1.computeTrendline)(values, {
41
+ type: tl.type,
42
+ order: tl.order,
43
+ period: tl.period,
44
+ forecastForward: tl.forecastForward,
45
+ forecastBackward: tl.forecastBackward,
46
+ }, isXY ? xValues : undefined);
47
+ if (!result || result.points.length < 2)
48
+ continue;
49
+ var tlName = (_d = tl.name) !== null && _d !== void 0 ? _d : "".concat(dataLabel ? dataLabel + " " : "").concat((_e = tl.type) !== null && _e !== void 0 ? _e : "linear", " trend");
50
+ overlays.push(tslib_1.__assign({ type: "line", name: tlName,
51
+ // On a category chart the index x overlays the category axis even
52
+ // when forecasting extends beyond the data range; a horizontal bar
53
+ // keeps its categories on y.
54
+ data: result.points.map(function (p) { return (horizontal ? [p.y, p.x] : [p.x, p.y]); }), showSymbol: false, smooth: tl.type === "poly", lineStyle: {
55
+ color: (_f = tl.color) !== null && _f !== void 0 ? _f : seriesColor,
56
+ type: "dashed",
57
+ width: 2,
58
+ }, itemStyle: { color: (_g = tl.color) !== null && _g !== void 0 ? _g : seriesColor }, tooltip: { show: false }, z: 5 }, useSecondary));
59
+ }
60
+ }
61
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
62
+ finally {
63
+ try {
64
+ if (_p && !_p.done && (_b = _o.return)) _b.call(_o);
65
+ }
66
+ finally { if (e_1) throw e_1.error; }
67
+ }
68
+ // Error bars — a custom series of whiskers. valueType "custom" reads
69
+ // per-point magnitudes from the spec's plus/minus ranges, resolved
70
+ // through the same extractor the series values use.
71
+ if (series.errorBars) {
72
+ var direction = (_h = series.errorBars.direction) !== null && _h !== void 0 ? _h : "y";
73
+ // An X error bar on an XY chart sizes from the X values (a percentage
74
+ // or deviation of X); a category chart has only value-axis bars, so a
75
+ // horizontal bar's whisker runs along x whatever the direction says.
76
+ var alongX_1 = isXY ? direction === "x" : horizontal || direction === "x";
77
+ var magnitudeSource = isXY && alongX_1 ? xValues : values;
78
+ var magnitudes = (0, error_bars_1.computeErrorBars)(magnitudeSource, (0, error_bars_1.resolveCustomErrorBarValues)(series.errorBars, resolveRange));
79
+ if (magnitudes) {
80
+ var noEndCap_1 = (_j = series.errorBars.noEndCap) !== null && _j !== void 0 ? _j : false;
81
+ var errorData = [];
82
+ for (var i = 0; i < values.length; i++) {
83
+ var v = values[i];
84
+ var y = typeof v === "number" && Number.isFinite(v) ? v : null;
85
+ var x = isXY ? xValues === null || xValues === void 0 ? void 0 : xValues[i] : i;
86
+ if (y === null || typeof x !== "number" || !Number.isFinite(x)) {
87
+ continue;
88
+ }
89
+ // [a, b] is the point's (x, y) data coordinate; a horizontal bar
90
+ // keeps its value on x and its category on y.
91
+ var _q = tslib_1.__read(!isXY && horizontal ? [y, x] : [x, y], 2), a = _q[0], b = _q[1];
92
+ errorData.push([a, b, (_k = magnitudes.plus[i]) !== null && _k !== void 0 ? _k : 0, (_l = magnitudes.minus[i]) !== null && _l !== void 0 ? _l : 0]);
93
+ }
94
+ overlays.push(tslib_1.__assign(tslib_1.__assign({ type: "custom", name: "".concat(dataLabel ? dataLabel + " " : "", "error"), data: errorData, z: 6, tooltip: { show: false } }, useSecondary), { renderItem: function (_params, api) {
95
+ var a = api.value(0);
96
+ var b = api.value(1);
97
+ var plus = api.value(2);
98
+ var minus = api.value(3);
99
+ var center = api.coord([a, b]);
100
+ var hi = alongX_1 ? api.coord([a + plus, b]) : api.coord([a, b + plus]);
101
+ var lo = alongX_1 ? api.coord([a - minus, b]) : api.coord([a, b - minus]);
102
+ var stroke = { stroke: seriesColor, lineWidth: 1 };
103
+ var children = [
104
+ {
105
+ type: "line",
106
+ shape: alongX_1
107
+ ? { x1: lo[0], y1: center[1], x2: hi[0], y2: center[1] }
108
+ : { x1: center[0], y1: lo[1], x2: center[0], y2: hi[1] },
109
+ style: stroke,
110
+ },
111
+ ];
112
+ if (!noEndCap_1) {
113
+ var cap = ERROR_BAR_CAP_HALF;
114
+ children.push({
115
+ type: "line",
116
+ shape: alongX_1
117
+ ? { x1: hi[0], y1: center[1] - cap, x2: hi[0], y2: center[1] + cap }
118
+ : { x1: center[0] - cap, y1: hi[1], x2: center[0] + cap, y2: hi[1] },
119
+ style: stroke,
120
+ }, {
121
+ type: "line",
122
+ shape: alongX_1
123
+ ? { x1: lo[0], y1: center[1] - cap, x2: lo[0], y2: center[1] + cap }
124
+ : { x1: center[0] - cap, y1: lo[1], x2: center[0] + cap, y2: lo[1] },
125
+ style: stroke,
126
+ });
127
+ }
128
+ return { type: "group", children: children };
129
+ } }));
130
+ }
131
+ }
132
+ return overlays;
133
+ };
134
+ exports.buildEchartsOverlaySeries = buildEchartsOverlaySeries;
@@ -1,12 +1,21 @@
1
1
  import type { ChartSpec, SheetRange, TreemapChart } from "@rowsncolumns/spreadsheet";
2
2
  type Extractor = (range: SheetRange, hiddenStrategy?: ChartSpec["hiddenDimensionStrategy"]) => (string | number | boolean | null | undefined)[];
3
3
  export type HierarchyRow = {
4
+ /** The node this row defines — the innermost filled level cell. */
4
5
  label: string;
6
+ /** The immediate parent (the last entry of `path`), null for a root. */
5
7
  parent: string | null;
6
8
  value: number | null;
9
+ /**
10
+ * The level names above the node, top level first, after Excel's
11
+ * fill-down of blank level cells. Absent on a legacy adjacency row
12
+ * (`parent` alone, naming another row's label).
13
+ */
14
+ path?: string[];
7
15
  };
8
16
  export type HierarchyNode = {
9
17
  name: string;
18
+ /** Unique within the tree: the node's path joined with "/". */
10
19
  id?: string;
11
20
  value?: number | null;
12
21
  children?: HierarchyNode[];
@@ -19,10 +28,23 @@ type ExtractOptions = {
19
28
  export declare const getHierarchyHeaderTitle: (spec: TreemapChart, options: ExtractOptions) => string | undefined;
20
29
  export declare const extractHierarchyRows: (spec: TreemapChart, options: ExtractOptions) => HierarchyRow[];
21
30
  export declare const buildHierarchyTree: (rows: HierarchyRow[]) => HierarchyNode[];
22
- export declare const toPlotlyHierarchy: (rows: HierarchyRow[]) => {
31
+ export type PlotlyHierarchy = {
32
+ /** Node names, as drawn. */
23
33
  labels: string[];
34
+ /** Unique node ids (the path joined with "/"); `parents` reference these. */
35
+ ids: string[];
36
+ /** Parent id per node, "" for a root. */
24
37
  parents: string[];
25
38
  values: number[];
39
+ /** Depth per node, 0 for a root. */
40
+ depths: number[];
26
41
  };
42
+ export declare const toPlotlyHierarchy: (rows: HierarchyRow[]) => PlotlyHierarchy;
43
+ /**
44
+ * One solid colour per top-level category, inherited by every descendant
45
+ * (Excel colours a treemap / sunburst by its first level), in tree order.
46
+ * Returns the colour per node of `toPlotlyHierarchy`'s flat arrays.
47
+ */
48
+ export declare const hierarchyNodeColors: (hierarchy: Pick<PlotlyHierarchy, "ids" | "parents">, palette: string[]) => string[];
27
49
  export {};
28
50
  //# sourceMappingURL=hierarchy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hierarchy.d.ts","sourceRoot":"","sources":["../../../utils/hierarchy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EACT,UAAU,EACV,YAAY,EACb,MAAM,2BAA2B,CAAC;AAEnC,KAAK,SAAS,GAAG,CACf,KAAK,EAAE,UAAU,EACjB,cAAc,CAAC,EAAE,SAAS,CAAC,yBAAyB,CAAC,KAClD,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,wBAAwB,EAAE,SAAS,CAAC;IACpC,wBAAwB,EAAE,SAAS,CAAC;IACpC,uBAAuB,CAAC,EAAE,SAAS,CAAC,yBAAyB,CAAC,CAAC;CAChE,CAAC;AA+CF,eAAO,MAAM,uBAAuB,GAClC,MAAM,YAAY,EAClB,SAAS,cAAc,KACtB,MAAM,GAAG,SAgBX,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,MAAM,YAAY,EAClB,SAAS,cAAc,KACtB,YAAY,EAyCd,CAAC;AAyBF,eAAO,MAAM,kBAAkB,GAAI,MAAM,YAAY,EAAE,KAAG,aAAa,EAoDtE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,MAAM,YAAY,EAAE;;;;CAoBrD,CAAC"}
1
+ {"version":3,"file":"hierarchy.d.ts","sourceRoot":"","sources":["../../../utils/hierarchy.ts"],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