@astryx-vue/charts 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +4 -2
- package/charts.css +7 -0
- package/css.d.ts +3 -0
- package/dist/index.d.ts +799 -0
- package/dist/index.js +2667 -0
- package/package.json +74 -3
- package/styles/chart-axis.css +15 -0
- package/styles/chart-grid.css +9 -0
- package/styles/chart-legend.css +13 -0
- package/styles/chart-swatch.css +24 -0
- package/styles/chart-tooltip.css +24 -0
- package/styles/chart.css +45 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,799 @@
|
|
|
1
|
+
import { Ref, VNodeChild } from "vue";
|
|
2
|
+
import { ScaleBand, ScaleLinear, scaleBand, scaleLinear } from "d3-scale";
|
|
3
|
+
//#region src/color.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* 颜色解析与序列化。图表配色、透明度换算、GL 通道都用这里的函数。
|
|
6
|
+
*
|
|
7
|
+
* 只认三类输入:hex(`#rgb`、`#rgba`、`#rrggbb`、`#rrggbbaa`,带不带 `#` 都行)、
|
|
8
|
+
* `rgb()` / `rgba()`、以及 token 表达式里用到的几个颜色名。解析不了(比如
|
|
9
|
+
* `var()`、`oklch()`)一律返回 null,让调用方原样保留原表达式,而不是猜一个值。
|
|
10
|
+
*/
|
|
11
|
+
/** 一个颜色拆成 0-255 的 RGB 三个通道和 0-1 的透明度。 */
|
|
12
|
+
interface RGBA {
|
|
13
|
+
r: number;
|
|
14
|
+
g: number;
|
|
15
|
+
b: number;
|
|
16
|
+
a: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 解析 hex 颜色。支持 `#rgb`、`#rgba`、`#rrggbb`、`#rrggbbaa`,`#` 可有可无。
|
|
20
|
+
* 其它输入返回 null。
|
|
21
|
+
*/
|
|
22
|
+
export declare function parseHex(hex: string): RGBA | null;
|
|
23
|
+
/**
|
|
24
|
+
* 解析 `rgb()` / `rgba()`。通道可以用逗号或空格分隔,可以用 `/ alpha`,
|
|
25
|
+
* 也可以写百分比。通道和透明度都会夹到合法范围。
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseRgb(value: string): RGBA | null;
|
|
28
|
+
/**
|
|
29
|
+
* 解析一个具体的 CSS 颜色字符串:hex、`rgb()` / `rgba()`,以及 token 表达式里
|
|
30
|
+
* 用到的几个颜色名。解析不了返回 null。
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseColor(value: string): RGBA | null;
|
|
33
|
+
/** 把 0-255 的三个通道拼成大写 `#RRGGBB`。 */
|
|
34
|
+
export declare function formatHex(r: number, g: number, b: number): string;
|
|
35
|
+
/** 完全不透明时输出 `#RRGGBB`,否则输出 `rgba(r, g, b, a)`。 */
|
|
36
|
+
export declare function formatColor({ r, g, b, a }: RGBA): string;
|
|
37
|
+
/**
|
|
38
|
+
* 把解析后的颜色转成 0-1 的 `[r, g, b]` 浮点数,给 WebGL 的 uniform 和顶点属性用。
|
|
39
|
+
*
|
|
40
|
+
* 参数是解析后的结果,所以每个调用方都走同一条校验路径:`toGLFloats(parseHex(color))`。
|
|
41
|
+
* 传 null 或通道非有限时返回中性灰。透明度故意丢掉,GL 那边自己混合。
|
|
42
|
+
*/
|
|
43
|
+
export declare function toGLFloats(color: RGBA | null): [number, number, number];
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/types.d.ts
|
|
46
|
+
/**
|
|
47
|
+
* 图表的核心类型。比例尺、标记、交互都从这里取。
|
|
48
|
+
*
|
|
49
|
+
* 和上游的区别只有两处:① `render()` 返回 Vue 的 `VNodeChild`,不再是 ReactNode;
|
|
50
|
+
* ② `render()` 是可选的——这个包目前只做「算」,不算「画」,渲染由后续工作补上。
|
|
51
|
+
*/
|
|
52
|
+
type ChartScale = ScaleLinear<number, number> | ScaleBand<string>;
|
|
53
|
+
/**
|
|
54
|
+
* 一个标记的颜色:要么是一串固定颜色,要么是一个按数据点取色的函数
|
|
55
|
+
* (比如正值一个色、负值一个色)。
|
|
56
|
+
*/
|
|
57
|
+
type ColorAccessor = string | ((datum: Record<string, unknown>, index: number) => string);
|
|
58
|
+
/**
|
|
59
|
+
* 没有显式 `yDomain` 时,y 轴范围怎么定:
|
|
60
|
+
* - `'auto'`(默认):带零基线的标记(bar、area)把 0 算进范围;只有连续点的
|
|
61
|
+
* 图表(line、dot 等)上下留一点余量,免得点和边缘粘在一起。
|
|
62
|
+
* - `'zero'`:以 0 为中心对称,适合正负数据(比如盈亏)。
|
|
63
|
+
* - `'data'`:紧贴数据范围,不强制含 0,也不留余量。
|
|
64
|
+
*/
|
|
65
|
+
type YBaseline = 'auto' | 'zero' | 'data';
|
|
66
|
+
interface ChartMargin {
|
|
67
|
+
top: number;
|
|
68
|
+
right: number;
|
|
69
|
+
bottom: number;
|
|
70
|
+
left: number;
|
|
71
|
+
}
|
|
72
|
+
/** 一个数据点算出来的像素位置。 */
|
|
73
|
+
interface ResolvedPoint {
|
|
74
|
+
/** 绘图区坐标系里的 x 像素 */
|
|
75
|
+
px: number;
|
|
76
|
+
/** 绘图区坐标系里的 y 像素(标记的顶边) */
|
|
77
|
+
py: number;
|
|
78
|
+
/** y 方向的基线像素(标记的底边);堆叠时和 `py` 不同 */
|
|
79
|
+
py0: number;
|
|
80
|
+
/** 在数据数组里的下标 */
|
|
81
|
+
dataIndex: number;
|
|
82
|
+
}
|
|
83
|
+
/** 传给每个系列的 `resolve()` 和 `render()` 的上下文。 */
|
|
84
|
+
interface SeriesContext {
|
|
85
|
+
data: Record<string, unknown>[];
|
|
86
|
+
xKey: string;
|
|
87
|
+
xScale: ChartScale;
|
|
88
|
+
yScale: ScaleLinear<number, number>;
|
|
89
|
+
/**
|
|
90
|
+
* 按行排布的标记(如热力图)用的分类 y 比例尺。只有系列声明了
|
|
91
|
+
* `layout.yBandKey` 时才存在,这时 y 轴是分类轴,线性 `yScale` 便用不上了。
|
|
92
|
+
*/
|
|
93
|
+
yBandScale?: ScaleBand<string>;
|
|
94
|
+
/** 绘图区宽度 */
|
|
95
|
+
width: number;
|
|
96
|
+
/** 绘图区高度 */
|
|
97
|
+
height: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 每个标记工厂返回的对象的统一形状。标记自己知道怎么算位置、怎么画,
|
|
101
|
+
* 图表根只负责遍历和调用。
|
|
102
|
+
*
|
|
103
|
+
* 一个 SeriesDef 只能用一次:布局和渲染会就地往上写 `_uid`、`_isTopOfStack`、
|
|
104
|
+
* `_resolvedColor`,所以同一个对象不能同时给两个 `<Chart>` 用。每张图都要新建一份。
|
|
105
|
+
*/
|
|
106
|
+
interface SeriesDef {
|
|
107
|
+
/** 标记类型标识 */
|
|
108
|
+
readonly type: string;
|
|
109
|
+
/**
|
|
110
|
+
* 这个系列的语义键,通常就是 dataKey。既当图例文案的兜底,也用来协调堆叠和分组。
|
|
111
|
+
* 它不保证唯一(两个系列可以共用同一个 dataKey),所以绝不能当 Map 的键或列表的
|
|
112
|
+
* 渲染键——那是 `_uid` 的活。
|
|
113
|
+
*/
|
|
114
|
+
readonly key: string;
|
|
115
|
+
/** 这个系列读哪些数据列——用来算 y 轴范围 */
|
|
116
|
+
readonly dataKeys: string[];
|
|
117
|
+
/**
|
|
118
|
+
* 一次布局里唯一的实例身份,由布局按系列在 `series` 数组里的位置赋值。
|
|
119
|
+
* 算好的点位映射、渲染键、提示框查找都用它。不要自己设。
|
|
120
|
+
*/
|
|
121
|
+
_uid?: string;
|
|
122
|
+
/** 这个系列是不是所在堆叠组的最上一层(布局时写入) */
|
|
123
|
+
_isTopOfStack?: boolean;
|
|
124
|
+
/** 图例上显示的固定颜色。颜色是按点取色时为 undefined。 */
|
|
125
|
+
readonly color?: string;
|
|
126
|
+
/**
|
|
127
|
+
* 图表根给没写死颜色的系列(自动配色或按点取色)分配的调色板颜色。
|
|
128
|
+
* 既当渲染兜底,也当图例和提示框的代表色。不要自己设。
|
|
129
|
+
*/
|
|
130
|
+
_resolvedColor?: string;
|
|
131
|
+
/** 图例上的可读文案,没给就用 `key`。 */
|
|
132
|
+
readonly label?: string;
|
|
133
|
+
/** 图表根用来跨系列协调的布局提示 */
|
|
134
|
+
readonly layout: {
|
|
135
|
+
/** 堆叠组:同一组的系列累加 */
|
|
136
|
+
stack?: string;
|
|
137
|
+
/** 柱状分组:同一组的系列把带宽平分 */
|
|
138
|
+
group?: string;
|
|
139
|
+
/** 这个系列是否要求 y 轴范围包含 0 */
|
|
140
|
+
includeZero?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* 设了它,图表的 y 轴就按这个数据列的不同取值建分类比例尺(比如热力图的每一天),
|
|
143
|
+
* 而不是数值比例尺。布局会把它以 `yBandScale` 交给标记和坐标轴,左侧坐标轴就能把
|
|
144
|
+
* 分类对齐到每一行。热力图还应该写 `dataKeys: []`,免得喂给(已经用不上的)线性 y 轴范围。
|
|
145
|
+
*/
|
|
146
|
+
yBandKey?: string;
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* 算出每个数据点的像素位置。布局阶段由图表根调用。
|
|
150
|
+
* 堆叠时收到预先算好的累计偏移。
|
|
151
|
+
*/
|
|
152
|
+
resolve: (ctx: SeriesContext, stackOffsets?: {
|
|
153
|
+
y0: number;
|
|
154
|
+
y1: number;
|
|
155
|
+
}[], groupInfo?: {
|
|
156
|
+
index: number;
|
|
157
|
+
count: number;
|
|
158
|
+
}) => ResolvedPoint[];
|
|
159
|
+
/**
|
|
160
|
+
* 按算好的位置把标记画出来。渲染阶段由图表根调用。
|
|
161
|
+
* 返回 SVG 元素(WebGL 标记自己管 canvas)。
|
|
162
|
+
*/
|
|
163
|
+
render?: (resolved: ResolvedPoint[], ctx: SeriesContext) => VNodeChild;
|
|
164
|
+
}
|
|
165
|
+
/** 所有系列算好的位置 */
|
|
166
|
+
type ResolvedPositions = Map<string, ResolvedPoint[]>;
|
|
167
|
+
/** 换算成绘图区坐标的指针事件 */
|
|
168
|
+
interface ChartPointerEvent {
|
|
169
|
+
x: number;
|
|
170
|
+
y: number;
|
|
171
|
+
nearest: (ResolvedPoint & {
|
|
172
|
+
seriesKey: string;
|
|
173
|
+
}) | null;
|
|
174
|
+
active: boolean;
|
|
175
|
+
}
|
|
176
|
+
/** 图表根提供给交互子组件的上下文 */
|
|
177
|
+
interface ChartContext {
|
|
178
|
+
width: number;
|
|
179
|
+
height: number;
|
|
180
|
+
margin: ChartMargin;
|
|
181
|
+
data: Record<string, unknown>[];
|
|
182
|
+
xKey: string;
|
|
183
|
+
xScale: ChartScale;
|
|
184
|
+
yScale: ScaleLinear<number, number>;
|
|
185
|
+
/**
|
|
186
|
+
* 分类 y 比例尺(比如热力图的每一行),系列声明了 `layout.yBandKey` 时才有。
|
|
187
|
+
* 画 y 轴的东西(`ChartAxis`)在它存在时应该优先用它。
|
|
188
|
+
*/
|
|
189
|
+
yBandScale?: ScaleBand<string>;
|
|
190
|
+
resolved: Map<string, ResolvedPoint[]>;
|
|
191
|
+
onPointer: (handler: (e: ChartPointerEvent) => void) => () => void;
|
|
192
|
+
svgRef: Ref<SVGSVGElement | null>;
|
|
193
|
+
}
|
|
194
|
+
/** 这个标记类型是不是纯标注类。 */
|
|
195
|
+
export declare function isUtilityMarkType(type: string): boolean;
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/legend.d.ts
|
|
198
|
+
interface LegendItem {
|
|
199
|
+
label: string;
|
|
200
|
+
color: string;
|
|
201
|
+
/** 标记类型——决定色块形状(柱状是方块,其余是短线) */
|
|
202
|
+
type?: string;
|
|
203
|
+
}
|
|
204
|
+
/** 从系列列表推出图例项,跳过标注类标记。 */
|
|
205
|
+
export declare function deriveLegendItems(series: readonly SeriesDef[]): LegendItem[];
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region src/ChartLegend/types.d.ts
|
|
208
|
+
/** 图例摆在图表的哪一边。`start` / `end` 是逻辑方位,跟着书写方向走。 */
|
|
209
|
+
type LegendPosition = 'top' | 'bottom' | 'start' | 'end';
|
|
210
|
+
/** 图例在它所在的那条边上怎么对齐。 */
|
|
211
|
+
type LegendAlignment = 'start' | 'center' | 'end';
|
|
212
|
+
interface ChartLegendProps {
|
|
213
|
+
/** 要显示的图例项 @default [] */
|
|
214
|
+
items?: LegendItem[];
|
|
215
|
+
/** 图例相对图表的位置 @default 'bottom' */
|
|
216
|
+
position?: LegendPosition;
|
|
217
|
+
/** 图例在位置上怎么对齐 @default 'start' */
|
|
218
|
+
alignment?: LegendAlignment;
|
|
219
|
+
}
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/tooltip.d.ts
|
|
222
|
+
/**
|
|
223
|
+
* 提示框里的一行:某个系列在鼠标停留的 x 位置上的取值。
|
|
224
|
+
* 形状稳定,用户可以依赖它写自己的提示框内容。
|
|
225
|
+
*/
|
|
226
|
+
interface TooltipSeriesValue {
|
|
227
|
+
/** 系列键(就是 SeriesDef.key) */
|
|
228
|
+
key: string;
|
|
229
|
+
/** 显示文案,系列没写就用 key */
|
|
230
|
+
label: string;
|
|
231
|
+
/** 系列颜色 */
|
|
232
|
+
color: string;
|
|
233
|
+
/** 标记类型——决定默认样式里色块的形状 */
|
|
234
|
+
type: string;
|
|
235
|
+
/** 这个系列在鼠标位置的原始值 */
|
|
236
|
+
value: unknown;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* 生成提示框要显示的行。跳过标注类标记,也跳过布局没能算出点位的系列。
|
|
240
|
+
*
|
|
241
|
+
* 纯函数、同步,调用方可以放心缓存结果。
|
|
242
|
+
*/
|
|
243
|
+
export declare function deriveTooltipSeriesValues(series: readonly SeriesDef[], datum: Record<string, unknown> | undefined, resolvedKeys: ReadonlySet<string>): TooltipSeriesValue[];
|
|
244
|
+
/**
|
|
245
|
+
* 鼠标停在某个下标上时,这个系列要不要画一个悬停圆点。
|
|
246
|
+
* 柱状改成高亮整条「带」,标注类标记没有数据点可高亮。
|
|
247
|
+
*/
|
|
248
|
+
export declare function shouldRenderHoverDot(seriesType: string): boolean;
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/ChartTooltip/types.d.ts
|
|
251
|
+
/** 提示框相对悬停点的位置。 */
|
|
252
|
+
type ChartTooltipPlacement = 'auto' | 'right' | 'left' | 'top';
|
|
253
|
+
interface ChartTooltipProps {
|
|
254
|
+
/**
|
|
255
|
+
* 系列定义:用来把悬停的那行走成每个系列一行的内容。
|
|
256
|
+
* 通过 `<Chart tooltip>` 打开时由 Chart 自动注入;单独用的时候要把同一份 `series` 传进来。
|
|
257
|
+
*/
|
|
258
|
+
series?: readonly SeriesDef[];
|
|
259
|
+
/**
|
|
260
|
+
* 要不要在悬停的 x 位置画指示。柱状图在 band 轴上画整列高亮,折线/面积/散点画竖线。
|
|
261
|
+
* @default true
|
|
262
|
+
*/
|
|
263
|
+
hoverIndicator?: boolean;
|
|
264
|
+
/** 要不要在每个系列的点上画一个悬停圆点(柱状跳过)。@default true */
|
|
265
|
+
showHoverDots?: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* 卡片相对悬停点的位置。`auto` 放在右边,放不下就翻到左边。
|
|
268
|
+
* @default 'auto'
|
|
269
|
+
*/
|
|
270
|
+
placement?: ChartTooltipPlacement;
|
|
271
|
+
}
|
|
272
|
+
interface ChartTooltipSlots {
|
|
273
|
+
/**
|
|
274
|
+
* 自定义卡片内容,作用域参数是悬停的 x 值和每个系列的一行。
|
|
275
|
+
* 不写就用内置样式。返回空内容时不显示卡片,但高亮和圆点照画。
|
|
276
|
+
*/
|
|
277
|
+
content?: (scope: {
|
|
278
|
+
xValue: unknown;
|
|
279
|
+
rows: TooltipSeriesValue[];
|
|
280
|
+
}) => unknown;
|
|
281
|
+
}
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/Chart/types.d.ts
|
|
284
|
+
/** 不写 `margin` 时绘图区四周留多少像素。 */
|
|
285
|
+
export declare const DEFAULT_MARGIN: ChartMargin;
|
|
286
|
+
/**
|
|
287
|
+
* 数据点(行数 × 数据列数)不超过这个数时,额外输出一张视觉隐藏的数据表。
|
|
288
|
+
* 再多的表对读屏用户只是噪音,所以大图表只保留名字。
|
|
289
|
+
*/
|
|
290
|
+
export declare const MAX_TABLE_POINTS = 100;
|
|
291
|
+
/** 图例的配置。`legend` 给 `true` 就是用这一份默认值。 */
|
|
292
|
+
type ChartLegendConfig = Omit<ChartLegendProps, 'items'> & {
|
|
293
|
+
/** 显式指定图例项;不写就从系列推出来。 */
|
|
294
|
+
items?: ChartLegendProps['items'];
|
|
295
|
+
};
|
|
296
|
+
/** 提示框的配置。自定义内容用 `<Chart>` 的 `tooltip` 插槽,不走 props。 */
|
|
297
|
+
type ChartTooltipConfig = Omit<ChartTooltipProps, 'series'>;
|
|
298
|
+
interface ChartProps {
|
|
299
|
+
/** 要画的数据行。每行既有 x 那一列,也有一到多个系列的数据列。 */
|
|
300
|
+
data: Record<string, unknown>[];
|
|
301
|
+
/** 每行里当 x 用的字段名,所有系列共用。 */
|
|
302
|
+
xKey: string;
|
|
303
|
+
/** 标记定义,按顺序画在同一条 x/y 坐标系上。 */
|
|
304
|
+
series: SeriesDef[];
|
|
305
|
+
/** 图表高度(CSS 像素)。非有限值和负数都当 0。@default 300 */
|
|
306
|
+
height?: number;
|
|
307
|
+
/**
|
|
308
|
+
* 图表宽度(CSS 像素)。浏览器里第一次量到容器宽度之后就不再用了,
|
|
309
|
+
* 服务端渲染没有容器可量,靠它出图。
|
|
310
|
+
* @default 0
|
|
311
|
+
*/
|
|
312
|
+
width?: number;
|
|
313
|
+
/** 绘图区内边距的部分覆盖值,没写的边用默认值。 */
|
|
314
|
+
margin?: Partial<ChartMargin>;
|
|
315
|
+
/** 没写 `yDomain` 时 y 轴范围怎么定。@default 'auto' */
|
|
316
|
+
yBaseline?: YBaseline;
|
|
317
|
+
/** 显式 y 轴范围 `[min, max]`。它说了算——不加基线、不留余量。 */
|
|
318
|
+
yDomain?: [number, number];
|
|
319
|
+
/** 数值 x 轴的显式范围 `[min, max]`。`data` 为空时也照用(流式窗口要稳定)。band 轴上忽略。 */
|
|
320
|
+
xDomain?: [number, number];
|
|
321
|
+
/** 显示从系列推出来的图例,或者改成别的摆位。@default false */
|
|
322
|
+
legend?: boolean | ChartLegendConfig;
|
|
323
|
+
/** 显示分组的悬停提示框。@default false */
|
|
324
|
+
tooltip?: boolean | ChartTooltipConfig;
|
|
325
|
+
/** 图表标题,同时是 SVG 的无障碍名字。 */
|
|
326
|
+
title?: string;
|
|
327
|
+
/** 标题下面的补充说明,同时是 SVG 的无障碍描述。 */
|
|
328
|
+
subtitle?: string;
|
|
329
|
+
}
|
|
330
|
+
interface ChartSlots {
|
|
331
|
+
/** 画在系列后面的网格,一般是 `<ChartGrid>`。 */
|
|
332
|
+
grid?: () => unknown;
|
|
333
|
+
/** 画在系列后面的坐标轴,一般是若干个 `<ChartAxis>`。 */
|
|
334
|
+
axes?: () => unknown;
|
|
335
|
+
/** 画在指针捕获层上面的交互层。 */
|
|
336
|
+
interactions?: () => unknown;
|
|
337
|
+
/** 提示框的自定义内容,作用域参数是 `{ xValue, rows }`。 */
|
|
338
|
+
tooltip?: (scope: {
|
|
339
|
+
xValue: unknown;
|
|
340
|
+
rows: unknown[];
|
|
341
|
+
}) => unknown;
|
|
342
|
+
/** 额外内容,画在内置提示框之后。 */
|
|
343
|
+
default?: () => unknown;
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/Chart/Chart.vue.d.ts
|
|
347
|
+
type __VLS_Slots = ChartSlots;
|
|
348
|
+
declare const __VLS_base: import("vue").DefineComponent<ChartProps, {
|
|
349
|
+
element: import("vue").Ref<HTMLElement | null, HTMLElement | null>;
|
|
350
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ChartProps> & Readonly<{}>, {
|
|
351
|
+
height: number;
|
|
352
|
+
width: number;
|
|
353
|
+
margin: Partial<ChartMargin>;
|
|
354
|
+
yBaseline: YBaseline;
|
|
355
|
+
yDomain: [number, number];
|
|
356
|
+
xDomain: [number, number];
|
|
357
|
+
legend: boolean | ChartLegendConfig;
|
|
358
|
+
tooltip: boolean | ChartTooltipConfig;
|
|
359
|
+
title: string;
|
|
360
|
+
subtitle: string;
|
|
361
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
362
|
+
declare const __VLS_export$5: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
363
|
+
declare const _default: typeof __VLS_export$5;
|
|
364
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
365
|
+
new (): {
|
|
366
|
+
$slots: S;
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region src/ChartAxis/types.d.ts
|
|
371
|
+
/** 坐标轴画在绘图区的哪一条边上。 */
|
|
372
|
+
type ChartAxisPosition = 'top' | 'right' | 'bottom' | 'left';
|
|
373
|
+
interface ChartAxisProps {
|
|
374
|
+
/** 画在哪条边上 */
|
|
375
|
+
position: ChartAxisPosition;
|
|
376
|
+
/** 想要几个刻度(近似值,d3 决定最终数量)@default 5 */
|
|
377
|
+
tickCount?: number;
|
|
378
|
+
/** 最多显示几个刻度文字,超出的按等间隔跳过 */
|
|
379
|
+
maxTicks?: number;
|
|
380
|
+
/** 自定义刻度文字 */
|
|
381
|
+
tickFormat?: (value: unknown) => string;
|
|
382
|
+
/** 把刻度文字截断到这么多个字(末尾补省略号) */
|
|
383
|
+
truncate?: number;
|
|
384
|
+
/** 刻度滑动时要不要过渡动画,流式更新时更好看 @default true */
|
|
385
|
+
animated?: boolean;
|
|
386
|
+
/**
|
|
387
|
+
* 画不画轴线。默认只有 `position="bottom"` 画。
|
|
388
|
+
* 开了 `showTicks` 会强制画上,不然刻度线没有着落。
|
|
389
|
+
*/
|
|
390
|
+
showAxisLine?: boolean;
|
|
391
|
+
/** 每个刻度处画不画一小段垂直的短刻度线 @default false */
|
|
392
|
+
showTicks?: boolean;
|
|
393
|
+
}
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region src/ChartAxis/ChartAxis.vue.d.ts
|
|
396
|
+
declare const __VLS_export$4: import("vue").DefineComponent<ChartAxisProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ChartAxisProps> & Readonly<{}>, {
|
|
397
|
+
tickCount: number;
|
|
398
|
+
maxTicks: number;
|
|
399
|
+
tickFormat: (value: unknown) => string;
|
|
400
|
+
truncate: number;
|
|
401
|
+
animated: boolean;
|
|
402
|
+
showAxisLine: boolean;
|
|
403
|
+
showTicks: boolean;
|
|
404
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
405
|
+
declare const _default$1: typeof __VLS_export$4;
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/ChartGrid/types.d.ts
|
|
408
|
+
interface ChartGridProps {
|
|
409
|
+
/** 画不画横向网格线 @default true */
|
|
410
|
+
horizontal?: boolean;
|
|
411
|
+
/** 画不画纵向网格线 @default false */
|
|
412
|
+
vertical?: boolean;
|
|
413
|
+
/**
|
|
414
|
+
* 每条轴上大约画几条网格线。和 `<ChartAxis>` 的 `tickCount` 保持一致,
|
|
415
|
+
* 网格线才会和刻度落在同一个值上。
|
|
416
|
+
* @default 5
|
|
417
|
+
*/
|
|
418
|
+
tickCount?: number;
|
|
419
|
+
}
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/ChartGrid/ChartGrid.vue.d.ts
|
|
422
|
+
declare const __VLS_export$3: import("vue").DefineComponent<ChartGridProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ChartGridProps> & Readonly<{}>, {
|
|
423
|
+
tickCount: number;
|
|
424
|
+
horizontal: boolean;
|
|
425
|
+
vertical: boolean;
|
|
426
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
427
|
+
declare const _default$2: typeof __VLS_export$3;
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/ChartLegend/ChartLegend.vue.d.ts
|
|
430
|
+
declare const __VLS_export$2: import("vue").DefineComponent<ChartLegendProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ChartLegendProps> & Readonly<{}>, {
|
|
431
|
+
items: LegendItem[];
|
|
432
|
+
position: LegendPosition;
|
|
433
|
+
alignment: LegendAlignment;
|
|
434
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
435
|
+
declare const _default$3: typeof __VLS_export$2;
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region src/ChartSwatch/types.d.ts
|
|
438
|
+
/** 色块的视觉形态,由标记类型决定。 */
|
|
439
|
+
type ChartSwatchVariant = 'square' | 'line';
|
|
440
|
+
interface ChartSwatchProps {
|
|
441
|
+
/** 填充色,一般就是系列颜色 */
|
|
442
|
+
color: string;
|
|
443
|
+
/**
|
|
444
|
+
* 形态。`square` 是方块(柱状系列),`line` 是一小段横线(折线、散点、面积等)。
|
|
445
|
+
* @default 'square'
|
|
446
|
+
*/
|
|
447
|
+
variant?: ChartSwatchVariant;
|
|
448
|
+
}
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region src/ChartSwatch/ChartSwatch.vue.d.ts
|
|
451
|
+
declare const __VLS_export$1: import("vue").DefineComponent<ChartSwatchProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ChartSwatchProps> & Readonly<{}>, {
|
|
452
|
+
variant: ChartSwatchVariant;
|
|
453
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
454
|
+
declare const _default$4: typeof __VLS_export$1;
|
|
455
|
+
//#endregion
|
|
456
|
+
//#region src/ChartSwatch/swatch.d.ts
|
|
457
|
+
/**
|
|
458
|
+
* 标记类型对应的色块形态:柱状是方块,其余(折线、散点、面积……)都是一小段线。
|
|
459
|
+
*
|
|
460
|
+
* 图例和提示框都走这一条规则,同一个系列在两处长得一样。
|
|
461
|
+
*/
|
|
462
|
+
export declare function swatchVariantForType(type: string | undefined): ChartSwatchVariant;
|
|
463
|
+
//#endregion
|
|
464
|
+
//#region src/ChartTooltip/ChartTooltip.vue.d.ts
|
|
465
|
+
declare const __VLS_export: import("vue").DefineComponent<ChartTooltipProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ChartTooltipProps> & Readonly<{}>, {
|
|
466
|
+
series: readonly SeriesDef[];
|
|
467
|
+
hoverIndicator: boolean;
|
|
468
|
+
showHoverDots: boolean;
|
|
469
|
+
placement: ChartTooltipPlacement;
|
|
470
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
471
|
+
declare const _default$5: typeof __VLS_export;
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region src/ChartTooltip/position.d.ts
|
|
474
|
+
interface CardPositionInput {
|
|
475
|
+
/** 卡片左上角贴着悬停点时,在视口里的位置 */
|
|
476
|
+
anchorLeft: number;
|
|
477
|
+
anchorTop: number;
|
|
478
|
+
/** 卡片自身的尺寸 */
|
|
479
|
+
width: number;
|
|
480
|
+
height: number;
|
|
481
|
+
/** 视口尺寸 */
|
|
482
|
+
viewportWidth: number;
|
|
483
|
+
viewportHeight: number;
|
|
484
|
+
}
|
|
485
|
+
export declare function computeCardPosition(input: CardPositionInput, placement: ChartTooltipPlacement): {
|
|
486
|
+
x: number;
|
|
487
|
+
y: number;
|
|
488
|
+
};
|
|
489
|
+
//#endregion
|
|
490
|
+
//#region src/context.d.ts
|
|
491
|
+
/**
|
|
492
|
+
* 读当前图表的上下文。只能在 `<Chart>` 里用。
|
|
493
|
+
*
|
|
494
|
+
* 返回的对象身份不变,字段是活的:图表重新量到宽度、重新布局之后,
|
|
495
|
+
* 同样的对象读出来的比例尺和尺寸就是新的。所以取值要写在 `computed` 或渲染里,
|
|
496
|
+
* 不要在 `setup` 里一次性解构出来。
|
|
497
|
+
*/
|
|
498
|
+
export declare function useChart(): ChartContext;
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region src/getChartColors.d.ts
|
|
501
|
+
/**
|
|
502
|
+
* 从一个「取变量值」的函数算出整套图表配色,不需要 DOM、不需要主题对象。
|
|
503
|
+
*
|
|
504
|
+
* 三套配色都能适应任意数量:类别色在固定的槽位里循环;顺序色和发散色在色阶停靠点
|
|
505
|
+
* 够用时直接取设计好的那几档,要得更多就在色阶上插值,而不是默默截断。
|
|
506
|
+
*/
|
|
507
|
+
/** 顺序色阶可用的色相名 */
|
|
508
|
+
type SequentialHue = 'blue' | 'shamrock' | 'orange' | 'pink' | 'purple' | 'red' | 'teal' | 'yellow' | 'gray';
|
|
509
|
+
/** 配色 API */
|
|
510
|
+
interface ChartColorsAPI {
|
|
511
|
+
categorical: (n: number) => string[];
|
|
512
|
+
sequential: Record<SequentialHue, (n: number) => string[]>;
|
|
513
|
+
diverging: {
|
|
514
|
+
positiveNegative: (n: number) => string[];
|
|
515
|
+
coldHot: (n: number) => string[];
|
|
516
|
+
custom: (neg: SequentialHue, pos: SequentialHue, n: number, midpoint?: string) => string[];
|
|
517
|
+
};
|
|
518
|
+
semantic: {
|
|
519
|
+
positive: string;
|
|
520
|
+
negative: string;
|
|
521
|
+
warning: string;
|
|
522
|
+
neutral: string;
|
|
523
|
+
};
|
|
524
|
+
/** 图表骨架(坐标轴、网格、刻度、标签)的结构色 */
|
|
525
|
+
structural: {
|
|
526
|
+
axis: string;
|
|
527
|
+
grid: string;
|
|
528
|
+
tick: string;
|
|
529
|
+
label: string;
|
|
530
|
+
};
|
|
531
|
+
alpha: (hex: string, opacity: number) => string;
|
|
532
|
+
}
|
|
533
|
+
/** 把一个变量名取成当前值 */
|
|
534
|
+
type TokenResolver = (name: string) => string;
|
|
535
|
+
/** 从一个取变量值的函数算出整套配色。这是最底层的入口。 */
|
|
536
|
+
export declare function getChartColorsFromResolver(resolve: TokenResolver): ChartColorsAPI;
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region src/useChartColors.d.ts
|
|
539
|
+
/**
|
|
540
|
+
* 当前主题下的图表配色。
|
|
541
|
+
*
|
|
542
|
+
* ```ts
|
|
543
|
+
* const colors = useChartColors()
|
|
544
|
+
* colors.categorical(5)
|
|
545
|
+
* colors.semantic.positive
|
|
546
|
+
* ```
|
|
547
|
+
*
|
|
548
|
+
* 返回的对象整个包共用一份,身份不变,可以直接放进 `watch` / `computed` 的依赖里。
|
|
549
|
+
*/
|
|
550
|
+
export declare function useChartColors(): ChartColorsAPI;
|
|
551
|
+
//#endregion
|
|
552
|
+
//#region src/formatters.d.ts
|
|
553
|
+
/**
|
|
554
|
+
* 数字、货币、百分比和日期的格式化函数。
|
|
555
|
+
*
|
|
556
|
+
* 三条约定:
|
|
557
|
+
* - 不好看的值原样返回。非有限数(NaN、±Infinity)和读不出数字的字符串不加工,
|
|
558
|
+
* 免得出现「InfinityB」这类垃圾;任何输入都不抛错。
|
|
559
|
+
* - 数字和日期都交给带缓存的 `Intl` 格式化器,所以输出跟随语言,进位也正确。
|
|
560
|
+
* - 日期按格里高利历输出。有些语言(如 `fa-IR`、`th-TH`)默认用别的历法,
|
|
561
|
+
* 不指定就会变成波斯历数字或佛历年份。
|
|
562
|
+
*/
|
|
563
|
+
/** 一种 BCP 47 语言标签,例如 `'en-US'`、`'de-DE'`。 */
|
|
564
|
+
type ChartLocale = string;
|
|
565
|
+
/** 按语言把几个词连成「甲、乙和丙」这样的并列短语。 */
|
|
566
|
+
export declare function formatList(values: readonly string[], locale: ChartLocale): string;
|
|
567
|
+
/**
|
|
568
|
+
* 缩写数字:`1200` → 「1.2K」,`1500000` → 「1.5M」,`1e12` → 「1T」。
|
|
569
|
+
*
|
|
570
|
+
* 读不成有限数的值原样返回,所以可以直接拿它当坐标轴刻度格式化器。
|
|
571
|
+
*/
|
|
572
|
+
export declare function compactNumber(value: unknown, locale: ChartLocale): string;
|
|
573
|
+
/**
|
|
574
|
+
* 生成货币格式化函数。
|
|
575
|
+
*
|
|
576
|
+
* 负号的顺序是「符号在前、货币符号在后」,所以负数读作「-$1.5K」而不是「$-1.5K」。
|
|
577
|
+
* 一千以上用缩写,一千以内用带千分位的普通数字。
|
|
578
|
+
*
|
|
579
|
+
* @example
|
|
580
|
+
* ```
|
|
581
|
+
* currency('$', locale)(1500) // $1.5K
|
|
582
|
+
* currency('€', locale)(12) // €12
|
|
583
|
+
* ```
|
|
584
|
+
*/
|
|
585
|
+
export declare function currency(symbol?: string, locale?: ChartLocale): (value: unknown) => string;
|
|
586
|
+
/**
|
|
587
|
+
* 百分比格式化:`0.45` → 「45%」,`1.2` → 「120%」,`0.005` → 「0.5%」。
|
|
588
|
+
*
|
|
589
|
+
* 入参是比例,不是百分数。整数百分比不显示小数位,其余最多一位。
|
|
590
|
+
*/
|
|
591
|
+
export declare function percent(value: unknown, locale: ChartLocale): string;
|
|
592
|
+
/** 短日期,例如「Jan 5」「Mar 12」。 */
|
|
593
|
+
export declare function shortDate(value: unknown, locale: ChartLocale): string;
|
|
594
|
+
/** 年月,例如「Jan 2024」「Mar 2025」。 */
|
|
595
|
+
export declare function monthYear(value: unknown, locale: ChartLocale): string;
|
|
596
|
+
//#endregion
|
|
597
|
+
//#region src/layout.d.ts
|
|
598
|
+
interface LayoutInput {
|
|
599
|
+
data: Record<string, unknown>[];
|
|
600
|
+
xKey: string;
|
|
601
|
+
series: SeriesDef[];
|
|
602
|
+
width: number;
|
|
603
|
+
height: number;
|
|
604
|
+
/** 没给 `yDomain` 时 y 轴范围怎么定,默认 `'auto'`。 */
|
|
605
|
+
yBaseline?: YBaseline;
|
|
606
|
+
/** 显式 y 轴范围 `[min, max]`。它说了算——不加基线、不留余量、不 `nice()`。 */
|
|
607
|
+
yDomain?: [number, number];
|
|
608
|
+
/**
|
|
609
|
+
* 数值/线性 x 轴的显式范围 `[min, max]`。它说了算,`data` 为空时也照用
|
|
610
|
+
* (流式窗口要稳定)。band 比例尺时忽略。
|
|
611
|
+
*/
|
|
612
|
+
xDomain?: [number, number];
|
|
613
|
+
}
|
|
614
|
+
interface LayoutResult {
|
|
615
|
+
xScale: ChartScale;
|
|
616
|
+
yScale: ReturnType<typeof scaleLinear<number, number>>;
|
|
617
|
+
/**
|
|
618
|
+
* 分类 y 比例尺。有系列声明了 `layout.yBandKey`(比如热力图的每一行)时才有,
|
|
619
|
+
* 这时 y 轴是分类轴,线性 `yScale` 用不上。
|
|
620
|
+
*/
|
|
621
|
+
yBandScale?: ReturnType<typeof scaleBand<string>>;
|
|
622
|
+
resolved: Map<string, ResolvedPoint[]>;
|
|
623
|
+
}
|
|
624
|
+
export declare function computeLayout({ data, xKey, series, width, height, yBaseline, yDomain, xDomain }: LayoutInput): LayoutResult;
|
|
625
|
+
//#endregion
|
|
626
|
+
//#region src/markColor.d.ts
|
|
627
|
+
/** 整个系列共用一种颜色时(line、area、band 等)的取色。 */
|
|
628
|
+
export declare function seriesFill(def: SeriesDef, color: ColorAccessor | undefined): string;
|
|
629
|
+
/** 每个数据点各取一色:取色函数优先,其次固定串,最后调色板。 */
|
|
630
|
+
export declare function pointFill(def: SeriesDef, color: ColorAccessor | undefined, datum: Record<string, unknown>, index: number): string;
|
|
631
|
+
//#endregion
|
|
632
|
+
//#region src/marks/area.d.ts
|
|
633
|
+
interface AreaOptions {
|
|
634
|
+
color?: string;
|
|
635
|
+
opacity?: number;
|
|
636
|
+
curve?: 'linear' | 'monotone' | 'natural' | 'step';
|
|
637
|
+
stack?: string;
|
|
638
|
+
gradient?: boolean;
|
|
639
|
+
stroke?: boolean;
|
|
640
|
+
label?: string;
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* 面积系列:线下面填色,支持堆叠和渐变。
|
|
644
|
+
*
|
|
645
|
+
* 缺失值、非有限值(包括堆叠基线断开的位置)给 NaN,画的时候留空洞,
|
|
646
|
+
* 而不是掉到 0 画成一片假的面积。
|
|
647
|
+
*/
|
|
648
|
+
export declare function area(dataKey: string, options?: AreaOptions): SeriesDef;
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region src/marks/band.d.ts
|
|
651
|
+
interface BandOptions {
|
|
652
|
+
upper: string;
|
|
653
|
+
lower: string;
|
|
654
|
+
color?: string;
|
|
655
|
+
opacity?: number;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* 置信区间带:上下界之间的那条面积。
|
|
659
|
+
*
|
|
660
|
+
* 上下界缺失或不是数字时给 NaN,画的时候断成空洞,而不是塌成一条零基线。
|
|
661
|
+
* 属于标注类标记,不进图例和提示框。
|
|
662
|
+
*/
|
|
663
|
+
export declare function band(options: BandOptions): SeriesDef;
|
|
664
|
+
//#endregion
|
|
665
|
+
//#region src/marks/bar.d.ts
|
|
666
|
+
interface BarOptions {
|
|
667
|
+
color?: ColorAccessor;
|
|
668
|
+
opacity?: number;
|
|
669
|
+
radius?: number;
|
|
670
|
+
stack?: string;
|
|
671
|
+
group?: string;
|
|
672
|
+
label?: string;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* 柱状图系列。y 轴按 `includeZero` 把 0 算进范围,负值从 0 往下长。
|
|
676
|
+
*
|
|
677
|
+
* 每条柱的像素宽度和偏移取决于分组情况,由 `resolve()` 现算并记在 `slot` 里,
|
|
678
|
+
* 画的时候从同一份状态里取,所以两条路径看到的是同一个宽度。
|
|
679
|
+
*/
|
|
680
|
+
export declare function bar(dataKey: string, options?: BarOptions): SeriesDef;
|
|
681
|
+
//#endregion
|
|
682
|
+
//#region src/marks/candlestick.d.ts
|
|
683
|
+
interface CandlestickOptions {
|
|
684
|
+
open: string;
|
|
685
|
+
high: string;
|
|
686
|
+
low: string;
|
|
687
|
+
close: string;
|
|
688
|
+
upColor?: string;
|
|
689
|
+
downColor?: string;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* K 线(OHLC)系列。band 比例尺和线性/时间比例尺都能用。
|
|
693
|
+
* 点位的 y 取收盘价;缺任何一个 OHLC 字段的那根蜡烛画的时候跳过,而不是画到 0。
|
|
694
|
+
* 属于数据系列,会进图例和提示框。
|
|
695
|
+
*/
|
|
696
|
+
export declare function candlestick(options: CandlestickOptions): SeriesDef;
|
|
697
|
+
//#endregion
|
|
698
|
+
//#region src/marks/dot.d.ts
|
|
699
|
+
interface DotOptions {
|
|
700
|
+
color?: ColorAccessor;
|
|
701
|
+
radius?: number;
|
|
702
|
+
opacity?: number;
|
|
703
|
+
dodge?: boolean;
|
|
704
|
+
label?: string;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* 散点系列。
|
|
708
|
+
*
|
|
709
|
+
* 缺失值和非有限值给 NaN,画的时候跳过,不会落到基线上。开了 `dodge` 会把落在
|
|
710
|
+
* 同一 x 上的点横向错开,错开时不管非有限的点,一个缺失值不会把整组挤歪。
|
|
711
|
+
*/
|
|
712
|
+
export declare function dot(dataKey: string, options?: DotOptions): SeriesDef;
|
|
713
|
+
//#endregion
|
|
714
|
+
//#region src/marks/errorBar.d.ts
|
|
715
|
+
interface ErrorBarOptions {
|
|
716
|
+
/** 上界的数据列 */
|
|
717
|
+
high: string;
|
|
718
|
+
/** 下界的数据列 */
|
|
719
|
+
low: string;
|
|
720
|
+
/** 描边颜色 */
|
|
721
|
+
color?: string;
|
|
722
|
+
/** 描边宽度 */
|
|
723
|
+
strokeWidth?: number;
|
|
724
|
+
/** 须线两端小横杠的宽度(像素) */
|
|
725
|
+
capWidth?: number;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* 误差条(须线)系列:上下界是绝对值,所以不对称的区间也能画。
|
|
729
|
+
* 配对 `bar()` 或 `dot()` 用。缺任何一侧上下界的点画的时候跳过,
|
|
730
|
+
* 而不是贴着坐标轴画一根误导人的零高度须线。
|
|
731
|
+
* 属于标注类标记,不进图例和提示框。
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* ```
|
|
735
|
+
* series={[bar('mean'), errorBar({high: 'upper95', low: 'lower95'})]}
|
|
736
|
+
* ```
|
|
737
|
+
*/
|
|
738
|
+
export declare function errorBar(options: ErrorBarOptions): SeriesDef;
|
|
739
|
+
//#endregion
|
|
740
|
+
//#region src/marks/line.d.ts
|
|
741
|
+
type CurveType = 'linear' | 'monotone' | 'natural' | 'step';
|
|
742
|
+
interface LineOptions {
|
|
743
|
+
color?: string;
|
|
744
|
+
curve?: CurveType;
|
|
745
|
+
strokeWidth?: number;
|
|
746
|
+
dots?: boolean;
|
|
747
|
+
label?: string;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* 折线系列。
|
|
751
|
+
*
|
|
752
|
+
* 缺失值和非有限值给 NaN,画的时候会断开(而不是掉到基线画出一条假线),
|
|
753
|
+
* 逐点的小圆点也只画在有限的位置上。
|
|
754
|
+
*/
|
|
755
|
+
export declare function line(dataKey: string, options?: LineOptions): SeriesDef;
|
|
756
|
+
//#endregion
|
|
757
|
+
//#region src/marks/referenceLine.d.ts
|
|
758
|
+
interface ReferenceLineOptions {
|
|
759
|
+
/** 在这个 y 值处画一条横线 */
|
|
760
|
+
y?: number;
|
|
761
|
+
/** 第二个 y 值——在 y 和 y2 之间涂一条带 */
|
|
762
|
+
y2?: number;
|
|
763
|
+
/** 在这个 x 值处画一条竖线 */
|
|
764
|
+
x?: number;
|
|
765
|
+
/** 线或带的颜色 */
|
|
766
|
+
color?: string;
|
|
767
|
+
/** 描边宽度(画线时用) */
|
|
768
|
+
strokeWidth?: number;
|
|
769
|
+
/** 虚线样式 */
|
|
770
|
+
strokeDasharray?: string;
|
|
771
|
+
/** 文字标签 */
|
|
772
|
+
label?: string;
|
|
773
|
+
/** 标签位置 */
|
|
774
|
+
labelPosition?: 'start' | 'end';
|
|
775
|
+
/** 涂带的透明度(设了 y2 时用) */
|
|
776
|
+
bandOpacity?: number;
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* 横向或纵向的参考线、参考带。它不是数据系列,画在固定的数值上。
|
|
780
|
+
*
|
|
781
|
+
* 画的位置要现算(取决于比例尺、绘图区大小和标签宽度),所以这个工厂没有点位可算,
|
|
782
|
+
* `resolve()` 永远返回空数组——所有几何都在 `render()` 里。
|
|
783
|
+
* 标签牌会被夹在绘图区内(绘图区本身是裁切的),横竖两个方向都一样。
|
|
784
|
+
*/
|
|
785
|
+
export declare function referenceLine(options: ReferenceLineOptions): SeriesDef;
|
|
786
|
+
//#endregion
|
|
787
|
+
//#region src/utils.d.ts
|
|
788
|
+
/** 判断一个比例尺是不是 d3 的 band 比例尺(分类轴上每个类占一条「带」)。 */
|
|
789
|
+
export declare function isBandScale(scale: ChartScale): scale is ScaleBand<string>;
|
|
790
|
+
/**
|
|
791
|
+
* 算出一条数据在 x 方向的像素位置。band 比例尺返回这条「带」的中心。
|
|
792
|
+
*
|
|
793
|
+
* 非 band 比例尺走数值路径:有限数字直接用,Date 和数字字符串也照 d3 的规则转换。
|
|
794
|
+
* 转出来不是有限值的(读不成数字、或者原始值就是 ±Infinity)一律给 NaN——标记看到
|
|
795
|
+
* NaN 会跳过这个点(画在画布外),而不是照 d3 的换算画到某个错位置。
|
|
796
|
+
*/
|
|
797
|
+
export declare function xPixel(d: Record<string, unknown>, xKey: string, xScale: ChartScale): number;
|
|
798
|
+
//#endregion
|
|
799
|
+
export { type AreaOptions, type BandOptions, type BarOptions, type CandlestickOptions, type CardPositionInput, _default as Chart, _default$1 as ChartAxis, type ChartAxisPosition, type ChartAxisProps, type ChartColorsAPI, type ChartContext, _default$2 as ChartGrid, type ChartGridProps, _default$3 as ChartLegend, type ChartLegendConfig, type ChartLegendProps, type ChartLocale, type ChartMargin, type ChartPointerEvent, type ChartProps, type ChartScale, type ChartSlots, _default$4 as ChartSwatch, type ChartSwatchProps, type ChartSwatchVariant, _default$5 as ChartTooltip, type ChartTooltipConfig, type ChartTooltipPlacement, type ChartTooltipProps, type ChartTooltipSlots, type ColorAccessor, type DotOptions, type ErrorBarOptions, type LayoutInput, type LayoutResult, type LegendAlignment, type LegendItem, type LegendPosition, type LineOptions, type RGBA, type ReferenceLineOptions, type ResolvedPoint, type ResolvedPositions, type SequentialHue, type SeriesContext, type SeriesDef, type TokenResolver, type TooltipSeriesValue, type YBaseline };
|