@validationcloud/fractal-ui 1.51.0 → 1.53.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.
Files changed (25) hide show
  1. package/dist/assets/vc-logo.svg.js +4 -0
  2. package/dist/components/echarts-renderer/calculate-title-layout.d.ts +8 -0
  3. package/dist/components/echarts-renderer/calculate-title-layout.js +72 -0
  4. package/dist/components/echarts-renderer/calculate-title-layout.test.d.ts +1 -0
  5. package/dist/components/echarts-renderer/detect-horizontal-bars.d.ts +13 -0
  6. package/dist/components/echarts-renderer/detect-horizontal-bars.js +13 -0
  7. package/dist/components/echarts-renderer/mavrik-chart.d.ts +19 -0
  8. package/dist/components/echarts-renderer/mavrik-chart.js +12 -0
  9. package/dist/components/echarts-renderer/mavrik-theme-horizontal.json.d.ts +277 -0
  10. package/dist/components/echarts-renderer/mavrik-theme-horizontal.json.js +33 -0
  11. package/dist/components/echarts-renderer/mavrik-theme.d.ts +246 -0
  12. package/dist/components/echarts-renderer/mavrik-theme.js +18 -6
  13. package/dist/components/echarts-renderer/mavrik-theme.json.d.ts +15 -7
  14. package/dist/components/echarts-renderer/mavrik-theme.json.js +18 -18
  15. package/dist/components/echarts-renderer/sanitize-chart-options.d.ts +6 -0
  16. package/dist/components/echarts-renderer/sanitize-chart-options.js +9 -0
  17. package/dist/components/echarts-renderer/use-chart-instance.d.ts +0 -1
  18. package/dist/components/echarts-renderer/use-chart-instance.js +54 -37
  19. package/dist/components/echarts-renderer/watermark-graphic.d.ts +12 -0
  20. package/dist/components/echarts-renderer/watermark-graphic.js +25 -0
  21. package/dist/index.d.ts +2 -1
  22. package/dist/index.js +57 -54
  23. package/dist/lib/render-chart-to-image.js +36 -19
  24. package/dist/lib/render-mavrik-chart-to-image.d.ts +33 -0
  25. package/package.json +19 -15
