@squadbase/vantage 0.6.2-dev1.a7c4a3e → 0.6.2-dev1.abc3f77
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/add-4GHF2TX2.js +6 -0
- package/dist/add-4GHF2TX2.js.map +1 -0
- package/dist/{build-JB4VOMUI.js → build-A23M4GCH.js} +9 -9
- package/dist/{build-JB4VOMUI.js.map → build-A23M4GCH.js.map} +1 -1
- package/dist/{check-ZJYK6RLG.js → check-FBHT6W6J.js} +7 -7
- package/dist/{check-ZJYK6RLG.js.map → check-FBHT6W6J.js.map} +1 -1
- package/dist/chunk-2IAPIOPS.js +152 -0
- package/dist/chunk-2IAPIOPS.js.map +1 -0
- package/dist/{chunk-5ZOP4SQR.js → chunk-2N72FKLB.js} +12 -7
- package/dist/chunk-2N72FKLB.js.map +1 -0
- package/dist/chunk-57GHR5LN.js +163 -0
- package/dist/chunk-57GHR5LN.js.map +1 -0
- package/dist/{chunk-BCE22JSM.js → chunk-5C2SEDPH.js} +50 -14
- package/dist/chunk-5C2SEDPH.js.map +1 -0
- package/dist/chunk-6OTTGAPO.js +44 -0
- package/dist/chunk-6OTTGAPO.js.map +1 -0
- package/dist/{chunk-RPZAALCX.js → chunk-7S52M2SL.js} +256 -165
- package/dist/chunk-7S52M2SL.js.map +1 -0
- package/dist/{chunk-U2M6HGKQ.js → chunk-AABMKHEU.js} +4 -4
- package/dist/{chunk-U2M6HGKQ.js.map → chunk-AABMKHEU.js.map} +1 -1
- package/dist/{chunk-PVTHHV7X.js → chunk-ANZLVSEP.js} +28 -7
- package/dist/chunk-ANZLVSEP.js.map +1 -0
- package/dist/chunk-CKWPK4RO.js +50 -0
- package/dist/chunk-CKWPK4RO.js.map +1 -0
- package/dist/{chunk-QI3XQKHS.js → chunk-GNXCX4WE.js} +10 -3
- package/dist/chunk-GNXCX4WE.js.map +1 -0
- package/dist/chunk-JXFCSF3K.js +673 -0
- package/dist/chunk-JXFCSF3K.js.map +1 -0
- package/dist/{chunk-PXRX5PEC.js → chunk-PDOBHMUQ.js} +3 -3
- package/dist/chunk-PDOBHMUQ.js.map +1 -0
- package/dist/chunk-QOXXOFGL.js +7051 -0
- package/dist/chunk-QOXXOFGL.js.map +1 -0
- package/dist/{chunk-ZVANIULZ.js → chunk-RNTDBX6S.js} +4 -4
- package/dist/{chunk-ZVANIULZ.js.map → chunk-RNTDBX6S.js.map} +1 -1
- package/dist/chunk-S5MDTHH7.js +466 -0
- package/dist/chunk-S5MDTHH7.js.map +1 -0
- package/dist/chunk-SDJTTMLK.js +1877 -0
- package/dist/chunk-SDJTTMLK.js.map +1 -0
- package/dist/{chunk-EP6JHXSR.js → chunk-SHZM3EXB.js} +68 -12
- package/dist/chunk-SHZM3EXB.js.map +1 -0
- package/dist/{chunk-A2UUGASH.js → chunk-U736PVHY.js} +2 -2
- package/dist/chunk-U736PVHY.js.map +1 -0
- package/dist/{chunk-JGRMRXXZ.js → chunk-UWSQUHX6.js} +4 -99
- package/dist/chunk-UWSQUHX6.js.map +1 -0
- package/dist/cli.js +12 -11
- package/dist/cli.js.map +1 -1
- package/dist/client/index.d.ts +34 -3
- package/dist/client/index.js +211 -12
- package/dist/client/index.js.map +1 -1
- package/dist/components/index.d.ts +1740 -29
- package/dist/components/index.js +7 -4
- package/dist/delta-text-CvwBGJ95.d.ts +15 -0
- package/dist/{dev-FCEC3UKQ.js → dev-H4I2JL63.js} +10 -10
- package/dist/dev-H4I2JL63.js.map +1 -0
- package/dist/doc/index.d.ts +215 -2
- package/dist/doc/index.js +309 -5
- package/dist/doc/index.js.map +1 -1
- package/dist/{docs-EJJ3BECT.js → docs-JVP4RPKT.js} +3 -3
- package/dist/{docs-EJJ3BECT.js.map → docs-JVP4RPKT.js.map} +1 -1
- package/dist/{doctor-WHZXPERA.js → doctor-B2O3GJDU.js} +7 -7
- package/dist/{doctor-WHZXPERA.js.map → doctor-B2O3GJDU.js.map} +1 -1
- package/dist/format-U0cQl069.d.ts +243 -0
- package/dist/markdown/index.js +1 -1
- package/dist/markdown/index.js.map +1 -1
- package/dist/{preview-OGMCNQUO.js → preview-T6CLSQVX.js} +3 -3
- package/dist/{preview-OGMCNQUO.js.map → preview-T6CLSQVX.js.map} +1 -1
- package/dist/query/index.d.ts +0 -11
- package/dist/query/index.js +2 -2
- package/dist/{routes-GTFO5PUF.js → routes-PVKNT777.js} +6 -6
- package/dist/{routes-GTFO5PUF.js.map → routes-PVKNT777.js.map} +1 -1
- package/dist/{search-6Y422SV6.js → search-5LC4XPB5.js} +3 -3
- package/dist/{search-6Y422SV6.js.map → search-5LC4XPB5.js.map} +1 -1
- package/dist/slide/index.d.ts +272 -1
- package/dist/slide/index.js +1021 -14
- package/dist/slide/index.js.map +1 -1
- package/dist/table/index.js +14 -10
- package/dist/table/index.js.map +1 -1
- package/dist/ui/index.d.ts +148 -12
- package/dist/ui/index.js +1340 -88
- package/dist/ui/index.js.map +1 -1
- package/dist/{upgrade-AL4KZZR4.js → upgrade-6DT7ADRP.js} +7 -7
- package/dist/{upgrade-AL4KZZR4.js.map → upgrade-6DT7ADRP.js.map} +1 -1
- package/dist/vite/index.d.ts +10 -0
- package/dist/vite/index.js +4 -4
- package/docs/en/changelog.md +2 -0
- package/docs/en/components.md +42 -17
- package/docs/en/doc/delta-text.md +40 -0
- package/docs/en/doc/doc-action-items.md +49 -0
- package/docs/en/doc/doc-callout.md +38 -0
- package/docs/en/doc/doc-data-table.md +60 -0
- package/docs/en/doc/doc-executive-summary.md +64 -0
- package/docs/en/doc/doc-figure.md +56 -0
- package/docs/en/doc/doc-key-findings.md +61 -0
- package/docs/en/doc/doc-kpi-scorecard.md +80 -0
- package/docs/en/doc/doc-notes-and-sources.md +43 -0
- package/docs/en/doc/doc-report-header.md +46 -0
- package/docs/en/pages-and-metadata.md +15 -0
- package/docs/en/parts/area-chart.md +99 -0
- package/docs/en/parts/bar-chart.md +91 -0
- package/docs/en/parts/bar-list.md +50 -0
- package/docs/en/parts/category-bar.md +37 -0
- package/docs/en/parts/chart-frame.md +39 -0
- package/docs/en/parts/data-table.md +22 -0
- package/docs/en/parts/delta.md +51 -0
- package/docs/en/parts/donut-chart.md +72 -0
- package/docs/en/parts/format.md +43 -0
- package/docs/en/parts/funnel-steps.md +2 -1
- package/docs/en/parts/heatmap.md +53 -0
- package/docs/en/parts/kpi-card.md +58 -0
- package/docs/en/parts/legend.md +35 -0
- package/docs/en/parts/line-chart.md +94 -0
- package/docs/en/parts/metric-value.md +3 -2
- package/docs/en/parts/progress-circle.md +33 -0
- package/docs/en/parts/sample-data.md +39 -0
- package/docs/en/parts/scatter-chart.md +56 -0
- package/docs/en/parts/sparkline.md +1 -1
- package/docs/en/parts/tracker.md +36 -0
- package/docs/en/parts/trend-indicator.md +17 -1
- package/docs/en/parts/updated-at.md +30 -0
- package/docs/en/parts/waterfall-chart.md +56 -0
- package/docs/en/slide/slide-chart-full.md +48 -0
- package/docs/en/slide/slide-chart-insight.md +52 -0
- package/docs/en/slide/slide-columns.md +46 -0
- package/docs/en/slide/slide-comparison.md +68 -0
- package/docs/en/slide/slide-cover.md +39 -0
- package/docs/en/slide/slide-exec-summary.md +47 -0
- package/docs/en/slide/slide-heading.md +38 -0
- package/docs/en/slide/slide-kpi-grid.md +55 -0
- package/docs/en/slide/slide-kpi-hero.md +58 -0
- package/docs/en/slide/slide-next-actions.md +49 -0
- package/docs/en/slide/slide-scorecard-table.md +54 -0
- package/docs/en/slide/slide-section.md +44 -0
- package/docs/en/slide/slide-source-line.md +34 -0
- package/docs/en/ui/alert-dialog.md +42 -0
- package/docs/en/ui/avatar.md +31 -0
- package/docs/en/ui/combobox.md +74 -0
- package/docs/en/ui/drawer.md +41 -0
- package/docs/en/ui/empty.md +1 -1
- package/docs/en/ui/error-state.md +4 -3
- package/docs/en/ui/field.md +42 -0
- package/docs/en/ui/hover-card.md +21 -0
- package/docs/en/ui/kbd.md +17 -0
- package/docs/en/ui/loading.md +1 -1
- package/docs/en/ui/pagination.md +36 -0
- package/docs/en/ui/radio-group.md +21 -0
- package/docs/en/ui/toast.md +44 -0
- package/docs/en/ui/toggle-group.md +4 -3
- package/docs/en/ui-and-theming.md +1 -1
- package/docs/index.json +1184 -114
- package/docs/ja/changelog.md +33 -0
- package/docs/ja/components.md +68 -101
- package/docs/ja/doc/delta-text.md +40 -0
- package/docs/ja/doc/doc-action-items.md +49 -0
- package/docs/ja/doc/doc-callout.md +38 -0
- package/docs/ja/doc/doc-data-table.md +60 -0
- package/docs/ja/doc/doc-executive-summary.md +64 -0
- package/docs/ja/doc/doc-figure.md +56 -0
- package/docs/ja/doc/doc-key-findings.md +61 -0
- package/docs/ja/doc/doc-kpi-scorecard.md +80 -0
- package/docs/ja/doc/doc-notes-and-sources.md +43 -0
- package/docs/ja/doc/doc-report-header.md +46 -0
- package/docs/ja/page-types/csv.md +83 -0
- package/docs/ja/page-types/doc.md +83 -0
- package/docs/ja/page-types/excel.md +82 -0
- package/docs/ja/page-types/slide.md +133 -0
- package/docs/ja/page-types.md +47 -0
- package/docs/ja/pages-and-metadata.md +15 -0
- package/docs/ja/parts/area-chart.md +85 -0
- package/docs/ja/parts/bar-chart.md +95 -0
- package/docs/ja/parts/bar-list.md +58 -0
- package/docs/ja/parts/category-bar.md +36 -0
- package/docs/ja/parts/chart-frame.md +36 -0
- package/docs/ja/parts/data-table.md +22 -0
- package/docs/ja/parts/delta.md +51 -0
- package/docs/ja/parts/donut-chart.md +66 -0
- package/docs/ja/parts/echart.md +3 -0
- package/docs/ja/parts/format.md +44 -0
- package/docs/ja/parts/funnel-steps.md +27 -8
- package/docs/ja/parts/heatmap.md +45 -0
- package/docs/ja/parts/kpi-card.md +56 -0
- package/docs/ja/parts/legend.md +36 -0
- package/docs/ja/parts/line-chart.md +84 -0
- package/docs/ja/parts/metric-value.md +3 -2
- package/docs/ja/parts/progress-circle.md +34 -0
- package/docs/ja/parts/sample-data.md +61 -0
- package/docs/ja/parts/scatter-chart.md +69 -0
- package/docs/ja/parts/sparkline.md +2 -2
- package/docs/ja/parts/tracker.md +32 -0
- package/docs/ja/parts/trend-indicator.md +17 -1
- package/docs/ja/parts/updated-at.md +27 -0
- package/docs/ja/parts/waterfall-chart.md +61 -0
- package/docs/ja/routing.md +8 -86
- package/docs/ja/slide/slide-chart-full.md +48 -0
- package/docs/ja/slide/slide-chart-insight.md +52 -0
- package/docs/ja/slide/slide-columns.md +46 -0
- package/docs/ja/slide/slide-comparison.md +68 -0
- package/docs/ja/slide/slide-cover.md +39 -0
- package/docs/ja/slide/slide-exec-summary.md +47 -0
- package/docs/ja/slide/slide-heading.md +38 -0
- package/docs/ja/slide/slide-kpi-grid.md +55 -0
- package/docs/ja/slide/slide-kpi-hero.md +58 -0
- package/docs/ja/slide/slide-next-actions.md +49 -0
- package/docs/ja/slide/slide-scorecard-table.md +54 -0
- package/docs/ja/slide/slide-section.md +44 -0
- package/docs/ja/slide/slide-source-line.md +34 -0
- package/docs/ja/ui/alert-dialog.md +41 -0
- package/docs/ja/ui/avatar.md +31 -0
- package/docs/ja/ui/combobox.md +74 -0
- package/docs/ja/ui/drawer.md +41 -0
- package/docs/ja/ui/empty.md +1 -1
- package/docs/ja/ui/error-state.md +4 -3
- package/docs/ja/ui/field.md +42 -0
- package/docs/ja/ui/hover-card.md +21 -0
- package/docs/ja/ui/kbd.md +16 -0
- package/docs/ja/ui/loading.md +1 -1
- package/docs/ja/ui/pagination.md +36 -0
- package/docs/ja/ui/radio-group.md +21 -0
- package/docs/ja/ui/toast.md +46 -0
- package/docs/ja/ui/toggle-group.md +4 -3
- package/docs/ja/ui-and-theming.md +14 -7
- package/package.json +43 -29
- package/registry/ui/accordion.tsx +76 -0
- package/registry/ui/alert-dialog.tsx +189 -0
- package/registry/ui/alert.tsx +80 -0
- package/registry/ui/app-shell.tsx +287 -0
- package/registry/ui/area-chart.tsx +3701 -0
- package/registry/ui/attention-list.tsx +303 -0
- package/registry/ui/avatar.tsx +110 -0
- package/registry/ui/badge.tsx +56 -0
- package/registry/ui/bar-chart.tsx +3698 -0
- package/registry/ui/bar-list.tsx +3743 -0
- package/registry/ui/box-plot-chart.tsx +3906 -0
- package/registry/ui/breadcrumb.tsx +128 -0
- package/registry/ui/button.tsx +62 -0
- package/registry/ui/calendar.tsx +223 -0
- package/registry/ui/card.tsx +107 -0
- package/registry/ui/category-bar.tsx +1290 -0
- package/registry/ui/chart-frame.tsx +1393 -0
- package/registry/ui/checkbox.tsx +30 -0
- package/registry/ui/collapsible.tsx +23 -0
- package/registry/ui/combobox.tsx +310 -0
- package/registry/ui/command.tsx +198 -0
- package/registry/ui/dashboard-card.tsx +217 -0
- package/registry/ui/data-table.tsx +693 -146
- package/registry/ui/date-range-picker.tsx +390 -0
- package/registry/ui/delta.tsx +191 -0
- package/registry/ui/dialog.tsx +161 -0
- package/registry/ui/donut-chart.tsx +3751 -0
- package/registry/ui/drawer.tsx +229 -0
- package/registry/ui/dropdown-menu.tsx +274 -0
- package/registry/ui/echart.tsx +1040 -0
- package/registry/ui/field.tsx +240 -0
- package/registry/ui/filter-bar.tsx +392 -0
- package/registry/ui/funnel-steps.tsx +3569 -0
- package/registry/ui/heatmap.tsx +1786 -0
- package/registry/ui/histogram-chart.tsx +3986 -0
- package/registry/ui/hover-card.tsx +52 -0
- package/registry/ui/input-group.tsx +160 -0
- package/registry/ui/input.tsx +24 -0
- package/registry/ui/kbd.tsx +30 -0
- package/registry/ui/kpi-card.tsx +704 -0
- package/registry/ui/label.tsx +22 -0
- package/registry/ui/legend.tsx +3563 -0
- package/registry/ui/line-chart.tsx +3699 -0
- package/registry/ui/metric-value.tsx +62 -0
- package/registry/ui/multi-select.tsx +232 -0
- package/registry/ui/page-shell.tsx +282 -0
- package/registry/ui/pagination.tsx +140 -0
- package/registry/ui/paired-chart.tsx +3827 -0
- package/registry/ui/placeholder.tsx +36 -0
- package/registry/ui/popover.tsx +92 -0
- package/registry/ui/progress-circle.tsx +867 -0
- package/registry/ui/progress.tsx +85 -0
- package/registry/ui/radio-group.tsx +39 -0
- package/registry/ui/sample-data.tsx +86 -0
- package/registry/ui/scatter-chart.tsx +4212 -0
- package/registry/ui/scroll-area.tsx +56 -0
- package/registry/ui/searchable-select.tsx +214 -0
- package/registry/ui/section-header.tsx +43 -0
- package/registry/ui/segmented-control.tsx +76 -0
- package/registry/ui/select.tsx +255 -0
- package/registry/ui/separator.tsx +27 -0
- package/registry/ui/sheet.tsx +139 -0
- package/registry/ui/sidebar.tsx +725 -0
- package/registry/ui/skeleton.tsx +17 -0
- package/registry/ui/slider.tsx +56 -0
- package/registry/ui/sparkline.tsx +230 -0
- package/registry/ui/spinner.tsx +14 -0
- package/registry/ui/states.tsx +90 -0
- package/registry/ui/status-badge.tsx +121 -0
- package/registry/ui/switch.tsx +34 -0
- package/registry/ui/table.tsx +118 -0
- package/registry/ui/tabs.tsx +84 -0
- package/registry/ui/textarea.tsx +22 -0
- package/registry/ui/toast.tsx +250 -0
- package/registry/ui/toggle-group.tsx +91 -0
- package/registry/ui/toggle.tsx +47 -0
- package/registry/ui/tooltip.tsx +72 -0
- package/registry/ui/tracker.tsx +849 -0
- package/registry/ui/trend-indicator.tsx +74 -0
- package/registry/ui/updated-at.tsx +122 -0
- package/registry/ui/waterfall-chart.tsx +4248 -0
- package/skills/vantage-add-feature/SKILL.md +9 -7
- package/skills/vantage-design/SKILL.md +36 -24
- package/skills/vantage-design/references/extract.md +16 -14
- package/skills/vantage-design/references/format.md +6 -5
- package/skills/vantage-design/references/presets.md +60 -110
- package/skills/vantage-pitfalls/SKILL.md +10 -1
- package/skills/vantage-slide/SKILL.md +71 -36
- package/templates/AGENTS.md +26 -3
- package/templates/agents/api.md +29 -0
- package/templates/agents/csv.md +2 -1
- package/templates/agents/doc.md +52 -3
- package/templates/agents/page.md +54 -9
- package/templates/agents/slide.md +83 -3
- package/templates/agents/xlsx.md +2 -1
- package/theme.css +247 -132
- package/dist/add-DY4AXANK.js +0 -6
- package/dist/add-DY4AXANK.js.map +0 -1
- package/dist/chunk-5ZOP4SQR.js.map +0 -1
- package/dist/chunk-A2UUGASH.js.map +0 -1
- package/dist/chunk-BCE22JSM.js.map +0 -1
- package/dist/chunk-DTDVSFRY.js +0 -29
- package/dist/chunk-DTDVSFRY.js.map +0 -1
- package/dist/chunk-EP6JHXSR.js.map +0 -1
- package/dist/chunk-JGRMRXXZ.js.map +0 -1
- package/dist/chunk-KLEIVDUV.js +0 -165
- package/dist/chunk-KLEIVDUV.js.map +0 -1
- package/dist/chunk-MP3QSOXL.js +0 -2232
- package/dist/chunk-MP3QSOXL.js.map +0 -1
- package/dist/chunk-PVTHHV7X.js.map +0 -1
- package/dist/chunk-PXRX5PEC.js.map +0 -1
- package/dist/chunk-QI3XQKHS.js.map +0 -1
- package/dist/chunk-RPZAALCX.js.map +0 -1
- package/dist/chunk-T3FLAGI6.js +0 -316
- package/dist/chunk-T3FLAGI6.js.map +0 -1
- package/dist/dev-FCEC3UKQ.js.map +0 -1
|
@@ -0,0 +1,673 @@
|
|
|
1
|
+
import { Button } from './chunk-PDOBHMUQ.js';
|
|
2
|
+
import { cn } from './chunk-U736PVHY.js';
|
|
3
|
+
import { createContext, forwardRef, useRef, useState, useMemo, useEffect, useCallback, useContext } from 'react';
|
|
4
|
+
import { use, init } from 'echarts/core';
|
|
5
|
+
import { BarChart, CustomChart, LineChart, PieChart } from 'echarts/charts';
|
|
6
|
+
import { GridComponent, LegendComponent, MarkAreaComponent, MarkLineComponent, MarkPointComponent, TooltipComponent } from 'echarts/components';
|
|
7
|
+
import { CanvasRenderer } from 'echarts/renderers';
|
|
8
|
+
import { Check, Copy, Download } from 'lucide-react';
|
|
9
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
10
|
+
|
|
11
|
+
// @squadbase/vantage — generated build. Do not edit.
|
|
12
|
+
var CHART_OTHER_COLOR = "color-mix(in oklab, var(--neutral) 50%, var(--background))";
|
|
13
|
+
var ChartFrameContext = createContext(false);
|
|
14
|
+
var SERIES_TOKENS = ["--chart-1", "--chart-2", "--chart-3", "--chart-4", "--chart-5"];
|
|
15
|
+
var tokenScopes = /* @__PURE__ */ new WeakMap();
|
|
16
|
+
var OPTION_COLOR_TOKENS = [
|
|
17
|
+
"--background",
|
|
18
|
+
"--card",
|
|
19
|
+
"--muted",
|
|
20
|
+
"--primary",
|
|
21
|
+
"--destructive",
|
|
22
|
+
...["positive", "negative", "warning", "neutral", "info"].flatMap((tone) => ["", "-fill", "-subtle"].map((suffix) => `--${tone}${suffix}`))
|
|
23
|
+
];
|
|
24
|
+
var normalizeContext;
|
|
25
|
+
var ZRENDER_COLOR_RE = /^(?:#[0-9a-f]{6}|rgba?\()/i;
|
|
26
|
+
function toCanvasColor(value) {
|
|
27
|
+
const raw = value.trim();
|
|
28
|
+
if (!raw) return null;
|
|
29
|
+
if (normalizeContext === void 0) {
|
|
30
|
+
const canvas = document.createElement("canvas");
|
|
31
|
+
canvas.width = 1;
|
|
32
|
+
canvas.height = 1;
|
|
33
|
+
normalizeContext = canvas.getContext("2d", { willReadFrequently: true });
|
|
34
|
+
}
|
|
35
|
+
const ctx = normalizeContext;
|
|
36
|
+
if (!ctx) return raw;
|
|
37
|
+
ctx.fillStyle = "#000000";
|
|
38
|
+
ctx.fillStyle = raw;
|
|
39
|
+
const onBlack = ctx.fillStyle;
|
|
40
|
+
ctx.fillStyle = "#ffffff";
|
|
41
|
+
ctx.fillStyle = raw;
|
|
42
|
+
if (onBlack !== ctx.fillStyle || typeof onBlack !== "string") return null;
|
|
43
|
+
if (ZRENDER_COLOR_RE.test(onBlack)) return onBlack;
|
|
44
|
+
ctx.clearRect(0, 0, 1, 1);
|
|
45
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
46
|
+
const [r = 0, g = 0, b = 0, a = 0] = ctx.getImageData(0, 0, 1, 1).data;
|
|
47
|
+
return a === 255 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${Math.round(a / 255 * 1e3) / 1e3})`;
|
|
48
|
+
}
|
|
49
|
+
function readChartTokens(el) {
|
|
50
|
+
if (typeof document === "undefined") return null;
|
|
51
|
+
const target = el ?? document.documentElement;
|
|
52
|
+
if (!target) return null;
|
|
53
|
+
const styles = getComputedStyle(target);
|
|
54
|
+
const read = (name) => toCanvasColor(styles.getPropertyValue(name));
|
|
55
|
+
const series = [];
|
|
56
|
+
for (const token of SERIES_TOKENS) {
|
|
57
|
+
const color = read(token);
|
|
58
|
+
if (color) series.push(color);
|
|
59
|
+
}
|
|
60
|
+
const tokens = {
|
|
61
|
+
series,
|
|
62
|
+
colors: Object.fromEntries(OPTION_COLOR_TOKENS.map((name) => [name, styles.getPropertyValue(name).trim()])),
|
|
63
|
+
surface: readChartSurface(target),
|
|
64
|
+
...styles.fontFamily ? { fontFamily: styles.fontFamily } : {},
|
|
65
|
+
foreground: read("--foreground"),
|
|
66
|
+
mutedForeground: read("--muted-foreground"),
|
|
67
|
+
border: read("--border"),
|
|
68
|
+
popover: read("--popover"),
|
|
69
|
+
popoverForeground: read("--popover-foreground")
|
|
70
|
+
};
|
|
71
|
+
tokenScopes.set(tokens, target);
|
|
72
|
+
return tokens;
|
|
73
|
+
}
|
|
74
|
+
function sameChartTokens(a, b) {
|
|
75
|
+
if (a === b) return true;
|
|
76
|
+
if (!a || !b) return false;
|
|
77
|
+
return tokenScopes.get(a) === tokenScopes.get(b) && a.surface === b.surface && Object.keys(a.colors ?? {}).length === Object.keys(b.colors ?? {}).length && Object.entries(a.colors ?? {}).every(([name, value]) => b.colors?.[name] === value) && a.series.length === b.series.length && a.series.every((color, i) => color === b.series[i]) && a.fontFamily === b.fontFamily && a.foreground === b.foreground && a.mutedForeground === b.mutedForeground && a.border === b.border && a.popover === b.popover && a.popoverForeground === b.popoverForeground;
|
|
78
|
+
}
|
|
79
|
+
function watchChartTokens(onChange, scope) {
|
|
80
|
+
if (typeof document === "undefined") return () => {
|
|
81
|
+
};
|
|
82
|
+
let frame = 0;
|
|
83
|
+
const schedule = () => {
|
|
84
|
+
if (frame) return;
|
|
85
|
+
frame = requestAnimationFrame(() => {
|
|
86
|
+
frame = 0;
|
|
87
|
+
onChange();
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
const themeObserver = new MutationObserver(schedule);
|
|
91
|
+
const attributeFilter = ["class", "style", "data-theme"];
|
|
92
|
+
for (let node = scope ?? document.body ?? document.documentElement; node; node = node.parentElement) {
|
|
93
|
+
themeObserver.observe(node, { attributes: true, attributeFilter });
|
|
94
|
+
}
|
|
95
|
+
const styleObserver = new MutationObserver(schedule);
|
|
96
|
+
if (document.head) {
|
|
97
|
+
styleObserver.observe(document.head, {
|
|
98
|
+
childList: true,
|
|
99
|
+
subtree: true,
|
|
100
|
+
characterData: true,
|
|
101
|
+
attributes: true,
|
|
102
|
+
attributeFilter: ["href", "media", "disabled"]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const onLoad = (event) => {
|
|
106
|
+
if (event.target instanceof HTMLLinkElement) schedule();
|
|
107
|
+
};
|
|
108
|
+
document.addEventListener("load", onLoad, true);
|
|
109
|
+
const media = window.matchMedia("(prefers-color-scheme: dark)");
|
|
110
|
+
media.addEventListener("change", schedule);
|
|
111
|
+
return () => {
|
|
112
|
+
if (frame) cancelAnimationFrame(frame);
|
|
113
|
+
themeObserver.disconnect();
|
|
114
|
+
styleObserver.disconnect();
|
|
115
|
+
document.removeEventListener("load", onLoad, true);
|
|
116
|
+
media.removeEventListener("change", schedule);
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function axisTheme(tokens, splitLine) {
|
|
120
|
+
const line = tokens.border ?? void 0;
|
|
121
|
+
return {
|
|
122
|
+
axisLine: { show: false },
|
|
123
|
+
axisTick: { show: false },
|
|
124
|
+
axisLabel: { show: true, color: tokens.mutedForeground ?? void 0, fontSize: 12 },
|
|
125
|
+
// Faint horizontal rules only: the border colour at low opacity.
|
|
126
|
+
splitLine: { show: splitLine, lineStyle: { color: line ? [line] : void 0, opacity: 0.5, width: 1 } },
|
|
127
|
+
splitArea: { show: false }
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function buildChartTheme(tokens) {
|
|
131
|
+
const text = tokens.foreground ?? void 0;
|
|
132
|
+
const muted = tokens.mutedForeground ?? void 0;
|
|
133
|
+
const line = tokens.border ?? void 0;
|
|
134
|
+
return {
|
|
135
|
+
// Let the page background show through: charts sit on cards, not on a canvas.
|
|
136
|
+
backgroundColor: "transparent",
|
|
137
|
+
...tokens.series.length > 0 ? { color: tokens.series } : {},
|
|
138
|
+
textStyle: { color: text, ...tokens.fontFamily ? { fontFamily: tokens.fontFamily } : {} },
|
|
139
|
+
title: { textStyle: { color: text }, subtextStyle: { color: muted } },
|
|
140
|
+
legend: { textStyle: { color: muted } },
|
|
141
|
+
categoryAxis: axisTheme(tokens, false),
|
|
142
|
+
valueAxis: axisTheme(tokens, true),
|
|
143
|
+
logAxis: axisTheme(tokens, true),
|
|
144
|
+
timeAxis: axisTheme(tokens, true),
|
|
145
|
+
tooltip: {
|
|
146
|
+
// ECharts' default 0.4s transform lags the tooltip ~300ms behind the cursor.
|
|
147
|
+
transitionDuration: 0,
|
|
148
|
+
backgroundColor: tokens.popover ?? void 0,
|
|
149
|
+
borderColor: line,
|
|
150
|
+
borderWidth: 1,
|
|
151
|
+
padding: [8, 12],
|
|
152
|
+
// Rounded card with a soft shadow; in dark mode the shadow barely shows, so the border carries the edge.
|
|
153
|
+
extraCssText: "border-radius:8px;box-shadow:var(--shadow-card, 0 4px 12px rgb(0 0 0 / 0.08));",
|
|
154
|
+
textStyle: {
|
|
155
|
+
color: tokens.popoverForeground ?? void 0,
|
|
156
|
+
fontSize: 12,
|
|
157
|
+
...tokens.fontFamily ? { fontFamily: tokens.fontFamily } : {}
|
|
158
|
+
},
|
|
159
|
+
axisPointer: { lineStyle: { color: line }, crossStyle: { color: line } }
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function useChartTokens(scope) {
|
|
164
|
+
const [tokens, setTokens] = useState(() => readChartTokens());
|
|
165
|
+
const tokensRef = useRef(tokens);
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
const target = scope && "current" in scope ? scope.current : scope;
|
|
168
|
+
const sync = () => {
|
|
169
|
+
const next = readChartTokens(target);
|
|
170
|
+
if (sameChartTokens(tokensRef.current, next)) return;
|
|
171
|
+
tokensRef.current = next;
|
|
172
|
+
setTokens(next);
|
|
173
|
+
};
|
|
174
|
+
sync();
|
|
175
|
+
return watchChartTokens(sync, target);
|
|
176
|
+
}, [scope]);
|
|
177
|
+
return tokens;
|
|
178
|
+
}
|
|
179
|
+
var SERIES_TOKEN_NAME_RE = /^chart-([1-5])$/;
|
|
180
|
+
var TONE_NAME_RE = /^(?:positive|warning|negative|neutral|info)(?:-fill)?$/;
|
|
181
|
+
var CSS_VAR_RE = /^var\(\s*(--[\w-]+)\s*(?:,\s*(.+))?\)$/;
|
|
182
|
+
var EMBEDDED_VAR_RE = /var\(\s*(--[\w-]+)\s*\)/g;
|
|
183
|
+
function resolveChartColors(colors, tokens) {
|
|
184
|
+
return colors.map((color) => {
|
|
185
|
+
const token = SERIES_TOKEN_NAME_RE.exec(color.trim());
|
|
186
|
+
if (token) return tokens?.series[Number(token[1]) - 1] ?? "";
|
|
187
|
+
if (TONE_NAME_RE.test(color.trim())) {
|
|
188
|
+
if (typeof document === "undefined") return "";
|
|
189
|
+
const target = (tokens && tokenScopes.get(tokens)) ?? document.documentElement;
|
|
190
|
+
return toCanvasColor(getComputedStyle(target).getPropertyValue(`--${color.trim()}`)) ?? "";
|
|
191
|
+
}
|
|
192
|
+
if (typeof document === "undefined") return color;
|
|
193
|
+
let value = color.trim();
|
|
194
|
+
const cssVar = CSS_VAR_RE.exec(value);
|
|
195
|
+
const styles = getComputedStyle((tokens && tokenScopes.get(tokens)) ?? document.documentElement);
|
|
196
|
+
if (cssVar) {
|
|
197
|
+
value = styles.getPropertyValue(cssVar[1]).trim() || (cssVar[2] ?? "").trim();
|
|
198
|
+
} else if (value.includes("var(")) {
|
|
199
|
+
value = value.replace(EMBEDDED_VAR_RE, (_, name) => styles.getPropertyValue(name).trim());
|
|
200
|
+
}
|
|
201
|
+
return toCanvasColor(value) ?? "";
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function resolveFillColors(tokens) {
|
|
205
|
+
const [positive = "", warning = "", negative = "", neutral = ""] = resolveChartColors(
|
|
206
|
+
["positive-fill", "warning-fill", "negative-fill", "neutral-fill"],
|
|
207
|
+
tokens
|
|
208
|
+
);
|
|
209
|
+
return { positive, warning, negative, neutral };
|
|
210
|
+
}
|
|
211
|
+
var TRANSPARENT_RE = /^(?:transparent|rgba\([^)]*,\s*0(?:\.0+)?\))$/i;
|
|
212
|
+
function readChartSurface(el) {
|
|
213
|
+
if (typeof document === "undefined") return null;
|
|
214
|
+
for (let node = el; node; node = node.parentElement) {
|
|
215
|
+
const bg = getComputedStyle(node).backgroundColor.trim();
|
|
216
|
+
if (bg && !TRANSPARENT_RE.test(bg)) {
|
|
217
|
+
const color = toCanvasColor(bg);
|
|
218
|
+
if (color) return color;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return toCanvasColor(getComputedStyle(el ?? document.documentElement).getPropertyValue("--background"));
|
|
222
|
+
}
|
|
223
|
+
var WIDTH_BUCKET = 40;
|
|
224
|
+
function useChartSurface(forwarded, tokens) {
|
|
225
|
+
const [node, setNode] = useState(null);
|
|
226
|
+
const scopedTokens = useChartTokens(node);
|
|
227
|
+
const [surface, setSurface] = useState(void 0);
|
|
228
|
+
const [width, setWidth] = useState(void 0);
|
|
229
|
+
const ref = useCallback(
|
|
230
|
+
(el) => {
|
|
231
|
+
setNode(el);
|
|
232
|
+
if (typeof forwarded === "function") forwarded(el);
|
|
233
|
+
else if (forwarded) forwarded.current = el;
|
|
234
|
+
},
|
|
235
|
+
[forwarded]
|
|
236
|
+
);
|
|
237
|
+
useEffect(() => {
|
|
238
|
+
if (!node) return;
|
|
239
|
+
setSurface(readChartSurface(node) ?? void 0);
|
|
240
|
+
}, [node, tokens, scopedTokens]);
|
|
241
|
+
useEffect(() => {
|
|
242
|
+
if (!node || typeof ResizeObserver === "undefined") return;
|
|
243
|
+
const update = (w) => setWidth(Math.floor(w / WIDTH_BUCKET) * WIDTH_BUCKET);
|
|
244
|
+
update(node.getBoundingClientRect().width);
|
|
245
|
+
const observer = new ResizeObserver((entries) => update(entries[0]?.contentRect.width ?? 0));
|
|
246
|
+
observer.observe(node);
|
|
247
|
+
return () => observer.disconnect();
|
|
248
|
+
}, [node]);
|
|
249
|
+
return { ref, surface, width, tokens: scopedTokens };
|
|
250
|
+
}
|
|
251
|
+
use([
|
|
252
|
+
BarChart,
|
|
253
|
+
CustomChart,
|
|
254
|
+
LineChart,
|
|
255
|
+
PieChart,
|
|
256
|
+
GridComponent,
|
|
257
|
+
LegendComponent,
|
|
258
|
+
MarkAreaComponent,
|
|
259
|
+
MarkLineComponent,
|
|
260
|
+
MarkPointComponent,
|
|
261
|
+
TooltipComponent,
|
|
262
|
+
CanvasRenderer
|
|
263
|
+
]);
|
|
264
|
+
var HEADER_PAD_X = 16;
|
|
265
|
+
var HEADER_PAD_TOP = 16;
|
|
266
|
+
var HEADER_PAD_BOTTOM = 12;
|
|
267
|
+
var HEADER_LINE_HEIGHT = 20;
|
|
268
|
+
var HEADER_GAP = 4;
|
|
269
|
+
var HEADER_FONT_SIZE = 14;
|
|
270
|
+
function wrapChartText(text, maxWidth, measure) {
|
|
271
|
+
const lines = [];
|
|
272
|
+
let line = "";
|
|
273
|
+
for (const ch of text) {
|
|
274
|
+
if (ch === "\n") {
|
|
275
|
+
lines.push(line);
|
|
276
|
+
line = "";
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (line !== "" && measure(line + ch) > maxWidth) {
|
|
280
|
+
lines.push(line);
|
|
281
|
+
line = ch.trim() === "" ? "" : ch;
|
|
282
|
+
} else {
|
|
283
|
+
line += ch;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (line !== "" || lines.length === 0) lines.push(line);
|
|
287
|
+
return lines.filter((l, i) => l !== "" || i < lines.length - 1);
|
|
288
|
+
}
|
|
289
|
+
function chartExportHeaderLayout(header, width, measure) {
|
|
290
|
+
const title = header?.title?.trim();
|
|
291
|
+
const summary = header?.summary?.trim();
|
|
292
|
+
if (!title && !summary) return { lines: [], height: 0 };
|
|
293
|
+
const room = Math.max(40, width - HEADER_PAD_X * 2);
|
|
294
|
+
const lines = [
|
|
295
|
+
...title ? wrapChartText(title, room, (t) => measure(t, "title")).map((text) => ({ text, kind: "title" })) : [],
|
|
296
|
+
...summary ? wrapChartText(summary, room, (t) => measure(t, "summary")).map((text) => ({ text, kind: "summary" })) : []
|
|
297
|
+
];
|
|
298
|
+
const gap = title && summary ? HEADER_GAP : 0;
|
|
299
|
+
return { lines, height: HEADER_PAD_TOP + lines.length * HEADER_LINE_HEIGHT + gap + HEADER_PAD_BOTTOM };
|
|
300
|
+
}
|
|
301
|
+
function loadImage(src) {
|
|
302
|
+
return new Promise((resolve, reject) => {
|
|
303
|
+
const image = new Image();
|
|
304
|
+
image.onload = () => resolve(image);
|
|
305
|
+
image.onerror = () => reject(new Error("PNG \u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F"));
|
|
306
|
+
image.src = src;
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
async function pngWithHeader(dataUrl, header, look, pixelRatio) {
|
|
310
|
+
const image = await loadImage(dataUrl);
|
|
311
|
+
const width = image.width / pixelRatio;
|
|
312
|
+
const plotHeight = image.height / pixelRatio;
|
|
313
|
+
const canvas = document.createElement("canvas");
|
|
314
|
+
const ctx = canvas.getContext("2d");
|
|
315
|
+
if (!ctx) return dataUrl;
|
|
316
|
+
const font = (kind) => `${kind === "title" ? 500 : 400} ${HEADER_FONT_SIZE}px ${look.fontFamily}`;
|
|
317
|
+
ctx.font = font("title");
|
|
318
|
+
const layout = chartExportHeaderLayout(header, width, (text, kind) => {
|
|
319
|
+
ctx.font = font(kind);
|
|
320
|
+
return ctx.measureText(text).width;
|
|
321
|
+
});
|
|
322
|
+
if (layout.height === 0) return dataUrl;
|
|
323
|
+
canvas.width = Math.round(image.width);
|
|
324
|
+
canvas.height = Math.round((layout.height + plotHeight) * pixelRatio);
|
|
325
|
+
ctx.scale(pixelRatio, pixelRatio);
|
|
326
|
+
ctx.fillStyle = look.background;
|
|
327
|
+
ctx.fillRect(0, 0, width, layout.height + plotHeight);
|
|
328
|
+
ctx.textBaseline = "middle";
|
|
329
|
+
let y = HEADER_PAD_TOP;
|
|
330
|
+
let previous = null;
|
|
331
|
+
for (const line of layout.lines) {
|
|
332
|
+
if (previous === "title" && line.kind === "summary") y += HEADER_GAP;
|
|
333
|
+
ctx.font = font(line.kind);
|
|
334
|
+
ctx.fillStyle = line.kind === "title" ? look.color : look.mutedColor;
|
|
335
|
+
ctx.fillText(line.text, HEADER_PAD_X, y + HEADER_LINE_HEIGHT / 2);
|
|
336
|
+
y += HEADER_LINE_HEIGHT;
|
|
337
|
+
previous = line.kind;
|
|
338
|
+
}
|
|
339
|
+
ctx.drawImage(image, 0, layout.height, width, plotHeight);
|
|
340
|
+
return canvas.toDataURL("image/png");
|
|
341
|
+
}
|
|
342
|
+
function useResolvedChartColors(colors) {
|
|
343
|
+
const tokens = useChartTokens();
|
|
344
|
+
const key = colors.join("\0");
|
|
345
|
+
return useMemo(() => resolveChartColors(colors, tokens), [key, tokens]);
|
|
346
|
+
}
|
|
347
|
+
var COMPONENT_MAIN_TYPES = /* @__PURE__ */ new Set([
|
|
348
|
+
"title",
|
|
349
|
+
"legend",
|
|
350
|
+
"grid",
|
|
351
|
+
"xAxis",
|
|
352
|
+
"yAxis",
|
|
353
|
+
"polar",
|
|
354
|
+
"radiusAxis",
|
|
355
|
+
"angleAxis",
|
|
356
|
+
"radar",
|
|
357
|
+
"dataZoom",
|
|
358
|
+
"visualMap",
|
|
359
|
+
"tooltip",
|
|
360
|
+
"axisPointer",
|
|
361
|
+
"toolbox",
|
|
362
|
+
"brush",
|
|
363
|
+
"geo",
|
|
364
|
+
"parallel",
|
|
365
|
+
"parallelAxis",
|
|
366
|
+
"singleAxis",
|
|
367
|
+
"graphic",
|
|
368
|
+
"calendar",
|
|
369
|
+
"dataset",
|
|
370
|
+
"series",
|
|
371
|
+
"matrix",
|
|
372
|
+
"thumbnail"
|
|
373
|
+
]);
|
|
374
|
+
function echartSetOptionOpts(prev, next) {
|
|
375
|
+
const special = (o) => "timeline" in o || "baseOption" in o || "options" in o || "media" in o;
|
|
376
|
+
if (!prev || special(prev) || special(next)) return { notMerge: true, lazyUpdate: true };
|
|
377
|
+
const types = /* @__PURE__ */ new Set();
|
|
378
|
+
for (const key of [...Object.keys(prev), ...Object.keys(next)]) if (COMPONENT_MAIN_TYPES.has(key)) types.add(key);
|
|
379
|
+
return { notMerge: false, replaceMerge: [...types], lazyUpdate: true };
|
|
380
|
+
}
|
|
381
|
+
var ID_TYPES = [
|
|
382
|
+
"title",
|
|
383
|
+
"legend",
|
|
384
|
+
"grid",
|
|
385
|
+
"xAxis",
|
|
386
|
+
"yAxis",
|
|
387
|
+
"polar",
|
|
388
|
+
"radiusAxis",
|
|
389
|
+
"angleAxis",
|
|
390
|
+
"radar",
|
|
391
|
+
"dataZoom",
|
|
392
|
+
"visualMap",
|
|
393
|
+
"geo",
|
|
394
|
+
"singleAxis",
|
|
395
|
+
"calendar"
|
|
396
|
+
];
|
|
397
|
+
var createStableIdState = () => ({ ids: /* @__PURE__ */ new Map(), order: /* @__PURE__ */ new Map() });
|
|
398
|
+
function shapeOf(v) {
|
|
399
|
+
if (Array.isArray(v)) return "[]";
|
|
400
|
+
if (!v || typeof v !== "object" || Object.getPrototypeOf(v) !== Object.prototype) return ".";
|
|
401
|
+
const o = v;
|
|
402
|
+
return `{${Object.keys(o).filter((k) => o[k] !== void 0).sort().map((k) => k === "type" || k === "id" ? `${k}=${String(o[k])}` : `${k}:${shapeOf(o[k])}`).join(",")}}`;
|
|
403
|
+
}
|
|
404
|
+
function withStableIds(option, state = createStableIdState()) {
|
|
405
|
+
const out = { ...option };
|
|
406
|
+
const taken = /* @__PURE__ */ new Set();
|
|
407
|
+
const list = (v) => Array.isArray(v) ? v : v && typeof v === "object" ? [v] : null;
|
|
408
|
+
const give = (key, pick) => {
|
|
409
|
+
const items = list(out[key]);
|
|
410
|
+
if (!items) return;
|
|
411
|
+
const used = new Set(items.flatMap((c) => c && c.id != null ? [String(c.id)] : []));
|
|
412
|
+
const bases = items.map((c, i) => {
|
|
413
|
+
if (!c || typeof c !== "object" || c.id != null) return null;
|
|
414
|
+
let base = pick(c, i);
|
|
415
|
+
for (let n = 2; used.has(base) || taken.has(`${key}\0${base}`); n++) base = `${pick(c, i)}#${n}`;
|
|
416
|
+
used.add(base);
|
|
417
|
+
taken.add(`${key}\0${base}`);
|
|
418
|
+
return base;
|
|
419
|
+
});
|
|
420
|
+
const prevOrder = state.order.get(key) ?? [];
|
|
421
|
+
const cur = bases.filter((b) => b !== null);
|
|
422
|
+
const inOrder = cur.length === prevOrder.length && cur.every((b, i) => b === prevOrder[i]);
|
|
423
|
+
state.order.set(key, cur);
|
|
424
|
+
out[key] = items.map((c, i) => {
|
|
425
|
+
const base = bases[i];
|
|
426
|
+
if (base == null) return c;
|
|
427
|
+
const shape = shapeOf(c);
|
|
428
|
+
const prev = state.ids.get(base);
|
|
429
|
+
const version = !prev ? 0 : prev.shape === shape && inOrder ? prev.version : prev.version + 1;
|
|
430
|
+
state.ids.set(base, { shape, version });
|
|
431
|
+
return { ...c, id: version ? `${base}~v${version}` : base };
|
|
432
|
+
});
|
|
433
|
+
};
|
|
434
|
+
give("series", (c, i) => `series:${typeof c.name === "string" && c.name ? c.name : i}`);
|
|
435
|
+
for (const key of ID_TYPES) give(key, (_c, i) => `${key}:${i}`);
|
|
436
|
+
return out;
|
|
437
|
+
}
|
|
438
|
+
function snapshotOption(v) {
|
|
439
|
+
if (Array.isArray(v)) return v.map(snapshotOption);
|
|
440
|
+
if (v && typeof v === "object") {
|
|
441
|
+
const proto = Object.getPrototypeOf(v);
|
|
442
|
+
if (proto === Object.prototype || proto === null) {
|
|
443
|
+
return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, snapshotOption(x)]));
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return v;
|
|
447
|
+
}
|
|
448
|
+
function optionEquals(a, b) {
|
|
449
|
+
if (Object.is(a, b)) return true;
|
|
450
|
+
if (typeof a !== "object" || typeof b !== "object" || !a || !b) return false;
|
|
451
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
452
|
+
if (Array.isArray(a)) {
|
|
453
|
+
const bb = b;
|
|
454
|
+
return a.length === bb.length && a.every((v, i) => optionEquals(v, bb[i]));
|
|
455
|
+
}
|
|
456
|
+
if (a instanceof Date || b instanceof Date) return a instanceof Date && b instanceof Date && a.getTime() === b.getTime();
|
|
457
|
+
const pa = Object.getPrototypeOf(a);
|
|
458
|
+
if (pa !== Object.prototype && pa !== null || Object.getPrototypeOf(b) !== pa) return false;
|
|
459
|
+
const ka = Object.keys(a);
|
|
460
|
+
const kb = Object.keys(b);
|
|
461
|
+
return ka.length === kb.length && ka.every((k) => Object.hasOwn(b, k) && optionEquals(a[k], b[k]));
|
|
462
|
+
}
|
|
463
|
+
function withGraphicFont(option, fontFamily) {
|
|
464
|
+
const graphic = option.graphic;
|
|
465
|
+
if (!fontFamily || !Array.isArray(graphic)) return option;
|
|
466
|
+
return {
|
|
467
|
+
...option,
|
|
468
|
+
graphic: graphic.map(
|
|
469
|
+
(g) => g && g.type === "text" && g.style && !g.style.fontFamily ? { ...g, style: { ...g.style, fontFamily } } : g
|
|
470
|
+
)
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function withMotionPreference(option, reducedMotion) {
|
|
474
|
+
return { ...option, animation: reducedMotion ? false : option.animation ?? true };
|
|
475
|
+
}
|
|
476
|
+
var REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";
|
|
477
|
+
function usePrefersReducedMotion() {
|
|
478
|
+
const [reduced, setReduced] = useState(
|
|
479
|
+
() => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(REDUCED_MOTION_QUERY).matches
|
|
480
|
+
);
|
|
481
|
+
useEffect(() => {
|
|
482
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
|
|
483
|
+
const media = window.matchMedia(REDUCED_MOTION_QUERY);
|
|
484
|
+
const sync = () => setReduced(media.matches);
|
|
485
|
+
sync();
|
|
486
|
+
media.addEventListener("change", sync);
|
|
487
|
+
return () => media.removeEventListener("change", sync);
|
|
488
|
+
}, []);
|
|
489
|
+
return reduced;
|
|
490
|
+
}
|
|
491
|
+
var EChart = forwardRef(function EChart2({
|
|
492
|
+
option,
|
|
493
|
+
height,
|
|
494
|
+
loading = false,
|
|
495
|
+
theme,
|
|
496
|
+
onEvents,
|
|
497
|
+
ariaLabel,
|
|
498
|
+
className,
|
|
499
|
+
actions = false,
|
|
500
|
+
fileName = "chart.png",
|
|
501
|
+
exportHeader
|
|
502
|
+
}, ref) {
|
|
503
|
+
const containerRef = useRef(null);
|
|
504
|
+
const [instance, setInstance] = useState(null);
|
|
505
|
+
const [copied, setCopied] = useState(false);
|
|
506
|
+
const tokens = useChartTokens(containerRef);
|
|
507
|
+
const reducedMotion = usePrefersReducedMotion();
|
|
508
|
+
const appliedRef = useRef(null);
|
|
509
|
+
const snapshotRef = useRef(null);
|
|
510
|
+
const idStateRef = useRef(createStableIdState());
|
|
511
|
+
const autoTheme = useMemo(() => tokens ? buildChartTheme(tokens) : void 0, [tokens]);
|
|
512
|
+
const resolvedTheme = theme ?? autoTheme;
|
|
513
|
+
useEffect(() => {
|
|
514
|
+
const container = containerRef.current;
|
|
515
|
+
if (!container) return;
|
|
516
|
+
const inst = init(container, resolvedTheme, { renderer: "canvas" });
|
|
517
|
+
appliedRef.current = null;
|
|
518
|
+
snapshotRef.current = null;
|
|
519
|
+
container.dataset.rendering = "";
|
|
520
|
+
inst.on("finished", () => {
|
|
521
|
+
delete container.dataset.rendering;
|
|
522
|
+
});
|
|
523
|
+
setInstance(inst);
|
|
524
|
+
let frame = 0;
|
|
525
|
+
const observer = new ResizeObserver(() => {
|
|
526
|
+
cancelAnimationFrame(frame);
|
|
527
|
+
frame = requestAnimationFrame(() => {
|
|
528
|
+
if (!inst.isDisposed()) inst.resize();
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
observer.observe(container);
|
|
532
|
+
return () => {
|
|
533
|
+
observer.disconnect();
|
|
534
|
+
cancelAnimationFrame(frame);
|
|
535
|
+
inst.dispose();
|
|
536
|
+
};
|
|
537
|
+
}, [resolvedTheme]);
|
|
538
|
+
useEffect(() => {
|
|
539
|
+
if (!instance || instance.isDisposed()) return;
|
|
540
|
+
const prepared = withGraphicFont(
|
|
541
|
+
withMotionPreference(option, reducedMotion),
|
|
542
|
+
theme === void 0 ? tokens?.fontFamily : void 0
|
|
543
|
+
);
|
|
544
|
+
if (snapshotRef.current && optionEquals(snapshotRef.current, prepared)) return;
|
|
545
|
+
if (containerRef.current) containerRef.current.dataset.rendering = "";
|
|
546
|
+
const next = withStableIds(prepared, idStateRef.current);
|
|
547
|
+
instance.setOption(next, echartSetOptionOpts(appliedRef.current, next));
|
|
548
|
+
appliedRef.current = next;
|
|
549
|
+
snapshotRef.current = snapshotOption(prepared);
|
|
550
|
+
}, [instance, option, reducedMotion, theme, tokens?.fontFamily]);
|
|
551
|
+
useEffect(() => {
|
|
552
|
+
if (!instance || instance.isDisposed()) return;
|
|
553
|
+
if (loading) instance.showLoading();
|
|
554
|
+
else instance.hideLoading();
|
|
555
|
+
}, [instance, loading]);
|
|
556
|
+
useEffect(() => {
|
|
557
|
+
if (!instance || instance.isDisposed() || !onEvents) return;
|
|
558
|
+
const entries = Object.entries(onEvents);
|
|
559
|
+
for (const [event, handler] of entries) {
|
|
560
|
+
instance.on(event, handler);
|
|
561
|
+
}
|
|
562
|
+
return () => {
|
|
563
|
+
if (instance.isDisposed()) return;
|
|
564
|
+
for (const [event, handler] of entries) {
|
|
565
|
+
instance.off(event, handler);
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
}, [instance, onEvents]);
|
|
569
|
+
const includeTitle = typeof actions === "object" ? actions.includeTitle ?? true : true;
|
|
570
|
+
const getPngDataUrl = useCallback(async () => {
|
|
571
|
+
if (!instance) return null;
|
|
572
|
+
let backgroundColor = "#ffffff";
|
|
573
|
+
for (let el = containerRef.current; el; el = el.parentElement) {
|
|
574
|
+
const bg = getComputedStyle(el).backgroundColor;
|
|
575
|
+
if (bg && bg !== "rgba(0, 0, 0, 0)" && bg !== "transparent") {
|
|
576
|
+
backgroundColor = bg;
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
const pixelRatio = 2;
|
|
581
|
+
const dataUrl = instance.getDataURL({ type: "png", pixelRatio, backgroundColor });
|
|
582
|
+
if (!includeTitle || !exportHeader || !(exportHeader.title || exportHeader.summary) || !containerRef.current) return dataUrl;
|
|
583
|
+
try {
|
|
584
|
+
const style = getComputedStyle(containerRef.current);
|
|
585
|
+
return await pngWithHeader(
|
|
586
|
+
dataUrl,
|
|
587
|
+
exportHeader,
|
|
588
|
+
{ background: backgroundColor, color: style.color, mutedColor: tokens?.mutedForeground ?? style.color, fontFamily: style.fontFamily },
|
|
589
|
+
pixelRatio
|
|
590
|
+
);
|
|
591
|
+
} catch {
|
|
592
|
+
return dataUrl;
|
|
593
|
+
}
|
|
594
|
+
}, [instance, includeTitle, exportHeader, tokens]);
|
|
595
|
+
const handleCopy = useCallback(async () => {
|
|
596
|
+
const dataUrl = await getPngDataUrl();
|
|
597
|
+
if (!dataUrl) return;
|
|
598
|
+
try {
|
|
599
|
+
const blob = await (await fetch(dataUrl)).blob();
|
|
600
|
+
await navigator.clipboard.write([new ClipboardItem({ "image/png": blob })]);
|
|
601
|
+
setCopied(true);
|
|
602
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
603
|
+
} catch {
|
|
604
|
+
}
|
|
605
|
+
}, [getPngDataUrl]);
|
|
606
|
+
const handleDownload = useCallback(async () => {
|
|
607
|
+
const dataUrl = await getPngDataUrl();
|
|
608
|
+
if (!dataUrl) return;
|
|
609
|
+
const link = document.createElement("a");
|
|
610
|
+
link.href = dataUrl;
|
|
611
|
+
link.download = fileName;
|
|
612
|
+
link.click();
|
|
613
|
+
}, [getPngDataUrl, fileName]);
|
|
614
|
+
const inFrame = useContext(ChartFrameContext);
|
|
615
|
+
const styleHeight = height == null ? void 0 : typeof height === "number" ? `${height}px` : height;
|
|
616
|
+
return /* @__PURE__ */ jsxs(
|
|
617
|
+
"div",
|
|
618
|
+
{
|
|
619
|
+
ref,
|
|
620
|
+
"data-slot": "echart",
|
|
621
|
+
className: cn("group relative w-full", height == null && "h-[400px]", className),
|
|
622
|
+
style: styleHeight != null ? { height: styleHeight } : void 0,
|
|
623
|
+
children: [
|
|
624
|
+
/* @__PURE__ */ jsx(
|
|
625
|
+
"div",
|
|
626
|
+
{
|
|
627
|
+
ref: containerRef,
|
|
628
|
+
"data-slot": "echart-canvas",
|
|
629
|
+
className: "h-full w-full",
|
|
630
|
+
role: inFrame ? void 0 : "img",
|
|
631
|
+
"aria-label": inFrame ? void 0 : ariaLabel ?? "\u30C1\u30E3\u30FC\u30C8"
|
|
632
|
+
}
|
|
633
|
+
),
|
|
634
|
+
actions && /* @__PURE__ */ jsxs(
|
|
635
|
+
"div",
|
|
636
|
+
{
|
|
637
|
+
"data-slot": "echart-actions",
|
|
638
|
+
className: "absolute top-2 right-2 z-10 flex gap-1 pointer-events-none opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 focus-within:pointer-events-auto focus-within:opacity-100 [@media(hover:none)]:pointer-events-auto [@media(hover:none)]:opacity-100",
|
|
639
|
+
children: [
|
|
640
|
+
/* @__PURE__ */ jsx(
|
|
641
|
+
Button,
|
|
642
|
+
{
|
|
643
|
+
type: "button",
|
|
644
|
+
variant: "ghost",
|
|
645
|
+
size: "icon-sm",
|
|
646
|
+
onClick: handleCopy,
|
|
647
|
+
"aria-label": copied ? "\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F" : "PNG \u3092\u30AF\u30EA\u30C3\u30D7\u30DC\u30FC\u30C9\u306B\u30B3\u30D4\u30FC",
|
|
648
|
+
children: copied ? /* @__PURE__ */ jsx(Check, { className: "size-4" }) : /* @__PURE__ */ jsx(Copy, { className: "size-4" })
|
|
649
|
+
}
|
|
650
|
+
),
|
|
651
|
+
/* @__PURE__ */ jsx(
|
|
652
|
+
Button,
|
|
653
|
+
{
|
|
654
|
+
type: "button",
|
|
655
|
+
variant: "ghost",
|
|
656
|
+
size: "icon-sm",
|
|
657
|
+
onClick: handleDownload,
|
|
658
|
+
"aria-label": "PNG \u3092\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9",
|
|
659
|
+
children: /* @__PURE__ */ jsx(Download, { className: "size-4" })
|
|
660
|
+
}
|
|
661
|
+
)
|
|
662
|
+
]
|
|
663
|
+
}
|
|
664
|
+
)
|
|
665
|
+
]
|
|
666
|
+
}
|
|
667
|
+
);
|
|
668
|
+
});
|
|
669
|
+
EChart.displayName = "EChart";
|
|
670
|
+
|
|
671
|
+
export { CHART_OTHER_COLOR, ChartFrameContext, EChart, resolveChartColors, resolveFillColors, useChartSurface, useResolvedChartColors };
|
|
672
|
+
//# sourceMappingURL=chunk-JXFCSF3K.js.map
|
|
673
|
+
//# sourceMappingURL=chunk-JXFCSF3K.js.map
|