@rowsncolumns/charts 28.1.2 → 28.1.4

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 (35) hide show
  1. package/dist/cjs/basic-chart/basic-chart.d.ts.map +1 -1
  2. package/dist/cjs/basic-chart/basic-chart.js +138 -76
  3. package/dist/cjs/basic-chart/helpers.d.ts +9 -0
  4. package/dist/cjs/basic-chart/helpers.d.ts.map +1 -1
  5. package/dist/cjs/basic-chart/helpers.js +55 -1
  6. package/dist/cjs/plotly/basic-chart/basic-chart.d.ts.map +1 -1
  7. package/dist/cjs/plotly/basic-chart/basic-chart.js +218 -128
  8. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  9. package/dist/cjs/utils/axis-number-format.d.ts +14 -0
  10. package/dist/cjs/utils/axis-number-format.d.ts.map +1 -1
  11. package/dist/cjs/utils/axis-number-format.js +41 -1
  12. package/dist/cjs/utils/empty-cells.d.ts +9 -0
  13. package/dist/cjs/utils/empty-cells.d.ts.map +1 -1
  14. package/dist/cjs/utils/empty-cells.js +26 -1
  15. package/dist/cjs/utils/legend-layout.d.ts +168 -0
  16. package/dist/cjs/utils/legend-layout.d.ts.map +1 -0
  17. package/dist/cjs/utils/legend-layout.js +338 -0
  18. package/dist/esm/basic-chart/basic-chart.d.ts.map +1 -1
  19. package/dist/esm/basic-chart/basic-chart.js +96 -34
  20. package/dist/esm/basic-chart/helpers.d.ts +9 -0
  21. package/dist/esm/basic-chart/helpers.d.ts.map +1 -1
  22. package/dist/esm/basic-chart/helpers.js +30 -0
  23. package/dist/esm/plotly/basic-chart/basic-chart.d.ts.map +1 -1
  24. package/dist/esm/plotly/basic-chart/basic-chart.js +136 -6
  25. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  26. package/dist/esm/utils/axis-number-format.d.ts +14 -0
  27. package/dist/esm/utils/axis-number-format.d.ts.map +1 -1
  28. package/dist/esm/utils/axis-number-format.js +36 -0
  29. package/dist/esm/utils/empty-cells.d.ts +9 -0
  30. package/dist/esm/utils/empty-cells.d.ts.map +1 -1
  31. package/dist/esm/utils/empty-cells.js +21 -0
  32. package/dist/esm/utils/legend-layout.d.ts +168 -0
  33. package/dist/esm/utils/legend-layout.d.ts.map +1 -0
  34. package/dist/esm/utils/legend-layout.js +299 -0
  35. package/package.json +7 -7
