@rowsncolumns/charts 28.1.17 → 28.1.18
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/Readme.md +18 -1
- 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 +175 -151
- package/dist/cjs/components/editors/chart-editor.d.ts +7 -1
- package/dist/cjs/components/editors/chart-editor.d.ts.map +1 -1
- package/dist/cjs/components/editors/chart-editor.js +3 -2
- package/dist/cjs/config.d.ts +10 -0
- package/dist/cjs/config.d.ts.map +1 -1
- package/dist/cjs/config.js +45 -10
- package/dist/cjs/types.d.ts +10 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/utils/echarts-gl-loader.d.ts +6 -0
- package/dist/cjs/utils/echarts-gl-loader.d.ts.map +1 -1
- package/dist/cjs/utils/echarts-gl-loader.js +42 -1
- package/dist/cjs/utils/three-d.d.ts +12 -1
- package/dist/cjs/utils/three-d.d.ts.map +1 -1
- package/dist/cjs/utils/three-d.js +4 -1
- 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 +60 -35
- package/dist/esm/components/editors/chart-editor.d.ts +7 -1
- package/dist/esm/components/editors/chart-editor.d.ts.map +1 -1
- package/dist/esm/components/editors/chart-editor.js +4 -3
- package/dist/esm/config.d.ts +10 -0
- package/dist/esm/config.d.ts.map +1 -1
- package/dist/esm/config.js +20 -0
- package/dist/esm/types.d.ts +10 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/utils/echarts-gl-loader.d.ts +6 -0
- package/dist/esm/utils/echarts-gl-loader.d.ts.map +1 -1
- package/dist/esm/utils/echarts-gl-loader.js +40 -0
- package/dist/esm/utils/three-d.d.ts +12 -1
- package/dist/esm/utils/three-d.d.ts.map +1 -1
- package/dist/esm/utils/three-d.js +4 -1
- package/package.json +1 -1
|
@@ -16,7 +16,13 @@ type ChartEditorProps = {
|
|
|
16
16
|
* from the data range. Without it the switched series are unnamed.
|
|
17
17
|
*/
|
|
18
18
|
getFormattedValue?: ChartCellLabelGetter;
|
|
19
|
+
/**
|
|
20
|
+
* Mirror of the renderer's `enable3D`: `false` hides the presets that
|
|
21
|
+
* render through echarts-gl (3-D Column / Bar / Line / Area / Surface).
|
|
22
|
+
* An existing 3-D spec keeps its `sourceChartType`. Default `true`.
|
|
23
|
+
*/
|
|
24
|
+
enable3D?: boolean;
|
|
19
25
|
};
|
|
20
|
-
export declare const ChartEditor: ({ chart, sheetId, onSubmit, onRequestMoveChart, getFormattedValue, }: ChartEditorProps) => React.JSX.Element;
|
|
26
|
+
export declare const ChartEditor: ({ chart, sheetId, onSubmit, onRequestMoveChart, getFormattedValue, enable3D, }: ChartEditorProps) => React.JSX.Element;
|
|
21
27
|
export default ChartEditor;
|
|
22
28
|
//# sourceMappingURL=chart-editor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-editor.d.ts","sourceRoot":"","sources":["../../../../components/editors/chart-editor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAGV,aAAa,EAGd,MAAM,2BAA2B,CAAC;AAwBnC,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AAuDvC,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IACtC;;;;OAIG;IACH,kBAAkB,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAChD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"chart-editor.d.ts","sourceRoot":"","sources":["../../../../components/editors/chart-editor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAGV,aAAa,EAGd,MAAM,2BAA2B,CAAC;AAwBnC,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AAuDvC,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IACtC;;;;OAIG;IACH,kBAAkB,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAChD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAuBF,eAAO,MAAM,WAAW,GAAI,gFAOzB,gBAAgB,sBAmhClB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -56,8 +56,9 @@ var Section = function (_a) {
|
|
|
56
56
|
};
|
|
57
57
|
var ChartEditor = function (_a) {
|
|
58
58
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
59
|
-
var chart = _a.chart, sheetId = _a.sheetId, onSubmit = _a.onSubmit, onRequestMoveChart = _a.onRequestMoveChart, getFormattedValue = _a.getFormattedValue;
|
|
59
|
+
var chart = _a.chart, sheetId = _a.sheetId, onSubmit = _a.onSubmit, onRequestMoveChart = _a.onRequestMoveChart, getFormattedValue = _a.getFormattedValue, enable3D = _a.enable3D;
|
|
60
60
|
var setChartDialogState = (0, editing_chart_atom_1.useSetChartEditorDialogState)();
|
|
61
|
+
var chartTypes = (0, config_1.getChartTypes)({ enable3D: enable3D });
|
|
61
62
|
// Close dialog
|
|
62
63
|
var closeDialog = function () { return setChartDialogState(false); };
|
|
63
64
|
// Keyed on chart identity so a position sync (move/resize while the
|
|
@@ -232,7 +233,7 @@ var ChartEditor = function (_a) {
|
|
|
232
233
|
react_1.default.createElement(ui_1.DropdownRightSlot, null,
|
|
233
234
|
react_1.default.createElement(icons_1.TriangleDownIcon, null)))),
|
|
234
235
|
react_1.default.createElement(ui_1.DropdownMenuPortal, null,
|
|
235
|
-
react_1.default.createElement(ui_1.DropdownMenuContent, { align: "start", sideOffset: 0 },
|
|
236
|
+
react_1.default.createElement(ui_1.DropdownMenuContent, { align: "start", sideOffset: 0 }, chartTypes.map(function (_a) {
|
|
236
237
|
var _b = tslib_1.__read(_a, 2), category = _b[0], types = _b[1];
|
|
237
238
|
return (react_1.default.createElement(ui_1.DropdownMenuSub, { key: category },
|
|
238
239
|
react_1.default.createElement(ui_1.DropdownMenuSubTrigger, null,
|
package/dist/cjs/config.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { ChartSpec } from "@rowsncolumns/spreadsheet";
|
|
2
|
+
import { type ThreeDRenderOptions } from "./utils/three-d";
|
|
2
3
|
export declare const CHART_TYPES: Array<[string, Array<[string, Partial<ChartSpec>]>]>;
|
|
4
|
+
/**
|
|
5
|
+
* The Chart editor's preset list. With `enable3D: false` the presets the
|
|
6
|
+
* renderer would draw through echarts-gl (3-D Column / Bar / Line / Area,
|
|
7
|
+
* their stacked variants and 3-D Surface) are left out; 3-D Pie and
|
|
8
|
+
* Contour stay since they never render in WebGL. A spec that already
|
|
9
|
+
* carries a 3-D `sourceChartType` is not rewritten — only the picker
|
|
10
|
+
* changes (rowsncolumns/spreadsheet#1187).
|
|
11
|
+
*/
|
|
12
|
+
export declare const getChartTypes: (options?: ThreeDRenderOptions) => Array<[string, Array<[string, Partial<ChartSpec>]>]>;
|
|
3
13
|
/**
|
|
4
14
|
* True when a spec is doughnut-shaped: the first-class
|
|
5
15
|
* `chartType: "doughnut"` token, or the two legacy pie encodings —
|
package/dist/cjs/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAsRhF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAgB1E,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACxB,UAAU,mBAAmB,KAC5B,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAarD,CAAC;AAYF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,OAAO,CAAC,SAAS,CAAC,KAAG,OAQzD,CAAC;AAuBF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,OAAO,CAAC,SAAS,CAAC,KAAG,MA4B9D,CAAC"}
|
package/dist/cjs/config.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getChartPresetLabel = exports.isDoughnutSpec = exports.CHART_TYPES = void 0;
|
|
3
|
+
exports.getChartPresetLabel = exports.isDoughnutSpec = exports.getChartTypes = exports.CHART_TYPES = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var pie_explosion_1 = require("./utils/pie-explosion");
|
|
6
|
+
var three_d_1 = require("./utils/three-d");
|
|
6
7
|
// Excel's 3-D chart classes degrade to a 2-D chartType with the authored
|
|
7
8
|
// class kept as `sourceChartType` (BAR_3D, LINE_3D, PIE_3D, AREA_3D,
|
|
8
9
|
// SURFACE, SURFACE_3D). The renderer draws BAR_3D / LINE_3D / AREA_3D /
|
|
@@ -277,6 +278,40 @@ exports.CHART_TYPES = [
|
|
|
277
278
|
["Stock", STOCK_CHART_TYPES],
|
|
278
279
|
["Combo", COMBO_CHART_TYPES],
|
|
279
280
|
];
|
|
281
|
+
/**
|
|
282
|
+
* The Chart editor's preset list. With `enable3D: false` the presets the
|
|
283
|
+
* renderer would draw through echarts-gl (3-D Column / Bar / Line / Area,
|
|
284
|
+
* their stacked variants and 3-D Surface) are left out; 3-D Pie and
|
|
285
|
+
* Contour stay since they never render in WebGL. A spec that already
|
|
286
|
+
* carries a 3-D `sourceChartType` is not rewritten — only the picker
|
|
287
|
+
* changes (rowsncolumns/spreadsheet#1187).
|
|
288
|
+
*/
|
|
289
|
+
var getChartTypes = function (options) {
|
|
290
|
+
var e_1, _a;
|
|
291
|
+
if ((options === null || options === void 0 ? void 0 : options.enable3D) !== false)
|
|
292
|
+
return exports.CHART_TYPES;
|
|
293
|
+
var groups = [];
|
|
294
|
+
try {
|
|
295
|
+
for (var CHART_TYPES_1 = tslib_1.__values(exports.CHART_TYPES), CHART_TYPES_1_1 = CHART_TYPES_1.next(); !CHART_TYPES_1_1.done; CHART_TYPES_1_1 = CHART_TYPES_1.next()) {
|
|
296
|
+
var _b = tslib_1.__read(CHART_TYPES_1_1.value, 2), category = _b[0], presets = _b[1];
|
|
297
|
+
var kept = presets.filter(function (_a) {
|
|
298
|
+
var _b = tslib_1.__read(_a, 2), preset = _b[1];
|
|
299
|
+
return (0, three_d_1.resolve3DRenderKind)(preset.sourceChartType) === null;
|
|
300
|
+
});
|
|
301
|
+
if (kept.length > 0)
|
|
302
|
+
groups.push([category, kept]);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
306
|
+
finally {
|
|
307
|
+
try {
|
|
308
|
+
if (CHART_TYPES_1_1 && !CHART_TYPES_1_1.done && (_a = CHART_TYPES_1.return)) _a.call(CHART_TYPES_1);
|
|
309
|
+
}
|
|
310
|
+
finally { if (e_1) throw e_1.error; }
|
|
311
|
+
}
|
|
312
|
+
return groups;
|
|
313
|
+
};
|
|
314
|
+
exports.getChartTypes = getChartTypes;
|
|
280
315
|
/** Parse a radius entry ("40%" | 40 | 0) into a number, NaN-safe. */
|
|
281
316
|
var parseRadiusValue = function (value) {
|
|
282
317
|
if (typeof value === "number")
|
|
@@ -333,7 +368,7 @@ var PRESET_DISCRIMINATORS = [
|
|
|
333
368
|
* Falls back to the capitalized chartType when no preset matches.
|
|
334
369
|
*/
|
|
335
370
|
var getChartPresetLabel = function (spec) {
|
|
336
|
-
var
|
|
371
|
+
var e_2, _a, e_3, _b;
|
|
337
372
|
var _c;
|
|
338
373
|
var loose = spec;
|
|
339
374
|
// Doughnut first — it has several encodings (see isDoughnutSpec) and
|
|
@@ -345,8 +380,8 @@ var getChartPresetLabel = function (spec) {
|
|
|
345
380
|
: "Doughnut";
|
|
346
381
|
}
|
|
347
382
|
try {
|
|
348
|
-
for (var
|
|
349
|
-
var _d = tslib_1.__read(
|
|
383
|
+
for (var CHART_TYPES_2 = tslib_1.__values(exports.CHART_TYPES), CHART_TYPES_2_1 = CHART_TYPES_2.next(); !CHART_TYPES_2_1.done; CHART_TYPES_2_1 = CHART_TYPES_2.next()) {
|
|
384
|
+
var _d = tslib_1.__read(CHART_TYPES_2_1.value, 2), presets = _d[1];
|
|
350
385
|
var _loop_1 = function (name_1, config) {
|
|
351
386
|
if (config.chartType !== spec.chartType)
|
|
352
387
|
return "continue";
|
|
@@ -364,28 +399,28 @@ var getChartPresetLabel = function (spec) {
|
|
|
364
399
|
return { value: name_1 };
|
|
365
400
|
};
|
|
366
401
|
try {
|
|
367
|
-
for (var presets_1 = (
|
|
402
|
+
for (var presets_1 = (e_3 = void 0, tslib_1.__values(presets)), presets_1_1 = presets_1.next(); !presets_1_1.done; presets_1_1 = presets_1.next()) {
|
|
368
403
|
var _e = tslib_1.__read(presets_1_1.value, 2), name_1 = _e[0], config = _e[1];
|
|
369
404
|
var state_1 = _loop_1(name_1, config);
|
|
370
405
|
if (typeof state_1 === "object")
|
|
371
406
|
return state_1.value;
|
|
372
407
|
}
|
|
373
408
|
}
|
|
374
|
-
catch (
|
|
409
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
375
410
|
finally {
|
|
376
411
|
try {
|
|
377
412
|
if (presets_1_1 && !presets_1_1.done && (_b = presets_1.return)) _b.call(presets_1);
|
|
378
413
|
}
|
|
379
|
-
finally { if (
|
|
414
|
+
finally { if (e_3) throw e_3.error; }
|
|
380
415
|
}
|
|
381
416
|
}
|
|
382
417
|
}
|
|
383
|
-
catch (
|
|
418
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
384
419
|
finally {
|
|
385
420
|
try {
|
|
386
|
-
if (
|
|
421
|
+
if (CHART_TYPES_2_1 && !CHART_TYPES_2_1.done && (_a = CHART_TYPES_2.return)) _a.call(CHART_TYPES_2);
|
|
387
422
|
}
|
|
388
|
-
finally { if (
|
|
423
|
+
finally { if (e_2) throw e_2.error; }
|
|
389
424
|
}
|
|
390
425
|
var chartType = (_c = spec.chartType) !== null && _c !== void 0 ? _c : "";
|
|
391
426
|
return chartType.charAt(0).toUpperCase() + chartType.slice(1);
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -21,6 +21,16 @@ export type EChartComponentProps = ChartComponentProps & {
|
|
|
21
21
|
* honored.
|
|
22
22
|
*/
|
|
23
23
|
getFormattingFromRange?: ReturnType<typeof useSpreadsheetState>["getFormattingFromRange"];
|
|
24
|
+
/**
|
|
25
|
+
* Draw BAR_3D / LINE_3D / AREA_3D / SURFACE_3D specs through echarts-gl
|
|
26
|
+
* (WebGL). `false` keeps them on their 2-D fallback and never loads
|
|
27
|
+
* echarts-gl — for a page whose Content-Security-Policy has no
|
|
28
|
+
* `'unsafe-eval'`, which claygl needs. The spec keeps its
|
|
29
|
+
* `sourceChartType`, so the xlsx export still writes the 3-D chart. Pass
|
|
30
|
+
* the same value to `ChartEditor` so it hides the 3-D presets. Default
|
|
31
|
+
* `true`.
|
|
32
|
+
*/
|
|
33
|
+
enable3D?: boolean;
|
|
24
34
|
/**
|
|
25
35
|
* Request edit chart
|
|
26
36
|
* @param chart
|
package/dist/cjs/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG;IACvD;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,wBAAwB,EAAE,UAAU,CAClC,OAAO,mBAAmB,CAC3B,CAAC,0BAA0B,CAAC,CAAC;IAC9B;;OAEG;IACH,wBAAwB,EAAE,UAAU,CAClC,OAAO,mBAAmB,CAC3B,CAAC,0BAA0B,CAAC,CAAC;IAC9B;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,UAAU,CACjC,OAAO,mBAAmB,CAC3B,CAAC,wBAAwB,CAAC,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC3C;;OAEG;IACH,kBAAkB,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,oBAAoB,CAAC,CAAC;CAC7E,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG;IACvD;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,wBAAwB,EAAE,UAAU,CAClC,OAAO,mBAAmB,CAC3B,CAAC,0BAA0B,CAAC,CAAC;IAC9B;;OAEG;IACH,wBAAwB,EAAE,UAAU,CAClC,OAAO,mBAAmB,CAC3B,CAAC,0BAA0B,CAAC,CAAC;IAC9B;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,UAAU,CACjC,OAAO,mBAAmB,CAC3B,CAAC,wBAAwB,CAAC,CAAC;IAC5B;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC3C;;OAEG;IACH,kBAAkB,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,oBAAoB,CAAC,CAAC;CAC7E,CAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export type EchartsGlLoadState = "unloaded" | "loading" | "ready" | "failed";
|
|
2
2
|
export declare const getEchartsGlState: () => EchartsGlLoadState;
|
|
3
|
+
/**
|
|
4
|
+
* Record that the loaded module failed at render time (echarts-gl threw
|
|
5
|
+
* from `setOption`), so the renderer keeps the 2-D fallback and never
|
|
6
|
+
* retries 3-D for the rest of the page's lifetime. Warns once per page.
|
|
7
|
+
*/
|
|
8
|
+
export declare const markEchartsGlFailed: (error?: unknown) => void;
|
|
3
9
|
/**
|
|
4
10
|
* Kick off (or join) the echarts-gl dynamic import and register the 3-D
|
|
5
11
|
* charts/components the renderer uses. Resolves true when 3-D rendering is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"echarts-gl-loader.d.ts","sourceRoot":"","sources":["../../../utils/echarts-gl-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"echarts-gl-loader.d.ts","sourceRoot":"","sources":["../../../utils/echarts-gl-loader.ts"],"names":[],"mappings":"AAqBA,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAK7E,eAAO,MAAM,iBAAiB,QAAO,kBAA2B,CAAC;AAgBjE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,OAAO,KAAG,IAUrD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,QAAO,OAAO,CAAC,OAAO,CA8B/C,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,8BAA8B,QAAO,IAGjD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.__resetEchartsGlLoaderForTests = exports.loadEchartsGl = exports.getEchartsGlState = void 0;
|
|
3
|
+
exports.__resetEchartsGlLoaderForTests = exports.loadEchartsGl = exports.markEchartsGlFailed = exports.getEchartsGlState = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
/**
|
|
6
6
|
* Lazy loader for echarts-gl.
|
|
@@ -11,6 +11,14 @@ var tslib_1 = require("tslib");
|
|
|
11
11
|
* draws the 2-D fallback immediately, and upgrades to 3-D when the module
|
|
12
12
|
* resolves. A failed import latches the "failed" state so the renderer
|
|
13
13
|
* keeps the 2-D fallback without retrying on every update.
|
|
14
|
+
*
|
|
15
|
+
* A page whose Content-Security-Policy has no `'unsafe-eval'` is treated
|
|
16
|
+
* the same way: echarts-gl's `EffectCompositor` makes claygl compile its
|
|
17
|
+
* size expressions with `new Function`, which the browser blocks there
|
|
18
|
+
* (`EvalError`, surfaced by claygl as "Invalid expression."). The import
|
|
19
|
+
* itself still succeeds, so the loader probes `new Function` once before
|
|
20
|
+
* importing and latches "failed" instead of letting `setOption` throw
|
|
21
|
+
* later (rowsncolumns/spreadsheet#1187).
|
|
14
22
|
*/
|
|
15
23
|
var components_1 = require("echarts/components");
|
|
16
24
|
var echarts = tslib_1.__importStar(require("echarts/core"));
|
|
@@ -18,6 +26,34 @@ var state = "unloaded";
|
|
|
18
26
|
var loadPromise = null;
|
|
19
27
|
var getEchartsGlState = function () { return state; };
|
|
20
28
|
exports.getEchartsGlState = getEchartsGlState;
|
|
29
|
+
/**
|
|
30
|
+
* True when the page lets scripts construct functions from source — what
|
|
31
|
+
* claygl needs for every GL chart. False under a CSP whose `script-src`
|
|
32
|
+
* lacks `'unsafe-eval'`.
|
|
33
|
+
*/
|
|
34
|
+
var canEvaluateCode = function () {
|
|
35
|
+
try {
|
|
36
|
+
new Function("");
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
catch (_a) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Record that the loaded module failed at render time (echarts-gl threw
|
|
45
|
+
* from `setOption`), so the renderer keeps the 2-D fallback and never
|
|
46
|
+
* retries 3-D for the rest of the page's lifetime. Warns once per page.
|
|
47
|
+
*/
|
|
48
|
+
var markEchartsGlFailed = function (error) {
|
|
49
|
+
if (state !== "failed") {
|
|
50
|
+
// eslint-disable-next-line no-console
|
|
51
|
+
console.warn("echarts-gl failed to render a 3-D chart; 3-D charts render as their 2-D fallback on this page.", error);
|
|
52
|
+
}
|
|
53
|
+
state = "failed";
|
|
54
|
+
loadPromise = Promise.resolve(false);
|
|
55
|
+
};
|
|
56
|
+
exports.markEchartsGlFailed = markEchartsGlFailed;
|
|
21
57
|
/**
|
|
22
58
|
* Kick off (or join) the echarts-gl dynamic import and register the 3-D
|
|
23
59
|
* charts/components the renderer uses. Resolves true when 3-D rendering is
|
|
@@ -25,6 +61,11 @@ exports.getEchartsGlState = getEchartsGlState;
|
|
|
25
61
|
*/
|
|
26
62
|
var loadEchartsGl = function () {
|
|
27
63
|
if (!loadPromise) {
|
|
64
|
+
if (!canEvaluateCode()) {
|
|
65
|
+
state = "failed";
|
|
66
|
+
loadPromise = Promise.resolve(false);
|
|
67
|
+
return loadPromise;
|
|
68
|
+
}
|
|
28
69
|
state = "loading";
|
|
29
70
|
loadPromise = Promise.all([
|
|
30
71
|
Promise.resolve().then(function () { return tslib_1.__importStar(require("echarts-gl/charts")); }),
|
|
@@ -44,14 +44,25 @@ export declare const normalize3DSourceType: (sourceChartType?: string | null) =>
|
|
|
44
44
|
export declare const is3DSpec: (spec: {
|
|
45
45
|
sourceChartType?: string | null;
|
|
46
46
|
} | null | undefined) => boolean;
|
|
47
|
+
/** Host opt-out of the WebGL pipeline (`enable3D` on the renderer / editor). */
|
|
48
|
+
export type ThreeDRenderOptions = {
|
|
49
|
+
/**
|
|
50
|
+
* `false` keeps every spec on its 2-D fallback: echarts-gl is never
|
|
51
|
+
* loaded and the Chart editor offers no echarts-gl preset. The spec's
|
|
52
|
+
* `sourceChartType` is untouched, so the xlsx export still writes the
|
|
53
|
+
* 3-D chart (rowsncolumns/spreadsheet#1187). Default `true`.
|
|
54
|
+
*/
|
|
55
|
+
enable3D?: boolean;
|
|
56
|
+
};
|
|
47
57
|
/**
|
|
48
58
|
* Map a `sourceChartType` token to the echarts-gl series kind it renders
|
|
49
59
|
* as, or null when the 3-D pipeline should not run:
|
|
50
60
|
* - PIE_3D — echarts-gl has no pie3D, so the 2-D pie fallback stays.
|
|
51
61
|
* - AREA_3D — echarts-gl has no area3D; rendered as line3D.
|
|
52
62
|
* - non-3-D / unknown tokens.
|
|
63
|
+
* - any token when the host turned 3-D off (`enable3D: false`).
|
|
53
64
|
*/
|
|
54
|
-
export declare const resolve3DRenderKind: (sourceChartType?: string | null) => ThreeDRenderKind | null;
|
|
65
|
+
export declare const resolve3DRenderKind: (sourceChartType?: string | null, options?: ThreeDRenderOptions) => ThreeDRenderKind | null;
|
|
55
66
|
/** Excel's Contour: the surface grid seen from above, as a flat heatmap. */
|
|
56
67
|
export declare const isContourSpec: (spec: {
|
|
57
68
|
sourceChartType?: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"three-d.d.ts","sourceRoot":"","sources":["../../../utils/three-d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,QAAA,MAAM,cAAc,8EAOV,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAI9D;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,kBAAkB,MAAM,GAAG,IAAI,KAC9B,gBAAgB,GAAG,IAIrB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,MAAM;IAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KAC3D,OAAgE,CAAC;AAEpE
|
|
1
|
+
{"version":3,"file":"three-d.d.ts","sourceRoot":"","sources":["../../../utils/three-d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,QAAA,MAAM,cAAc,8EAOV,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAI9D;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAChC,kBAAkB,MAAM,GAAG,IAAI,KAC9B,gBAAgB,GAAG,IAIrB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GACnB,MAAM;IAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KAC3D,OAAgE,CAAC;AAEpE,gFAAgF;AAChF,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC9B,kBAAkB,MAAM,GAAG,IAAI,EAC/B,UAAU,mBAAmB,KAC5B,gBAAgB,GAAG,IAerB,CAAC;AAEF,4EAA4E;AAC5E,eAAO,MAAM,aAAa,GACxB,MAAM;IAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KAC3D,OAAqE,CAAC;AAEzE,uFAAuF;AACvF,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,iBAAiB,EAAE,KAC1B,YAAY,EAcd,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;CACvC,CAAC;AAEF,wDAAwD;AACxD,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAKnD,8DAA8D;AAC9D,eAAO,MAAM,gBAAgB,GAAI,QAAQ,iBAAiB,EAAE,KAAG,MACO,CAAC;AAEvE;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,iBAAiB,EAAE,KAAG,WAAW,EAUvE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,QAAQ,iBAAiB,EAAE,KAC1B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,EAAE,CAAA;CAAE,EASpC,CAAC;AAEL;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,iBAAiB,EAAE,KAC1B,WAAW,EAcb,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,WAAW,EAAE,KAAG,CAAC,MAAM,EAAE,MAAM,CASrE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAY/C,CAAC"}
|
|
@@ -64,8 +64,11 @@ exports.is3DSpec = is3DSpec;
|
|
|
64
64
|
* - PIE_3D — echarts-gl has no pie3D, so the 2-D pie fallback stays.
|
|
65
65
|
* - AREA_3D — echarts-gl has no area3D; rendered as line3D.
|
|
66
66
|
* - non-3-D / unknown tokens.
|
|
67
|
+
* - any token when the host turned 3-D off (`enable3D: false`).
|
|
67
68
|
*/
|
|
68
|
-
var resolve3DRenderKind = function (sourceChartType) {
|
|
69
|
+
var resolve3DRenderKind = function (sourceChartType, options) {
|
|
70
|
+
if ((options === null || options === void 0 ? void 0 : options.enable3D) === false)
|
|
71
|
+
return null;
|
|
69
72
|
switch ((0, exports.normalize3DSourceType)(sourceChartType)) {
|
|
70
73
|
case "BAR_3D":
|
|
71
74
|
return "bar3D";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { EChartComponentProps } from "../types";
|
|
3
3
|
export type BasicChartProps = EChartComponentProps;
|
|
4
|
-
export declare const BasicChart: ({ width, height, chart, theme, isDarkMode, sheetId, readonly, getDomainValuesFromRange, getSeriesValuesFromRange, getFormattingFromRange, onDeleteChart, onUpdateChart, onRequestEdit, onRequestCalculate, isSelected, fieldButtons, locale, }: BasicChartProps) => React.JSX.Element;
|
|
4
|
+
export declare const BasicChart: ({ width, height, chart, theme, isDarkMode, sheetId, readonly, getDomainValuesFromRange, getSeriesValuesFromRange, getFormattingFromRange, onDeleteChart, onUpdateChart, onRequestEdit, onRequestCalculate, isSelected, fieldButtons, locale, enable3D, }: BasicChartProps) => React.JSX.Element;
|
|
5
5
|
//# sourceMappingURL=basic-chart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAkEA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"basic-chart.d.ts","sourceRoot":"","sources":["../../../basic-chart/basic-chart.tsx"],"names":[],"mappings":"AAkEA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAyTrD,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAiGnD,eAAO,MAAM,UAAU,GAAI,0PAmBxB,eAAe,sBA2wHjB,CAAC"}
|
|
@@ -20,7 +20,7 @@ import { canSwitchRowColumn, cellLabelGetterFromRangeReader, switchRowColumn, }
|
|
|
20
20
|
import { coerceCalculatedLabel, getChartDataRanges, } from "../utils/chart-spec-utils";
|
|
21
21
|
import { getChartPalette } from "../utils/chart-styles";
|
|
22
22
|
import { clampDoughnutHole, doughnutRings } from "../utils/doughnut";
|
|
23
|
-
import { getEchartsGlState, loadEchartsGl, } from "../utils/echarts-gl-loader";
|
|
23
|
+
import { getEchartsGlState, loadEchartsGl, markEchartsGlFailed, } from "../utils/echarts-gl-loader";
|
|
24
24
|
import { buildEchartsOverlaySeries } from "../utils/echarts-overlays";
|
|
25
25
|
import { applyEmptyCellsPolicy, connectsAcrossEmptyCells, isLineLikeChartType, isolatedPointIndexes, } from "../utils/empty-cells";
|
|
26
26
|
import { gradientToEcharts } from "../utils/gradient";
|
|
@@ -248,7 +248,7 @@ const defaultLegendConfig = {
|
|
|
248
248
|
};
|
|
249
249
|
/** Category-axis title gap: clears one row of tick labels (#986). */
|
|
250
250
|
const CATEGORY_AXIS_NAME_GAP = categoryAxisNameGap();
|
|
251
|
-
export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, readonly, getDomainValuesFromRange, getSeriesValuesFromRange, getFormattingFromRange, onDeleteChart, onUpdateChart, onRequestEdit, onRequestCalculate, isSelected, fieldButtons, locale, }) => {
|
|
251
|
+
export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, readonly, getDomainValuesFromRange, getSeriesValuesFromRange, getFormattingFromRange, onDeleteChart, onUpdateChart, onRequestEdit, onRequestCalculate, isSelected, fieldButtons, locale, enable3D, }) => {
|
|
252
252
|
const spec = chart.spec;
|
|
253
253
|
const explicitChartTitle = chart.spec.title ?? undefined;
|
|
254
254
|
const hierarchyTitleRef = useRef(explicitChartTitle);
|
|
@@ -428,7 +428,7 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
|
|
|
428
428
|
// SSR, import failure, PIE_3D) the 2-D fallback renders untouched.
|
|
429
429
|
// The 3-D and region-map gates key off disjoint sourceChartType
|
|
430
430
|
// tokens, so a spec can never satisfy both.
|
|
431
|
-
const threeDRenderKind = resolve3DRenderKind(spec.sourceChartType);
|
|
431
|
+
const threeDRenderKind = resolve3DRenderKind(spec.sourceChartType, { enable3D });
|
|
432
432
|
const canRender3D = threeDRenderKind !== null && isWebGLAvailable();
|
|
433
433
|
const willRender3D = canRender3D && getEchartsGlState() === "ready";
|
|
434
434
|
if (canRender3D && !willRender3D && getEchartsGlState() !== "failed") {
|
|
@@ -1327,38 +1327,63 @@ export const BasicChart = ({ width, height, chart, theme, isDarkMode, sheetId, r
|
|
|
1327
1327
|
inRange: { color: [...SURFACE_COLOR_RAMP] },
|
|
1328
1328
|
};
|
|
1329
1329
|
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1330
|
+
// echarts-gl builds its GL scene inside setOption, and that can
|
|
1331
|
+
// throw after the module loaded fine — claygl compiles compositor
|
|
1332
|
+
// sizes with `new Function`, which a CSP without 'unsafe-eval'
|
|
1333
|
+
// blocks (rowsncolumns/spreadsheet#1187). Latch the failure so no
|
|
1334
|
+
// chart retries 3-D, drop the half-built instance and draw the 2-D
|
|
1335
|
+
// fallback instead of leaving the chart blank.
|
|
1336
|
+
try {
|
|
1337
|
+
chartRef.current?.setOption({
|
|
1338
|
+
tooltip: {
|
|
1339
|
+
textStyle: { fontSize: 12 },
|
|
1340
|
+
formatter: threeDTooltipFormatter,
|
|
1341
|
+
},
|
|
1342
|
+
legend: threeDRenderKind === "line3D" || stackedBar3D
|
|
1343
|
+
? applyLegendOverrides({
|
|
1344
|
+
...defaultLegendConfig,
|
|
1345
|
+
show: seriesNames.length > 1,
|
|
1346
|
+
data: seriesNames,
|
|
1347
|
+
}, spec.legend)
|
|
1348
|
+
: { show: false },
|
|
1349
|
+
xAxis3D: { ...xAxis3D, name: spec.horizontalAxisTitle ?? "" },
|
|
1350
|
+
yAxis3D: { ...yAxis3D, name: "" },
|
|
1351
|
+
zAxis3D: { type: "value", name: spec.verticalAxisTitle ?? "" },
|
|
1352
|
+
grid3D: {
|
|
1353
|
+
boxDepth: Math.max(20, Math.min(100, seriesNames.length * 20)),
|
|
1354
|
+
viewControl: { autoRotate: false },
|
|
1355
|
+
},
|
|
1356
|
+
...(visualMap ? { visualMap: [visualMap] } : {}),
|
|
1357
|
+
series: threeDSeries,
|
|
1358
|
+
}, {
|
|
1359
|
+
replaceMerge: [
|
|
1360
|
+
"series",
|
|
1361
|
+
"xAxis3D",
|
|
1362
|
+
"yAxis3D",
|
|
1363
|
+
"zAxis3D",
|
|
1364
|
+
"visualMap",
|
|
1365
|
+
"legend",
|
|
1366
|
+
"tooltip",
|
|
1367
|
+
],
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
catch (error) {
|
|
1371
|
+
markEchartsGlFailed(error);
|
|
1372
|
+
try {
|
|
1373
|
+
chartRef.current?.dispose();
|
|
1374
|
+
}
|
|
1375
|
+
catch {
|
|
1376
|
+
// A GL instance that threw mid-build may not dispose cleanly.
|
|
1377
|
+
}
|
|
1378
|
+
chartRef.current = undefined;
|
|
1379
|
+
renderedIn3D.current = false;
|
|
1380
|
+
previousChartType.current = undefined;
|
|
1381
|
+
previousSeriesCount.current = undefined;
|
|
1382
|
+
initializeChart();
|
|
1383
|
+
applyThemeOptions();
|
|
1384
|
+
await updateChart();
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1362
1387
|
// Re-apply theme-derived title / palette / tooltip colors — lost
|
|
1363
1388
|
// when the instance was re-initialized on entry into 3-D.
|
|
1364
1389
|
renderedIn3D.current = true;
|
|
@@ -16,7 +16,13 @@ type ChartEditorProps = {
|
|
|
16
16
|
* from the data range. Without it the switched series are unnamed.
|
|
17
17
|
*/
|
|
18
18
|
getFormattedValue?: ChartCellLabelGetter;
|
|
19
|
+
/**
|
|
20
|
+
* Mirror of the renderer's `enable3D`: `false` hides the presets that
|
|
21
|
+
* render through echarts-gl (3-D Column / Bar / Line / Area / Surface).
|
|
22
|
+
* An existing 3-D spec keeps its `sourceChartType`. Default `true`.
|
|
23
|
+
*/
|
|
24
|
+
enable3D?: boolean;
|
|
19
25
|
};
|
|
20
|
-
export declare const ChartEditor: ({ chart, sheetId, onSubmit, onRequestMoveChart, getFormattedValue, }: ChartEditorProps) => React.JSX.Element;
|
|
26
|
+
export declare const ChartEditor: ({ chart, sheetId, onSubmit, onRequestMoveChart, getFormattedValue, enable3D, }: ChartEditorProps) => React.JSX.Element;
|
|
21
27
|
export default ChartEditor;
|
|
22
28
|
//# sourceMappingURL=chart-editor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-editor.d.ts","sourceRoot":"","sources":["../../../../components/editors/chart-editor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAGV,aAAa,EAGd,MAAM,2BAA2B,CAAC;AAwBnC,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AAuDvC,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IACtC;;;;OAIG;IACH,kBAAkB,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAChD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"chart-editor.d.ts","sourceRoot":"","sources":["../../../../components/editors/chart-editor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAGV,aAAa,EAGd,MAAM,2BAA2B,CAAC;AAwBnC,OAAO,KAAkB,MAAM,OAAO,CAAC;AAIvC,OAAO,EAEL,KAAK,oBAAoB,EAG1B,MAAM,+BAA+B,CAAC;AAuDvC,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IACtC;;;;OAIG;IACH,kBAAkB,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAChD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAuBF,eAAO,MAAM,WAAW,GAAI,gFAOzB,gBAAgB,sBAmhClB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { uuid } from "@rowsncolumns/utils";
|
|
|
7
7
|
import { useFormik } from "formik";
|
|
8
8
|
import React, { useMemo } from "react";
|
|
9
9
|
import { useSetChartEditorDialogState } from "../../atoms/editing-chart.atom";
|
|
10
|
-
import {
|
|
10
|
+
import { getChartPresetLabel, getChartTypes } from "../../config";
|
|
11
11
|
import { canSwitchRowColumn, inferSeriesOrientation, switchRowColumn, } from "../../utils/chart-orientation";
|
|
12
12
|
import { isBasicChartSpec, isBubbleChartSpec, isHierarchyChartSpec, mergeChartSpec, } from "../../utils/chart-spec-utils";
|
|
13
13
|
import { applyChartColorPalette, applyChartQuickLayout, applyChartStyle, CHART_COLOR_PALETTES, CHART_QUICK_LAYOUTS, CHART_STYLES, resetChartToMatchStyle, } from "../../utils/chart-styles";
|
|
@@ -47,8 +47,9 @@ const Section = ({ title, defaultOpen = false, children, }) => (React.createElem
|
|
|
47
47
|
React.createElement(ChevronRightIcon, { className: "shrink-0 transition-transform group-open:rotate-90" }),
|
|
48
48
|
title),
|
|
49
49
|
React.createElement("div", { className: "flex flex-col gap-2 pb-3" }, children)));
|
|
50
|
-
export const ChartEditor = ({ chart, sheetId, onSubmit, onRequestMoveChart, getFormattedValue, }) => {
|
|
50
|
+
export const ChartEditor = ({ chart, sheetId, onSubmit, onRequestMoveChart, getFormattedValue, enable3D, }) => {
|
|
51
51
|
const setChartDialogState = useSetChartEditorDialogState();
|
|
52
|
+
const chartTypes = getChartTypes({ enable3D });
|
|
52
53
|
// Close dialog
|
|
53
54
|
const closeDialog = () => setChartDialogState(false);
|
|
54
55
|
// Keyed on chart identity so a position sync (move/resize while the
|
|
@@ -218,7 +219,7 @@ export const ChartEditor = ({ chart, sheetId, onSubmit, onRequestMoveChart, getF
|
|
|
218
219
|
React.createElement(DropdownRightSlot, null,
|
|
219
220
|
React.createElement(TriangleDownIcon, null)))),
|
|
220
221
|
React.createElement(DropdownMenuPortal, null,
|
|
221
|
-
React.createElement(DropdownMenuContent, { align: "start", sideOffset: 0 },
|
|
222
|
+
React.createElement(DropdownMenuContent, { align: "start", sideOffset: 0 }, chartTypes.map(([category, types]) => {
|
|
222
223
|
return (React.createElement(DropdownMenuSub, { key: category },
|
|
223
224
|
React.createElement(DropdownMenuSubTrigger, null,
|
|
224
225
|
React.createElement(DropdownLeftSlot, null,
|
package/dist/esm/config.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { ChartSpec } from "@rowsncolumns/spreadsheet";
|
|
2
|
+
import { type ThreeDRenderOptions } from "./utils/three-d";
|
|
2
3
|
export declare const CHART_TYPES: Array<[string, Array<[string, Partial<ChartSpec>]>]>;
|
|
4
|
+
/**
|
|
5
|
+
* The Chart editor's preset list. With `enable3D: false` the presets the
|
|
6
|
+
* renderer would draw through echarts-gl (3-D Column / Bar / Line / Area,
|
|
7
|
+
* their stacked variants and 3-D Surface) are left out; 3-D Pie and
|
|
8
|
+
* Contour stay since they never render in WebGL. A spec that already
|
|
9
|
+
* carries a 3-D `sourceChartType` is not rewritten — only the picker
|
|
10
|
+
* changes (rowsncolumns/spreadsheet#1187).
|
|
11
|
+
*/
|
|
12
|
+
export declare const getChartTypes: (options?: ThreeDRenderOptions) => Array<[string, Array<[string, Partial<ChartSpec>]>]>;
|
|
3
13
|
/**
|
|
4
14
|
* True when a spec is doughnut-shaped: the first-class
|
|
5
15
|
* `chartType: "doughnut"` token, or the two legacy pie encodings —
|
package/dist/esm/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAsRhF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAgB1E,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACxB,UAAU,mBAAmB,KAC5B,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAarD,CAAC;AAYF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,OAAO,CAAC,SAAS,CAAC,KAAG,OAQzD,CAAC;AAuBF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,OAAO,CAAC,SAAS,CAAC,KAAG,MA4B9D,CAAC"}
|
package/dist/esm/config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_PIE_EXPLOSION } from "./utils/pie-explosion";
|
|
2
|
+
import { resolve3DRenderKind } from "./utils/three-d";
|
|
2
3
|
// Excel's 3-D chart classes degrade to a 2-D chartType with the authored
|
|
3
4
|
// class kept as `sourceChartType` (BAR_3D, LINE_3D, PIE_3D, AREA_3D,
|
|
4
5
|
// SURFACE, SURFACE_3D). The renderer draws BAR_3D / LINE_3D / AREA_3D /
|
|
@@ -273,6 +274,25 @@ export const CHART_TYPES = [
|
|
|
273
274
|
["Stock", STOCK_CHART_TYPES],
|
|
274
275
|
["Combo", COMBO_CHART_TYPES],
|
|
275
276
|
];
|
|
277
|
+
/**
|
|
278
|
+
* The Chart editor's preset list. With `enable3D: false` the presets the
|
|
279
|
+
* renderer would draw through echarts-gl (3-D Column / Bar / Line / Area,
|
|
280
|
+
* their stacked variants and 3-D Surface) are left out; 3-D Pie and
|
|
281
|
+
* Contour stay since they never render in WebGL. A spec that already
|
|
282
|
+
* carries a 3-D `sourceChartType` is not rewritten — only the picker
|
|
283
|
+
* changes (rowsncolumns/spreadsheet#1187).
|
|
284
|
+
*/
|
|
285
|
+
export const getChartTypes = (options) => {
|
|
286
|
+
if (options?.enable3D !== false)
|
|
287
|
+
return CHART_TYPES;
|
|
288
|
+
const groups = [];
|
|
289
|
+
for (const [category, presets] of CHART_TYPES) {
|
|
290
|
+
const kept = presets.filter(([, preset]) => resolve3DRenderKind(preset.sourceChartType) === null);
|
|
291
|
+
if (kept.length > 0)
|
|
292
|
+
groups.push([category, kept]);
|
|
293
|
+
}
|
|
294
|
+
return groups;
|
|
295
|
+
};
|
|
276
296
|
/** Parse a radius entry ("40%" | 40 | 0) into a number, NaN-safe. */
|
|
277
297
|
const parseRadiusValue = (value) => {
|
|
278
298
|
if (typeof value === "number")
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -21,6 +21,16 @@ export type EChartComponentProps = ChartComponentProps & {
|
|
|
21
21
|
* honored.
|
|
22
22
|
*/
|
|
23
23
|
getFormattingFromRange?: ReturnType<typeof useSpreadsheetState>["getFormattingFromRange"];
|
|
24
|
+
/**
|
|
25
|
+
* Draw BAR_3D / LINE_3D / AREA_3D / SURFACE_3D specs through echarts-gl
|
|
26
|
+
* (WebGL). `false` keeps them on their 2-D fallback and never loads
|
|
27
|
+
* echarts-gl — for a page whose Content-Security-Policy has no
|
|
28
|
+
* `'unsafe-eval'`, which claygl needs. The spec keeps its
|
|
29
|
+
* `sourceChartType`, so the xlsx export still writes the 3-D chart. Pass
|
|
30
|
+
* the same value to `ChartEditor` so it hides the 3-D presets. Default
|
|
31
|
+
* `true`.
|
|
32
|
+
*/
|
|
33
|
+
enable3D?: boolean;
|
|
24
34
|
/**
|
|
25
35
|
* Request edit chart
|
|
26
36
|
* @param chart
|
package/dist/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG;IACvD;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,wBAAwB,EAAE,UAAU,CAClC,OAAO,mBAAmB,CAC3B,CAAC,0BAA0B,CAAC,CAAC;IAC9B;;OAEG;IACH,wBAAwB,EAAE,UAAU,CAClC,OAAO,mBAAmB,CAC3B,CAAC,0BAA0B,CAAC,CAAC;IAC9B;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,UAAU,CACjC,OAAO,mBAAmB,CAC3B,CAAC,wBAAwB,CAAC,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC3C;;OAEG;IACH,kBAAkB,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,oBAAoB,CAAC,CAAC;CAC7E,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG;IACvD;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,wBAAwB,EAAE,UAAU,CAClC,OAAO,mBAAmB,CAC3B,CAAC,0BAA0B,CAAC,CAAC;IAC9B;;OAEG;IACH,wBAAwB,EAAE,UAAU,CAClC,OAAO,mBAAmB,CAC3B,CAAC,0BAA0B,CAAC,CAAC;IAC9B;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,UAAU,CACjC,OAAO,mBAAmB,CAC3B,CAAC,wBAAwB,CAAC,CAAC;IAC5B;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC3C;;OAEG;IACH,kBAAkB,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,oBAAoB,CAAC,CAAC;CAC7E,CAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export type EchartsGlLoadState = "unloaded" | "loading" | "ready" | "failed";
|
|
2
2
|
export declare const getEchartsGlState: () => EchartsGlLoadState;
|
|
3
|
+
/**
|
|
4
|
+
* Record that the loaded module failed at render time (echarts-gl threw
|
|
5
|
+
* from `setOption`), so the renderer keeps the 2-D fallback and never
|
|
6
|
+
* retries 3-D for the rest of the page's lifetime. Warns once per page.
|
|
7
|
+
*/
|
|
8
|
+
export declare const markEchartsGlFailed: (error?: unknown) => void;
|
|
3
9
|
/**
|
|
4
10
|
* Kick off (or join) the echarts-gl dynamic import and register the 3-D
|
|
5
11
|
* charts/components the renderer uses. Resolves true when 3-D rendering is
|