@rowsncolumns/charts 27.0.34 → 28.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/atoms/pivot-chart.atom.d.ts +14 -0
- package/dist/cjs/atoms/pivot-chart.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/pivot-chart.atom.js +9 -0
- package/dist/cjs/basic-chart/basic-chart.d.ts +1 -1
- package/dist/cjs/basic-chart/basic-chart.d.ts.map +1 -1
- package/dist/cjs/basic-chart/basic-chart.js +863 -371
- package/dist/cjs/components/dialogs/pivot-chart-dialog.d.ts +39 -0
- package/dist/cjs/components/dialogs/pivot-chart-dialog.d.ts.map +1 -0
- package/dist/cjs/components/dialogs/pivot-chart-dialog.js +100 -0
- package/dist/cjs/components/editors/chart-editor.d.ts +13 -1
- package/dist/cjs/components/editors/chart-editor.d.ts.map +1 -1
- package/dist/cjs/components/editors/chart-editor.js +225 -59
- package/dist/cjs/config.d.ts.map +1 -1
- package/dist/cjs/config.js +149 -12
- package/dist/cjs/hooks/use-charts.d.ts +21 -6
- package/dist/cjs/hooks/use-charts.d.ts.map +1 -1
- package/dist/cjs/hooks/use-charts.js +13 -1
- package/dist/cjs/hooks/use-on-create-chart.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-create-chart.js +7 -1
- package/dist/cjs/hooks/use-on-move-chart-to-sheet.d.ts +12 -0
- package/dist/cjs/hooks/use-on-move-chart-to-sheet.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-move-chart-to-sheet.js +26 -0
- package/dist/cjs/hooks/use-on-move-chart.d.ts +1 -1
- package/dist/cjs/hooks/use-on-move-chart.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-move-chart.js +2 -2
- package/dist/cjs/hooks/use-on-resize-chart.d.ts +1 -1
- package/dist/cjs/hooks/use-on-resize-chart.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-resize-chart.js +2 -2
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +34 -1
- package/dist/cjs/interface/create-chart.d.ts.map +1 -1
- package/dist/cjs/interface/create-chart.js +33 -42
- package/dist/cjs/interface/delete-chart.d.ts.map +1 -1
- package/dist/cjs/interface/delete-chart.js +4 -0
- package/dist/cjs/interface/move-chart-to-sheet.d.ts +13 -0
- package/dist/cjs/interface/move-chart-to-sheet.d.ts.map +1 -0
- package/dist/cjs/interface/move-chart-to-sheet.js +136 -0
- package/dist/cjs/interface/move-chart.d.ts +2 -2
- package/dist/cjs/interface/move-chart.d.ts.map +1 -1
- package/dist/cjs/interface/move-chart.js +7 -1
- package/dist/cjs/interface/resize-chart.d.ts +2 -2
- package/dist/cjs/interface/resize-chart.d.ts.map +1 -1
- package/dist/cjs/interface/resize-chart.js +7 -1
- package/dist/cjs/interface/update-chart.d.ts.map +1 -1
- package/dist/cjs/interface/update-chart.js +4 -0
- package/dist/cjs/plotly/basic-chart/basic-chart.d.ts +1 -1
- package/dist/cjs/plotly/basic-chart/basic-chart.d.ts.map +1 -1
- package/dist/cjs/plotly/basic-chart/basic-chart.js +970 -585
- package/dist/cjs/plotly/basic-chart/helpers.d.ts.map +1 -1
- package/dist/cjs/plotly/basic-chart/helpers.js +3 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/cjs/types.d.ts +7 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/utils/axis-number-format.d.ts +69 -0
- package/dist/cjs/utils/axis-number-format.d.ts.map +1 -0
- package/dist/cjs/utils/axis-number-format.js +217 -0
- package/dist/cjs/utils/category-levels.d.ts +27 -0
- package/dist/cjs/utils/category-levels.d.ts.map +1 -0
- package/dist/cjs/utils/category-levels.js +80 -0
- package/dist/cjs/utils/chart-image.d.ts +8 -0
- package/dist/cjs/utils/chart-image.d.ts.map +1 -0
- package/dist/cjs/utils/chart-image.js +28 -0
- package/dist/cjs/utils/chart-orientation.d.ts +67 -0
- package/dist/cjs/utils/chart-orientation.d.ts.map +1 -0
- package/dist/cjs/utils/chart-orientation.js +265 -0
- package/dist/cjs/utils/chart-spec-utils.d.ts +3 -0
- package/dist/cjs/utils/chart-spec-utils.d.ts.map +1 -1
- package/dist/cjs/utils/chart-spec-utils.js +12 -4
- package/dist/cjs/utils/chart-styles.d.ts +75 -0
- package/dist/cjs/utils/chart-styles.d.ts.map +1 -0
- package/dist/cjs/utils/chart-styles.js +283 -0
- package/dist/cjs/utils/empty-cells.d.ts +30 -0
- package/dist/cjs/utils/empty-cells.d.ts.map +1 -0
- package/dist/cjs/utils/empty-cells.js +91 -0
- package/dist/cjs/utils/overrides.d.ts +6 -1
- package/dist/cjs/utils/overrides.d.ts.map +1 -1
- package/dist/cjs/utils/overrides.js +19 -7
- package/dist/cjs/utils/pie-explosion.d.ts +30 -0
- package/dist/cjs/utils/pie-explosion.d.ts.map +1 -0
- package/dist/cjs/utils/pie-explosion.js +55 -0
- package/dist/cjs/utils/plotly-click.d.ts +34 -0
- package/dist/cjs/utils/plotly-click.d.ts.map +1 -0
- package/dist/cjs/utils/plotly-click.js +49 -0
- package/dist/cjs/utils/plotly-surface.d.ts +14 -0
- package/dist/cjs/utils/plotly-surface.d.ts.map +1 -0
- package/dist/cjs/utils/plotly-surface.js +64 -0
- package/dist/cjs/utils/plotly-title.d.ts +12 -0
- package/dist/cjs/utils/plotly-title.d.ts.map +1 -0
- package/dist/cjs/utils/plotly-title.js +24 -0
- package/dist/cjs/utils/series-click.d.ts +39 -0
- package/dist/cjs/utils/series-click.d.ts.map +1 -0
- package/dist/cjs/utils/series-click.js +75 -0
- package/dist/cjs/utils/three-d.d.ts +17 -1
- package/dist/cjs/utils/three-d.d.ts.map +1 -1
- package/dist/cjs/utils/three-d.js +32 -4
- package/dist/esm/atoms/pivot-chart.atom.d.ts +14 -0
- package/dist/esm/atoms/pivot-chart.atom.d.ts.map +1 -0
- package/dist/esm/atoms/pivot-chart.atom.js +4 -0
- package/dist/esm/basic-chart/basic-chart.d.ts +1 -1
- package/dist/esm/basic-chart/basic-chart.d.ts.map +1 -1
- package/dist/esm/basic-chart/basic-chart.js +680 -178
- package/dist/esm/components/dialogs/pivot-chart-dialog.d.ts +39 -0
- package/dist/esm/components/dialogs/pivot-chart-dialog.d.ts.map +1 -0
- package/dist/esm/components/dialogs/pivot-chart-dialog.js +89 -0
- package/dist/esm/components/editors/chart-editor.d.ts +13 -1
- package/dist/esm/components/editors/chart-editor.d.ts.map +1 -1
- package/dist/esm/components/editors/chart-editor.js +164 -20
- package/dist/esm/config.d.ts.map +1 -1
- package/dist/esm/config.js +149 -12
- package/dist/esm/hooks/use-charts.d.ts +21 -6
- package/dist/esm/hooks/use-charts.d.ts.map +1 -1
- package/dist/esm/hooks/use-charts.js +13 -1
- package/dist/esm/hooks/use-on-create-chart.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-create-chart.js +7 -1
- package/dist/esm/hooks/use-on-move-chart-to-sheet.d.ts +12 -0
- package/dist/esm/hooks/use-on-move-chart-to-sheet.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-move-chart-to-sheet.js +19 -0
- package/dist/esm/hooks/use-on-move-chart.d.ts +1 -1
- package/dist/esm/hooks/use-on-move-chart.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-move-chart.js +2 -2
- package/dist/esm/hooks/use-on-resize-chart.d.ts +1 -1
- package/dist/esm/hooks/use-on-resize-chart.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-resize-chart.js +2 -2
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +14 -0
- package/dist/esm/interface/create-chart.d.ts.map +1 -1
- package/dist/esm/interface/create-chart.js +36 -58
- package/dist/esm/interface/delete-chart.d.ts.map +1 -1
- package/dist/esm/interface/delete-chart.js +4 -0
- package/dist/esm/interface/move-chart-to-sheet.d.ts +13 -0
- package/dist/esm/interface/move-chart-to-sheet.d.ts.map +1 -0
- package/dist/esm/interface/move-chart-to-sheet.js +126 -0
- package/dist/esm/interface/move-chart.d.ts +2 -2
- package/dist/esm/interface/move-chart.d.ts.map +1 -1
- package/dist/esm/interface/move-chart.js +7 -1
- package/dist/esm/interface/resize-chart.d.ts +2 -2
- package/dist/esm/interface/resize-chart.d.ts.map +1 -1
- package/dist/esm/interface/resize-chart.js +7 -1
- package/dist/esm/interface/update-chart.d.ts.map +1 -1
- package/dist/esm/interface/update-chart.js +4 -0
- package/dist/esm/plotly/basic-chart/basic-chart.d.ts +1 -1
- package/dist/esm/plotly/basic-chart/basic-chart.d.ts.map +1 -1
- package/dist/esm/plotly/basic-chart/basic-chart.js +858 -463
- package/dist/esm/plotly/basic-chart/helpers.d.ts.map +1 -1
- package/dist/esm/plotly/basic-chart/helpers.js +3 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types.d.ts +7 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/utils/axis-number-format.d.ts +69 -0
- package/dist/esm/utils/axis-number-format.d.ts.map +1 -0
- package/dist/esm/utils/axis-number-format.js +170 -0
- package/dist/esm/utils/category-levels.d.ts +27 -0
- package/dist/esm/utils/category-levels.d.ts.map +1 -0
- package/dist/esm/utils/category-levels.js +65 -0
- package/dist/esm/utils/chart-image.d.ts +8 -0
- package/dist/esm/utils/chart-image.d.ts.map +1 -0
- package/dist/esm/utils/chart-image.js +24 -0
- package/dist/esm/utils/chart-orientation.d.ts +67 -0
- package/dist/esm/utils/chart-orientation.d.ts.map +1 -0
- package/dist/esm/utils/chart-orientation.js +234 -0
- package/dist/esm/utils/chart-spec-utils.d.ts +3 -0
- package/dist/esm/utils/chart-spec-utils.d.ts.map +1 -1
- package/dist/esm/utils/chart-spec-utils.js +10 -2
- package/dist/esm/utils/chart-styles.d.ts +75 -0
- package/dist/esm/utils/chart-styles.d.ts.map +1 -0
- package/dist/esm/utils/chart-styles.js +357 -0
- package/dist/esm/utils/empty-cells.d.ts +30 -0
- package/dist/esm/utils/empty-cells.d.ts.map +1 -0
- package/dist/esm/utils/empty-cells.js +67 -0
- package/dist/esm/utils/overrides.d.ts +6 -1
- package/dist/esm/utils/overrides.d.ts.map +1 -1
- package/dist/esm/utils/overrides.js +14 -2
- package/dist/esm/utils/pie-explosion.d.ts +30 -0
- package/dist/esm/utils/pie-explosion.d.ts.map +1 -0
- package/dist/esm/utils/pie-explosion.js +43 -0
- package/dist/esm/utils/plotly-click.d.ts +34 -0
- package/dist/esm/utils/plotly-click.d.ts.map +1 -0
- package/dist/esm/utils/plotly-click.js +44 -0
- package/dist/esm/utils/plotly-surface.d.ts +14 -0
- package/dist/esm/utils/plotly-surface.d.ts.map +1 -0
- package/dist/esm/utils/plotly-surface.js +45 -0
- package/dist/esm/utils/plotly-title.d.ts +12 -0
- package/dist/esm/utils/plotly-title.d.ts.map +1 -0
- package/dist/esm/utils/plotly-title.js +20 -0
- package/dist/esm/utils/series-click.d.ts +39 -0
- package/dist/esm/utils/series-click.d.ts.map +1 -0
- package/dist/esm/utils/series-click.js +66 -0
- package/dist/esm/utils/three-d.d.ts +17 -1
- package/dist/esm/utils/three-d.d.ts.map +1 -1
- package/dist/esm/utils/three-d.js +29 -3
- package/package.json +16 -12
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyChartQuickLayout = exports.CHART_QUICK_LAYOUTS = exports.applyChartStyle = exports.CHART_STYLES = exports.getChartPalette = exports.resetChartToMatchStyle = exports.applyChartColorPalette = exports.CHART_COLOR_PALETTES = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
/**
|
|
6
|
+
* Office's Change Colors gallery. Colorful 1 is the theme itself (no
|
|
7
|
+
* `colors` — the renderer keeps its accent fallback); the rest are the
|
|
8
|
+
* default Office theme's derived palettes.
|
|
9
|
+
*/
|
|
10
|
+
exports.CHART_COLOR_PALETTES = [
|
|
11
|
+
{ id: "colorful1", label: "Colorful Palette 1", kind: "colorful" },
|
|
12
|
+
{
|
|
13
|
+
id: "colorful2",
|
|
14
|
+
label: "Colorful Palette 2",
|
|
15
|
+
kind: "colorful",
|
|
16
|
+
colors: ["#4472C4", "#A5A5A5", "#5B9BD5", "#264478", "#636363", "#255E91"],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "colorful3",
|
|
20
|
+
label: "Colorful Palette 3",
|
|
21
|
+
kind: "colorful",
|
|
22
|
+
colors: ["#ED7D31", "#FFC000", "#70AD47", "#9E480E", "#997300", "#43682B"],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "colorful4",
|
|
26
|
+
label: "Colorful Palette 4",
|
|
27
|
+
kind: "colorful",
|
|
28
|
+
colors: ["#70AD47", "#4472C4", "#FFC000", "#43682B", "#264478", "#997300"],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "mono1",
|
|
32
|
+
label: "Monochromatic Palette 1",
|
|
33
|
+
kind: "monochromatic",
|
|
34
|
+
colors: ["#1F3864", "#2F5597", "#4472C4", "#8FAADC", "#B4C7E7", "#DAE3F3"],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "mono2",
|
|
38
|
+
label: "Monochromatic Palette 2",
|
|
39
|
+
kind: "monochromatic",
|
|
40
|
+
colors: ["#833C0B", "#C55A11", "#ED7D31", "#F4B183", "#F8CBAD", "#FBE5D6"],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "mono3",
|
|
44
|
+
label: "Monochromatic Palette 3",
|
|
45
|
+
kind: "monochromatic",
|
|
46
|
+
colors: ["#525252", "#7B7B7B", "#A5A5A5", "#C9C9C9", "#DBDBDB", "#EDEDED"],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "mono4",
|
|
50
|
+
label: "Monochromatic Palette 4",
|
|
51
|
+
kind: "monochromatic",
|
|
52
|
+
colors: ["#375623", "#548235", "#70AD47", "#A9D18E", "#C5E0B4", "#E2F0D9"],
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
var stripSeriesColor = function (entry) {
|
|
56
|
+
var _color = entry.color, _gradient = entry.gradient, _dataPointColors = entry.dataPointColors, _negativeColor = entry.negativeColor, rest = tslib_1.__rest(entry, ["color", "gradient", "dataPointColors", "negativeColor"]);
|
|
57
|
+
return rest;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Strip the per-series colour overrides so the chart-level palette shows
|
|
61
|
+
* through. Hierarchy specs (treemap / sunburst) carry no series.
|
|
62
|
+
*/
|
|
63
|
+
var withoutSeriesColors = function (spec) {
|
|
64
|
+
return "series" in spec && Array.isArray(spec.series)
|
|
65
|
+
? tslib_1.__assign(tslib_1.__assign({}, spec), { series: spec.series.map(stripSeriesColor) })
|
|
66
|
+
: spec;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Change Colors: set the palette and clear every series' own colour so the
|
|
70
|
+
* palette applies (a series colour always wins over the palette).
|
|
71
|
+
*/
|
|
72
|
+
var applyChartColorPalette = function (spec, palette) { return (tslib_1.__assign(tslib_1.__assign({}, withoutSeriesColors(spec)), { palette: palette.colors ? tslib_1.__spreadArray([], tslib_1.__read(palette.colors), false) : undefined })); };
|
|
73
|
+
exports.applyChartColorPalette = applyChartColorPalette;
|
|
74
|
+
/**
|
|
75
|
+
* Reset to Match Style: drop the per-series formatting overrides so the
|
|
76
|
+
* series follow the chart style's palette again. Chart-level fields are
|
|
77
|
+
* untouched — they *are* the style.
|
|
78
|
+
*/
|
|
79
|
+
var resetChartToMatchStyle = function (spec) {
|
|
80
|
+
return withoutSeriesColors(spec);
|
|
81
|
+
};
|
|
82
|
+
exports.resetChartToMatchStyle = resetChartToMatchStyle;
|
|
83
|
+
/**
|
|
84
|
+
* The series colour cycle a renderer should use: the spec's palette when
|
|
85
|
+
* one is set, else the caller's theme accents.
|
|
86
|
+
*/
|
|
87
|
+
var getChartPalette = function (spec, fallback) {
|
|
88
|
+
return (spec === null || spec === void 0 ? void 0 : spec.palette) && spec.palette.length > 0
|
|
89
|
+
? tslib_1.__spreadArray([], tslib_1.__read(spec.palette), false) : tslib_1.__spreadArray([], tslib_1.__read(fallback), false);
|
|
90
|
+
};
|
|
91
|
+
exports.getChartPalette = getChartPalette;
|
|
92
|
+
var GRAYSCALE_PALETTE = [
|
|
93
|
+
"#404040",
|
|
94
|
+
"#7F7F7F",
|
|
95
|
+
"#A5A5A5",
|
|
96
|
+
"#BFBFBF",
|
|
97
|
+
"#D9D9D9",
|
|
98
|
+
"#595959",
|
|
99
|
+
];
|
|
100
|
+
var MONOCHROME_PALETTE = exports.CHART_COLOR_PALETTES.find(function (palette) { return palette.id === "mono1"; }).colors;
|
|
101
|
+
var COLORFUL_PREVIEW = ["#4472C4", "#ED7D31", "#A5A5A5", "#FFC000"];
|
|
102
|
+
var setTitleFormat = function (spec, format) {
|
|
103
|
+
var _a;
|
|
104
|
+
return (tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.titleTextFormat) !== null && _a !== void 0 ? _a : {})), format));
|
|
105
|
+
};
|
|
106
|
+
var setAxisGridlines = function (spec, show) {
|
|
107
|
+
var _a;
|
|
108
|
+
return ({
|
|
109
|
+
valueAxisOptions: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.valueAxisOptions) !== null && _a !== void 0 ? _a : {})), { showMajorGridlines: show }),
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
/** Text colour for every chart text element (dark-frame styles). */
|
|
113
|
+
var setTextColor = function (spec, color) {
|
|
114
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
115
|
+
return ({
|
|
116
|
+
titleTextFormat: setTitleFormat(spec, { color: color }),
|
|
117
|
+
legend: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.legend) !== null && _a !== void 0 ? _a : {})), { textFormat: tslib_1.__assign(tslib_1.__assign({}, ((_c = (_b = spec.legend) === null || _b === void 0 ? void 0 : _b.textFormat) !== null && _c !== void 0 ? _c : {})), { color: color }) }),
|
|
118
|
+
valueAxisOptions: tslib_1.__assign(tslib_1.__assign({}, ((_d = spec.valueAxisOptions) !== null && _d !== void 0 ? _d : {})), { textFormat: tslib_1.__assign(tslib_1.__assign({}, ((_f = (_e = spec.valueAxisOptions) === null || _e === void 0 ? void 0 : _e.textFormat) !== null && _f !== void 0 ? _f : {})), { color: color }) }),
|
|
119
|
+
categoryAxisOptions: tslib_1.__assign(tslib_1.__assign({}, ((_g = spec.categoryAxisOptions) !== null && _g !== void 0 ? _g : {})), { textFormat: tslib_1.__assign(tslib_1.__assign({}, ((_j = (_h = spec.categoryAxisOptions) === null || _h === void 0 ? void 0 : _h.textFormat) !== null && _j !== void 0 ? _j : {})), { color: color }) }),
|
|
120
|
+
dataLabels: tslib_1.__assign(tslib_1.__assign({}, ((_k = spec.dataLabels) !== null && _k !== void 0 ? _k : {})), { textFormat: tslib_1.__assign(tslib_1.__assign({}, ((_m = (_l = spec.dataLabels) === null || _l === void 0 ? void 0 : _l.textFormat) !== null && _m !== void 0 ? _m : {})), { color: color }) }),
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* The Chart Styles gallery. Each entry pins the look Excel's style of that
|
|
125
|
+
* id implies onto the spec fields both renderers read: chart-area fill,
|
|
126
|
+
* gridlines, data labels, legend placement, title font and — for the
|
|
127
|
+
* grayscale / monochromatic rows — the palette. Per-series colours are
|
|
128
|
+
* left alone (Reset to Match Style clears them).
|
|
129
|
+
*/
|
|
130
|
+
exports.CHART_STYLES = [
|
|
131
|
+
{
|
|
132
|
+
id: 2,
|
|
133
|
+
label: "Style 1",
|
|
134
|
+
preview: { background: "#FFFFFF", bars: COLORFUL_PREVIEW },
|
|
135
|
+
apply: function (spec) {
|
|
136
|
+
var _a;
|
|
137
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { chartStyle: 2, backgroundColor: undefined }), setAxisGridlines(spec, true)), { dataLabels: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.dataLabels) !== null && _a !== void 0 ? _a : {})), { show: false }), titleTextFormat: setTitleFormat(spec, {
|
|
138
|
+
fontSize: 14,
|
|
139
|
+
bold: false,
|
|
140
|
+
color: undefined,
|
|
141
|
+
}) }));
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: 10,
|
|
146
|
+
label: "Style 2",
|
|
147
|
+
preview: { background: "#FFFFFF", bars: COLORFUL_PREVIEW },
|
|
148
|
+
apply: function (spec) {
|
|
149
|
+
var _a, _b;
|
|
150
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { chartStyle: 10, backgroundColor: undefined }), setAxisGridlines(spec, true)), { dataLabels: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.dataLabels) !== null && _a !== void 0 ? _a : {})), { show: true, position: "outsideEnd" }), legend: tslib_1.__assign(tslib_1.__assign({}, ((_b = spec.legend) !== null && _b !== void 0 ? _b : {})), { position: "top" }), titleTextFormat: setTitleFormat(spec, { fontSize: 16, bold: true }) }));
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: 18,
|
|
155
|
+
label: "Style 3",
|
|
156
|
+
preview: { background: "#FFFFFF", bars: COLORFUL_PREVIEW },
|
|
157
|
+
apply: function (spec) {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { chartStyle: 18, backgroundColor: undefined }), setAxisGridlines(spec, false)), { dataLabels: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.dataLabels) !== null && _a !== void 0 ? _a : {})), { show: true, position: "insideEnd" }), legend: tslib_1.__assign(tslib_1.__assign({}, ((_b = spec.legend) !== null && _b !== void 0 ? _b : {})), { position: "bottom" }), titleTextFormat: setTitleFormat(spec, { fontSize: 14, bold: true }) }));
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: 26,
|
|
164
|
+
label: "Style 4",
|
|
165
|
+
preview: { background: "#F2F2F2", bars: COLORFUL_PREVIEW },
|
|
166
|
+
apply: function (spec) {
|
|
167
|
+
var _a, _b;
|
|
168
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { chartStyle: 26, backgroundColor: "#F2F2F2" }), setAxisGridlines(spec, true)), { dataLabels: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.dataLabels) !== null && _a !== void 0 ? _a : {})), { show: false }), legend: tslib_1.__assign(tslib_1.__assign({}, ((_b = spec.legend) !== null && _b !== void 0 ? _b : {})), { position: "bottom" }), titleTextFormat: setTitleFormat(spec, { fontSize: 18, bold: true }) }));
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
id: 1,
|
|
173
|
+
label: "Style 5",
|
|
174
|
+
preview: { background: "#FFFFFF", bars: GRAYSCALE_PALETTE.slice(0, 4) },
|
|
175
|
+
apply: function (spec) { return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { chartStyle: 1, backgroundColor: undefined, palette: tslib_1.__spreadArray([], tslib_1.__read(GRAYSCALE_PALETTE), false) }), setAxisGridlines(spec, true)), { titleTextFormat: setTitleFormat(spec, { fontSize: 14, bold: false }) })); },
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
id: 3,
|
|
179
|
+
label: "Style 6",
|
|
180
|
+
preview: { background: "#FFFFFF", bars: MONOCHROME_PALETTE.slice(0, 4) },
|
|
181
|
+
apply: function (spec) { return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { chartStyle: 3, backgroundColor: undefined, palette: tslib_1.__spreadArray([], tslib_1.__read(MONOCHROME_PALETTE), false) }), setAxisGridlines(spec, true)), { titleTextFormat: setTitleFormat(spec, { fontSize: 14, bold: false }) })); },
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
id: 34,
|
|
185
|
+
label: "Style 7",
|
|
186
|
+
preview: { background: "#404040", bars: COLORFUL_PREVIEW },
|
|
187
|
+
apply: function (spec) {
|
|
188
|
+
var _a, _b, _c;
|
|
189
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { chartStyle: 34, backgroundColor: "#404040" }), setTextColor(spec, "#F2F2F2")), { valueAxisOptions: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.valueAxisOptions) !== null && _a !== void 0 ? _a : {})), { textFormat: tslib_1.__assign(tslib_1.__assign({}, ((_c = (_b = spec.valueAxisOptions) === null || _b === void 0 ? void 0 : _b.textFormat) !== null && _c !== void 0 ? _c : {})), { color: "#F2F2F2" }), showMajorGridlines: true }), titleTextFormat: setTitleFormat(spec, {
|
|
190
|
+
fontSize: 16,
|
|
191
|
+
bold: true,
|
|
192
|
+
color: "#FFFFFF",
|
|
193
|
+
}) }));
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
id: 42,
|
|
198
|
+
label: "Style 8",
|
|
199
|
+
preview: { background: "#000000", bars: COLORFUL_PREVIEW },
|
|
200
|
+
apply: function (spec) {
|
|
201
|
+
var _a, _b, _c;
|
|
202
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { chartStyle: 42, backgroundColor: "#000000" }), setTextColor(spec, "#FFFFFF")), { valueAxisOptions: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.valueAxisOptions) !== null && _a !== void 0 ? _a : {})), { textFormat: tslib_1.__assign(tslib_1.__assign({}, ((_c = (_b = spec.valueAxisOptions) === null || _b === void 0 ? void 0 : _b.textFormat) !== null && _c !== void 0 ? _c : {})), { color: "#FFFFFF" }), showMajorGridlines: false }), titleTextFormat: setTitleFormat(spec, {
|
|
203
|
+
fontSize: 16,
|
|
204
|
+
bold: true,
|
|
205
|
+
color: "#FFFFFF",
|
|
206
|
+
}) }));
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
];
|
|
210
|
+
var applyChartStyle = function (spec, style) { return style.apply(spec); };
|
|
211
|
+
exports.applyChartStyle = applyChartStyle;
|
|
212
|
+
/** Excel inserts placeholder axis titles when a layout shows axis titles the chart lacks. */
|
|
213
|
+
var AXIS_TITLE_PLACEHOLDER = "Axis Title";
|
|
214
|
+
var withAxisTitles = function (spec, show) {
|
|
215
|
+
return show
|
|
216
|
+
? {
|
|
217
|
+
verticalAxisTitle: spec.verticalAxisTitle || AXIS_TITLE_PLACEHOLDER,
|
|
218
|
+
horizontalAxisTitle: spec.horizontalAxisTitle || AXIS_TITLE_PLACEHOLDER,
|
|
219
|
+
}
|
|
220
|
+
: { verticalAxisTitle: undefined, horizontalAxisTitle: undefined };
|
|
221
|
+
};
|
|
222
|
+
var withDataLabels = function (spec, show, position) {
|
|
223
|
+
var _a;
|
|
224
|
+
return ({
|
|
225
|
+
dataLabels: tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.dataLabels) !== null && _a !== void 0 ? _a : {})), { show: show }), (show && position ? { position: position } : {})),
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Excel's Quick Layout gallery (the first six of the column-chart set).
|
|
230
|
+
* Layouts arrange the existing elements; they never touch colours.
|
|
231
|
+
*/
|
|
232
|
+
exports.CHART_QUICK_LAYOUTS = [
|
|
233
|
+
{
|
|
234
|
+
id: 1,
|
|
235
|
+
label: "Layout 1",
|
|
236
|
+
apply: function (spec) {
|
|
237
|
+
var _a;
|
|
238
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { legend: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.legend) !== null && _a !== void 0 ? _a : {})), { position: "right" }) }), withDataLabels(spec, false)), withAxisTitles(spec, false)));
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
id: 2,
|
|
243
|
+
label: "Layout 2",
|
|
244
|
+
apply: function (spec) {
|
|
245
|
+
var _a, _b;
|
|
246
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { legend: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.legend) !== null && _a !== void 0 ? _a : {})), { position: "top" }) }), withDataLabels(spec, true, "outsideEnd")), withAxisTitles(spec, false)), { valueAxisOptions: tslib_1.__assign(tslib_1.__assign({}, ((_b = spec.valueAxisOptions) !== null && _b !== void 0 ? _b : {})), { showMajorGridlines: false }) }));
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
id: 3,
|
|
251
|
+
label: "Layout 3",
|
|
252
|
+
apply: function (spec) {
|
|
253
|
+
var _a;
|
|
254
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { legend: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.legend) !== null && _a !== void 0 ? _a : {})), { position: "bottom" }) }), withDataLabels(spec, false)), withAxisTitles(spec, false)));
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
id: 4,
|
|
259
|
+
label: "Layout 4",
|
|
260
|
+
apply: function (spec) {
|
|
261
|
+
var _a, _b;
|
|
262
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { legend: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.legend) !== null && _a !== void 0 ? _a : {})), { position: "none" }) }), withDataLabels(spec, true, "insideEnd")), withAxisTitles(spec, false)), { valueAxisOptions: tslib_1.__assign(tslib_1.__assign({}, ((_b = spec.valueAxisOptions) !== null && _b !== void 0 ? _b : {})), { showMajorGridlines: false }) }));
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
id: 5,
|
|
267
|
+
label: "Layout 5",
|
|
268
|
+
apply: function (spec) {
|
|
269
|
+
var _a;
|
|
270
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { legend: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.legend) !== null && _a !== void 0 ? _a : {})), { position: "none" }) }), withDataLabels(spec, false)), withAxisTitles(spec, true)));
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
id: 6,
|
|
275
|
+
label: "Layout 6",
|
|
276
|
+
apply: function (spec) {
|
|
277
|
+
var _a;
|
|
278
|
+
return (tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, spec), { legend: tslib_1.__assign(tslib_1.__assign({}, ((_a = spec.legend) !== null && _a !== void 0 ? _a : {})), { position: "right" }) }), withDataLabels(spec, false)), withAxisTitles(spec, true)));
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
];
|
|
282
|
+
var applyChartQuickLayout = function (spec, layout) { return layout.apply(spec); };
|
|
283
|
+
exports.applyChartQuickLayout = applyChartQuickLayout;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { EmbeddedChart } from "@rowsncolumns/spreadsheet";
|
|
2
|
+
type ChartSpec = EmbeddedChart["spec"];
|
|
3
|
+
export type EmptyCellsPolicy = NonNullable<ChartSpec["emptyCells"]>;
|
|
4
|
+
type EmptyCellsSpec = Pick<ChartSpec, "emptyCells" | "showNaAsEmpty">;
|
|
5
|
+
export declare const isChartErrorValue: (value: unknown) => boolean;
|
|
6
|
+
/** Excel's default is a gap. */
|
|
7
|
+
export declare const getEmptyCellsPolicy: (spec: EmptyCellsSpec) => EmptyCellsPolicy;
|
|
8
|
+
/** Only a line-like series has a line to carry across the hole. */
|
|
9
|
+
export declare const isLineLikeChartType: (chartType: ChartSpec["chartType"] | null | undefined) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* "Connect data points with line" — the renderer bridges the gap
|
|
12
|
+
* (echarts `connectNulls`, plotly `connectgaps`).
|
|
13
|
+
*/
|
|
14
|
+
export declare const connectsAcrossEmptyCells: (spec: EmptyCellsSpec, lineLike: boolean) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Plot-ready values for one series under the chart's "Hidden and Empty
|
|
17
|
+
* Cells" settings. `values` are the sanitized numbers (blanks and errors
|
|
18
|
+
* already `undefined`), `rawValues` the cells as read, index-aligned, so
|
|
19
|
+
* a blank can be told from an error:
|
|
20
|
+
*
|
|
21
|
+
* - a blank follows `emptyCells`: `"zero"` plots 0, `"gaps"` and
|
|
22
|
+
* `"connect"` leave `null` (the renderer's connect flag bridges it);
|
|
23
|
+
* - an error is a blank while `showNaAsEmpty` is on (Excel's default);
|
|
24
|
+
* with it off a line-like series is drawn straight through the point
|
|
25
|
+
* (linear interpolation between its numeric neighbours — Excel's
|
|
26
|
+
* pre-2016 #N/A behaviour), and any other series leaves a gap.
|
|
27
|
+
*/
|
|
28
|
+
export declare const applyEmptyCellsPolicy: (values: readonly (number | null | undefined)[], rawValues: readonly unknown[], spec: EmptyCellsSpec, lineLike: boolean) => (number | null)[];
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=empty-cells.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyEmptyCellsPolicy = exports.connectsAcrossEmptyCells = exports.isLineLikeChartType = exports.getEmptyCellsPolicy = exports.isChartErrorValue = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var CHART_ERROR_VALUES = new Set([
|
|
6
|
+
"#N/A",
|
|
7
|
+
"#VALUE!",
|
|
8
|
+
"#REF!",
|
|
9
|
+
"#DIV/0!",
|
|
10
|
+
"#NUM!",
|
|
11
|
+
"#NAME?",
|
|
12
|
+
"#NULL!",
|
|
13
|
+
"#SPILL!",
|
|
14
|
+
"#CALC!",
|
|
15
|
+
"#GETTING_DATA",
|
|
16
|
+
]);
|
|
17
|
+
var isChartErrorValue = function (value) {
|
|
18
|
+
return typeof value === "string" && CHART_ERROR_VALUES.has(value.toUpperCase());
|
|
19
|
+
};
|
|
20
|
+
exports.isChartErrorValue = isChartErrorValue;
|
|
21
|
+
/** Excel's default is a gap. */
|
|
22
|
+
var getEmptyCellsPolicy = function (spec) { var _a; return (_a = spec.emptyCells) !== null && _a !== void 0 ? _a : "gaps"; };
|
|
23
|
+
exports.getEmptyCellsPolicy = getEmptyCellsPolicy;
|
|
24
|
+
/** Only a line-like series has a line to carry across the hole. */
|
|
25
|
+
var isLineLikeChartType = function (chartType) { return chartType === "line" || chartType === "area"; };
|
|
26
|
+
exports.isLineLikeChartType = isLineLikeChartType;
|
|
27
|
+
/**
|
|
28
|
+
* "Connect data points with line" — the renderer bridges the gap
|
|
29
|
+
* (echarts `connectNulls`, plotly `connectgaps`).
|
|
30
|
+
*/
|
|
31
|
+
var connectsAcrossEmptyCells = function (spec, lineLike) { return lineLike && (0, exports.getEmptyCellsPolicy)(spec) === "connect"; };
|
|
32
|
+
exports.connectsAcrossEmptyCells = connectsAcrossEmptyCells;
|
|
33
|
+
/**
|
|
34
|
+
* Plot-ready values for one series under the chart's "Hidden and Empty
|
|
35
|
+
* Cells" settings. `values` are the sanitized numbers (blanks and errors
|
|
36
|
+
* already `undefined`), `rawValues` the cells as read, index-aligned, so
|
|
37
|
+
* a blank can be told from an error:
|
|
38
|
+
*
|
|
39
|
+
* - a blank follows `emptyCells`: `"zero"` plots 0, `"gaps"` and
|
|
40
|
+
* `"connect"` leave `null` (the renderer's connect flag bridges it);
|
|
41
|
+
* - an error is a blank while `showNaAsEmpty` is on (Excel's default);
|
|
42
|
+
* with it off a line-like series is drawn straight through the point
|
|
43
|
+
* (linear interpolation between its numeric neighbours — Excel's
|
|
44
|
+
* pre-2016 #N/A behaviour), and any other series leaves a gap.
|
|
45
|
+
*/
|
|
46
|
+
var applyEmptyCellsPolicy = function (values, rawValues, spec, lineLike) {
|
|
47
|
+
var e_1, _a;
|
|
48
|
+
var policy = (0, exports.getEmptyCellsPolicy)(spec);
|
|
49
|
+
var naAsEmpty = spec.showNaAsEmpty !== false;
|
|
50
|
+
var plotted = values.map(function (value) {
|
|
51
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
52
|
+
});
|
|
53
|
+
var legacyErrors = [];
|
|
54
|
+
for (var i = 0; i < plotted.length; i++) {
|
|
55
|
+
if (plotted[i] !== null)
|
|
56
|
+
continue;
|
|
57
|
+
if (!naAsEmpty && (0, exports.isChartErrorValue)(rawValues[i])) {
|
|
58
|
+
legacyErrors.push(i);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (policy === "zero")
|
|
62
|
+
plotted[i] = 0;
|
|
63
|
+
}
|
|
64
|
+
if (lineLike) {
|
|
65
|
+
try {
|
|
66
|
+
for (var legacyErrors_1 = tslib_1.__values(legacyErrors), legacyErrors_1_1 = legacyErrors_1.next(); !legacyErrors_1_1.done; legacyErrors_1_1 = legacyErrors_1.next()) {
|
|
67
|
+
var i = legacyErrors_1_1.value;
|
|
68
|
+
var prev = i - 1;
|
|
69
|
+
while (prev >= 0 && plotted[prev] === null)
|
|
70
|
+
prev--;
|
|
71
|
+
var next = i + 1;
|
|
72
|
+
while (next < plotted.length && plotted[next] === null)
|
|
73
|
+
next++;
|
|
74
|
+
if (prev < 0 || next >= plotted.length)
|
|
75
|
+
continue;
|
|
76
|
+
var a = plotted[prev];
|
|
77
|
+
var b = plotted[next];
|
|
78
|
+
plotted[i] = a + ((b - a) * (i - prev)) / (next - prev);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
82
|
+
finally {
|
|
83
|
+
try {
|
|
84
|
+
if (legacyErrors_1_1 && !legacyErrors_1_1.done && (_a = legacyErrors_1.return)) _a.call(legacyErrors_1);
|
|
85
|
+
}
|
|
86
|
+
finally { if (e_1) throw e_1.error; }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return plotted;
|
|
90
|
+
};
|
|
91
|
+
exports.applyEmptyCellsPolicy = applyEmptyCellsPolicy;
|
|
@@ -2,7 +2,12 @@ import type { LegendComponentOption } from "echarts";
|
|
|
2
2
|
/** Build an echarts `textStyle` from a parsed `ChartTextFormat`. */
|
|
3
3
|
export declare const textFormatToEchartsTextStyle: (fmt: any) => Record<string, any> | undefined;
|
|
4
4
|
export declare const applyLegendOverrides: (legend: LegendComponentOption, opts: any) => LegendComponentOption;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* `numberFormatPattern` is the axis' RESOLVED format (explicit pattern or
|
|
7
|
+
* the linked source-cell format — see `resolveValueAxisNumberFormat`); it
|
|
8
|
+
* becomes the tick-label formatter.
|
|
9
|
+
*/
|
|
10
|
+
export declare const applyAxisOverrides: (axis: any, opts: any, numberFormatPattern?: string) => any;
|
|
6
11
|
export declare const dataLabelFormatter: (opts: any) => (params: any) => string;
|
|
7
12
|
export declare const buildSeriesLabelOption: (opts: any) => {
|
|
8
13
|
readonly show: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../../utils/overrides.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../../utils/overrides.ts"],"names":[],"mappings":"AACA,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,QA4B7B,CAAC;AAqBF,eAAO,MAAM,kBAAkB,GAAI,MAAM,GAAG,MAAM,QAAQ,GAAG,WA4B5D,CAAC;AAWF,eAAO,MAAM,sBAAsB,GAAI,MAAM,GAAG;;;iCAvCU,GAAG;aA+C5D,CAAC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.buildSeriesLabelOption = exports.dataLabelFormatter = exports.applyAxisOverrides = exports.applyLegendOverrides = exports.textFormatToEchartsTextStyle = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var utils_1 = require("@rowsncolumns/utils");
|
|
6
|
+
var axis_number_format_1 = require("./axis-number-format");
|
|
6
7
|
// Map ChartSpec.legend / dataLabels / axisOptions to ECharts option
|
|
7
8
|
// fragments. Each helper is a no-op when the spec field is missing, so
|
|
8
9
|
// callers can spread the result without checks. Shared by the main
|
|
@@ -76,11 +77,22 @@ var applyLegendOverrides = function (legend, opts) {
|
|
|
76
77
|
return next;
|
|
77
78
|
};
|
|
78
79
|
exports.applyLegendOverrides = applyLegendOverrides;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
/**
|
|
81
|
+
* `numberFormatPattern` is the axis' RESOLVED format (explicit pattern or
|
|
82
|
+
* the linked source-cell format — see `resolveValueAxisNumberFormat`); it
|
|
83
|
+
* becomes the tick-label formatter.
|
|
84
|
+
*/
|
|
85
|
+
var applyAxisOverrides = function (axis, opts, numberFormatPattern) {
|
|
86
|
+
var _a, _b, _c, _d, _e;
|
|
87
|
+
var formatter = (0, axis_number_format_1.valueAxisLabelFormatter)(numberFormatPattern);
|
|
88
|
+
if (!opts && !formatter)
|
|
82
89
|
return axis;
|
|
83
90
|
var next = tslib_1.__assign({}, axis);
|
|
91
|
+
if (formatter) {
|
|
92
|
+
next.axisLabel = tslib_1.__assign(tslib_1.__assign({}, ((_a = next.axisLabel) !== null && _a !== void 0 ? _a : {})), { formatter: formatter });
|
|
93
|
+
}
|
|
94
|
+
if (!opts)
|
|
95
|
+
return next;
|
|
84
96
|
if (opts.logarithmic)
|
|
85
97
|
next.type = "log";
|
|
86
98
|
if (opts.reverse)
|
|
@@ -92,17 +104,17 @@ var applyAxisOverrides = function (axis, opts) {
|
|
|
92
104
|
if (opts.visible === false)
|
|
93
105
|
next.show = false;
|
|
94
106
|
if (opts.showMajorGridlines === false) {
|
|
95
|
-
next.splitLine = tslib_1.__assign(tslib_1.__assign({}, ((
|
|
107
|
+
next.splitLine = tslib_1.__assign(tslib_1.__assign({}, ((_b = next.splitLine) !== null && _b !== void 0 ? _b : {})), { show: false });
|
|
96
108
|
}
|
|
97
109
|
if (opts.showMajorGridlines === true) {
|
|
98
|
-
next.splitLine = tslib_1.__assign(tslib_1.__assign({}, ((
|
|
110
|
+
next.splitLine = tslib_1.__assign(tslib_1.__assign({}, ((_c = next.splitLine) !== null && _c !== void 0 ? _c : {})), { show: true });
|
|
99
111
|
}
|
|
100
112
|
// Axis label text style (tick labels) + axis title font come from
|
|
101
113
|
// <c:txPr>. Without this echarts uses its default (~black on light).
|
|
102
114
|
var axisTextStyle = (0, exports.textFormatToEchartsTextStyle)(opts.textFormat);
|
|
103
115
|
if (axisTextStyle) {
|
|
104
|
-
next.axisLabel = tslib_1.__assign(tslib_1.__assign({}, ((
|
|
105
|
-
next.nameTextStyle = tslib_1.__assign(tslib_1.__assign({}, ((
|
|
116
|
+
next.axisLabel = tslib_1.__assign(tslib_1.__assign({}, ((_d = next.axisLabel) !== null && _d !== void 0 ? _d : {})), axisTextStyle);
|
|
117
|
+
next.nameTextStyle = tslib_1.__assign(tslib_1.__assign({}, ((_e = next.nameTextStyle) !== null && _e !== void 0 ? _e : {})), axisTextStyle);
|
|
106
118
|
}
|
|
107
119
|
return next;
|
|
108
120
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exploded pie / doughnut (rowsncolumns/spreadsheet#668 C-32). Excel stores
|
|
3
|
+
* the explosion as a percentage of the pie radius (`<c:explosion val="25"/>`,
|
|
4
|
+
* 25 being the gallery default); each slice moves outward along its own
|
|
5
|
+
* bisector by that much. Both renderers resolve the spec value here.
|
|
6
|
+
*/
|
|
7
|
+
/** Excel's gallery "Exploded Pie" / "Exploded Doughnut" explosion. */
|
|
8
|
+
export declare const DEFAULT_PIE_EXPLOSION = 25;
|
|
9
|
+
/**
|
|
10
|
+
* The explosion percentage a spec asks for, `0` when the slices touch
|
|
11
|
+
* (absent, non-numeric, negative or `0`).
|
|
12
|
+
*/
|
|
13
|
+
export declare const resolveExplosion: (spec: {
|
|
14
|
+
explosion?: number | null;
|
|
15
|
+
} | null | undefined) => number;
|
|
16
|
+
/**
|
|
17
|
+
* The outer radius of a pie in pixels for the container it renders in:
|
|
18
|
+
* echarts' `radius` is a percentage of half the shorter side (default
|
|
19
|
+
* `"75%"`) or an absolute pixel count.
|
|
20
|
+
*/
|
|
21
|
+
export declare const pieRadiusPx: (radius: (string | number)[] | null | undefined, width: number, height: number) => number;
|
|
22
|
+
/**
|
|
23
|
+
* echarts has no slice offset of its own; the exploded look is its
|
|
24
|
+
* `select` state (`selectedOffset`, in pixels) with every slice selected.
|
|
25
|
+
* The percentage is of the pie radius, so the offset scales with it.
|
|
26
|
+
*/
|
|
27
|
+
export declare const explosionOffsetPx: (explosion: number, radiusPx: number) => number;
|
|
28
|
+
/** plotly pie `pull` — a fraction of the radius. */
|
|
29
|
+
export declare const explosionToPlotlyPull: (explosion: number) => number | undefined;
|
|
30
|
+
//# sourceMappingURL=pie-explosion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pie-explosion.d.ts","sourceRoot":"","sources":["../../../utils/pie-explosion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,sEAAsE;AACtE,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAKxC;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM;IAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KACrD,MAIF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,IAAI,GAAG,SAAS,EAC9C,OAAO,MAAM,EACb,QAAQ,MAAM,KACb,MAOF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,WAAW,MAAM,EAAE,UAAU,MAAM,WAC3B,CAAC;AAE3C,oDAAoD;AACpD,eAAO,MAAM,qBAAqB,GAAI,WAAW,MAAM,uBACG,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Exploded pie / doughnut (rowsncolumns/spreadsheet#668 C-32). Excel stores
|
|
4
|
+
* the explosion as a percentage of the pie radius (`<c:explosion val="25"/>`,
|
|
5
|
+
* 25 being the gallery default); each slice moves outward along its own
|
|
6
|
+
* bisector by that much. Both renderers resolve the spec value here.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.explosionToPlotlyPull = exports.explosionOffsetPx = exports.pieRadiusPx = exports.resolveExplosion = exports.DEFAULT_PIE_EXPLOSION = void 0;
|
|
10
|
+
/** Excel's gallery "Exploded Pie" / "Exploded Doughnut" explosion. */
|
|
11
|
+
exports.DEFAULT_PIE_EXPLOSION = 25;
|
|
12
|
+
/** OOXML `CT_UnsignedInt` explosion — Excel's dialog caps it at 400%. */
|
|
13
|
+
var MAX_PIE_EXPLOSION = 400;
|
|
14
|
+
/**
|
|
15
|
+
* The explosion percentage a spec asks for, `0` when the slices touch
|
|
16
|
+
* (absent, non-numeric, negative or `0`).
|
|
17
|
+
*/
|
|
18
|
+
var resolveExplosion = function (spec) {
|
|
19
|
+
var explosion = spec === null || spec === void 0 ? void 0 : spec.explosion;
|
|
20
|
+
if (typeof explosion !== "number" || !Number.isFinite(explosion))
|
|
21
|
+
return 0;
|
|
22
|
+
return Math.min(MAX_PIE_EXPLOSION, Math.max(0, explosion));
|
|
23
|
+
};
|
|
24
|
+
exports.resolveExplosion = resolveExplosion;
|
|
25
|
+
/**
|
|
26
|
+
* The outer radius of a pie in pixels for the container it renders in:
|
|
27
|
+
* echarts' `radius` is a percentage of half the shorter side (default
|
|
28
|
+
* `"75%"`) or an absolute pixel count.
|
|
29
|
+
*/
|
|
30
|
+
var pieRadiusPx = function (radius, width, height) {
|
|
31
|
+
var _a;
|
|
32
|
+
var half = Math.max(0, Math.min(width, height)) / 2;
|
|
33
|
+
var outer = (_a = radius === null || radius === void 0 ? void 0 : radius[radius.length - 1]) !== null && _a !== void 0 ? _a : "75%";
|
|
34
|
+
if (typeof outer === "number")
|
|
35
|
+
return Math.max(0, outer);
|
|
36
|
+
var parsed = Number.parseFloat(outer);
|
|
37
|
+
if (!Number.isFinite(parsed))
|
|
38
|
+
return half * 0.75;
|
|
39
|
+
return outer.trim().endsWith("%") ? (half * parsed) / 100 : parsed;
|
|
40
|
+
};
|
|
41
|
+
exports.pieRadiusPx = pieRadiusPx;
|
|
42
|
+
/**
|
|
43
|
+
* echarts has no slice offset of its own; the exploded look is its
|
|
44
|
+
* `select` state (`selectedOffset`, in pixels) with every slice selected.
|
|
45
|
+
* The percentage is of the pie radius, so the offset scales with it.
|
|
46
|
+
*/
|
|
47
|
+
var explosionOffsetPx = function (explosion, radiusPx) {
|
|
48
|
+
return Math.round((radiusPx * explosion) / 100);
|
|
49
|
+
};
|
|
50
|
+
exports.explosionOffsetPx = explosionOffsetPx;
|
|
51
|
+
/** plotly pie `pull` — a fraction of the radius. */
|
|
52
|
+
var explosionToPlotlyPull = function (explosion) {
|
|
53
|
+
return explosion > 0 ? Math.min(1, explosion / 100) : undefined;
|
|
54
|
+
};
|
|
55
|
+
exports.explosionToPlotlyPull = explosionToPlotlyPull;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* plotly click → chart selection (rowsncolumns/spreadsheet#668 C-37 / C-38).
|
|
3
|
+
*
|
|
4
|
+
* The plotly renderer is interactive with `layout.dragmode: false`: plotly
|
|
5
|
+
* reports `plotly_click` but never starts a drag, so a body drag reaches
|
|
6
|
+
* the embed's move handler instead. plotly does not track that drag either
|
|
7
|
+
* and treats the mouseup as a click, so the caller compares the click's
|
|
8
|
+
* pointer position with where the pointer went down.
|
|
9
|
+
*/
|
|
10
|
+
/** Pointer travel (px) beyond which a mouseup is a drag, not a click. */
|
|
11
|
+
export declare const CLICK_DRAG_TOLERANCE_PX = 3;
|
|
12
|
+
export declare const wasDragged: (pointerDown: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
} | undefined, clickEvent: {
|
|
16
|
+
clientX?: number;
|
|
17
|
+
clientY?: number;
|
|
18
|
+
} | undefined) => boolean;
|
|
19
|
+
export type PlotlyClickPoint = {
|
|
20
|
+
curveNumber: number;
|
|
21
|
+
/** Index of the clicked point within its trace (a category index). */
|
|
22
|
+
pointNumber?: number;
|
|
23
|
+
data?: unknown;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The `spec.series` entry (and data point) a plotly click lands on. Traces
|
|
27
|
+
* tagged with `meta.rncSeriesIndex` resolve through the tag; untagged ones
|
|
28
|
+
* map by curve position while it fits; anything else is not a series.
|
|
29
|
+
*/
|
|
30
|
+
export declare const resolvePlotlyClickSelection: (points: ReadonlyArray<PlotlyClickPoint> | undefined, seriesCount: number) => {
|
|
31
|
+
seriesIndex: number;
|
|
32
|
+
dataIndex?: number;
|
|
33
|
+
} | undefined;
|
|
34
|
+
//# sourceMappingURL=plotly-click.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plotly-click.d.ts","sourceRoot":"","sources":["../../../utils/plotly-click.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,yEAAyE;AACzE,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,eAAO,MAAM,UAAU,GACrB,aAAa;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,EACjD,YAAY;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,KAC7D,OAQF,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,GACtC,QAAQ,aAAa,CAAC,gBAAgB,CAAC,GAAG,SAAS,EACnD,aAAa,MAAM,KAClB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAkBhD,CAAC"}
|