@@ -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/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/echarts-gl-loader.ts","../../utils/empty-cells.ts","../../utils/error-bars.ts","../../utils/gradient.ts","../../utils/hierarchy.ts","../../utils/histogram.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/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/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"}
@@ -65,5 +65,19 @@ export type PlotlyTickFormat = {
65
65
  * section is used — plotly applies one format to every tick.
66
66
  */
67
67
  export declare const numberFormatToPlotlyTicks: (pattern: string | undefined) => PlotlyTickFormat | undefined;
68
+ /**
69
+ * echarts `nameGap` for a value axis whose title sits in the middle, rotated
70
+ * beside the tick labels. The gap is the distance from the axis line to the
71
+ * title's centre, so it must clear the tick labels' full width: the labels
72
+ * ("$2,000.00", "1,500,000") are formatted from the plotted extremes and
73
+ * measured; the fixed default of 50px only fits labels up to ~4 digits and
74
+ * lets a currency axis title paint over its own tick labels.
75
+ */
76
+ export declare const valueAxisNameGap: ({ values, pattern, fontSize, minimum, }: {
77
+ values: readonly unknown[];
78
+ pattern: string | undefined;
79
+ fontSize?: number;
80
+ minimum?: number;
81
+ }) => number;
68
82
  export {};
69
83
  //# sourceMappingURL=axis-number-format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"axis-number-format.d.ts","sourceRoot":"","sources":["../../../utils/axis-number-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,yBAAyB,EACzB,KAAK,EACL,UAAU,EACX,MAAM,2BAA2B,CAAC;AAWnC,KAAK,iBAAiB,GAAG,CACvB,UAAU,EAAE,UAAU,EACtB,uBAAuB,CAAC,EAAE,yBAAyB,KAChD,OAAO,EAAE,CAAC;AAMf;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,YAGjC,CAAC;AAExC;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,GACpC,SAAS,UAAU,EAAE,GAAG,SAAS,EACjC,wBAAwB,iBAAiB,GAAG,SAAS,EACrD,0BAA0B,yBAAyB,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
3
- exports.numberFormatToPlotlyTicks = exports.circularTooltipFormatter = exports.resolveSeriesNumberFormats = exports.tooltipValueFormatter = exports.valueAxisLabelFormatter = exports.formatAxisValue = exports.resolveValueAxisNumberFormat = exports.resolveSourceNumberFormat = exports.isGeneralNumberFormat = void 0;
3
+ exports.valueAxisNameGap = exports.numberFormatToPlotlyTicks = exports.circularTooltipFormatter = exports.resolveSeriesNumberFormats = exports.tooltipValueFormatter = exports.valueAxisLabelFormatter = exports.formatAxisValue = exports.resolveValueAxisNumberFormat = exports.resolveSourceNumberFormat = exports.isGeneralNumberFormat = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var utils_1 = require("@rowsncolumns/utils");
6
6
  var patternOf = function (format) {
@@ -215,3 +215,43 @@ var firstSection = function (pattern) {
215
215
  }
216
216
  return pattern;
217
217
  };
218
+ /** Approximate rendered width of an axis tick label in px at `fontSize` (canvas when available). */
219
+ var measureLabelWidth = function (text, fontSize) {
220
+ if (typeof document !== "undefined") {
221
+ var ctx = document.createElement("canvas").getContext("2d");
222
+ if (ctx) {
223
+ ctx.font = "".concat(fontSize, "px sans-serif");
224
+ var width = ctx.measureText(text).width;
225
+ if (Number.isFinite(width) && width > 0)
226
+ return width;
227
+ }
228
+ }
229
+ // Headless fallback: ~0.6em per character (digits / punctuation heavy).
230
+ return text.length * fontSize * 0.6;
231
+ };
232
+ /**
233
+ * echarts `nameGap` for a value axis whose title sits in the middle, rotated
234
+ * beside the tick labels. The gap is the distance from the axis line to the
235
+ * title's centre, so it must clear the tick labels' full width: the labels
236
+ * ("$2,000.00", "1,500,000") are formatted from the plotted extremes and
237
+ * measured; the fixed default of 50px only fits labels up to ~4 digits and
238
+ * lets a currency axis title paint over its own tick labels.
239
+ */
240
+ var valueAxisNameGap = function (_a) {
241
+ var values = _a.values, pattern = _a.pattern, _b = _a.fontSize, fontSize = _b === void 0 ? 12 : _b, _c = _a.minimum, minimum = _c === void 0 ? 50 : _c;
242
+ var numbers = values.filter(function (v) { return typeof v === "number" && Number.isFinite(v); });
243
+ if (!numbers.length)
244
+ return minimum;
245
+ var min = Math.min.apply(Math, tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(numbers), false), [0], false));
246
+ var max = Math.max.apply(Math, tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(numbers), false), [0], false));
247
+ // echarts' default axis label puts thousands separators on plain numbers.
248
+ var defaultLabel = function (v) { return v.toLocaleString("en-US"); };
249
+ var labels = [min, max].map(function (v) {
250
+ return pattern ? (0, exports.formatAxisValue)(pattern, v) : defaultLabel(v);
251
+ });
252
+ var widest = Math.max.apply(Math, tslib_1.__spreadArray([], tslib_1.__read(labels.map(function (l) { return measureLabelWidth(l, fontSize); })), false));
253
+ // 8px tick-label margin + the rotated title's own line box + breathing room.
254
+ var AXIS_LABEL_MARGIN = 8;
255
+ return Math.max(minimum, Math.ceil(widest + AXIS_LABEL_MARGIN + fontSize + 6));
256
+ };
257
+ exports.valueAxisNameGap = valueAxisNameGap;
@@ -26,5 +26,14 @@ export declare const connectsAcrossEmptyCells: (spec: EmptyCellsSpec, lineLike:
26
26
  * pre-2016 #N/A behaviour), and any other series leaves a gap.
27
27
  */
28
28
  export declare const applyEmptyCellsPolicy: (values: readonly (number | null | undefined)[], rawValues: readonly unknown[], spec: EmptyCellsSpec, lineLike: boolean) => (number | null)[];
29
+ /**
30
+ * Indexes of the plotted points that have no plottable neighbour to draw a
31
+ * line segment to — a value between two gaps (or at an edge next to a gap).
32
+ * A line-only series (no markers) draws nothing for them, so a row of data
33
+ * followed by a blank row vanishes from the chart; Excel still plots an
34
+ * isolated marker there. When the series connects across gaps every point
35
+ * links to the next plotted one, so only a lone single point is isolated.
36
+ */
37
+ export declare const isolatedPointIndexes: (values: readonly (number | null | undefined)[], connectAcrossGaps?: boolean) => number[];
29
38
  export {};
30
39
  //# sourceMappingURL=empty-cells.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"empty-cells.d.ts","sourceRoot":"","sources":["../../../utils/empty-cells.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,KAAK,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAEvC,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;AAEpE,KAAK,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,YAAY,GAAG,eAAe,CAAC,CAAC;AAetE,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,OACuB,CAAC;AAE3E,gCAAgC;AAChC,eAAO,MAAM,mBAAmB,GAAI,MAAM,cAAc,KAAG,gBAChC,CAAC;AAE5B,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,GAC9B,WAAW,SAAS,CAAC,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,KACnD,OAAuD,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACnC,MAAM,cAAc,EACpB,UAAU,OAAO,KAChB,OAA8D,CAAC;AAElE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EAC9C,WAAW,SAAS,OAAO,EAAE,EAC7B,MAAM,cAAc,EACpB,UAAU,OAAO,KAChB,CAAC,MAAM,GAAG,IAAI,CAAC,EA4BjB,CAAC"}
1
+ {"version":3,"file":"empty-cells.d.ts","sourceRoot":"","sources":["../../../utils/empty-cells.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,KAAK,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAEvC,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;AAEpE,KAAK,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,YAAY,GAAG,eAAe,CAAC,CAAC;AAetE,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,OACuB,CAAC;AAE3E,gCAAgC;AAChC,eAAO,MAAM,mBAAmB,GAAI,MAAM,cAAc,KAAG,gBAChC,CAAC;AAE5B,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,GAC9B,WAAW,SAAS,CAAC,WAAW,CAAC,GAAG,IAAI,GAAG,SAAS,KACnD,OAAuD,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACnC,MAAM,cAAc,EACpB,UAAU,OAAO,KAChB,OAA8D,CAAC;AAElE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EAC9C,WAAW,SAAS,OAAO,EAAE,EAC7B,MAAM,cAAc,EACpB,UAAU,OAAO,KAChB,CAAC,MAAM,GAAG,IAAI,CAAC,EA4BjB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EAC9C,2BAAyB,KACxB,MAAM,EAYR,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyEmptyCellsPolicy = exports.connectsAcrossEmptyCells = exports.isLineLikeChartType = exports.getEmptyCellsPolicy = exports.isChartErrorValue = void 0;
3
+ exports.isolatedPointIndexes = exports.applyEmptyCellsPolicy = exports.connectsAcrossEmptyCells = exports.isLineLikeChartType = exports.getEmptyCellsPolicy = exports.isChartErrorValue = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var CHART_ERROR_VALUES = new Set([
6
6
  "#N/A",
@@ -89,3 +89,28 @@ var applyEmptyCellsPolicy = function (values, rawValues, spec, lineLike) {
89
89
  return plotted;
90
90
  };
91
91
  exports.applyEmptyCellsPolicy = applyEmptyCellsPolicy;
92
+ /**
93
+ * Indexes of the plotted points that have no plottable neighbour to draw a
94
+ * line segment to — a value between two gaps (or at an edge next to a gap).
95
+ * A line-only series (no markers) draws nothing for them, so a row of data
96
+ * followed by a blank row vanishes from the chart; Excel still plots an
97
+ * isolated marker there. When the series connects across gaps every point
98
+ * links to the next plotted one, so only a lone single point is isolated.
99
+ */
100
+ var isolatedPointIndexes = function (values, connectAcrossGaps) {
101
+ if (connectAcrossGaps === void 0) { connectAcrossGaps = false; }
102
+ var plotted = function (i) {
103
+ return i >= 0 && i < values.length && typeof values[i] === "number";
104
+ };
105
+ var indexes = [];
106
+ if (connectAcrossGaps) {
107
+ var all = values.flatMap(function (_, i) { return (plotted(i) ? [i] : []); });
108
+ return all.length === 1 ? all : [];
109
+ }
110
+ for (var i = 0; i < values.length; i++) {
111
+ if (plotted(i) && !plotted(i - 1) && !plotted(i + 1))
112
+ indexes.push(i);
113
+ }
114
+ return indexes;
115
+ };
116
+ exports.isolatedPointIndexes = isolatedPointIndexes;
@@ -0,0 +1,168 @@
1
+ export type LegendBandPosition = "top" | "bottom" | "left" | "right" | "topRight" | "none";
2
+ /** Space kept between neighbouring bands (legend ↔ axis title ↔ labels). */
3
+ export declare const BAND_GAP = 8;
4
+ /** Inset of the outermost band from the chart frame. */
5
+ export declare const EDGE_PAD = 10;
6
+ /** echarts `legend.padding` default used by both adapters' legend boxes. */
7
+ export declare const LEGEND_PADDING = 10;
8
+ /** echarts `legend.itemGap` default. */
9
+ export declare const LEGEND_ITEM_GAP = 10;
10
+ /** Approximate rendered width of `text` at `fontSize` (canvas when available). */
11
+ export declare const measureTextWidth: (text: string, fontSize: number) => number;
12
+ export type LegendBandInput = {
13
+ /** Legend entry labels, one per item. */
14
+ labels: readonly string[];
15
+ /** Legend text size in px. */
16
+ fontSize?: number;
17
+ /** Legend icon width in px. */
18
+ itemWidth?: number;
19
+ /** Gap between items (and between wrapped rows / columns) in px. */
20
+ itemGap?: number;
21
+ /** Legend box padding in px (each side). */
22
+ padding?: number;
23
+ /** Horizontal (top / bottom) or vertical (left / right) item flow. */
24
+ orientation: "horizontal" | "vertical";
25
+ /** Frame width available to a horizontal legend before it wraps. */
26
+ availableWidth: number;
27
+ /** Frame height available to a vertical legend before it wraps. */
28
+ availableHeight: number;
29
+ };
30
+ export type LegendBand = {
31
+ /** Rows of items (horizontal legends wrap long series lists). */
32
+ rows: number;
33
+ /** Columns of items (vertical legends wrap when taller than the frame). */
34
+ columns: number;
35
+ /** Rendered width in px including padding. */
36
+ width: number;
37
+ /** Rendered height in px including padding. */
38
+ height: number;
39
+ };
40
+ /**
41
+ * Estimate the legend's rendered box from its items. Horizontal legends
42
+ * pack items greedily into rows no wider than the frame; vertical legends
43
+ * stack items and spill into a new column when taller than the frame.
44
+ */
45
+ export declare const estimateLegendBand: ({ labels, fontSize, itemWidth, itemGap, padding, orientation, availableWidth, availableHeight, }: LegendBandInput) => LegendBand;
46
+ /**
47
+ * Pull the legend entry labels out of an echarts `legend.data` (strings or
48
+ * `{ name }` items); falls back to the series names, which is what echarts
49
+ * itself lists when `data` is empty.
50
+ */
51
+ export declare const legendLabelsFrom: (legendData: readonly unknown[] | undefined, seriesNames: readonly unknown[]) => string[];
52
+ /**
53
+ * Depth (px) of one row of echarts axis tick labels measured from the axis
54
+ * line: 5px tick + 8px label margin + one 12px line, rounded up. With
55
+ * `grid.containLabel` this is the part the grid already accounts for; the
56
+ * axis title sits beyond it.
57
+ */
58
+ export declare const echartsAxisLabelDepth: (fontSize?: number) => number;
59
+ /**
60
+ * echarts `nameGap` for a category axis whose title sits in the middle
61
+ * below the tick labels: clear one row of labels plus a small gap, measured
62
+ * to the title's centre line.
63
+ */
64
+ export declare const categoryAxisNameGap: (fontSize?: number) => number;
65
+ /** Height of the echarts chart-title band (padding 10 each side + one line). */
66
+ export declare const echartsTitleBand: (titleFontSize?: number) => number;
67
+ export type EchartsLegendBandInput = {
68
+ /** Resolved legend position (`undefined` = echarts default: top). */
69
+ position: LegendBandPosition | null | undefined;
70
+ /** Whether the legend renders at all (`show !== false` and has items). */
71
+ visible: boolean;
72
+ labels: readonly string[];
73
+ legendFontSize?: number;
74
+ legendItemWidth?: number;
75
+ width: number;
76
+ height: number;
77
+ /** A chart title is drawn across the top. */
78
+ hasTitle: boolean;
79
+ titleFontSize?: number;
80
+ /** The bottom axis carries a title (`name`). */
81
+ hasBottomAxisTitle: boolean;
82
+ /** `nameGap` used for the bottom axis title (px from axis line to title centre). */
83
+ bottomAxisNameGap: number;
84
+ /** The left axis carries a title (`name`). */
85
+ hasLeftAxisTitle: boolean;
86
+ axisFontSize?: number;
87
+ };
88
+ export type EchartsLegendBandLayout = {
89
+ band: LegendBand;
90
+ grid: {
91
+ left: number;
92
+ right: number;
93
+ top: number;
94
+ bottom: number;
95
+ containLabel: true;
96
+ };
97
+ /** Legend placement to spread over the positioned legend option. */
98
+ legend: {
99
+ top?: number | string;
100
+ bottom?: number | string;
101
+ left?: number | string;
102
+ right?: number | string;
103
+ };
104
+ };
105
+ /**
106
+ * Echarts cartesian geometry with a band reserved for the legend in its
107
+ * position, outside the axis-title band, outside the tick labels.
108
+ */
109
+ export declare const reserveEchartsLegendBand: ({ position, visible, labels, legendFontSize, legendItemWidth, width, height, hasTitle, titleFontSize, hasBottomAxisTitle, bottomAxisNameGap, hasLeftAxisTitle, axisFontSize, }: EchartsLegendBandInput) => EchartsLegendBandLayout;
110
+ export type PlotlyLegendBandInput = {
111
+ /** Resolved legend position (`undefined` = plotly default: right). */
112
+ position: LegendBandPosition | null | undefined;
113
+ visible: boolean;
114
+ labels: readonly string[];
115
+ legendFontSize?: number;
116
+ width: number;
117
+ height: number;
118
+ hasTitle: boolean;
119
+ titleFontSize?: number;
120
+ hasBottomAxisTitle: boolean;
121
+ hasLeftAxisTitle: boolean;
122
+ /**
123
+ * Px from the left axis line to the outer edge of its tick labels (and
124
+ * title when present) — what the legend must clear on the left.
125
+ */
126
+ leftAxisDepth: number;
127
+ /** Same for a secondary value axis drawn on the right (0 when absent). */
128
+ rightAxisDepth?: number;
129
+ /** `title.standoff` the caller sets on the bottom axis (px labels → title). */
130
+ bottomAxisTitleStandoff?: number;
131
+ axisFontSize?: number;
132
+ };
133
+ export type PlotlyLegendBandLayout = {
134
+ band: LegendBand;
135
+ margin: {
136
+ l: number;
137
+ r: number;
138
+ t: number;
139
+ b: number;
140
+ };
141
+ /** Legend anchor + orientation to spread over the legend option. */
142
+ legend: {
143
+ orientation: "h" | "v";
144
+ x: number;
145
+ y: number;
146
+ xanchor: "left" | "center" | "right";
147
+ yanchor: "top" | "middle" | "bottom";
148
+ } | null;
149
+ /** Bottom axis title standoff (px between tick labels and title). */
150
+ bottomAxisTitleStandoff: number;
151
+ /** Title pinned to the top of the container so it never drifts into the legend band. */
152
+ title: {
153
+ yref: "container";
154
+ y: number;
155
+ yanchor: "top";
156
+ pad: {
157
+ t: number;
158
+ };
159
+ };
160
+ };
161
+ /**
162
+ * Plotly geometry with a band reserved for the legend in its position.
163
+ * Legend coordinates are paper-relative (fractions of the plot area), so
164
+ * they are derived from the margins this returns; `automargin` on the
165
+ * axes may still grow a margin further for unusually deep tick labels.
166
+ */
167
+ export declare const reservePlotlyLegendBand: ({ position, visible, labels, legendFontSize, width, height, hasTitle, titleFontSize, hasBottomAxisTitle, hasLeftAxisTitle, leftAxisDepth, rightAxisDepth, bottomAxisTitleStandoff, axisFontSize, }: PlotlyLegendBandInput) => PlotlyLegendBandLayout;
168
+ //# sourceMappingURL=legend-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legend-layout.d.ts","sourceRoot":"","sources":["../../../utils/legend-layout.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,kBAAkB,GAC1B,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,GACP,UAAU,GACV,MAAM,CAAC;AAEX,4EAA4E;AAC5E,eAAO,MAAM,QAAQ,IAAI,CAAC;AAC1B,wDAAwD;AACxD,eAAO,MAAM,QAAQ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