@aura-react-comp/charts 0.3.1 → 0.4.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.
- package/esm/charts/area-chart/index.js +27 -23
- package/esm/charts/bar-chart/index.js +17 -21
- package/esm/charts/candlestick-chart/index.js +242 -180
- package/esm/charts/combo-chart/index.js +8 -20
- package/esm/charts/funnel-chart/index.js +133 -108
- package/esm/charts/gauge-chart/index.js +102 -105
- package/esm/charts/graph-chart/index.js +154 -114
- package/esm/charts/heatmap-chart/index.js +179 -135
- package/esm/charts/line-chart/index.js +28 -24
- package/esm/charts/pie-chart/index.d.ts.map +1 -1
- package/esm/charts/pie-chart/index.js +198 -139
- package/esm/charts/radar-chart/index.d.ts.map +1 -1
- package/esm/charts/radar-chart/index.js +154 -128
- package/esm/charts/ring-progress/index.js +81 -82
- package/esm/charts/sankey-chart/index.js +171 -141
- package/esm/charts/scatter-chart/index.d.ts.map +1 -1
- package/esm/charts/scatter-chart/index.js +225 -159
- package/esm/charts/sparkline/index.js +81 -66
- package/esm/charts/tree-chart/index.js +128 -102
- package/esm/charts/treemap-chart/index.js +162 -141
- package/esm/charts/waterfall-chart/index.js +165 -121
- package/esm/components/Legend.d.ts +3 -2
- package/esm/components/Legend.d.ts.map +1 -1
- package/esm/components/Legend.js +79 -48
- package/esm/components/Tooltip.js +62 -71
- package/esm/components/chart/index.d.ts +4 -1
- package/esm/components/chart/index.d.ts.map +1 -1
- package/esm/components/chart/index.js +80 -102
- package/esm/components/chart.less +13 -0
- package/esm/core/animation.js +31 -43
- package/esm/core/export.d.ts +34 -0
- package/esm/core/export.d.ts.map +1 -0
- package/esm/core/export.js +390 -0
- package/esm/core/force.js +22 -45
- package/esm/core/format.js +48 -52
- package/esm/core/hierarchy.js +60 -92
- package/esm/core/layout.js +32 -50
- package/esm/core/sampling.js +30 -53
- package/esm/core/sankey.js +35 -55
- package/esm/core/scale.js +72 -86
- package/esm/core/shape.js +101 -133
- package/esm/core/sync.d.ts +41 -0
- package/esm/core/sync.d.ts.map +1 -0
- package/esm/core/sync.js +120 -0
- package/esm/hooks/useChartExport.d.ts +19 -0
- package/esm/hooks/useChartExport.d.ts.map +1 -0
- package/esm/hooks/useChartExport.js +35 -0
- package/esm/hooks/useChartTheme.js +17 -19
- package/esm/hooks/useChartTransition.js +58 -73
- package/esm/hooks/useElementSize.js +19 -28
- package/esm/hooks/usePlotPointer.d.ts +23 -0
- package/esm/hooks/usePlotPointer.d.ts.map +1 -0
- package/esm/hooks/usePlotPointer.js +94 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +136 -47
- package/esm/internal/CartesianChart.d.ts.map +1 -1
- package/esm/internal/CartesianChart.js +666 -485
- package/esm/internal/model.js +44 -60
- package/esm/scene/canvas.js +100 -107
- package/esm/scene/svg.js +106 -99
- package/esm/scene/types.js +8 -15
- package/esm/style.css +10 -0
- package/esm/theme/index.js +143 -171
- package/esm/types.d.ts +4 -0
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js +0 -1
- package/package.json +1 -1
package/esm/style.css
CHANGED
|
@@ -59,6 +59,15 @@
|
|
|
59
59
|
.aura-chart__legend-item--inactive {
|
|
60
60
|
opacity: 0.45;
|
|
61
61
|
}
|
|
62
|
+
.aura-chart__legend-item--inactive .aura-chart__legend-text {
|
|
63
|
+
text-decoration: line-through;
|
|
64
|
+
}
|
|
65
|
+
.aura-chart__legend-item--static {
|
|
66
|
+
cursor: default;
|
|
67
|
+
}
|
|
68
|
+
.aura-chart__legend-item--static:hover {
|
|
69
|
+
opacity: 1;
|
|
70
|
+
}
|
|
62
71
|
.aura-chart__legend-dot {
|
|
63
72
|
width: 8px;
|
|
64
73
|
height: 8px;
|
|
@@ -71,6 +80,7 @@
|
|
|
71
80
|
min-height: 0;
|
|
72
81
|
width: 100%;
|
|
73
82
|
overflow: hidden;
|
|
83
|
+
touch-action: pan-y;
|
|
74
84
|
}
|
|
75
85
|
.aura-chart__zoom {
|
|
76
86
|
flex: 0 0 auto;
|
package/esm/theme/index.js
CHANGED
|
@@ -1,67 +1,45 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* 2. 读取发生在运行时(getComputedStyle),所以 `data-theme="dark"` 切换后
|
|
11
|
-
* 图表会跟着变,无需额外配置;
|
|
12
|
-
* 3. 提供 createChartTheme 做逐字段深合并,允许只覆盖一两个字段
|
|
13
|
-
* (比如只换色板),而不是整包替换。
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/** 图表主题结构:所有视觉常量集中于此,组件内不出现魔法值 */
|
|
17
|
-
|
|
18
|
-
/** Aura 令牌的静态兜底值:SSR 或未引入 tokens.css 时保证仍能出图 */
|
|
19
|
-
const AURA_FALLBACK = {
|
|
20
|
-
primary700: '#7c3aed',
|
|
21
|
-
primary600: '#9333ea',
|
|
22
|
-
textPrimary: '#111827',
|
|
23
|
-
textSecondary: '#6b7280',
|
|
24
|
-
border: '#e5e7eb',
|
|
25
|
-
bg: '#ffffff',
|
|
2
|
+
// src/theme/index.ts
|
|
3
|
+
var AURA_FALLBACK = {
|
|
4
|
+
primary700: "#7c3aed",
|
|
5
|
+
primary600: "#9333ea",
|
|
6
|
+
textPrimary: "#111827",
|
|
7
|
+
textSecondary: "#6b7280",
|
|
8
|
+
border: "#e5e7eb",
|
|
9
|
+
bg: "#ffffff",
|
|
26
10
|
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif"
|
|
27
11
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// pink
|
|
54
|
-
'#6366f1',
|
|
55
|
-
// indigo
|
|
56
|
-
'#84cc16',
|
|
57
|
-
// lime
|
|
58
|
-
'#06b6d4' // cyan
|
|
12
|
+
var DEFAULT_PALETTE = [
|
|
13
|
+
"#7c3aed",
|
|
14
|
+
// violet — Aura 品牌主色
|
|
15
|
+
"#0ea5e9",
|
|
16
|
+
// sky
|
|
17
|
+
"#10b981",
|
|
18
|
+
// emerald
|
|
19
|
+
"#f59e0b",
|
|
20
|
+
// amber
|
|
21
|
+
"#ef4444",
|
|
22
|
+
// red
|
|
23
|
+
"#8b5cf6",
|
|
24
|
+
// purple
|
|
25
|
+
"#14b8a6",
|
|
26
|
+
// teal
|
|
27
|
+
"#f97316",
|
|
28
|
+
// orange
|
|
29
|
+
"#ec4899",
|
|
30
|
+
// pink
|
|
31
|
+
"#6366f1",
|
|
32
|
+
// indigo
|
|
33
|
+
"#84cc16",
|
|
34
|
+
// lime
|
|
35
|
+
"#06b6d4"
|
|
36
|
+
// cyan
|
|
59
37
|
];
|
|
60
38
|
function createBase(name, dark) {
|
|
61
39
|
return {
|
|
62
40
|
name,
|
|
63
41
|
palette: DEFAULT_PALETTE,
|
|
64
|
-
background:
|
|
42
|
+
background: "transparent",
|
|
65
43
|
font: {
|
|
66
44
|
family: AURA_FALLBACK.fontFamily,
|
|
67
45
|
size: 12,
|
|
@@ -70,31 +48,31 @@ function createBase(name, dark) {
|
|
|
70
48
|
weightMedium: 500
|
|
71
49
|
},
|
|
72
50
|
text: {
|
|
73
|
-
primary: dark ?
|
|
74
|
-
secondary: dark ?
|
|
75
|
-
accent: dark ?
|
|
51
|
+
primary: dark ? "#e5e7eb" : AURA_FALLBACK.textPrimary,
|
|
52
|
+
secondary: dark ? "#9ca3af" : AURA_FALLBACK.textSecondary,
|
|
53
|
+
accent: dark ? "#c4b5fd" : AURA_FALLBACK.primary700
|
|
76
54
|
},
|
|
77
55
|
axis: {
|
|
78
|
-
line: dark ?
|
|
79
|
-
tick: dark ?
|
|
80
|
-
label: dark ?
|
|
56
|
+
line: dark ? "#374151" : AURA_FALLBACK.border,
|
|
57
|
+
tick: dark ? "#374151" : AURA_FALLBACK.border,
|
|
58
|
+
label: dark ? "#9ca3af" : AURA_FALLBACK.textSecondary,
|
|
81
59
|
lineWidth: 1,
|
|
82
60
|
tickSize: 4
|
|
83
61
|
},
|
|
84
62
|
grid: {
|
|
85
|
-
line: dark ?
|
|
63
|
+
line: dark ? "rgba(229, 231, 235, 0.12)" : AURA_FALLBACK.border,
|
|
86
64
|
lineWidth: 1,
|
|
87
65
|
dash: [3, 3]
|
|
88
66
|
},
|
|
89
67
|
legend: {
|
|
90
|
-
text: dark ?
|
|
91
|
-
textInactive: dark ?
|
|
68
|
+
text: dark ? "#d1d5db" : AURA_FALLBACK.textSecondary,
|
|
69
|
+
textInactive: dark ? "#4b5563" : "#d1d5db"
|
|
92
70
|
},
|
|
93
71
|
tooltip: {
|
|
94
|
-
background: dark ?
|
|
95
|
-
border: dark ?
|
|
96
|
-
text: dark ?
|
|
97
|
-
shadow: dark ?
|
|
72
|
+
background: dark ? "#111827" : "#ffffff",
|
|
73
|
+
border: dark ? "#374151" : AURA_FALLBACK.border,
|
|
74
|
+
text: dark ? "#f3f4f6" : AURA_FALLBACK.textPrimary,
|
|
75
|
+
shadow: dark ? "0 8px 24px rgba(0, 0, 0, 0.5)" : "0 8px 24px rgba(17, 24, 39, 0.12)",
|
|
98
76
|
radius: 10
|
|
99
77
|
},
|
|
100
78
|
series: {
|
|
@@ -104,25 +82,20 @@ function createBase(name, dark) {
|
|
|
104
82
|
barRadius: 4,
|
|
105
83
|
emphasisWidth: 3
|
|
106
84
|
},
|
|
107
|
-
emphasis: dark ?
|
|
85
|
+
emphasis: dark ? "#c4b5fd" : AURA_FALLBACK.primary700
|
|
108
86
|
};
|
|
109
87
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
export const lightTheme = createBase('aura', false);
|
|
113
|
-
/** 暗色基础主题 */
|
|
114
|
-
export const darkTheme = createBase('aura-dark', true);
|
|
115
|
-
|
|
116
|
-
/** 递归深合并:只覆盖传入的字段 */
|
|
88
|
+
var lightTheme = createBase("aura", false);
|
|
89
|
+
var darkTheme = createBase("aura-dark", true);
|
|
117
90
|
function deepMerge(base, patch) {
|
|
118
|
-
if (!patch)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
};
|
|
91
|
+
if (!patch)
|
|
92
|
+
return base;
|
|
93
|
+
const out = { ...base };
|
|
122
94
|
for (const [key, value] of Object.entries(patch)) {
|
|
123
|
-
if (value ===
|
|
95
|
+
if (value === void 0)
|
|
96
|
+
continue;
|
|
124
97
|
const current = out[key];
|
|
125
|
-
if (value && typeof value ===
|
|
98
|
+
if (value && typeof value === "object" && !Array.isArray(value) && current && typeof current === "object" && !Array.isArray(current)) {
|
|
126
99
|
out[key] = deepMerge(current, value);
|
|
127
100
|
} else {
|
|
128
101
|
out[key] = value;
|
|
@@ -130,67 +103,64 @@ function deepMerge(base, patch) {
|
|
|
130
103
|
}
|
|
131
104
|
return out;
|
|
132
105
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
palette
|
|
140
|
-
} = options;
|
|
141
|
-
let theme = createBase(name ?? (dark ? 'aura-dark' : 'aura'), dark);
|
|
142
|
-
if (overrides) theme = deepMerge(theme, overrides);
|
|
143
|
-
if (palette && palette.length) theme = {
|
|
144
|
-
...theme,
|
|
145
|
-
palette
|
|
146
|
-
};
|
|
106
|
+
function createChartTheme(options = {}) {
|
|
107
|
+
const { dark = false, name, overrides, palette } = options;
|
|
108
|
+
let theme = createBase(name ?? (dark ? "aura-dark" : "aura"), dark);
|
|
109
|
+
if (overrides)
|
|
110
|
+
theme = deepMerge(theme, overrides);
|
|
111
|
+
if (palette && palette.length)
|
|
112
|
+
theme = { ...theme, palette };
|
|
147
113
|
return theme;
|
|
148
114
|
}
|
|
149
|
-
|
|
150
|
-
/** 读取单个 CSS 变量,取不到时返回兜底值 */
|
|
151
115
|
function cssVar(name, fallback, element) {
|
|
152
|
-
if (typeof window ===
|
|
116
|
+
if (typeof window === "undefined" || typeof document === "undefined")
|
|
117
|
+
return fallback;
|
|
153
118
|
const target = element ?? document.documentElement;
|
|
154
|
-
if (!target)
|
|
119
|
+
if (!target)
|
|
120
|
+
return fallback;
|
|
155
121
|
const value = window.getComputedStyle(target).getPropertyValue(name).trim();
|
|
156
122
|
return value || fallback;
|
|
157
123
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
124
|
+
function detectDarkMode(element) {
|
|
125
|
+
var _a, _b, _c, _d;
|
|
126
|
+
if (typeof document === "undefined")
|
|
127
|
+
return false;
|
|
162
128
|
const host = element ?? document.documentElement;
|
|
163
|
-
const explicit = host
|
|
164
|
-
const root = document.documentElement.getAttribute(
|
|
165
|
-
return (explicit ?? root) ===
|
|
129
|
+
const explicit = ((_b = (_a = host == null ? void 0 : host.closest) == null ? void 0 : _a.call(host, "[data-theme]")) == null ? void 0 : _b.getAttribute("data-theme")) ?? ((_d = (_c = host == null ? void 0 : host.closest) == null ? void 0 : _c.call(host, "[data-mode]")) == null ? void 0 : _d.getAttribute("data-mode"));
|
|
130
|
+
const root = document.documentElement.getAttribute("data-theme") ?? document.documentElement.getAttribute("data-mode");
|
|
131
|
+
return (explicit ?? root) === "dark";
|
|
166
132
|
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* 从 Aura 的 CSS 变量读取一份主题。
|
|
170
|
-
*
|
|
171
|
-
* 这是「默认为本组件库主题」的落地实现:颜色不是写死的常量,
|
|
172
|
-
* 而是宿主页面上真实生效的值 —— 宿主改 `--aura-primary-700`,图表跟着变。
|
|
173
|
-
*/
|
|
174
|
-
export function readAuraTheme(element) {
|
|
133
|
+
function readAuraTheme(element) {
|
|
175
134
|
const dark = detectDarkMode(element);
|
|
176
135
|
const base = dark ? darkTheme : lightTheme;
|
|
177
|
-
const primary = cssVar(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
136
|
+
const primary = cssVar(
|
|
137
|
+
"--aura-primary-700",
|
|
138
|
+
dark ? "#c4b5fd" : "#7c3aed",
|
|
139
|
+
element
|
|
140
|
+
);
|
|
141
|
+
const textPrimary = cssVar("--aura-text", base.text.primary, element);
|
|
142
|
+
const textSecondary = cssVar(
|
|
143
|
+
"--aura-text-secondary",
|
|
144
|
+
base.text.secondary,
|
|
145
|
+
element
|
|
146
|
+
);
|
|
147
|
+
const textTertiary = cssVar(
|
|
148
|
+
"--aura-text-tertiary",
|
|
149
|
+
dark ? "#6b7280" : "#9ca3af",
|
|
150
|
+
element
|
|
151
|
+
);
|
|
152
|
+
const border = cssVar("--aura-border", base.axis.line, element);
|
|
153
|
+
const bgSecondary = cssVar(
|
|
154
|
+
"--aura-bg-secondary",
|
|
155
|
+
base.tooltip.background,
|
|
156
|
+
element
|
|
157
|
+
);
|
|
158
|
+
const fontFamily = cssVar("--aura-font-family", base.font.family, element);
|
|
186
159
|
const palette = [primary, ...DEFAULT_PALETTE.slice(1)];
|
|
187
160
|
return {
|
|
188
161
|
...base,
|
|
189
162
|
palette,
|
|
190
|
-
font: {
|
|
191
|
-
...base.font,
|
|
192
|
-
family: fontFamily
|
|
193
|
-
},
|
|
163
|
+
font: { ...base.font, family: fontFamily },
|
|
194
164
|
text: {
|
|
195
165
|
primary: textPrimary,
|
|
196
166
|
secondary: textSecondary,
|
|
@@ -204,7 +174,7 @@ export function readAuraTheme(element) {
|
|
|
204
174
|
},
|
|
205
175
|
grid: {
|
|
206
176
|
...base.grid,
|
|
207
|
-
line: dark ?
|
|
177
|
+
line: dark ? "rgba(229, 231, 235, 0.12)" : border
|
|
208
178
|
},
|
|
209
179
|
legend: {
|
|
210
180
|
text: textSecondary,
|
|
@@ -219,82 +189,84 @@ export function readAuraTheme(element) {
|
|
|
219
189
|
emphasis: primary
|
|
220
190
|
};
|
|
221
191
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
if (input === 'light') return lightTheme;
|
|
192
|
+
function resolveTheme(input, element) {
|
|
193
|
+
if (!input)
|
|
194
|
+
return readAuraTheme(element);
|
|
195
|
+
if (typeof input === "string") {
|
|
196
|
+
if (input === "dark")
|
|
197
|
+
return darkTheme;
|
|
198
|
+
if (input === "light")
|
|
199
|
+
return lightTheme;
|
|
231
200
|
return readAuraTheme(element);
|
|
232
201
|
}
|
|
233
|
-
// 判定「完整主题」:必须带 palette 与 font 两个必填块
|
|
234
202
|
const candidate = input;
|
|
235
203
|
if (Array.isArray(candidate.palette) && candidate.font && candidate.axis) {
|
|
236
204
|
return candidate;
|
|
237
205
|
}
|
|
238
|
-
// 不再区分亮暗分支:readAuraTheme 内部会按 data-mode/data-theme 判定暗色,
|
|
239
|
-
// 并读取当前色板生效的 CSS 变量 —— 静态 darkTheme 的 accent 等主锚色写死
|
|
240
|
-
// 在默认紫罗兰上,暗色叠加局部覆盖时会跟色板脱节。
|
|
241
206
|
const base = readAuraTheme(element);
|
|
242
207
|
return deepMerge(base, input);
|
|
243
208
|
}
|
|
244
|
-
|
|
245
|
-
/** 按索引取色,超出色板长度时循环 */
|
|
246
|
-
export function colorAt(theme, index) {
|
|
209
|
+
function colorAt(theme, index) {
|
|
247
210
|
const palette = theme.palette.length ? theme.palette : DEFAULT_PALETTE;
|
|
248
211
|
return palette[(index % palette.length + palette.length) % palette.length];
|
|
249
212
|
}
|
|
250
|
-
|
|
251
|
-
/** 给颜色加透明度(支持 #rgb / #rrggbb / rgb() 三种输入) */
|
|
252
|
-
/** 解析 #rgb / #rrggbb / rgb() 为 [r,g,b];失败返回 null */
|
|
253
|
-
export function parseColor(input) {
|
|
213
|
+
function parseColor(input) {
|
|
254
214
|
const value = input.trim();
|
|
255
215
|
const hex = value.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);
|
|
256
216
|
if (hex) {
|
|
257
217
|
const raw = hex[1];
|
|
258
|
-
const full = raw.length === 3 ? raw.split(
|
|
259
|
-
return [
|
|
218
|
+
const full = raw.length === 3 ? raw.split("").map((char) => char + char).join("") : raw;
|
|
219
|
+
return [
|
|
220
|
+
parseInt(full.slice(0, 2), 16),
|
|
221
|
+
parseInt(full.slice(2, 4), 16),
|
|
222
|
+
parseInt(full.slice(4, 6), 16)
|
|
223
|
+
];
|
|
260
224
|
}
|
|
261
225
|
const rgb = value.match(/^rgba?\(([^)]+)\)$/i);
|
|
262
226
|
if (rgb) {
|
|
263
|
-
const parts = rgb[1].split(
|
|
264
|
-
if (parts.length >= 3 && parts.slice(0, 3).every(part => Number.isFinite(part))) {
|
|
227
|
+
const parts = rgb[1].split(",").map((part) => Number.parseFloat(part.trim()));
|
|
228
|
+
if (parts.length >= 3 && parts.slice(0, 3).every((part) => Number.isFinite(part))) {
|
|
265
229
|
return [parts[0], parts[1], parts[2]];
|
|
266
230
|
}
|
|
267
231
|
}
|
|
268
232
|
return null;
|
|
269
233
|
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* 颜色线性插值。
|
|
273
|
-
*
|
|
274
|
-
* 热力图、连续色阶需要它:给定两端颜色与 0~1 的位置,返回中间色。
|
|
275
|
-
* 任一端无法解析时返回 to,避免产出非法 CSS。
|
|
276
|
-
*/
|
|
277
|
-
export function mixColor(from, to, t) {
|
|
234
|
+
function mixColor(from, to, t) {
|
|
278
235
|
const a = parseColor(from);
|
|
279
236
|
const b = parseColor(to);
|
|
280
|
-
if (!a || !b)
|
|
237
|
+
if (!a || !b)
|
|
238
|
+
return to;
|
|
281
239
|
const ratio = t < 0 ? 0 : t > 1 ? 1 : t;
|
|
282
|
-
const channel = index => Math.round(a[index] + (b[index] - a[index]) * ratio);
|
|
240
|
+
const channel = (index) => Math.round(a[index] + (b[index] - a[index]) * ratio);
|
|
283
241
|
return `rgb(${channel(0)}, ${channel(1)}, ${channel(2)})`;
|
|
284
242
|
}
|
|
285
|
-
|
|
243
|
+
function withAlpha(color, alpha) {
|
|
286
244
|
const hex = color.trim();
|
|
287
|
-
if (hex.startsWith(
|
|
245
|
+
if (hex.startsWith("#")) {
|
|
288
246
|
const raw = hex.slice(1);
|
|
289
|
-
const full = raw.length === 3 ? raw.split(
|
|
290
|
-
if (full.length !== 6)
|
|
247
|
+
const full = raw.length === 3 ? raw.split("").map((c) => c + c).join("") : raw;
|
|
248
|
+
if (full.length !== 6)
|
|
249
|
+
return hex;
|
|
291
250
|
const r = parseInt(full.slice(0, 2), 16);
|
|
292
251
|
const g = parseInt(full.slice(2, 4), 16);
|
|
293
252
|
const b = parseInt(full.slice(4, 6), 16);
|
|
294
253
|
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
295
254
|
}
|
|
296
|
-
if (hex.startsWith(
|
|
297
|
-
return hex.replace(
|
|
255
|
+
if (hex.startsWith("rgb(")) {
|
|
256
|
+
return hex.replace("rgb(", "rgba(").replace(")", `, ${alpha})`);
|
|
298
257
|
}
|
|
299
258
|
return hex;
|
|
300
|
-
}
|
|
259
|
+
}
|
|
260
|
+
export {
|
|
261
|
+
DEFAULT_PALETTE,
|
|
262
|
+
colorAt,
|
|
263
|
+
createChartTheme,
|
|
264
|
+
darkTheme,
|
|
265
|
+
detectDarkMode,
|
|
266
|
+
lightTheme,
|
|
267
|
+
mixColor,
|
|
268
|
+
parseColor,
|
|
269
|
+
readAuraTheme,
|
|
270
|
+
resolveTheme,
|
|
271
|
+
withAlpha
|
|
272
|
+
};
|
package/esm/types.d.ts
CHANGED
|
@@ -69,6 +69,8 @@ export interface LegendConfig {
|
|
|
69
69
|
/** 位置,默认 top */
|
|
70
70
|
position?: 'top' | 'bottom';
|
|
71
71
|
align?: 'left' | 'center' | 'right';
|
|
72
|
+
/** 是否允许点击图例切换系列显隐,默认 true */
|
|
73
|
+
selectable?: boolean;
|
|
72
74
|
}
|
|
73
75
|
export interface TooltipConfig {
|
|
74
76
|
show?: boolean;
|
|
@@ -164,5 +166,7 @@ export interface BaseChartProps {
|
|
|
164
166
|
}) => void;
|
|
165
167
|
/** 数值格式化(tooltip 与坐标轴默认共用) */
|
|
166
168
|
valueFormatter?: (value: number) => string;
|
|
169
|
+
/** 跨图表联动分组名:同组图表悬停或触摸时自动同步十字准星与 Tooltip */
|
|
170
|
+
syncGroup?: string;
|
|
167
171
|
}
|
|
168
172
|
//# sourceMappingURL=types.d.ts.map
|
package/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,sCAAsC;AACtC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAE9E,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAE7D,WAAW;AACX,MAAM,WAAW,YAAY;IAC3B,oBAAoB;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,uCAAuC;IACvC,IAAI,CA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