@damoqiongqiu/ice-chart 0.17.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 +530 -0
- package/dist/index.cjs +25 -0
- package/dist/index.mjs +25 -0
- package/dist/index.umd.js +25 -0
- package/dist/types/ICEChart.d.mts +330 -0
- package/dist/types/ICEChart.d.ts +330 -0
- package/dist/types/a11y.d.mts +85 -0
- package/dist/types/a11y.d.ts +85 -0
- package/dist/types/animation/motion.d.mts +11 -0
- package/dist/types/animation/motion.d.ts +11 -0
- package/dist/types/components/Axis.d.mts +60 -0
- package/dist/types/components/Axis.d.ts +60 -0
- package/dist/types/components/Brush.d.mts +19 -0
- package/dist/types/components/Brush.d.ts +19 -0
- package/dist/types/components/ChartComponent.d.mts +48 -0
- package/dist/types/components/ChartComponent.d.ts +48 -0
- package/dist/types/components/Crosshair.d.mts +40 -0
- package/dist/types/components/Crosshair.d.ts +40 -0
- package/dist/types/components/DataZoomSlider.d.mts +30 -0
- package/dist/types/components/DataZoomSlider.d.ts +30 -0
- package/dist/types/components/GridLines.d.mts +37 -0
- package/dist/types/components/GridLines.d.ts +37 -0
- package/dist/types/components/Highlight.d.mts +34 -0
- package/dist/types/components/Highlight.d.ts +34 -0
- package/dist/types/components/Legend.d.mts +26 -0
- package/dist/types/components/Legend.d.ts +26 -0
- package/dist/types/components/PlotArea.d.mts +21 -0
- package/dist/types/components/PlotArea.d.ts +21 -0
- package/dist/types/components/PolarGrid.d.mts +34 -0
- package/dist/types/components/PolarGrid.d.ts +34 -0
- package/dist/types/components/RadarGrid.d.mts +25 -0
- package/dist/types/components/RadarGrid.d.ts +25 -0
- package/dist/types/components/Title.d.mts +14 -0
- package/dist/types/components/Title.d.ts +14 -0
- package/dist/types/components/Tooltip.d.mts +48 -0
- package/dist/types/components/Tooltip.d.ts +48 -0
- package/dist/types/components/series/AreaSeries.d.mts +14 -0
- package/dist/types/components/series/AreaSeries.d.ts +14 -0
- package/dist/types/components/series/BarSeries.d.mts +39 -0
- package/dist/types/components/series/BarSeries.d.ts +39 -0
- package/dist/types/components/series/BoxplotSeries.d.mts +16 -0
- package/dist/types/components/series/BoxplotSeries.d.ts +16 -0
- package/dist/types/components/series/CandlestickSeries.d.mts +13 -0
- package/dist/types/components/series/CandlestickSeries.d.ts +13 -0
- package/dist/types/components/series/CurveSeriesBase.d.mts +58 -0
- package/dist/types/components/series/CurveSeriesBase.d.ts +58 -0
- package/dist/types/components/series/FunctionSeries.d.mts +22 -0
- package/dist/types/components/series/FunctionSeries.d.ts +22 -0
- package/dist/types/components/series/FunnelSeries.d.mts +38 -0
- package/dist/types/components/series/FunnelSeries.d.ts +38 -0
- package/dist/types/components/series/GaugeSeries.d.mts +45 -0
- package/dist/types/components/series/GaugeSeries.d.ts +45 -0
- package/dist/types/components/series/GraphSeries.d.mts +39 -0
- package/dist/types/components/series/GraphSeries.d.ts +39 -0
- package/dist/types/components/series/HeatmapSeries.d.mts +21 -0
- package/dist/types/components/series/HeatmapSeries.d.ts +21 -0
- package/dist/types/components/series/LineSeries.d.mts +31 -0
- package/dist/types/components/series/LineSeries.d.ts +31 -0
- package/dist/types/components/series/LiquidSeries.d.mts +55 -0
- package/dist/types/components/series/LiquidSeries.d.ts +55 -0
- package/dist/types/components/series/ParametricSeries.d.mts +30 -0
- package/dist/types/components/series/ParametricSeries.d.ts +30 -0
- package/dist/types/components/series/PieSeries.d.mts +44 -0
- package/dist/types/components/series/PieSeries.d.ts +44 -0
- package/dist/types/components/series/RadarSeries.d.mts +30 -0
- package/dist/types/components/series/RadarSeries.d.ts +30 -0
- package/dist/types/components/series/SankeySeries.d.mts +34 -0
- package/dist/types/components/series/SankeySeries.d.ts +34 -0
- package/dist/types/components/series/ScatterSeries.d.mts +11 -0
- package/dist/types/components/series/ScatterSeries.d.ts +11 -0
- package/dist/types/components/series/SeriesBase.d.mts +214 -0
- package/dist/types/components/series/SeriesBase.d.ts +214 -0
- package/dist/types/components/series/TreemapSeries.d.mts +48 -0
- package/dist/types/components/series/TreemapSeries.d.ts +48 -0
- package/dist/types/components/series/WaterfallSeries.d.mts +17 -0
- package/dist/types/components/series/WaterfallSeries.d.ts +17 -0
- package/dist/types/components/series/createSeries.d.mts +10 -0
- package/dist/types/components/series/createSeries.d.ts +10 -0
- package/dist/types/components/series/index.d.mts +29 -0
- package/dist/types/components/series/index.d.ts +29 -0
- package/dist/types/expr/diagnostics.d.mts +45 -0
- package/dist/types/expr/diagnostics.d.ts +45 -0
- package/dist/types/expr/expr.d.mts +44 -0
- package/dist/types/expr/expr.d.ts +44 -0
- package/dist/types/expr/sample.d.mts +34 -0
- package/dist/types/expr/sample.d.ts +34 -0
- package/dist/types/index.d.mts +80 -0
- package/dist/types/index.d.ts +80 -0
- package/dist/types/interaction/ChartLink.d.mts +16 -0
- package/dist/types/interaction/ChartLink.d.ts +16 -0
- package/dist/types/interaction/HitResolver.d.mts +44 -0
- package/dist/types/interaction/HitResolver.d.ts +44 -0
- package/dist/types/interaction/InteractionController.d.mts +147 -0
- package/dist/types/interaction/InteractionController.d.ts +147 -0
- package/dist/types/internal.d.mts +232 -0
- package/dist/types/internal.d.ts +232 -0
- package/dist/types/layout/force.d.mts +48 -0
- package/dist/types/layout/force.d.ts +48 -0
- package/dist/types/layout/layout.d.mts +9 -0
- package/dist/types/layout/layout.d.ts +9 -0
- package/dist/types/layout/sankey.d.mts +47 -0
- package/dist/types/layout/sankey.d.ts +47 -0
- package/dist/types/layout/treemap.d.mts +35 -0
- package/dist/types/layout/treemap.d.ts +35 -0
- package/dist/types/option/normalize.d.mts +68 -0
- package/dist/types/option/normalize.d.ts +68 -0
- package/dist/types/scale/BandScale.d.mts +36 -0
- package/dist/types/scale/BandScale.d.ts +36 -0
- package/dist/types/scale/LinearScale.d.mts +21 -0
- package/dist/types/scale/LinearScale.d.ts +21 -0
- package/dist/types/scale/LogScale.d.mts +24 -0
- package/dist/types/scale/LogScale.d.ts +24 -0
- package/dist/types/scale/Scale.d.mts +38 -0
- package/dist/types/scale/Scale.d.ts +38 -0
- package/dist/types/scale/TimeScale.d.mts +28 -0
- package/dist/types/scale/TimeScale.d.ts +28 -0
- package/dist/types/scale/format.d.mts +5 -0
- package/dist/types/scale/format.d.ts +5 -0
- package/dist/types/scale/index.d.mts +7 -0
- package/dist/types/scale/index.d.ts +7 -0
- package/dist/types/theme/chartTheme.d.mts +54 -0
- package/dist/types/theme/chartTheme.d.ts +54 -0
- package/dist/types/types.d.mts +689 -0
- package/dist/types/types.d.ts +689 -0
- package/dist/types/util/emitter.d.mts +11 -0
- package/dist/types/util/emitter.d.ts +11 -0
- package/dist/types/util/math.d.mts +14 -0
- package/dist/types/util/math.d.ts +14 -0
- package/dist/types/util/text.d.mts +10 -0
- package/dist/types/util/text.d.ts +10 -0
- package/package.json +100 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { ICE, ICEGroup } from 'ice-render';
|
|
2
|
+
import type { ChartOption, DataItem } from './types.mjs';
|
|
3
|
+
import type { ChartLayout, InternalSeries, NormalizedOption } from './internal.mjs';
|
|
4
|
+
import { GridLines } from './components/GridLines.mjs';
|
|
5
|
+
import { PlotArea } from './components/PlotArea.mjs';
|
|
6
|
+
import { Axis } from './components/Axis.mjs';
|
|
7
|
+
import { Legend } from './components/Legend.mjs';
|
|
8
|
+
import { Title } from './components/Title.mjs';
|
|
9
|
+
import { Tooltip } from './components/Tooltip.mjs';
|
|
10
|
+
import { Crosshair } from './components/Crosshair.mjs';
|
|
11
|
+
import { Highlight } from './components/Highlight.mjs';
|
|
12
|
+
import { Brush } from './components/Brush.mjs';
|
|
13
|
+
import { RadarGrid } from './components/RadarGrid.mjs';
|
|
14
|
+
import { PolarGrid } from './components/PolarGrid.mjs';
|
|
15
|
+
import { DataZoomSlider } from './components/DataZoomSlider.mjs';
|
|
16
|
+
import type { SeriesBase } from './components/series/SeriesBase.mjs';
|
|
17
|
+
import { InteractionController } from './interaction/InteractionController.mjs';
|
|
18
|
+
import { type A11yTreeOptions, type DataTable } from './a11y.mjs';
|
|
19
|
+
/** 快照格式版本:结构变化时递增,还原时校验。 */
|
|
20
|
+
export declare const SNAPSHOT_VERSION = 1;
|
|
21
|
+
export { setMotionPreference, getMotionPreference, shouldAnimate } from './animation/motion.mjs';
|
|
22
|
+
export type { MotionPreference } from './animation/motion.mjs';
|
|
23
|
+
export interface SnapshotRestoreOptions {
|
|
24
|
+
/**
|
|
25
|
+
* 还原时叠加的非序列化配置补丁(formatter、函数型回调等)。
|
|
26
|
+
* series 按 id 或下标逐项合并,不会覆盖快照里的数据。
|
|
27
|
+
*/
|
|
28
|
+
optionPatch?: Partial<ChartOption> & {
|
|
29
|
+
series?: any[];
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface ChartSnapshot {
|
|
33
|
+
version: number;
|
|
34
|
+
option: ChartOption;
|
|
35
|
+
view: {
|
|
36
|
+
x: [any, any] | null;
|
|
37
|
+
y: [any, any] | null;
|
|
38
|
+
yAxes: Array<[any, any] | null>;
|
|
39
|
+
};
|
|
40
|
+
hidden: Record<string, boolean>;
|
|
41
|
+
hiddenSlices: Record<string, boolean>;
|
|
42
|
+
}
|
|
43
|
+
/** 判断一个对象是不是 ice-chart 快照(用于 createChart 的入参分派)。 */
|
|
44
|
+
export declare function isChartSnapshot(value: any): boolean;
|
|
45
|
+
/** 把补丁合进快照里的 option:series 按 id/下标逐项合并,其余字段浅覆盖。 */
|
|
46
|
+
export declare function mergeOptionPatch(base: any, patch: any): any;
|
|
47
|
+
export interface ICEChartOptions {
|
|
48
|
+
renderMode?: 'dirty-rect' | 'full';
|
|
49
|
+
dpr?: number;
|
|
50
|
+
/** 监听容器尺寸变化并自动重排(需要 ResizeObserver)。 */
|
|
51
|
+
autoResize?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface ApplyOptionOptions {
|
|
54
|
+
/** true = 播「更新」动画;'enter' = 播「入场」动画;false = 不播。 */
|
|
55
|
+
animate?: boolean | 'enter' | 'update';
|
|
56
|
+
/** 保留当前缩放窗口(图例切换、数据更新时用)。 */
|
|
57
|
+
preserveView?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* ICEChart:把一份声明式 option 编译成 ice-render 组件树,并挂上交互层。
|
|
61
|
+
*
|
|
62
|
+
* 分工:
|
|
63
|
+
* - 归一化(数据 → 数据域 / 堆叠)由 option/normalize 负责,纯函数、可单测;
|
|
64
|
+
* - 布局(标题 / 图例 / 坐标轴 / 绘图区)由 layout 负责,纯函数、可单测;
|
|
65
|
+
* - 渲染由 ice-render 组件负责(脏矩形局部重绘、离屏缓存、HiDPI 全部由引擎兜底);
|
|
66
|
+
* - 交互由 InteractionController 负责,对外只抛语义事件。
|
|
67
|
+
*/
|
|
68
|
+
export declare class ICEChart {
|
|
69
|
+
ice: ICE;
|
|
70
|
+
option: ChartOption;
|
|
71
|
+
norm: NormalizedOption;
|
|
72
|
+
layout: ChartLayout;
|
|
73
|
+
root: ICEGroup;
|
|
74
|
+
plotArea: PlotArea;
|
|
75
|
+
grid: GridLines;
|
|
76
|
+
radarGrid: RadarGrid;
|
|
77
|
+
/** 极坐标网格(r(θ) 曲线用;画在直角坐标场景里,配合 aspect:'equal')。 */
|
|
78
|
+
polarGrid: PolarGrid;
|
|
79
|
+
axisX: Axis;
|
|
80
|
+
/** y 轴组件,与 norm.yAxes 一一对应(axisYList[0] 是主 y 轴)。 */
|
|
81
|
+
axisYList: Axis[];
|
|
82
|
+
legend: Legend | null;
|
|
83
|
+
titleComponent: Title | null;
|
|
84
|
+
tooltip: Tooltip | null;
|
|
85
|
+
crosshair: Crosshair | null;
|
|
86
|
+
highlight: Highlight | null;
|
|
87
|
+
brushComponent: Brush | null;
|
|
88
|
+
dataZoomSlider: DataZoomSlider | null;
|
|
89
|
+
seriesComponents: SeriesBase[];
|
|
90
|
+
controller: InteractionController;
|
|
91
|
+
/** 交互层使用的别名(与 InteractionHost 接口约定一致)。 */
|
|
92
|
+
get brush(): Brush | null;
|
|
93
|
+
/** 未经缩放/筛选的完整数据域(缩放约束与跨图联动用)。 */
|
|
94
|
+
fullXDomain: any[];
|
|
95
|
+
fullYDomain: any[];
|
|
96
|
+
/** 每个 y 轴的完整数据域(未缩放)。 */
|
|
97
|
+
fullYDomains: any[][];
|
|
98
|
+
private emitter;
|
|
99
|
+
private canvasEl;
|
|
100
|
+
private chartOptions;
|
|
101
|
+
private viewState;
|
|
102
|
+
/** 存在 function 系列时为真:y 轴数据域每次重建都按可视 x 区间重算(自动贴合)。 */
|
|
103
|
+
private autoYCurve;
|
|
104
|
+
private hiddenIds;
|
|
105
|
+
private hiddenSlices;
|
|
106
|
+
private seriesSignature;
|
|
107
|
+
private axisSignature;
|
|
108
|
+
private resizeObserver;
|
|
109
|
+
private destroyed;
|
|
110
|
+
/** 抑制对外事件的重入深度(跨图联动时避免 A→B→A 的回环)。 */
|
|
111
|
+
private silenceDepth;
|
|
112
|
+
private a11yMirror;
|
|
113
|
+
/**
|
|
114
|
+
* 更新动画期间的坐标轴数据域过渡。
|
|
115
|
+
*
|
|
116
|
+
* 数据更新时 y 轴数据域常常会变(例如最大值从 50 掉到 40),如果域瞬跳,
|
|
117
|
+
* 柱子会在动画**开始的那一帧**整体位移一下,值插值反而看不见。
|
|
118
|
+
* 所以域要和系列的值一起插值:每帧按同一进度重算域与坐标,动画结束时再回到常规路径。
|
|
119
|
+
*/
|
|
120
|
+
private domainTransition;
|
|
121
|
+
private domainFrameHandler;
|
|
122
|
+
constructor(target: any, option: ChartOption, chartOptions?: ICEChartOptions);
|
|
123
|
+
/** 更新配置。默认保留当前缩放窗口,可用 resetZoom 恢复。 */
|
|
124
|
+
setOption(option: ChartOption, options?: ApplyOptionOptions): this;
|
|
125
|
+
/** 取当前配置(函数字段保留;持久化请用 toJSON)。 */
|
|
126
|
+
getOption(): ChartOption;
|
|
127
|
+
/**
|
|
128
|
+
* 函数绘图 / 参数曲线的表达式诊断(**回答「用户是不是写错了公式」**)。
|
|
129
|
+
*
|
|
130
|
+
* 三类都覆盖:
|
|
131
|
+
* - `error`:语法错误(带位置)、未定义的变量、在当前区间内没有任何可绘制的值;
|
|
132
|
+
* - `warning`:参数定义了没用上、输出恒定(画出来是一条水平线)。
|
|
133
|
+
*
|
|
134
|
+
* 表达式来自用户输入,写错**不会**让图表崩掉(那会让表单很难用),
|
|
135
|
+
* 但错误必须能被拿到:表单据此标红 / 提示,控制台不必猜。
|
|
136
|
+
*/
|
|
137
|
+
expressionDiagnostics(): Array<{
|
|
138
|
+
seriesId: string;
|
|
139
|
+
diagnostics: NonNullable<InternalSeries['expressionDiagnostics']>;
|
|
140
|
+
}>;
|
|
141
|
+
/** 只取错误(标红用)。需要警告(提示用)请用 `expressionDiagnostics()`。 */
|
|
142
|
+
expressionErrors(): Array<{
|
|
143
|
+
seriesId: string;
|
|
144
|
+
message: string;
|
|
145
|
+
}>;
|
|
146
|
+
/** 更新单个系列的数据。 */
|
|
147
|
+
setData(seriesIdOrIndex: string | number, data: DataItem[]): this;
|
|
148
|
+
/**
|
|
149
|
+
* **追加**数据(实时数据流专用):把新点接到系列末尾,超出 `maxPoints` 时从头裁掉,
|
|
150
|
+
* 形成滑动窗口。相对 `setData` 的两点差别:
|
|
151
|
+
*
|
|
152
|
+
* 1. **不做值插值**(`animate` 默认 false):窗口滑动会让下标整体前移,
|
|
153
|
+
* 插值会把「这一点」插向「下一点的值」,看起来像被拖住。
|
|
154
|
+
* 流畅度由推送频率决定(60Hz 推送就是 60fps 的平滑滚动);
|
|
155
|
+
* 2. 只重算被追加的系列所在的那条链路(走 `applyOption` 的常规更新路径,`preserveView` 保持缩放窗口)。
|
|
156
|
+
*
|
|
157
|
+
* ```ts
|
|
158
|
+
* chart.appendData('cpu', [[t, value]], { maxPoints: 180 });
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
appendData(seriesIdOrIndex: string | number, items: DataItem[], options?: {
|
|
162
|
+
maxPoints?: number;
|
|
163
|
+
animate?: boolean;
|
|
164
|
+
}): this;
|
|
165
|
+
/** 设置数据域(缩放 / 联动入口)。 */
|
|
166
|
+
setDomain(axis: 'x' | 'y', domain: any[], source?: string): this;
|
|
167
|
+
/** 恢复完整数据域。 */
|
|
168
|
+
resetZoom(): this;
|
|
169
|
+
/** 切换系列显隐(图例点击、程序化控制都走这里)。 */
|
|
170
|
+
toggleSeries(seriesId: string, forceSelected?: boolean): this;
|
|
171
|
+
isSeriesSelected(seriesId: string): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* 切换饼图扇区显隐(极坐标图例点击走这里)。
|
|
174
|
+
* 扇区键是 `seriesId#dataIndex`,与系列显隐彼此独立。
|
|
175
|
+
*/
|
|
176
|
+
toggleSlice(seriesId: string, dataIndex: number, forceSelected?: boolean): this;
|
|
177
|
+
/** 键盘 / 程序化焦点:把悬停定位到某个数据点。 */
|
|
178
|
+
showHoverAt(seriesId: string, dataIndex: number): this;
|
|
179
|
+
/** 跨图联动:按 x 数据值显示悬停。 */
|
|
180
|
+
showHoverAtValue(xValue: any): this;
|
|
181
|
+
clearHover(): this;
|
|
182
|
+
getSelection(): any[];
|
|
183
|
+
clearSelection(): this;
|
|
184
|
+
/** 当前数据域。 */
|
|
185
|
+
getDomain(axis: 'x' | 'y'): any[];
|
|
186
|
+
/** 指定 y 轴的数据域(多轴叠加时按 index 区分)。 */
|
|
187
|
+
getAxisDomain(index: number): any[];
|
|
188
|
+
/** 设置指定 y 轴的数据域(多轴叠加时的程序化控制)。 */
|
|
189
|
+
setAxisDomain(index: number, domain: any[], source?: string): this;
|
|
190
|
+
/** 完整数据域(未缩放)。 */
|
|
191
|
+
fullDomain(axis: 'x' | 'y'): any[];
|
|
192
|
+
/** canvas 元素(无障碍镜像等 DOM 相关能力需要)。 */
|
|
193
|
+
get canvasElement(): any;
|
|
194
|
+
/** 数据表:屏幕阅读器可直接读取的「图表等价文本」。 */
|
|
195
|
+
getDataTable(): DataTable;
|
|
196
|
+
/**
|
|
197
|
+
* 无障碍节点树:引擎的组件树 + 逐数据点的虚拟节点。
|
|
198
|
+
* 应用层可据此构建自己的 DOM 镜像(焦点环、行内提示等)。
|
|
199
|
+
*/
|
|
200
|
+
getA11yTree(options?: A11yTreeOptions): any[];
|
|
201
|
+
/**
|
|
202
|
+
* 在 canvas 旁挂载视觉隐藏的数据表 + aria-live 播报区,
|
|
203
|
+
* 让屏幕阅读器既能读到整张数据表,也能听到当前悬停/键盘导航到的数据点。
|
|
204
|
+
*/
|
|
205
|
+
attachA11yMirror(): boolean;
|
|
206
|
+
detachA11yMirror(): void;
|
|
207
|
+
get a11yMirrorAttached(): boolean;
|
|
208
|
+
/** 手动播报一段无障碍文本(自定义交互时用)。 */
|
|
209
|
+
announceA11y(text: string): void;
|
|
210
|
+
on(event: string, fn: (payload: any) => void, scope?: any): this;
|
|
211
|
+
once(event: string, fn: (payload: any) => void, scope?: any): this;
|
|
212
|
+
off(event: string, fn?: (payload: any) => void, scope?: any): this;
|
|
213
|
+
emit(event: string, payload?: any): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* 在「静默」状态下执行一段操作:期间抛出的事件不会对外广播。
|
|
216
|
+
* 跨图联动用它打断 A→B→A 的事件回环,同时保留内部的视觉更新。
|
|
217
|
+
*/
|
|
218
|
+
silent<T>(fn: () => T): T;
|
|
219
|
+
/** 手动重排(响应式容器变化时调用)。不传尺寸则读取 canvas 的内容盒尺寸。 */
|
|
220
|
+
resize(cssWidth?: number, cssHeight?: number): this;
|
|
221
|
+
destroy(): void;
|
|
222
|
+
/** 等待下一帧渲染完成(测试与截图场景很有用)。 */
|
|
223
|
+
nextFrame(): Promise<void>;
|
|
224
|
+
/** 便捷方法:立即标脏并等待一帧(等价于 requestRender + nextFrame)。 */
|
|
225
|
+
render(): Promise<void>;
|
|
226
|
+
/** 文本格式化(坐标轴 / 提示框共用)。 */
|
|
227
|
+
formatAxisValue(axis: 'x' | 'y', value: any): string;
|
|
228
|
+
/** 导出成图片(透传引擎的 canvas 能力):常用于「保存为 PNG」。 */
|
|
229
|
+
toDataURL(type?: string, quality?: any): string;
|
|
230
|
+
/** 导出成 Blob(浏览器环境)。 */
|
|
231
|
+
toBlob(callback: (blob: any) => void, type?: string, quality?: any): void;
|
|
232
|
+
/**
|
|
233
|
+
* 从快照还原一个图表(静态工厂,等价于先 new 再 fromJSONObject)。
|
|
234
|
+
*
|
|
235
|
+
* ```ts
|
|
236
|
+
* const json = chart.toJSONString();
|
|
237
|
+
* const restored = ICEChart.restore('canvas-2', json);
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
static restore(target: any, snapshot: ChartSnapshot | string, options?: SnapshotRestoreOptions & {
|
|
241
|
+
chartOptions?: ICEChartOptions;
|
|
242
|
+
initialOption?: ChartOption;
|
|
243
|
+
}): ICEChart;
|
|
244
|
+
/**
|
|
245
|
+
* 导出图表快照(可 JSON 化)。
|
|
246
|
+
*
|
|
247
|
+
* 序列化的**唯一事实来源是 option**(声明式规格),不是引擎的组件树:
|
|
248
|
+
* 组件树只是 option 的渲染投影,里面没有数据语义(比例尺、数据点、命中缓存),
|
|
249
|
+
* 反序列化一棵组件树只会得到一个空壳。所以这里存的是
|
|
250
|
+
* 「option + 视图窗口 + 图例/扇区显隐」,这三样足以完整重建图形。
|
|
251
|
+
*
|
|
252
|
+
* 注意:函数字段(formatter 等)无法进 JSON,导出时会被丢弃;
|
|
253
|
+
* 还原时用 `restore(target, snapshot, { optionPatch })` 或 `fromJSONObject(snapshot, { patch })` 补回来。
|
|
254
|
+
*/
|
|
255
|
+
toJSON(): {
|
|
256
|
+
version: number;
|
|
257
|
+
option: ChartOption;
|
|
258
|
+
view: {
|
|
259
|
+
x: [any, any] | null;
|
|
260
|
+
y: [any, any] | null;
|
|
261
|
+
yAxes: Array<[any, any] | null>;
|
|
262
|
+
};
|
|
263
|
+
hidden: Record<string, boolean>;
|
|
264
|
+
hiddenSlices: Record<string, boolean>;
|
|
265
|
+
};
|
|
266
|
+
toJSONString(): string;
|
|
267
|
+
fromJSONString(json: string, options?: SnapshotRestoreOptions): this;
|
|
268
|
+
fromJSONObject(snapshot: any, options?: SnapshotRestoreOptions): this;
|
|
269
|
+
private loadSnapshot;
|
|
270
|
+
private applyOption;
|
|
271
|
+
/** dataZoom 的 start/end 只影响初始窗口。 */
|
|
272
|
+
private initialWindow;
|
|
273
|
+
/** 用当前 viewState 重新归一化 → 布局 → 同步组件。 */
|
|
274
|
+
/** 启动数据域过渡:每帧按系列动画进度插值 y 轴数据域。 */
|
|
275
|
+
private startDomainTransition;
|
|
276
|
+
private stepDomainTransition;
|
|
277
|
+
private stopDomainTransition;
|
|
278
|
+
private rebuild;
|
|
279
|
+
private buildScales;
|
|
280
|
+
private syncComponents;
|
|
281
|
+
/** 当前 x 数据域在完整数据域中的比例窗口(0~1),供 dataZoom 滑块显示。 */
|
|
282
|
+
domainFractions(): [number, number];
|
|
283
|
+
/** 由 dataZoom 滑块的比例窗口反推数据域。 */
|
|
284
|
+
setDomainFromFractions(start: number, end: number, source?: string): this;
|
|
285
|
+
/** 让 y 轴组件数量 / 位置与 norm.yAxes 保持一致(轴数量变化时增删组件)。 */
|
|
286
|
+
private syncAxisComponents;
|
|
287
|
+
private syncSeries;
|
|
288
|
+
/**
|
|
289
|
+
* 让引擎的 AnimationManager 把 progress 从 0 推到 1。
|
|
290
|
+
*
|
|
291
|
+
* 实测(`hitTest` 逐帧采样):引擎在补间期间把 `interactive` 置 false 只发生在
|
|
292
|
+
* 同一帧的同步块内(保存→置 false→补间→恢复),事件处理与命中检测看不到,
|
|
293
|
+
* 所以动画期间交互照常可用 —— 不需要额外的「驱动组件」绕开它。
|
|
294
|
+
*/
|
|
295
|
+
playStage(seriesComponent: SeriesBase, stage: {
|
|
296
|
+
duration?: number;
|
|
297
|
+
delay?: number;
|
|
298
|
+
easing?: string;
|
|
299
|
+
stagger?: number;
|
|
300
|
+
kind?: 'enter' | 'update';
|
|
301
|
+
}): void;
|
|
302
|
+
/** 兼容旧 API:按「入场」阶段播放。 */
|
|
303
|
+
playEnter(seriesComponent: SeriesBase, duration: number, easing: string): void;
|
|
304
|
+
/** 把当前所有未完成的动画一次性推到终态(截图 / 测试 / 无障碍瞬时模式用)。 */
|
|
305
|
+
finishAnimations(): this;
|
|
306
|
+
private currentRange;
|
|
307
|
+
private clampDomain;
|
|
308
|
+
/** index = -1 表示 x 轴,>=0 表示对应的 y 轴。 */
|
|
309
|
+
private clampAxisDomain;
|
|
310
|
+
private canvasRect;
|
|
311
|
+
private observeResize;
|
|
312
|
+
private registerTypes;
|
|
313
|
+
}
|
|
314
|
+
/** 计算分组柱形的槽位:同 stack 的系列共用一个槽,其余各自一槽。 */
|
|
315
|
+
export declare function computeBarSlots(series: InternalSeries[]): Record<string, {
|
|
316
|
+
index: number;
|
|
317
|
+
count: number;
|
|
318
|
+
}>;
|
|
319
|
+
/** 某个饼图系列里被隐藏的扇区下标。 */
|
|
320
|
+
export declare function hiddenSliceIndexes(norm: NormalizedOption, seriesId: string): number[];
|
|
321
|
+
/**
|
|
322
|
+
* 工厂函数:第二个参数既可以是声明式 option,也可以是 `toJSON()` 产出的快照。
|
|
323
|
+
*
|
|
324
|
+
* ```ts
|
|
325
|
+
* const chart = createChart('canvas-1', option);
|
|
326
|
+
* const snapshot = chart.toJSONString();
|
|
327
|
+
* const restored = createChart('canvas-2', snapshot); // 直接吃快照
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
export declare function createChart(target: any, optionOrSnapshot: ChartOption | ChartSnapshot | string, chartOptions?: ICEChartOptions): ICEChart;
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { ICE, ICEGroup } from 'ice-render';
|
|
2
|
+
import type { ChartOption, DataItem } from './types';
|
|
3
|
+
import type { ChartLayout, InternalSeries, NormalizedOption } from './internal';
|
|
4
|
+
import { GridLines } from './components/GridLines';
|
|
5
|
+
import { PlotArea } from './components/PlotArea';
|
|
6
|
+
import { Axis } from './components/Axis';
|
|
7
|
+
import { Legend } from './components/Legend';
|
|
8
|
+
import { Title } from './components/Title';
|
|
9
|
+
import { Tooltip } from './components/Tooltip';
|
|
10
|
+
import { Crosshair } from './components/Crosshair';
|
|
11
|
+
import { Highlight } from './components/Highlight';
|
|
12
|
+
import { Brush } from './components/Brush';
|
|
13
|
+
import { RadarGrid } from './components/RadarGrid';
|
|
14
|
+
import { PolarGrid } from './components/PolarGrid';
|
|
15
|
+
import { DataZoomSlider } from './components/DataZoomSlider';
|
|
16
|
+
import type { SeriesBase } from './components/series/SeriesBase';
|
|
17
|
+
import { InteractionController } from './interaction/InteractionController';
|
|
18
|
+
import { type A11yTreeOptions, type DataTable } from './a11y';
|
|
19
|
+
/** 快照格式版本:结构变化时递增,还原时校验。 */
|
|
20
|
+
export declare const SNAPSHOT_VERSION = 1;
|
|
21
|
+
export { setMotionPreference, getMotionPreference, shouldAnimate } from './animation/motion';
|
|
22
|
+
export type { MotionPreference } from './animation/motion';
|
|
23
|
+
export interface SnapshotRestoreOptions {
|
|
24
|
+
/**
|
|
25
|
+
* 还原时叠加的非序列化配置补丁(formatter、函数型回调等)。
|
|
26
|
+
* series 按 id 或下标逐项合并,不会覆盖快照里的数据。
|
|
27
|
+
*/
|
|
28
|
+
optionPatch?: Partial<ChartOption> & {
|
|
29
|
+
series?: any[];
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface ChartSnapshot {
|
|
33
|
+
version: number;
|
|
34
|
+
option: ChartOption;
|
|
35
|
+
view: {
|
|
36
|
+
x: [any, any] | null;
|
|
37
|
+
y: [any, any] | null;
|
|
38
|
+
yAxes: Array<[any, any] | null>;
|
|
39
|
+
};
|
|
40
|
+
hidden: Record<string, boolean>;
|
|
41
|
+
hiddenSlices: Record<string, boolean>;
|
|
42
|
+
}
|
|
43
|
+
/** 判断一个对象是不是 ice-chart 快照(用于 createChart 的入参分派)。 */
|
|
44
|
+
export declare function isChartSnapshot(value: any): boolean;
|
|
45
|
+
/** 把补丁合进快照里的 option:series 按 id/下标逐项合并,其余字段浅覆盖。 */
|
|
46
|
+
export declare function mergeOptionPatch(base: any, patch: any): any;
|
|
47
|
+
export interface ICEChartOptions {
|
|
48
|
+
renderMode?: 'dirty-rect' | 'full';
|
|
49
|
+
dpr?: number;
|
|
50
|
+
/** 监听容器尺寸变化并自动重排(需要 ResizeObserver)。 */
|
|
51
|
+
autoResize?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface ApplyOptionOptions {
|
|
54
|
+
/** true = 播「更新」动画;'enter' = 播「入场」动画;false = 不播。 */
|
|
55
|
+
animate?: boolean | 'enter' | 'update';
|
|
56
|
+
/** 保留当前缩放窗口(图例切换、数据更新时用)。 */
|
|
57
|
+
preserveView?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* ICEChart:把一份声明式 option 编译成 ice-render 组件树,并挂上交互层。
|
|
61
|
+
*
|
|
62
|
+
* 分工:
|
|
63
|
+
* - 归一化(数据 → 数据域 / 堆叠)由 option/normalize 负责,纯函数、可单测;
|
|
64
|
+
* - 布局(标题 / 图例 / 坐标轴 / 绘图区)由 layout 负责,纯函数、可单测;
|
|
65
|
+
* - 渲染由 ice-render 组件负责(脏矩形局部重绘、离屏缓存、HiDPI 全部由引擎兜底);
|
|
66
|
+
* - 交互由 InteractionController 负责,对外只抛语义事件。
|
|
67
|
+
*/
|
|
68
|
+
export declare class ICEChart {
|
|
69
|
+
ice: ICE;
|
|
70
|
+
option: ChartOption;
|
|
71
|
+
norm: NormalizedOption;
|
|
72
|
+
layout: ChartLayout;
|
|
73
|
+
root: ICEGroup;
|
|
74
|
+
plotArea: PlotArea;
|
|
75
|
+
grid: GridLines;
|
|
76
|
+
radarGrid: RadarGrid;
|
|
77
|
+
/** 极坐标网格(r(θ) 曲线用;画在直角坐标场景里,配合 aspect:'equal')。 */
|
|
78
|
+
polarGrid: PolarGrid;
|
|
79
|
+
axisX: Axis;
|
|
80
|
+
/** y 轴组件,与 norm.yAxes 一一对应(axisYList[0] 是主 y 轴)。 */
|
|
81
|
+
axisYList: Axis[];
|
|
82
|
+
legend: Legend | null;
|
|
83
|
+
titleComponent: Title | null;
|
|
84
|
+
tooltip: Tooltip | null;
|
|
85
|
+
crosshair: Crosshair | null;
|
|
86
|
+
highlight: Highlight | null;
|
|
87
|
+
brushComponent: Brush | null;
|
|
88
|
+
dataZoomSlider: DataZoomSlider | null;
|
|
89
|
+
seriesComponents: SeriesBase[];
|
|
90
|
+
controller: InteractionController;
|
|
91
|
+
/** 交互层使用的别名(与 InteractionHost 接口约定一致)。 */
|
|
92
|
+
get brush(): Brush | null;
|
|
93
|
+
/** 未经缩放/筛选的完整数据域(缩放约束与跨图联动用)。 */
|
|
94
|
+
fullXDomain: any[];
|
|
95
|
+
fullYDomain: any[];
|
|
96
|
+
/** 每个 y 轴的完整数据域(未缩放)。 */
|
|
97
|
+
fullYDomains: any[][];
|
|
98
|
+
private emitter;
|
|
99
|
+
private canvasEl;
|
|
100
|
+
private chartOptions;
|
|
101
|
+
private viewState;
|
|
102
|
+
/** 存在 function 系列时为真:y 轴数据域每次重建都按可视 x 区间重算(自动贴合)。 */
|
|
103
|
+
private autoYCurve;
|
|
104
|
+
private hiddenIds;
|
|
105
|
+
private hiddenSlices;
|
|
106
|
+
private seriesSignature;
|
|
107
|
+
private axisSignature;
|
|
108
|
+
private resizeObserver;
|
|
109
|
+
private destroyed;
|
|
110
|
+
/** 抑制对外事件的重入深度(跨图联动时避免 A→B→A 的回环)。 */
|
|
111
|
+
private silenceDepth;
|
|
112
|
+
private a11yMirror;
|
|
113
|
+
/**
|
|
114
|
+
* 更新动画期间的坐标轴数据域过渡。
|
|
115
|
+
*
|
|
116
|
+
* 数据更新时 y 轴数据域常常会变(例如最大值从 50 掉到 40),如果域瞬跳,
|
|
117
|
+
* 柱子会在动画**开始的那一帧**整体位移一下,值插值反而看不见。
|
|
118
|
+
* 所以域要和系列的值一起插值:每帧按同一进度重算域与坐标,动画结束时再回到常规路径。
|
|
119
|
+
*/
|
|
120
|
+
private domainTransition;
|
|
121
|
+
private domainFrameHandler;
|
|
122
|
+
constructor(target: any, option: ChartOption, chartOptions?: ICEChartOptions);
|
|
123
|
+
/** 更新配置。默认保留当前缩放窗口,可用 resetZoom 恢复。 */
|
|
124
|
+
setOption(option: ChartOption, options?: ApplyOptionOptions): this;
|
|
125
|
+
/** 取当前配置(函数字段保留;持久化请用 toJSON)。 */
|
|
126
|
+
getOption(): ChartOption;
|
|
127
|
+
/**
|
|
128
|
+
* 函数绘图 / 参数曲线的表达式诊断(**回答「用户是不是写错了公式」**)。
|
|
129
|
+
*
|
|
130
|
+
* 三类都覆盖:
|
|
131
|
+
* - `error`:语法错误(带位置)、未定义的变量、在当前区间内没有任何可绘制的值;
|
|
132
|
+
* - `warning`:参数定义了没用上、输出恒定(画出来是一条水平线)。
|
|
133
|
+
*
|
|
134
|
+
* 表达式来自用户输入,写错**不会**让图表崩掉(那会让表单很难用),
|
|
135
|
+
* 但错误必须能被拿到:表单据此标红 / 提示,控制台不必猜。
|
|
136
|
+
*/
|
|
137
|
+
expressionDiagnostics(): Array<{
|
|
138
|
+
seriesId: string;
|
|
139
|
+
diagnostics: NonNullable<InternalSeries['expressionDiagnostics']>;
|
|
140
|
+
}>;
|
|
141
|
+
/** 只取错误(标红用)。需要警告(提示用)请用 `expressionDiagnostics()`。 */
|
|
142
|
+
expressionErrors(): Array<{
|
|
143
|
+
seriesId: string;
|
|
144
|
+
message: string;
|
|
145
|
+
}>;
|
|
146
|
+
/** 更新单个系列的数据。 */
|
|
147
|
+
setData(seriesIdOrIndex: string | number, data: DataItem[]): this;
|
|
148
|
+
/**
|
|
149
|
+
* **追加**数据(实时数据流专用):把新点接到系列末尾,超出 `maxPoints` 时从头裁掉,
|
|
150
|
+
* 形成滑动窗口。相对 `setData` 的两点差别:
|
|
151
|
+
*
|
|
152
|
+
* 1. **不做值插值**(`animate` 默认 false):窗口滑动会让下标整体前移,
|
|
153
|
+
* 插值会把「这一点」插向「下一点的值」,看起来像被拖住。
|
|
154
|
+
* 流畅度由推送频率决定(60Hz 推送就是 60fps 的平滑滚动);
|
|
155
|
+
* 2. 只重算被追加的系列所在的那条链路(走 `applyOption` 的常规更新路径,`preserveView` 保持缩放窗口)。
|
|
156
|
+
*
|
|
157
|
+
* ```ts
|
|
158
|
+
* chart.appendData('cpu', [[t, value]], { maxPoints: 180 });
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
appendData(seriesIdOrIndex: string | number, items: DataItem[], options?: {
|
|
162
|
+
maxPoints?: number;
|
|
163
|
+
animate?: boolean;
|
|
164
|
+
}): this;
|
|
165
|
+
/** 设置数据域(缩放 / 联动入口)。 */
|
|
166
|
+
setDomain(axis: 'x' | 'y', domain: any[], source?: string): this;
|
|
167
|
+
/** 恢复完整数据域。 */
|
|
168
|
+
resetZoom(): this;
|
|
169
|
+
/** 切换系列显隐(图例点击、程序化控制都走这里)。 */
|
|
170
|
+
toggleSeries(seriesId: string, forceSelected?: boolean): this;
|
|
171
|
+
isSeriesSelected(seriesId: string): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* 切换饼图扇区显隐(极坐标图例点击走这里)。
|
|
174
|
+
* 扇区键是 `seriesId#dataIndex`,与系列显隐彼此独立。
|
|
175
|
+
*/
|
|
176
|
+
toggleSlice(seriesId: string, dataIndex: number, forceSelected?: boolean): this;
|
|
177
|
+
/** 键盘 / 程序化焦点:把悬停定位到某个数据点。 */
|
|
178
|
+
showHoverAt(seriesId: string, dataIndex: number): this;
|
|
179
|
+
/** 跨图联动:按 x 数据值显示悬停。 */
|
|
180
|
+
showHoverAtValue(xValue: any): this;
|
|
181
|
+
clearHover(): this;
|
|
182
|
+
getSelection(): any[];
|
|
183
|
+
clearSelection(): this;
|
|
184
|
+
/** 当前数据域。 */
|
|
185
|
+
getDomain(axis: 'x' | 'y'): any[];
|
|
186
|
+
/** 指定 y 轴的数据域(多轴叠加时按 index 区分)。 */
|
|
187
|
+
getAxisDomain(index: number): any[];
|
|
188
|
+
/** 设置指定 y 轴的数据域(多轴叠加时的程序化控制)。 */
|
|
189
|
+
setAxisDomain(index: number, domain: any[], source?: string): this;
|
|
190
|
+
/** 完整数据域(未缩放)。 */
|
|
191
|
+
fullDomain(axis: 'x' | 'y'): any[];
|
|
192
|
+
/** canvas 元素(无障碍镜像等 DOM 相关能力需要)。 */
|
|
193
|
+
get canvasElement(): any;
|
|
194
|
+
/** 数据表:屏幕阅读器可直接读取的「图表等价文本」。 */
|
|
195
|
+
getDataTable(): DataTable;
|
|
196
|
+
/**
|
|
197
|
+
* 无障碍节点树:引擎的组件树 + 逐数据点的虚拟节点。
|
|
198
|
+
* 应用层可据此构建自己的 DOM 镜像(焦点环、行内提示等)。
|
|
199
|
+
*/
|
|
200
|
+
getA11yTree(options?: A11yTreeOptions): any[];
|
|
201
|
+
/**
|
|
202
|
+
* 在 canvas 旁挂载视觉隐藏的数据表 + aria-live 播报区,
|
|
203
|
+
* 让屏幕阅读器既能读到整张数据表,也能听到当前悬停/键盘导航到的数据点。
|
|
204
|
+
*/
|
|
205
|
+
attachA11yMirror(): boolean;
|
|
206
|
+
detachA11yMirror(): void;
|
|
207
|
+
get a11yMirrorAttached(): boolean;
|
|
208
|
+
/** 手动播报一段无障碍文本(自定义交互时用)。 */
|
|
209
|
+
announceA11y(text: string): void;
|
|
210
|
+
on(event: string, fn: (payload: any) => void, scope?: any): this;
|
|
211
|
+
once(event: string, fn: (payload: any) => void, scope?: any): this;
|
|
212
|
+
off(event: string, fn?: (payload: any) => void, scope?: any): this;
|
|
213
|
+
emit(event: string, payload?: any): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* 在「静默」状态下执行一段操作:期间抛出的事件不会对外广播。
|
|
216
|
+
* 跨图联动用它打断 A→B→A 的事件回环,同时保留内部的视觉更新。
|
|
217
|
+
*/
|
|
218
|
+
silent<T>(fn: () => T): T;
|
|
219
|
+
/** 手动重排(响应式容器变化时调用)。不传尺寸则读取 canvas 的内容盒尺寸。 */
|
|
220
|
+
resize(cssWidth?: number, cssHeight?: number): this;
|
|
221
|
+
destroy(): void;
|
|
222
|
+
/** 等待下一帧渲染完成(测试与截图场景很有用)。 */
|
|
223
|
+
nextFrame(): Promise<void>;
|
|
224
|
+
/** 便捷方法:立即标脏并等待一帧(等价于 requestRender + nextFrame)。 */
|
|
225
|
+
render(): Promise<void>;
|
|
226
|
+
/** 文本格式化(坐标轴 / 提示框共用)。 */
|
|
227
|
+
formatAxisValue(axis: 'x' | 'y', value: any): string;
|
|
228
|
+
/** 导出成图片(透传引擎的 canvas 能力):常用于「保存为 PNG」。 */
|
|
229
|
+
toDataURL(type?: string, quality?: any): string;
|
|
230
|
+
/** 导出成 Blob(浏览器环境)。 */
|
|
231
|
+
toBlob(callback: (blob: any) => void, type?: string, quality?: any): void;
|
|
232
|
+
/**
|
|
233
|
+
* 从快照还原一个图表(静态工厂,等价于先 new 再 fromJSONObject)。
|
|
234
|
+
*
|
|
235
|
+
* ```ts
|
|
236
|
+
* const json = chart.toJSONString();
|
|
237
|
+
* const restored = ICEChart.restore('canvas-2', json);
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
static restore(target: any, snapshot: ChartSnapshot | string, options?: SnapshotRestoreOptions & {
|
|
241
|
+
chartOptions?: ICEChartOptions;
|
|
242
|
+
initialOption?: ChartOption;
|
|
243
|
+
}): ICEChart;
|
|
244
|
+
/**
|
|
245
|
+
* 导出图表快照(可 JSON 化)。
|
|
246
|
+
*
|
|
247
|
+
* 序列化的**唯一事实来源是 option**(声明式规格),不是引擎的组件树:
|
|
248
|
+
* 组件树只是 option 的渲染投影,里面没有数据语义(比例尺、数据点、命中缓存),
|
|
249
|
+
* 反序列化一棵组件树只会得到一个空壳。所以这里存的是
|
|
250
|
+
* 「option + 视图窗口 + 图例/扇区显隐」,这三样足以完整重建图形。
|
|
251
|
+
*
|
|
252
|
+
* 注意:函数字段(formatter 等)无法进 JSON,导出时会被丢弃;
|
|
253
|
+
* 还原时用 `restore(target, snapshot, { optionPatch })` 或 `fromJSONObject(snapshot, { patch })` 补回来。
|
|
254
|
+
*/
|
|
255
|
+
toJSON(): {
|
|
256
|
+
version: number;
|
|
257
|
+
option: ChartOption;
|
|
258
|
+
view: {
|
|
259
|
+
x: [any, any] | null;
|
|
260
|
+
y: [any, any] | null;
|
|
261
|
+
yAxes: Array<[any, any] | null>;
|
|
262
|
+
};
|
|
263
|
+
hidden: Record<string, boolean>;
|
|
264
|
+
hiddenSlices: Record<string, boolean>;
|
|
265
|
+
};
|
|
266
|
+
toJSONString(): string;
|
|
267
|
+
fromJSONString(json: string, options?: SnapshotRestoreOptions): this;
|
|
268
|
+
fromJSONObject(snapshot: any, options?: SnapshotRestoreOptions): this;
|
|
269
|
+
private loadSnapshot;
|
|
270
|
+
private applyOption;
|
|
271
|
+
/** dataZoom 的 start/end 只影响初始窗口。 */
|
|
272
|
+
private initialWindow;
|
|
273
|
+
/** 用当前 viewState 重新归一化 → 布局 → 同步组件。 */
|
|
274
|
+
/** 启动数据域过渡:每帧按系列动画进度插值 y 轴数据域。 */
|
|
275
|
+
private startDomainTransition;
|
|
276
|
+
private stepDomainTransition;
|
|
277
|
+
private stopDomainTransition;
|
|
278
|
+
private rebuild;
|
|
279
|
+
private buildScales;
|
|
280
|
+
private syncComponents;
|
|
281
|
+
/** 当前 x 数据域在完整数据域中的比例窗口(0~1),供 dataZoom 滑块显示。 */
|
|
282
|
+
domainFractions(): [number, number];
|
|
283
|
+
/** 由 dataZoom 滑块的比例窗口反推数据域。 */
|
|
284
|
+
setDomainFromFractions(start: number, end: number, source?: string): this;
|
|
285
|
+
/** 让 y 轴组件数量 / 位置与 norm.yAxes 保持一致(轴数量变化时增删组件)。 */
|
|
286
|
+
private syncAxisComponents;
|
|
287
|
+
private syncSeries;
|
|
288
|
+
/**
|
|
289
|
+
* 让引擎的 AnimationManager 把 progress 从 0 推到 1。
|
|
290
|
+
*
|
|
291
|
+
* 实测(`hitTest` 逐帧采样):引擎在补间期间把 `interactive` 置 false 只发生在
|
|
292
|
+
* 同一帧的同步块内(保存→置 false→补间→恢复),事件处理与命中检测看不到,
|
|
293
|
+
* 所以动画期间交互照常可用 —— 不需要额外的「驱动组件」绕开它。
|
|
294
|
+
*/
|
|
295
|
+
playStage(seriesComponent: SeriesBase, stage: {
|
|
296
|
+
duration?: number;
|
|
297
|
+
delay?: number;
|
|
298
|
+
easing?: string;
|
|
299
|
+
stagger?: number;
|
|
300
|
+
kind?: 'enter' | 'update';
|
|
301
|
+
}): void;
|
|
302
|
+
/** 兼容旧 API:按「入场」阶段播放。 */
|
|
303
|
+
playEnter(seriesComponent: SeriesBase, duration: number, easing: string): void;
|
|
304
|
+
/** 把当前所有未完成的动画一次性推到终态(截图 / 测试 / 无障碍瞬时模式用)。 */
|
|
305
|
+
finishAnimations(): this;
|
|
306
|
+
private currentRange;
|
|
307
|
+
private clampDomain;
|
|
308
|
+
/** index = -1 表示 x 轴,>=0 表示对应的 y 轴。 */
|
|
309
|
+
private clampAxisDomain;
|
|
310
|
+
private canvasRect;
|
|
311
|
+
private observeResize;
|
|
312
|
+
private registerTypes;
|
|
313
|
+
}
|
|
314
|
+
/** 计算分组柱形的槽位:同 stack 的系列共用一个槽,其余各自一槽。 */
|
|
315
|
+
export declare function computeBarSlots(series: InternalSeries[]): Record<string, {
|
|
316
|
+
index: number;
|
|
317
|
+
count: number;
|
|
318
|
+
}>;
|
|
319
|
+
/** 某个饼图系列里被隐藏的扇区下标。 */
|
|
320
|
+
export declare function hiddenSliceIndexes(norm: NormalizedOption, seriesId: string): number[];
|
|
321
|
+
/**
|
|
322
|
+
* 工厂函数:第二个参数既可以是声明式 option,也可以是 `toJSON()` 产出的快照。
|
|
323
|
+
*
|
|
324
|
+
* ```ts
|
|
325
|
+
* const chart = createChart('canvas-1', option);
|
|
326
|
+
* const snapshot = chart.toJSONString();
|
|
327
|
+
* const restored = createChart('canvas-2', snapshot); // 直接吃快照
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
export declare function createChart(target: any, optionOrSnapshot: ChartOption | ChartSnapshot | string, chartOptions?: ICEChartOptions): ICEChart;
|