@@ -1,3 +1,5 @@
1
+ import { EChartsOption } from 'echarts';
2
+ /** Default Mavrik theme with vertical gradients (for vertical bars and other charts) */
1
3
  export declare const MAVRIK_THEME: {
2
4
  readonly name: "mavrik";
3
5
  readonly config: {
@@ -63,6 +65,7 @@ export declare const MAVRIK_THEME: {
63
65
  axisLabel: {
64
66
  show: boolean;
65
67
  color: string;
68
+ hideOverlap: boolean;
66
69
  };
67
70
  nameLocation: string;
68
71
  nameTextStyle: {
@@ -84,6 +87,7 @@ export declare const MAVRIK_THEME: {
84
87
  axisLabel: {
85
88
  show: boolean;
86
89
  color: string;
90
+ hideOverlap: boolean;
87
91
  };
88
92
  nameLocation: string;
89
93
  nameTextStyle: {
@@ -109,6 +113,7 @@ export declare const MAVRIK_THEME: {
109
113
  axisLabel: {
110
114
  show: boolean;
111
115
  color: string;
116
+ hideOverlap: boolean;
112
117
  };
113
118
  nameLocation: string;
114
119
  nameTextStyle: {
@@ -137,6 +142,7 @@ export declare const MAVRIK_THEME: {
137
142
  axisLabel: {
138
143
  show: boolean;
139
144
  color: string;
145
+ hideOverlap: boolean;
140
146
  };
141
147
  nameLocation: string;
142
148
  nameTextStyle: {
@@ -225,3 +231,243 @@ export declare const MAVRIK_THEME: {
225
231
  };
226
232
  };
227
233
  };
234
+ /** Mavrik theme variant with horizontal gradients (for horizontal bar charts) */
235
+ export declare const MAVRIK_THEME_HORIZONTAL: {
236
+ readonly name: "mavrik-horizontal";
237
+ readonly config: {
238
+ color: {
239
+ type: string;
240
+ x: number;
241
+ y: number;
242
+ x2: number;
243
+ y2: number;
244
+ colorStops: {
245
+ offset: number;
246
+ color: string;
247
+ }[];
248
+ }[];
249
+ backgroundColor: string;
250
+ textStyle: {
251
+ fontFamily: string;
252
+ fontWeight: number;
253
+ };
254
+ title: {
255
+ top: number;
256
+ left: number;
257
+ textStyle: {
258
+ color: string;
259
+ fontSize: number;
260
+ fontWeight: number;
261
+ };
262
+ subtextStyle: {
263
+ color: string;
264
+ };
265
+ };
266
+ line: {
267
+ itemStyle: {
268
+ borderWidth: number;
269
+ };
270
+ lineStyle: {
271
+ width: number;
272
+ };
273
+ areaStyle: {
274
+ opacity: number;
275
+ };
276
+ showSymbol: boolean;
277
+ symbolSize: number;
278
+ symbol: string;
279
+ smooth: boolean;
280
+ sampling: string;
281
+ };
282
+ bar: {
283
+ barGap: string;
284
+ barCategoryGap: string;
285
+ };
286
+ categoryAxis: {
287
+ axisLine: {
288
+ show: boolean;
289
+ lineStyle: {
290
+ color: string;
291
+ type: string;
292
+ };
293
+ };
294
+ axisTick: {
295
+ show: boolean;
296
+ };
297
+ axisLabel: {
298
+ show: boolean;
299
+ color: string;
300
+ hideOverlap: boolean;
301
+ };
302
+ nameLocation: string;
303
+ nameTextStyle: {
304
+ color: string;
305
+ fontSize: number;
306
+ fontWeight: number;
307
+ };
308
+ splitLine: {
309
+ show: boolean;
310
+ };
311
+ };
312
+ valueAxis: {
313
+ axisLine: {
314
+ show: boolean;
315
+ };
316
+ axisTick: {
317
+ show: boolean;
318
+ };
319
+ axisLabel: {
320
+ show: boolean;
321
+ color: string;
322
+ hideOverlap: boolean;
323
+ };
324
+ nameLocation: string;
325
+ nameTextStyle: {
326
+ color: string;
327
+ fontSize: number;
328
+ fontWeight: number;
329
+ };
330
+ splitLine: {
331
+ show: boolean;
332
+ lineStyle: {
333
+ color: string[];
334
+ type: string;
335
+ };
336
+ };
337
+ };
338
+ logAxis: {
339
+ axisLine: {
340
+ show: boolean;
341
+ };
342
+ axisTick: {
343
+ show: boolean;
344
+ };
345
+ axisLabel: {
346
+ show: boolean;
347
+ color: string;
348
+ hideOverlap: boolean;
349
+ };
350
+ nameLocation: string;
351
+ nameTextStyle: {
352
+ color: string;
353
+ fontSize: number;
354
+ fontWeight: number;
355
+ };
356
+ splitLine: {
357
+ show: boolean;
358
+ lineStyle: {
359
+ color: string[];
360
+ type: string;
361
+ };
362
+ };
363
+ };
364
+ timeAxis: {
365
+ axisLine: {
366
+ show: boolean;
367
+ lineStyle: {
368
+ color: string;
369
+ };
370
+ };
371
+ axisTick: {
372
+ show: boolean;
373
+ };
374
+ axisLabel: {
375
+ show: boolean;
376
+ color: string;
377
+ hideOverlap: boolean;
378
+ };
379
+ nameLocation: string;
380
+ nameTextStyle: {
381
+ color: string;
382
+ fontSize: number;
383
+ fontWeight: number;
384
+ };
385
+ splitLine: {
386
+ show: boolean;
387
+ };
388
+ };
389
+ legend: {
390
+ top: number;
391
+ left: string;
392
+ right: number;
393
+ icon: string;
394
+ itemGap: number;
395
+ itemWidth: number;
396
+ itemHeight: number;
397
+ textStyle: {
398
+ color: string;
399
+ fontSize: number;
400
+ };
401
+ };
402
+ grid: {
403
+ top: number;
404
+ left: number;
405
+ right: number;
406
+ bottom: number;
407
+ outerBoundsMode: string;
408
+ outerBoundsContain: string;
409
+ };
410
+ dataZoom: {
411
+ backgroundColor: string;
412
+ borderColor: string;
413
+ borderRadius: number;
414
+ dataBackground: {
415
+ lineStyle: {
416
+ color: string;
417
+ width: number;
418
+ };
419
+ areaStyle: {
420
+ color: string;
421
+ };
422
+ };
423
+ selectedDataBackground: {
424
+ lineStyle: {
425
+ color: string;
426
+ width: number;
427
+ };
428
+ areaStyle: {
429
+ color: string;
430
+ };
431
+ };
432
+ fillerColor: string;
433
+ handleStyle: {
434
+ color: string;
435
+ borderColor: string;
436
+ };
437
+ moveHandleStyle: {
438
+ color: string;
439
+ };
440
+ brushStyle: {
441
+ color: string;
442
+ };
443
+ emphasis: {
444
+ handleStyle: {
445
+ color: string;
446
+ borderColor: string;
447
+ };
448
+ };
449
+ handleSize: string;
450
+ textStyle: {
451
+ color: string;
452
+ };
453
+ };
454
+ markPoint: {
455
+ label: {
456
+ color: string;
457
+ };
458
+ emphasis: {
459
+ label: {
460
+ color: string;
461
+ };
462
+ };
463
+ };
464
+ };
465
+ };
466
+ export type MavrikTheme = typeof MAVRIK_THEME | typeof MAVRIK_THEME_HORIZONTAL;
467
+ /**
468
+ * Selects the appropriate Mavrik theme variant based on chart options.
469
+ *
470
+ * - Returns horizontal gradient theme for horizontal bar charts
471
+ * - Returns vertical gradient theme for all other chart types
472
+ */
473
+ export declare function selectMavrikTheme(option: EChartsOption): MavrikTheme;
@@ -1,11 +1,23 @@
1
- import { isEChartsThemeOption as r } from "./echarts-theme-option.js";
2
- import o from "./mavrik-theme.json.js";
3
- if (!r(o))
1
+ import { hasHorizontalBars as t } from "./detect-horizontal-bars.js";
2
+ import { isEChartsThemeOption as o } from "./echarts-theme-option.js";
3
+ import r from "./mavrik-theme-horizontal.json.js";
4
+ import i from "./mavrik-theme.json.js";
5
+ if (!o(i))
4
6
  throw new Error("Invalid mavrik theme configuration");
5
- const t = {
7
+ if (!o(r))
8
+ throw new Error("Invalid mavrik horizontal theme configuration");
9
+ const e = {
6
10
  name: "mavrik",
7
- config: o
11
+ config: i
12
+ }, m = {
13
+ name: "mavrik-horizontal",
14
+ config: r
8
15
  };
16
+ function l(n) {
17
+ return t(n) ? m : e;
18
+ }
9
19
  export {
10
- t as MAVRIK_THEME
20
+ e as MAVRIK_THEME,
21
+ m as MAVRIK_THEME_HORIZONTAL,
22
+ l as selectMavrikTheme
11
23
  };
@@ -102,7 +102,8 @@ declare const _default: {
102
102
  },
103
103
  "axisLabel": {
104
104
  "show": true,
105
- "color": "#A7A9AD"
105
+ "color": "#A7A9AD",
106
+ "hideOverlap": true
106
107
  },
107
108
  "nameLocation": "middle",
108
109
  "nameTextStyle": {
@@ -123,7 +124,8 @@ declare const _default: {
123
124
  },
124
125
  "axisLabel": {
125
126
  "show": true,
126
- "color": "#A7A9AD"
127
+ "color": "#A7A9AD",
128
+ "hideOverlap": true
127
129
  },
128
130
  "nameLocation": "middle",
129
131
  "nameTextStyle": {
@@ -134,7 +136,9 @@ declare const _default: {
134
136
  "splitLine": {
135
137
  "show": true,
136
138
  "lineStyle": {
137
- "color": ["#3A3D46"],
139
+ "color": [
140
+ "#3A3D46"
141
+ ],
138
142
  "type": "dashed"
139
143
  }
140
144
  }
@@ -148,7 +152,8 @@ declare const _default: {
148
152
  },
149
153
  "axisLabel": {
150
154
  "show": true,
151
- "color": "#A7A9AD"
155
+ "color": "#A7A9AD",
156
+ "hideOverlap": true
152
157
  },
153
158
  "nameLocation": "middle",
154
159
  "nameTextStyle": {
@@ -159,7 +164,9 @@ declare const _default: {
159
164
  "splitLine": {
160
165
  "show": true,
161
166
  "lineStyle": {
162
- "color": ["#3A3D46"],
167
+ "color": [
168
+ "#3A3D46"
169
+ ],
163
170
  "type": "dashed"
164
171
  }
165
172
  }
@@ -176,7 +183,8 @@ declare const _default: {
176
183
  },
177
184
  "axisLabel": {
178
185
  "show": true,
179
- "color": "#A7A9AD"
186
+ "color": "#A7A9AD",
187
+ "hideOverlap": true
180
188
  },
181
189
  "nameLocation": "middle",
182
190
  "nameTextStyle": {
@@ -205,7 +213,7 @@ declare const _default: {
205
213
  "top": 132,
206
214
  "left": 32,
207
215
  "right": 32,
208
- "bottom": 70,
216
+ "bottom": 32,
209
217
  "outerBoundsMode": "same",
210
218
  "outerBoundsContain": "axisLabel"
211
219
  },
@@ -1,33 +1,33 @@
1
- const o = [{ type: "linear", x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: "#C14E64" }, { offset: 1, color: "#DF687D" }] }, { type: "linear", x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: "#FFFFFF" }, { offset: 1, color: "#FFFFFF" }] }, { type: "linear", x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: "#1E6FDA" }, { offset: 1, color: "#3F8CFF" }] }], e = "#242731", t = { fontFamily: "Poppins, sans-serif", fontWeight: 500 }, l = { top: 32, left: 32, textStyle: { color: "#FFFFFF", fontSize: 16, fontWeight: 600 }, subtextStyle: { color: "#A7A9AD" } }, i = { itemStyle: { borderWidth: 1 }, lineStyle: { width: 2 }, areaStyle: { opacity: 0.15 }, showSymbol: !1, symbolSize: 5, symbol: "circle", smooth: !1, sampling: "lttb" }, a = { barGap: "25%", barCategoryGap: "25%" }, s = { axisLine: { show: !0, lineStyle: { color: "#3A3D46", type: "dashed" } }, axisTick: { show: !1 }, axisLabel: { show: !0, color: "#A7A9AD" }, nameLocation: "middle", nameTextStyle: { color: "#A7A9AD", fontSize: 11, fontWeight: 400 }, splitLine: { show: !1 } }, r = { axisLine: { show: !1 }, axisTick: { show: !1 }, axisLabel: { show: !0, color: "#A7A9AD" }, nameLocation: "middle", nameTextStyle: { color: "#A7A9AD", fontSize: 11, fontWeight: 400 }, splitLine: { show: !0, lineStyle: { color: ["#3A3D46"], type: "dashed" } } }, n = { axisLine: { show: !1 }, axisTick: { show: !1 }, axisLabel: { show: !0, color: "#A7A9AD" }, nameLocation: "middle", nameTextStyle: { color: "#A7A9AD", fontSize: 11, fontWeight: 400 }, splitLine: { show: !0, lineStyle: { color: ["#3A3D46"], type: "dashed" } } }, c = { axisLine: { show: !0, lineStyle: { color: "#3A3D46" } }, axisTick: { show: !1 }, axisLabel: { show: !0, color: "#A7A9AD" }, nameLocation: "middle", nameTextStyle: { color: "#A7A9AD", fontSize: 11, fontWeight: 400 }, splitLine: { show: !1 } }, A = { top: 82, left: "auto", right: 32, icon: "circle", itemGap: 22, itemWidth: 12, itemHeight: 12, textStyle: { color: "#A7A9AD", fontSize: 11 } }, y = { top: 132, left: 32, right: 32, bottom: 70, outerBoundsMode: "same", outerBoundsContain: "axisLabel" }, d = { backgroundColor: "rgba(36, 39, 49, 0)", borderColor: "#3A3D46", borderRadius: 4, dataBackground: { lineStyle: { color: "#606060", width: 1 }, areaStyle: { color: "rgba(96, 96, 96, 0.3)" } }, selectedDataBackground: { lineStyle: { color: "#b36674", width: 1 }, areaStyle: { color: "rgba(164, 91, 105, 0.5)" } }, fillerColor: "rgba(82, 45, 52, 0.35)", handleStyle: { color: "#C14E64", borderColor: "#C14E64" }, moveHandleStyle: { color: "#b36674" }, brushStyle: { color: "rgba(95, 58, 65, 0.2)" }, emphasis: { handleStyle: { color: "rgb(209, 123, 140)", borderColor: "rgb(209, 123, 140)" } }, handleSize: "100%", textStyle: { color: "#A7A9AD" } }, f = { label: { color: "#A7A9AD" }, emphasis: { label: { color: "#FFFFFF" } } }, h = {
1
+ const o = [{ type: "linear", x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: "#C14E64" }, { offset: 1, color: "#DF687D" }] }, { type: "linear", x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: "#FFFFFF" }, { offset: 1, color: "#FFFFFF" }] }, { type: "linear", x: 0, y: 0, x2: 0, y2: 1, colorStops: [{ offset: 0, color: "#1E6FDA" }, { offset: 1, color: "#3F8CFF" }] }], e = "#242731", t = { fontFamily: "Poppins, sans-serif", fontWeight: 500 }, l = { top: 32, left: 32, textStyle: { color: "#FFFFFF", fontSize: 16, fontWeight: 600 }, subtextStyle: { color: "#A7A9AD" } }, r = { itemStyle: { borderWidth: 1 }, lineStyle: { width: 2 }, areaStyle: { opacity: 0.15 }, showSymbol: !1, symbolSize: 5, symbol: "circle", smooth: !1, sampling: "lttb" }, i = { barGap: "25%", barCategoryGap: "25%" }, a = { axisLine: { show: !0, lineStyle: { color: "#3A3D46", type: "dashed" } }, axisTick: { show: !1 }, axisLabel: { show: !0, color: "#A7A9AD", hideOverlap: !0 }, nameLocation: "middle", nameTextStyle: { color: "#A7A9AD", fontSize: 11, fontWeight: 400 }, splitLine: { show: !1 } }, s = { axisLine: { show: !1 }, axisTick: { show: !1 }, axisLabel: { show: !0, color: "#A7A9AD", hideOverlap: !0 }, nameLocation: "middle", nameTextStyle: { color: "#A7A9AD", fontSize: 11, fontWeight: 400 }, splitLine: { show: !0, lineStyle: { color: ["#3A3D46"], type: "dashed" } } }, n = { axisLine: { show: !1 }, axisTick: { show: !1 }, axisLabel: { show: !0, color: "#A7A9AD", hideOverlap: !0 }, nameLocation: "middle", nameTextStyle: { color: "#A7A9AD", fontSize: 11, fontWeight: 400 }, splitLine: { show: !0, lineStyle: { color: ["#3A3D46"], type: "dashed" } } }, c = { axisLine: { show: !0, lineStyle: { color: "#3A3D46" } }, axisTick: { show: !1 }, axisLabel: { show: !0, color: "#A7A9AD", hideOverlap: !0 }, nameLocation: "middle", nameTextStyle: { color: "#A7A9AD", fontSize: 11, fontWeight: 400 }, splitLine: { show: !1 } }, d = { top: 82, left: "auto", right: 32, icon: "circle", itemGap: 22, itemWidth: 12, itemHeight: 12, textStyle: { color: "#A7A9AD", fontSize: 11 } }, h = { top: 132, left: 32, right: 32, bottom: 32, outerBoundsMode: "same", outerBoundsContain: "axisLabel" }, A = { backgroundColor: "rgba(36, 39, 49, 0)", borderColor: "#3A3D46", borderRadius: 4, dataBackground: { lineStyle: { color: "#606060", width: 1 }, areaStyle: { color: "rgba(96, 96, 96, 0.3)" } }, selectedDataBackground: { lineStyle: { color: "#b36674", width: 1 }, areaStyle: { color: "rgba(164, 91, 105, 0.5)" } }, fillerColor: "rgba(82, 45, 52, 0.35)", handleStyle: { color: "#C14E64", borderColor: "#C14E64" }, moveHandleStyle: { color: "#b36674" }, brushStyle: { color: "rgba(95, 58, 65, 0.2)" }, emphasis: { handleStyle: { color: "rgb(209, 123, 140)", borderColor: "rgb(209, 123, 140)" } }, handleSize: "100%", textStyle: { color: "#A7A9AD" } }, y = { label: { color: "#A7A9AD" }, emphasis: { label: { color: "#FFFFFF" } } }, f = {
2
2
  color: o,
3
3
  backgroundColor: e,
4
4
  textStyle: t,
5
5
  title: l,
6
- line: i,
7
- bar: a,
8
- categoryAxis: s,
9
- valueAxis: r,
6
+ line: r,
7
+ bar: i,
8
+ categoryAxis: a,
9
+ valueAxis: s,
10
10
  logAxis: n,
11
11
  timeAxis: c,
12
- legend: A,
13
- grid: y,
14
- dataZoom: d,
15
- markPoint: f
12
+ legend: d,
13
+ grid: h,
14
+ dataZoom: A,
15
+ markPoint: y
16
16
  };
17
17
  export {
18
18
  e as backgroundColor,
19
- a as bar,
20
- s as categoryAxis,
19
+ i as bar,
20
+ a as categoryAxis,
21
21
  o as color,
22
- d as dataZoom,
23
- h as default,
24
- y as grid,
25
- A as legend,
26
- i as line,
22
+ A as dataZoom,
23
+ f as default,
24
+ h as grid,
25
+ d as legend,
26
+ r as line,
27
27
  n as logAxis,
28
- f as markPoint,
28
+ y as markPoint,
29
29
  t as textStyle,
30
30
  c as timeAxis,
31
31
  l as title,
32
- r as valueAxis
32
+ s as valueAxis
33
33
  };
@@ -0,0 +1,6 @@
1
+ import { EChartsOption } from 'echarts';
2
+ /**
3
+ * Removes problematic interactive components from chart options.
4
+ * These components have known issues with ECharts' cleanup lifecycle.
5
+ */
6
+ export declare function sanitizeChartOptions(option: EChartsOption): EChartsOption;
@@ -0,0 +1,9 @@
1
+ const n = /* @__PURE__ */ new Set(["axisPointer"]);
2
+ function i(t) {
3
+ return Object.fromEntries(
4
+ Object.entries(t).filter(([e]) => !n.has(e))
5
+ );
6
+ }
7
+ export {
8
+ i as sanitizeChartOptions
9
+ };
@@ -9,7 +9,6 @@ export type UseChartInstanceProps = {
9
9
  };
10
10
  export type UseChartInstanceReturn = {
11
11
  containerRef: React.RefObject<HTMLDivElement | null>;
12
- isReady: boolean;
13
12
  downloadChart: () => Promise<void>;
14
13
  };
15
14
  /**
@@ -1,46 +1,63 @@
1
1
  "use client";
2
- import { init as f, registerTheme as h } from "echarts";
3
- import { useRef as i, useState as w, useEffect as d, useCallback as g } from "react";
4
- const u = /* @__PURE__ */ new Set();
5
- function R(e, n) {
6
- u.has(e) || (h(e, n), u.add(e));
7
- }
8
- function b({ options: e, theme: n }) {
9
- const o = i(null), c = i(null), [s, a] = w(!1);
10
- d(() => {
11
- if (!o.current) return;
12
- n && R(n.name, n.config);
13
- const r = f(o.current, n?.name, {
14
- renderer: "svg"
15
- });
16
- c.current = r, r.setOption(e), a(!0);
17
- const t = new ResizeObserver(() => {
18
- r.resize();
2
+ import { useRef as d, useState as I, useEffect as w, useCallback as W } from "react";
3
+ import { calculateTitleLayout as p } from "./calculate-title-layout.js";
4
+ import { sanitizeChartOptions as g } from "./sanitize-chart-options.js";
5
+ import { addWatermarkToOptions as h } from "./watermark-graphic.js";
6
+ const z = /* @__PURE__ */ new Set();
7
+ function D({ options: i, theme: t }) {
8
+ const e = d(null), c = d(null), O = d(i), m = d(t?.config), [y, R] = I(!1);
9
+ O.current = i, m.current = t?.config, w(() => {
10
+ const s = e.current;
11
+ if (!s) return;
12
+ let n = !0, r;
13
+ const C = new ResizeObserver((o) => {
14
+ const a = o[0], u = c.current;
15
+ if (!a || !u) return;
16
+ const f = a.contentRect.width, l = g(O.current), v = h(
17
+ p(l, f, m.current)
18
+ );
19
+ u.setOption(v), u.resize();
19
20
  });
20
- return t.observe(o.current), () => {
21
- t.disconnect(), r.dispose(), c.current = null, a(!1);
21
+ return C.observe(s), (async () => {
22
+ try {
23
+ const o = await import("echarts");
24
+ if (!n || !e.current) return;
25
+ t && !z.has(t.name) && (o.registerTheme(t.name, t.config), z.add(t.name));
26
+ const a = o.getInstanceByDom(e.current);
27
+ a && a.dispose(), r = o.init(e.current, t?.name, {
28
+ renderer: "svg"
29
+ }), c.current = r;
30
+ const u = e.current.clientWidth, f = g(i), l = h(
31
+ p(f, u, t?.config)
32
+ );
33
+ r.setOption(l), r.resize(), R(!0);
34
+ } catch (o) {
35
+ console.error("Failed to load echarts", o);
36
+ }
37
+ })(), () => {
38
+ n = !1, C.disconnect(), r && r.dispose(), c.current = null, R(!1);
22
39
  };
23
- }, [e, n]), d(() => {
24
- !c.current || !s || c.current.setOption(e);
25
- }, [e, s]);
26
- const l = g(async () => {
27
- if (!c.current)
28
- throw new Error("Chart is not initialized");
29
- try {
30
- const r = c.current.getDataURL({
31
- type: "svg"
32
- }), t = document.createElement("a");
33
- t.download = `chart-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.svg`, t.href = r, document.body.appendChild(t), t.click(), document.body.removeChild(t);
34
- } catch (r) {
35
- throw console.error("Failed to download chart:", r), new Error("Failed to download chart");
36
- }
40
+ }, [t, i]), w(() => {
41
+ if (!y || !c.current || !e.current) return;
42
+ const s = e.current.clientWidth, n = g(i), r = h(
43
+ p(n, s, t?.config)
44
+ );
45
+ c.current.setOption(r);
46
+ }, [y, i, t?.config]);
47
+ const b = W(async () => {
48
+ if (!c.current) return;
49
+ const s = c.current.getDataURL({
50
+ type: "png",
51
+ pixelRatio: 2,
52
+ backgroundColor: "#fff"
53
+ }), n = document.createElement("a");
54
+ n.download = `chart-${(/* @__PURE__ */ new Date()).toISOString()}.png`, n.href = s, document.body.appendChild(n), n.click(), document.body.removeChild(n);
37
55
  }, []);
38
56
  return {
39
- containerRef: o,
40
- isReady: s,
41
- downloadChart: l
57
+ containerRef: e,
58
+ downloadChart: b
42
59
  };
43
60
  }
44
61
  export {
45
- b as useChartInstance
62
+ D as useChartInstance
46
63
  };
@@ -0,0 +1,12 @@
1
+ import { GraphicComponentOption } from 'echarts';
2
+ /**
3
+ * Watermark graphic element for ECharts charts.
4
+ * This is applied via setOption(), not via theme (themes don't properly merge graphic components).
5
+ */
6
+ export declare const WATERMARK_GRAPHIC: GraphicComponentOption;
7
+ /**
8
+ * Merges watermark graphic into existing ECharts options.
9
+ */
10
+ export declare function addWatermarkToOptions<T extends {
11
+ graphic?: GraphicComponentOption | GraphicComponentOption[];
12
+ }>(options: T): T;
@@ -0,0 +1,25 @@
1
+ import o from "../../assets/vc-logo.svg.js";
2
+ const a = 210, c = 24, i = {
3
+ type: "image",
4
+ left: "center",
5
+ top: "middle",
6
+ style: {
7
+ image: o,
8
+ width: a,
9
+ height: c
10
+ },
11
+ z: 100,
12
+ silent: !0
13
+ };
14
+ function s(r) {
15
+ const e = r.graphic;
16
+ let t;
17
+ return e === void 0 ? t = i : Array.isArray(e) ? t = [...e, i] : t = [e, i], {
18
+ ...r,
19
+ graphic: t
20
+ };
21
+ }
22
+ export {
23
+ i as WATERMARK_GRAPHIC,
24
+ s as addWatermarkToOptions
25
+ };
package/dist/index.d.ts CHANGED
@@ -6,7 +6,8 @@ export { EChartsRenderer, type EChartsRendererProps, type EChartsRendererRef, ty
6
6
  export { EChartsThemeOption, isEChartsThemeOption } from './components/echarts-renderer/echarts-theme-option';
7
7
  export { EChartsChartOption, isEChartsChartOption } from './components/echarts-renderer/echarts-chart-option';
8
8
  export { useChartInstance, type UseChartInstanceProps, type UseChartInstanceReturn, } from './components/echarts-renderer/use-chart-instance';
9
- export { MAVRIK_THEME } from './components/echarts-renderer/mavrik-theme';
9
+ export { MavrikChart, type MavrikChartProps } from './components/echarts-renderer/mavrik-chart';
10
+ export { MAVRIK_THEME, MAVRIK_THEME_HORIZONTAL } from './components/echarts-renderer/mavrik-theme';
10
11
  export { ClientModal } from './components/client-modal/client-modal';
11
12
  export { CopyButton } from './components/copy-button/copy-button';
12
13
  export { DecoratedIcon } from './components/decorated-icon/decorated-icon';