@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
|
@@ -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"}
|
|
@@ -7,12 +7,47 @@
|
|
|
7
7
|
* draws the 2-D fallback immediately, and upgrades to 3-D when the module
|
|
8
8
|
* resolves. A failed import latches the "failed" state so the renderer
|
|
9
9
|
* keeps the 2-D fallback without retrying on every update.
|
|
10
|
+
*
|
|
11
|
+
* A page whose Content-Security-Policy has no `'unsafe-eval'` is treated
|
|
12
|
+
* the same way: echarts-gl's `EffectCompositor` makes claygl compile its
|
|
13
|
+
* size expressions with `new Function`, which the browser blocks there
|
|
14
|
+
* (`EvalError`, surfaced by claygl as "Invalid expression."). The import
|
|
15
|
+
* itself still succeeds, so the loader probes `new Function` once before
|
|
16
|
+
* importing and latches "failed" instead of letting `setOption` throw
|
|
17
|
+
* later (rowsncolumns/spreadsheet#1187).
|
|
10
18
|
*/
|
|
11
19
|
import { VisualMapComponent } from "echarts/components";
|
|
12
20
|
import * as echarts from "echarts/core";
|
|
13
21
|
let state = "unloaded";
|
|
14
22
|
let loadPromise = null;
|
|
15
23
|
export const getEchartsGlState = () => state;
|
|
24
|
+
/**
|
|
25
|
+
* True when the page lets scripts construct functions from source — what
|
|
26
|
+
* claygl needs for every GL chart. False under a CSP whose `script-src`
|
|
27
|
+
* lacks `'unsafe-eval'`.
|
|
28
|
+
*/
|
|
29
|
+
const canEvaluateCode = () => {
|
|
30
|
+
try {
|
|
31
|
+
new Function("");
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Record that the loaded module failed at render time (echarts-gl threw
|
|
40
|
+
* from `setOption`), so the renderer keeps the 2-D fallback and never
|
|
41
|
+
* retries 3-D for the rest of the page's lifetime. Warns once per page.
|
|
42
|
+
*/
|
|
43
|
+
export const markEchartsGlFailed = (error) => {
|
|
44
|
+
if (state !== "failed") {
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console.warn("echarts-gl failed to render a 3-D chart; 3-D charts render as their 2-D fallback on this page.", error);
|
|
47
|
+
}
|
|
48
|
+
state = "failed";
|
|
49
|
+
loadPromise = Promise.resolve(false);
|
|
50
|
+
};
|
|
16
51
|
/**
|
|
17
52
|
* Kick off (or join) the echarts-gl dynamic import and register the 3-D
|
|
18
53
|
* charts/components the renderer uses. Resolves true when 3-D rendering is
|
|
@@ -20,6 +55,11 @@ export const getEchartsGlState = () => state;
|
|
|
20
55
|
*/
|
|
21
56
|
export const loadEchartsGl = () => {
|
|
22
57
|
if (!loadPromise) {
|
|
58
|
+
if (!canEvaluateCode()) {
|
|
59
|
+
state = "failed";
|
|
60
|
+
loadPromise = Promise.resolve(false);
|
|
61
|
+
return loadPromise;
|
|
62
|
+
}
|
|
23
63
|
state = "loading";
|
|
24
64
|
loadPromise = Promise.all([
|
|
25
65
|
import("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,gBA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
|
58
58
|
* - PIE_3D — echarts-gl has no pie3D, so the 2-D pie fallback stays.
|
|
59
59
|
* - AREA_3D — echarts-gl has no area3D; rendered as line3D.
|
|
60
60
|
* - non-3-D / unknown tokens.
|
|
61
|
+
* - any token when the host turned 3-D off (`enable3D: false`).
|
|
61
62
|
*/
|
|
62
|
-
export const resolve3DRenderKind = (sourceChartType) => {
|
|
63
|
+
export const resolve3DRenderKind = (sourceChartType, options) => {
|
|
64
|
+
if (options?.enable3D === false)
|
|
65
|
+
return null;
|
|
63
66
|
switch (normalize3DSourceType(sourceChartType)) {
|
|
64
67
|
case "BAR_3D":
|
|
65
68
|
return "bar3D";
|