@pyreon/charts 0.11.5 → 0.11.6
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 +31 -31
- package/lib/index.js.map +1 -1
- package/lib/manual.js.map +1 -1
- package/lib/types/index.d.ts +2 -2
- package/lib/types/manual.d.ts +2 -2
- package/package.json +18 -18
- package/src/chart-component.tsx +9 -9
- package/src/index.ts +3 -3
- package/src/loader.ts +54 -54
- package/src/manual.ts +4 -9
- package/src/tests/charts.test.tsx +178 -178
- package/src/types.ts +7 -7
- package/src/use-chart.ts +7 -7
package/src/loader.ts
CHANGED
|
@@ -17,85 +17,85 @@ type LooseOption = Record<string, unknown> & {
|
|
|
17
17
|
type ModuleLoader = () => Promise<unknown>
|
|
18
18
|
|
|
19
19
|
/** The argument type that `echarts/core.use()` accepts. */
|
|
20
|
-
type EChartsUseArg = Parameters<typeof import(
|
|
20
|
+
type EChartsUseArg = Parameters<typeof import('echarts/core').use>[0]
|
|
21
21
|
|
|
22
22
|
// ─── Chart type mapping ─────────────────────────────────────────────────────
|
|
23
23
|
|
|
24
24
|
const CHARTS: Record<string, ModuleLoader> = {
|
|
25
|
-
bar: () => import(
|
|
26
|
-
line: () => import(
|
|
27
|
-
pie: () => import(
|
|
28
|
-
scatter: () => import(
|
|
29
|
-
radar: () => import(
|
|
30
|
-
heatmap: () => import(
|
|
31
|
-
treemap: () => import(
|
|
32
|
-
sunburst: () => import(
|
|
33
|
-
sankey: () => import(
|
|
34
|
-
funnel: () => import(
|
|
35
|
-
gauge: () => import(
|
|
36
|
-
graph: () => import(
|
|
37
|
-
tree: () => import(
|
|
38
|
-
boxplot: () => import(
|
|
39
|
-
candlestick: () => import(
|
|
40
|
-
parallel: () => import(
|
|
41
|
-
themeRiver: () => import(
|
|
42
|
-
effectScatter: () => import(
|
|
43
|
-
lines: () => import(
|
|
44
|
-
pictorialBar: () => import(
|
|
45
|
-
custom: () => import(
|
|
46
|
-
map: () => import(
|
|
25
|
+
bar: () => import('echarts/charts').then((m) => m.BarChart),
|
|
26
|
+
line: () => import('echarts/charts').then((m) => m.LineChart),
|
|
27
|
+
pie: () => import('echarts/charts').then((m) => m.PieChart),
|
|
28
|
+
scatter: () => import('echarts/charts').then((m) => m.ScatterChart),
|
|
29
|
+
radar: () => import('echarts/charts').then((m) => m.RadarChart),
|
|
30
|
+
heatmap: () => import('echarts/charts').then((m) => m.HeatmapChart),
|
|
31
|
+
treemap: () => import('echarts/charts').then((m) => m.TreemapChart),
|
|
32
|
+
sunburst: () => import('echarts/charts').then((m) => m.SunburstChart),
|
|
33
|
+
sankey: () => import('echarts/charts').then((m) => m.SankeyChart),
|
|
34
|
+
funnel: () => import('echarts/charts').then((m) => m.FunnelChart),
|
|
35
|
+
gauge: () => import('echarts/charts').then((m) => m.GaugeChart),
|
|
36
|
+
graph: () => import('echarts/charts').then((m) => m.GraphChart),
|
|
37
|
+
tree: () => import('echarts/charts').then((m) => m.TreeChart),
|
|
38
|
+
boxplot: () => import('echarts/charts').then((m) => m.BoxplotChart),
|
|
39
|
+
candlestick: () => import('echarts/charts').then((m) => m.CandlestickChart),
|
|
40
|
+
parallel: () => import('echarts/charts').then((m) => m.ParallelChart),
|
|
41
|
+
themeRiver: () => import('echarts/charts').then((m) => m.ThemeRiverChart),
|
|
42
|
+
effectScatter: () => import('echarts/charts').then((m) => m.EffectScatterChart),
|
|
43
|
+
lines: () => import('echarts/charts').then((m) => m.LinesChart),
|
|
44
|
+
pictorialBar: () => import('echarts/charts').then((m) => m.PictorialBarChart),
|
|
45
|
+
custom: () => import('echarts/charts').then((m) => m.CustomChart),
|
|
46
|
+
map: () => import('echarts/charts').then((m) => m.MapChart),
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// ─── Component mapping ──────────────────────────────────────────────────────
|
|
50
50
|
|
|
51
51
|
// Multiple config keys can map to the same component (xAxis/yAxis → Grid)
|
|
52
52
|
const COMPONENTS: Record<string, ModuleLoader> = {
|
|
53
|
-
grid: () => import(
|
|
54
|
-
xAxis: () => import(
|
|
55
|
-
yAxis: () => import(
|
|
56
|
-
polar: () => import(
|
|
57
|
-
radar: () => import(
|
|
58
|
-
geo: () => import(
|
|
59
|
-
tooltip: () => import(
|
|
60
|
-
legend: () => import(
|
|
61
|
-
toolbox: () => import(
|
|
62
|
-
title: () => import(
|
|
63
|
-
dataZoom: () => import(
|
|
64
|
-
visualMap: () => import(
|
|
65
|
-
timeline: () => import(
|
|
66
|
-
graphic: () => import(
|
|
67
|
-
brush: () => import(
|
|
68
|
-
calendar: () => import(
|
|
69
|
-
dataset: () => import(
|
|
70
|
-
aria: () => import(
|
|
53
|
+
grid: () => import('echarts/components').then((m) => m.GridComponent),
|
|
54
|
+
xAxis: () => import('echarts/components').then((m) => m.GridComponent),
|
|
55
|
+
yAxis: () => import('echarts/components').then((m) => m.GridComponent),
|
|
56
|
+
polar: () => import('echarts/components').then((m) => m.PolarComponent),
|
|
57
|
+
radar: () => import('echarts/components').then((m) => m.RadarComponent),
|
|
58
|
+
geo: () => import('echarts/components').then((m) => m.GeoComponent),
|
|
59
|
+
tooltip: () => import('echarts/components').then((m) => m.TooltipComponent),
|
|
60
|
+
legend: () => import('echarts/components').then((m) => m.LegendComponent),
|
|
61
|
+
toolbox: () => import('echarts/components').then((m) => m.ToolboxComponent),
|
|
62
|
+
title: () => import('echarts/components').then((m) => m.TitleComponent),
|
|
63
|
+
dataZoom: () => import('echarts/components').then((m) => m.DataZoomComponent),
|
|
64
|
+
visualMap: () => import('echarts/components').then((m) => m.VisualMapComponent),
|
|
65
|
+
timeline: () => import('echarts/components').then((m) => m.TimelineComponent),
|
|
66
|
+
graphic: () => import('echarts/components').then((m) => m.GraphicComponent),
|
|
67
|
+
brush: () => import('echarts/components').then((m) => m.BrushComponent),
|
|
68
|
+
calendar: () => import('echarts/components').then((m) => m.CalendarComponent),
|
|
69
|
+
dataset: () => import('echarts/components').then((m) => m.DatasetComponent),
|
|
70
|
+
aria: () => import('echarts/components').then((m) => m.AriaComponent),
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// Series-level features
|
|
74
74
|
const SERIES_FEATURES: Record<string, ModuleLoader> = {
|
|
75
|
-
markPoint: () => import(
|
|
76
|
-
markLine: () => import(
|
|
77
|
-
markArea: () => import(
|
|
75
|
+
markPoint: () => import('echarts/components').then((m) => m.MarkPointComponent),
|
|
76
|
+
markLine: () => import('echarts/components').then((m) => m.MarkLineComponent),
|
|
77
|
+
markArea: () => import('echarts/components').then((m) => m.MarkAreaComponent),
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// ─── Renderers ──────────────────────────────────────────────────────────────
|
|
81
81
|
|
|
82
82
|
const RENDERERS: Record<string, ModuleLoader> = {
|
|
83
|
-
canvas: () => import(
|
|
84
|
-
svg: () => import(
|
|
83
|
+
canvas: () => import('echarts/renderers').then((m) => m.CanvasRenderer),
|
|
84
|
+
svg: () => import('echarts/renderers').then((m) => m.SVGRenderer),
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// ─── Core loading ───────────────────────────────────────────────────────────
|
|
88
88
|
|
|
89
|
-
let coreModule: typeof import(
|
|
90
|
-
let corePromise: Promise<typeof import(
|
|
89
|
+
let coreModule: typeof import('echarts/core') | null = null
|
|
90
|
+
let corePromise: Promise<typeof import('echarts/core')> | null = null
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* Lazily load echarts/core. Cached after first call.
|
|
94
94
|
*/
|
|
95
|
-
export async function getCore(): Promise<typeof import(
|
|
95
|
+
export async function getCore(): Promise<typeof import('echarts/core')> {
|
|
96
96
|
if (coreModule) return coreModule
|
|
97
97
|
if (!corePromise) {
|
|
98
|
-
corePromise = import(
|
|
98
|
+
corePromise = import('echarts/core').then((m) => {
|
|
99
99
|
coreModule = m
|
|
100
100
|
return m
|
|
101
101
|
})
|
|
@@ -106,7 +106,7 @@ export async function getCore(): Promise<typeof import("echarts/core")> {
|
|
|
106
106
|
/**
|
|
107
107
|
* Get the cached core module (null if not yet loaded).
|
|
108
108
|
*/
|
|
109
|
-
export function getCoreSync(): typeof import(
|
|
109
|
+
export function getCoreSync(): typeof import('echarts/core') | null {
|
|
110
110
|
return coreModule
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -116,7 +116,7 @@ const registered = new Set<string>()
|
|
|
116
116
|
const inflight = new Map<string, Promise<void>>()
|
|
117
117
|
|
|
118
118
|
async function loadAndRegister(
|
|
119
|
-
core: typeof import(
|
|
119
|
+
core: typeof import('echarts/core'),
|
|
120
120
|
key: string,
|
|
121
121
|
loader: ModuleLoader,
|
|
122
122
|
): Promise<void> {
|
|
@@ -139,8 +139,8 @@ async function loadAndRegister(
|
|
|
139
139
|
*/
|
|
140
140
|
export async function ensureModules(
|
|
141
141
|
option: LooseOption,
|
|
142
|
-
renderer:
|
|
143
|
-
): Promise<typeof import(
|
|
142
|
+
renderer: 'canvas' | 'svg' = 'canvas',
|
|
143
|
+
): Promise<typeof import('echarts/core')> {
|
|
144
144
|
const core = await getCore()
|
|
145
145
|
const loads: Promise<void>[] = []
|
|
146
146
|
|
package/src/manual.ts
CHANGED
|
@@ -25,12 +25,7 @@
|
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
export { Chart } from
|
|
29
|
-
export { manualUse as use } from
|
|
30
|
-
export type {
|
|
31
|
-
|
|
32
|
-
EChartsOption,
|
|
33
|
-
UseChartConfig,
|
|
34
|
-
UseChartResult,
|
|
35
|
-
} from "./types"
|
|
36
|
-
export { useChart } from "./use-chart"
|
|
28
|
+
export { Chart } from './chart-component'
|
|
29
|
+
export { manualUse as use } from './loader'
|
|
30
|
+
export type { ChartProps, EChartsOption, UseChartConfig, UseChartResult } from './types'
|
|
31
|
+
export { useChart } from './use-chart'
|