@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.
Files changed (132) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +530 -0
  3. package/dist/index.cjs +25 -0
  4. package/dist/index.mjs +25 -0
  5. package/dist/index.umd.js +25 -0
  6. package/dist/types/ICEChart.d.mts +330 -0
  7. package/dist/types/ICEChart.d.ts +330 -0
  8. package/dist/types/a11y.d.mts +85 -0
  9. package/dist/types/a11y.d.ts +85 -0
  10. package/dist/types/animation/motion.d.mts +11 -0
  11. package/dist/types/animation/motion.d.ts +11 -0
  12. package/dist/types/components/Axis.d.mts +60 -0
  13. package/dist/types/components/Axis.d.ts +60 -0
  14. package/dist/types/components/Brush.d.mts +19 -0
  15. package/dist/types/components/Brush.d.ts +19 -0
  16. package/dist/types/components/ChartComponent.d.mts +48 -0
  17. package/dist/types/components/ChartComponent.d.ts +48 -0
  18. package/dist/types/components/Crosshair.d.mts +40 -0
  19. package/dist/types/components/Crosshair.d.ts +40 -0
  20. package/dist/types/components/DataZoomSlider.d.mts +30 -0
  21. package/dist/types/components/DataZoomSlider.d.ts +30 -0
  22. package/dist/types/components/GridLines.d.mts +37 -0
  23. package/dist/types/components/GridLines.d.ts +37 -0
  24. package/dist/types/components/Highlight.d.mts +34 -0
  25. package/dist/types/components/Highlight.d.ts +34 -0
  26. package/dist/types/components/Legend.d.mts +26 -0
  27. package/dist/types/components/Legend.d.ts +26 -0
  28. package/dist/types/components/PlotArea.d.mts +21 -0
  29. package/dist/types/components/PlotArea.d.ts +21 -0
  30. package/dist/types/components/PolarGrid.d.mts +34 -0
  31. package/dist/types/components/PolarGrid.d.ts +34 -0
  32. package/dist/types/components/RadarGrid.d.mts +25 -0
  33. package/dist/types/components/RadarGrid.d.ts +25 -0
  34. package/dist/types/components/Title.d.mts +14 -0
  35. package/dist/types/components/Title.d.ts +14 -0
  36. package/dist/types/components/Tooltip.d.mts +48 -0
  37. package/dist/types/components/Tooltip.d.ts +48 -0
  38. package/dist/types/components/series/AreaSeries.d.mts +14 -0
  39. package/dist/types/components/series/AreaSeries.d.ts +14 -0
  40. package/dist/types/components/series/BarSeries.d.mts +39 -0
  41. package/dist/types/components/series/BarSeries.d.ts +39 -0
  42. package/dist/types/components/series/BoxplotSeries.d.mts +16 -0
  43. package/dist/types/components/series/BoxplotSeries.d.ts +16 -0
  44. package/dist/types/components/series/CandlestickSeries.d.mts +13 -0
  45. package/dist/types/components/series/CandlestickSeries.d.ts +13 -0
  46. package/dist/types/components/series/CurveSeriesBase.d.mts +58 -0
  47. package/dist/types/components/series/CurveSeriesBase.d.ts +58 -0
  48. package/dist/types/components/series/FunctionSeries.d.mts +22 -0
  49. package/dist/types/components/series/FunctionSeries.d.ts +22 -0
  50. package/dist/types/components/series/FunnelSeries.d.mts +38 -0
  51. package/dist/types/components/series/FunnelSeries.d.ts +38 -0
  52. package/dist/types/components/series/GaugeSeries.d.mts +45 -0
  53. package/dist/types/components/series/GaugeSeries.d.ts +45 -0
  54. package/dist/types/components/series/GraphSeries.d.mts +39 -0
  55. package/dist/types/components/series/GraphSeries.d.ts +39 -0
  56. package/dist/types/components/series/HeatmapSeries.d.mts +21 -0
  57. package/dist/types/components/series/HeatmapSeries.d.ts +21 -0
  58. package/dist/types/components/series/LineSeries.d.mts +31 -0
  59. package/dist/types/components/series/LineSeries.d.ts +31 -0
  60. package/dist/types/components/series/LiquidSeries.d.mts +55 -0
  61. package/dist/types/components/series/LiquidSeries.d.ts +55 -0
  62. package/dist/types/components/series/ParametricSeries.d.mts +30 -0
  63. package/dist/types/components/series/ParametricSeries.d.ts +30 -0
  64. package/dist/types/components/series/PieSeries.d.mts +44 -0
  65. package/dist/types/components/series/PieSeries.d.ts +44 -0
  66. package/dist/types/components/series/RadarSeries.d.mts +30 -0
  67. package/dist/types/components/series/RadarSeries.d.ts +30 -0
  68. package/dist/types/components/series/SankeySeries.d.mts +34 -0
  69. package/dist/types/components/series/SankeySeries.d.ts +34 -0
  70. package/dist/types/components/series/ScatterSeries.d.mts +11 -0
  71. package/dist/types/components/series/ScatterSeries.d.ts +11 -0
  72. package/dist/types/components/series/SeriesBase.d.mts +214 -0
  73. package/dist/types/components/series/SeriesBase.d.ts +214 -0
  74. package/dist/types/components/series/TreemapSeries.d.mts +48 -0
  75. package/dist/types/components/series/TreemapSeries.d.ts +48 -0
  76. package/dist/types/components/series/WaterfallSeries.d.mts +17 -0
  77. package/dist/types/components/series/WaterfallSeries.d.ts +17 -0
  78. package/dist/types/components/series/createSeries.d.mts +10 -0
  79. package/dist/types/components/series/createSeries.d.ts +10 -0
  80. package/dist/types/components/series/index.d.mts +29 -0
  81. package/dist/types/components/series/index.d.ts +29 -0
  82. package/dist/types/expr/diagnostics.d.mts +45 -0
  83. package/dist/types/expr/diagnostics.d.ts +45 -0
  84. package/dist/types/expr/expr.d.mts +44 -0
  85. package/dist/types/expr/expr.d.ts +44 -0
  86. package/dist/types/expr/sample.d.mts +34 -0
  87. package/dist/types/expr/sample.d.ts +34 -0
  88. package/dist/types/index.d.mts +80 -0
  89. package/dist/types/index.d.ts +80 -0
  90. package/dist/types/interaction/ChartLink.d.mts +16 -0
  91. package/dist/types/interaction/ChartLink.d.ts +16 -0
  92. package/dist/types/interaction/HitResolver.d.mts +44 -0
  93. package/dist/types/interaction/HitResolver.d.ts +44 -0
  94. package/dist/types/interaction/InteractionController.d.mts +147 -0
  95. package/dist/types/interaction/InteractionController.d.ts +147 -0
  96. package/dist/types/internal.d.mts +232 -0
  97. package/dist/types/internal.d.ts +232 -0
  98. package/dist/types/layout/force.d.mts +48 -0
  99. package/dist/types/layout/force.d.ts +48 -0
  100. package/dist/types/layout/layout.d.mts +9 -0
  101. package/dist/types/layout/layout.d.ts +9 -0
  102. package/dist/types/layout/sankey.d.mts +47 -0
  103. package/dist/types/layout/sankey.d.ts +47 -0
  104. package/dist/types/layout/treemap.d.mts +35 -0
  105. package/dist/types/layout/treemap.d.ts +35 -0
  106. package/dist/types/option/normalize.d.mts +68 -0
  107. package/dist/types/option/normalize.d.ts +68 -0
  108. package/dist/types/scale/BandScale.d.mts +36 -0
  109. package/dist/types/scale/BandScale.d.ts +36 -0
  110. package/dist/types/scale/LinearScale.d.mts +21 -0
  111. package/dist/types/scale/LinearScale.d.ts +21 -0
  112. package/dist/types/scale/LogScale.d.mts +24 -0
  113. package/dist/types/scale/LogScale.d.ts +24 -0
  114. package/dist/types/scale/Scale.d.mts +38 -0
  115. package/dist/types/scale/Scale.d.ts +38 -0
  116. package/dist/types/scale/TimeScale.d.mts +28 -0
  117. package/dist/types/scale/TimeScale.d.ts +28 -0
  118. package/dist/types/scale/format.d.mts +5 -0
  119. package/dist/types/scale/format.d.ts +5 -0
  120. package/dist/types/scale/index.d.mts +7 -0
  121. package/dist/types/scale/index.d.ts +7 -0
  122. package/dist/types/theme/chartTheme.d.mts +54 -0
  123. package/dist/types/theme/chartTheme.d.ts +54 -0
  124. package/dist/types/types.d.mts +689 -0
  125. package/dist/types/types.d.ts +689 -0
  126. package/dist/types/util/emitter.d.mts +11 -0
  127. package/dist/types/util/emitter.d.ts +11 -0
  128. package/dist/types/util/math.d.mts +14 -0
  129. package/dist/types/util/math.d.ts +14 -0
  130. package/dist/types/util/text.d.mts +10 -0
  131. package/dist/types/util/text.d.ts +10 -0
  132. package/package.json +100 -0
@@ -0,0 +1,214 @@
1
+ import { ChartComponent } from '../ChartComponent';
2
+ import type { ChartTheme, SeriesType } from '../../types';
3
+ import type { DataPoint, InternalSeries, Rect } from '../../internal';
4
+ import type { Scale } from '../../scale';
5
+ export interface SeriesCoord {
6
+ plot: Rect;
7
+ canvas: Rect;
8
+ xScale: Scale;
9
+ yScale: Scale;
10
+ /** 该系列绑定的 y 轴下标。 */
11
+ yAxisIndex?: number;
12
+ theme: ChartTheme;
13
+ }
14
+ export interface BarSlot {
15
+ index: number;
16
+ count: number;
17
+ }
18
+ /**
19
+ * 系列基类:数据 → 像素的缓存、动画插值、命中判定都收敛在这里。
20
+ *
21
+ * 三件事值得注意:
22
+ *
23
+ * 1. **像素缓存**:数据点的像素坐标只在数据 / 比例尺 / 尺寸变化时重算一次,
24
+ * render 与命中判定共用同一份缓存 —— 保证「画出来的样子」和「点得到的位置」必然一致。
25
+ *
26
+ * 2. **命中判定进引擎**:`containsLocalPoint` 由子类实现为「按数据语义判定」,
27
+ * 于是 `ice.hitTest()` / 引擎事件派发天然就能分辨「点在折线上」还是「点在空白处」,
28
+ * 不需要在图表外面再写一套坐标反查。
29
+ *
30
+ * 3. **动画走引擎的 AnimationManager**:`state.progress` 由引擎逐帧写入,
31
+ * 本组件按 progress 在「上一份数据的有效值」与「新数据」之间插值。
32
+ */
33
+ export declare abstract class SeriesBase extends ChartComponent {
34
+ abstract seriesType: SeriesType;
35
+ series: InternalSeries;
36
+ /** 图表主题(由 Chart 注入,供绘制标签 / 文本使用)。 */
37
+ chartTheme: ChartTheme | null;
38
+ /** 被隐藏的数据项下标(饼图扇区 / 漏斗阶段)。 */
39
+ hiddenSlices: number[];
40
+ coord: SeriesCoord | null;
41
+ /** 分组柱形的位置(由 Chart 计算)。 */
42
+ barSlot: BarSlot;
43
+ /** 每个点的像素坐标,2n 长度,[x0,y0,x1,y1,...];缺失点为 NaN。 */
44
+ protected pixels: Float64Array;
45
+ /** 每个点的有效数据值 [base, top],用于动画插值与柱形绘制。 */
46
+ protected effective: Float64Array;
47
+ /** 上一帧的有效值,作为动画起点。 */
48
+ protected fromEffective: Float64Array | null;
49
+ /** 实际参与绘制的点下标(降采样后可能少于总点数);null 表示全部点。 */
50
+ protected renderIndices: number[] | null;
51
+ /** 像素 x 是否单调递增(降采样与二分查找的前提)。 */
52
+ protected xMonotonic: boolean;
53
+ /** 第三维(气泡尺寸)的取值范围,映射到 symbolSizeRange。 */
54
+ protected sizeExtent: [number, number];
55
+ /** 每个数据项各自的动画进度(错峰入场用),0~1。 */
56
+ protected itemProgress: Float64Array;
57
+ /** 错峰比例:0 = 所有项同时动画。 */
58
+ protected stagger: number;
59
+ /** 当前动画阶段:enter 可以「画出来」,update 只能「动起来」。 */
60
+ protected animationKind: 'enter' | 'update';
61
+ /** 当前悬停的数据项(0 表示没有)。 */
62
+ hoverIndex: number | null;
63
+ private cacheKey;
64
+ /** 散点等「每个点都必须画」的系列不参与降采样。 */
65
+ protected supportsSampling: boolean;
66
+ /**
67
+ * 是否把绘制裁剪到组件盒(= 本场景的绘图区)。
68
+ *
69
+ * 直角坐标系列必须开:缩放后落在窗口外的数据点会被映射到很远的位置,
70
+ * 不裁剪就会一路画到 y 轴标签、图例甚至画布外面去(用户实测反馈的问题)。
71
+ * 折线要的是「被绘图区边缘裁掉」,而不是「在边界处断开」,所以只能靠 clip,不能靠过滤点。
72
+ */
73
+ protected clipToBox: boolean;
74
+ private localBoxScratch;
75
+ constructor(series: InternalSeries, props: {
76
+ left: number;
77
+ top: number;
78
+ width: number;
79
+ height: number;
80
+ zIndex?: number;
81
+ });
82
+ /** 组件本地盒向四周外扩,容纳线宽、标记与阴影。 */
83
+ protected __localBox(): number[];
84
+ protected paintPad(): number;
85
+ /**
86
+ * 数据点尺寸:三种来源按优先级解析。
87
+ * 1. `symbolSize` 是函数 → 交给调用方决定;
88
+ * 2. 数据项带第三维(气泡图的 `[x, y, size]`)→ 按 series 内的取值范围映射到 `symbolSizeRange`;
89
+ * 3. 固定数值 `symbolSize`。
90
+ */
91
+ symbolSizeAt(index: number): number;
92
+ /** 本系列的最大标记尺寸(脏矩形留白与命中容差要用)。 */
93
+ protected maxSymbolSize(): number;
94
+ setCoord(coord: SeriesCoord): this;
95
+ /** 设置被隐藏的数据项(图表层在每次同步时写入)。 */
96
+ setHiddenSlices(indexes: number[]): this;
97
+ /** 图表层在每次播放动画前注入该阶段的配置(错峰比例会存下来供逐项计算)。 */
98
+ setAnimationStage(stage: {
99
+ stagger?: number;
100
+ kind?: 'enter' | 'update';
101
+ } | null | undefined): this;
102
+ /** 是否正在播「入场」动画(用于「画出来」这类只在入场成立的动效)。 */
103
+ protected isEntering(): boolean;
104
+ /** 单个数据项的动画进度:把整体进度按「波浪」拆到每一项。 */
105
+ protected progressFor(index: number, total: number): number;
106
+ /** 每项进度的缓存(数据量变化时重建)。 */
107
+ protected computeItemProgress(): void;
108
+ /** 当前动画状态(测试与调试用;不参与序列化)。 */
109
+ getAnimationState(): {
110
+ progress: number;
111
+ kind: 'enter' | 'update';
112
+ stagger: number;
113
+ itemProgress: number[];
114
+ };
115
+ /**
116
+ * 设置/清除悬停项,并用引擎动画把 `highlightT` 从 0 推到 1(或反向)。
117
+ *
118
+ * 反馈动画由组件自己启动:它持有 `ice.animationManager`,不需要图表层代劳,
119
+ * 这样「悬停哪个图元」这件事就完全收敛在系列内部。
120
+ */
121
+ setHoverIndex(index: number | null): void;
122
+ /** 悬停反馈的进度(0~1)。 */
123
+ highlightT(): number;
124
+ /** 某个数据项当前的高亮强度:只有被悬停的那一项 > 0。 */
125
+ protected hoverBoost(index: number, amount?: number, t?: number): number;
126
+ /** 悬停叠加层的强度(0~1):只有被悬停的那一项 > 0。 */
127
+ protected hoverAlpha(index: number): number;
128
+ /**
129
+ * 在被悬停的矩形上叠一层「提亮 + 描边」。
130
+ *
131
+ * 刻意**只叠加、不改几何**:像热力图 / 树图 / K 线这种相邻图元紧挨着的类型,
132
+ * 改宽高会让命中区域与渲染区域分叉(指针停在边缘会来回抖),
133
+ * 叠加描边既能表达强调,又完全不动命中判定。
134
+ */
135
+ protected drawHoverOverlay(index: number, rect: Rect, options?: {
136
+ radius?: number;
137
+ fill?: string;
138
+ stroke?: string;
139
+ lineWidth?: number;
140
+ }): void;
141
+ /**
142
+ * 派生几何的缓存键。
143
+ *
144
+ * **必须**把参与动画的 state 字段一起放进来(progress / 阶段 / 错峰),
145
+ * 否则动画期间键不变、缓存命中,几何会冻结在动画开始的那一帧。
146
+ * 子类覆写 `rebuildPixels` 时用自己的几何参数组键,请一律走这个方法。
147
+ */
148
+ protected buildSeriesKey(parts: Array<any>): string;
149
+ /**
150
+ * 坐标系指纹:绘图区矩形 + 各比例尺的数据域。
151
+ *
152
+ * 子类自己拼键时最容易漏的就是数据域 —— 表面看不出来,实际后果是
153
+ * **像素缓存不失效**:缩放 / 平移 / 数据域过渡之后 `pixels` 还是旧位置,
154
+ * 「看得见的点」与「点得到的点」就此分叉(悬停高亮画在别处、命中判空)。
155
+ * 只在键里放域的**端点 + 长度**,因为这个函数动画期间每帧都会被调用,不能全量 join。
156
+ */
157
+ private coordKey;
158
+ /**
159
+ * 替换数据。`animate` 为真时,把当前有效值记为动画起点(首次进入时从 0 开始),
160
+ * 由 Chart 触发引擎动画把 state.progress 从 0 推到 1。
161
+ */
162
+ updateSeries(series: InternalSeries, animate: boolean, preserveAnimation?: boolean): this;
163
+ /** 与当前绘制一致的像素位置;缺失点返回 null。 */
164
+ pixelAt(index: number): [number, number] | null;
165
+ /** 数据点的像素矩形(柱形用)。 */
166
+ barRectAt(_index: number): Rect | null;
167
+ /** 命中判定:返回数据下标,-1 表示未命中。入参是组件本地像素坐标。 */
168
+ abstract hitTestIndex(localX: number, localY: number): number;
169
+ protected containsLocalPoint(localX: number, localY: number): boolean;
170
+ protected progress(): number;
171
+ /** 计算每个点的有效数据值(含动画插值)。 */
172
+ protected computeEffective(): void;
173
+ /** 数据 → 像素(带缓存)。 */
174
+ protected rebuildPixels(force?: boolean): void;
175
+ /**
176
+ * 计算实际绘制的点下标。
177
+ *
178
+ * 默认策略:点数超过「绘图区宽度 × 3」时用 LTTB 抽稀 —— 一个像素宽度画 3 个点已经过剩,
179
+ * 继续画只是白白光栅化。首尾点与极值点一定保留,所以看起来仍然「像原曲线」。
180
+ * 命中判定不受影响,它始终读全量像素缓存。
181
+ */
182
+ protected buildRenderIndices(n: number, plotWidth: number): number[] | null;
183
+ /** 实际参与绘制的点数。 */
184
+ protected renderCount(): number;
185
+ /** 第 k 个参与绘制的点对应的原始下标。 */
186
+ protected renderIndexAt(k: number): number;
187
+ /**
188
+ * 按 x 像素找最近的数据下标。
189
+ *
190
+ * 单调数据用二分查找(大点数下每次 mousemove 都是 O(n) 会直接掉帧),
191
+ * 非单调数据退化为线性扫描。
192
+ */
193
+ nearestIndexAtX(localX: number): number;
194
+ private buildCacheKey;
195
+ /** 遍历像素点,跳过缺失点形成的断点。 */
196
+ protected eachSegment(fn: (x0: number, y0: number, x1: number, y1: number, i: number) => void): void;
197
+ protected pointColor(_index: number): string;
198
+ protected lineWidthDevice(): number;
199
+ protected opacity(): number;
200
+ protected beginDraw(): void;
201
+ protected endDraw(): void;
202
+ protected drawSymbol(x: number, y: number, shape: string, size: number, fill: string, stroke: string): void;
203
+ protected pointByIndex(index: number): DataPoint | null;
204
+ }
205
+ /**
206
+ * LTTB(Largest Triangle Three Buckets)抽稀。
207
+ *
208
+ * 输入是渲染用的像素点集(x/y 交错,含 NaN 断点),返回保留下来的下标数组。
209
+ * 首点与末点一定保留;每个桶内取「与前后桶均值构成三角形面积最大」的点,
210
+ * 因此尖峰不会被抹平 —— 这正是它比等间隔抽样更适合行情/监控曲线的原因。
211
+ */
212
+ export declare function lttbIndices(pixels: Float64Array, n: number, threshold: number): number[];
213
+ /** 数据点第三维的取值范围(气泡尺寸映射用)。 */
214
+ export declare function computeSizeExtent(points: DataPoint[]): [number, number];
@@ -0,0 +1,48 @@
1
+ import { SeriesBase } from './SeriesBase.mjs';
2
+ import type { SeriesType, TreemapOption } from '../../types.mjs';
3
+ import type { Rect } from '../../internal.mjs';
4
+ import type { TreemapNodeLayout } from '../../layout/treemap.mjs';
5
+ export interface TreemapSeriesCoord {
6
+ plot: Rect;
7
+ canvas: Rect;
8
+ /** 布局结果(图表坐标系)。 */
9
+ layout: TreemapNodeLayout[];
10
+ options: TreemapOption;
11
+ }
12
+ /**
13
+ * 矩形树图:用嵌套矩形表达层级数据的构成。
14
+ *
15
+ * 布局是纯函数(`layoutTreemap`),这里只负责绘制与命中。
16
+ * 命中返回**最深的那个节点**(点在大类目里的小类目上,命中的是小类目)。
17
+ */
18
+ export declare class TreemapSeries extends SeriesBase {
19
+ seriesType: SeriesType;
20
+ treemap: TreemapSeriesCoord | null;
21
+ protected clipToBox: boolean;
22
+ private treemapKey;
23
+ /** 更新动画的起点布局(按「层级:名称」索引,跨数据更新仍能对上同一个节点)。 */
24
+ private morphFrom;
25
+ private morphing;
26
+ /**
27
+ * 数据更新时记下当前布局,下一次渲染按进度在「旧矩形 → 新矩形」之间插值。
28
+ * 这是 treemap 最值钱的动画:布局一变,矩形是「长大/挪过去」而不是瞬间跳。
29
+ */
30
+ updateSeries(series: any, animate: boolean, preserveAnimation?: boolean): this;
31
+ /** 节点的当前矩形:更新动画期间在旧布局与新布局之间插值。 */
32
+ private rectCache;
33
+ /**
34
+ * 节点当前矩形。
35
+ *
36
+ * 关键点:**子节点在父节点的插值结果内部按相对位置缩放**,而不是各自独立插值。
37
+ * 独立插值会让兄弟矩形在中途拼不满父矩形(露出父色形成缺口/错位),
38
+ * 这是树图布局过渡最容易被忽略的视觉缺陷。
39
+ */
40
+ private rectOf;
41
+ setCoord(coord: any): this;
42
+ protected paintPad(): number;
43
+ highlightRectAt(index: number): Rect | null;
44
+ /** 像素缓存 = 每个节点的矩形中心。 */
45
+ protected rebuildPixels(): void;
46
+ hitTestIndex(localX: number, localY: number): number;
47
+ protected doRender(): void;
48
+ }
@@ -0,0 +1,48 @@
1
+ import { SeriesBase } from './SeriesBase';
2
+ import type { SeriesType, TreemapOption } from '../../types';
3
+ import type { Rect } from '../../internal';
4
+ import type { TreemapNodeLayout } from '../../layout/treemap';
5
+ export interface TreemapSeriesCoord {
6
+ plot: Rect;
7
+ canvas: Rect;
8
+ /** 布局结果(图表坐标系)。 */
9
+ layout: TreemapNodeLayout[];
10
+ options: TreemapOption;
11
+ }
12
+ /**
13
+ * 矩形树图:用嵌套矩形表达层级数据的构成。
14
+ *
15
+ * 布局是纯函数(`layoutTreemap`),这里只负责绘制与命中。
16
+ * 命中返回**最深的那个节点**(点在大类目里的小类目上,命中的是小类目)。
17
+ */
18
+ export declare class TreemapSeries extends SeriesBase {
19
+ seriesType: SeriesType;
20
+ treemap: TreemapSeriesCoord | null;
21
+ protected clipToBox: boolean;
22
+ private treemapKey;
23
+ /** 更新动画的起点布局(按「层级:名称」索引,跨数据更新仍能对上同一个节点)。 */
24
+ private morphFrom;
25
+ private morphing;
26
+ /**
27
+ * 数据更新时记下当前布局,下一次渲染按进度在「旧矩形 → 新矩形」之间插值。
28
+ * 这是 treemap 最值钱的动画:布局一变,矩形是「长大/挪过去」而不是瞬间跳。
29
+ */
30
+ updateSeries(series: any, animate: boolean, preserveAnimation?: boolean): this;
31
+ /** 节点的当前矩形:更新动画期间在旧布局与新布局之间插值。 */
32
+ private rectCache;
33
+ /**
34
+ * 节点当前矩形。
35
+ *
36
+ * 关键点:**子节点在父节点的插值结果内部按相对位置缩放**,而不是各自独立插值。
37
+ * 独立插值会让兄弟矩形在中途拼不满父矩形(露出父色形成缺口/错位),
38
+ * 这是树图布局过渡最容易被忽略的视觉缺陷。
39
+ */
40
+ private rectOf;
41
+ setCoord(coord: any): this;
42
+ protected paintPad(): number;
43
+ highlightRectAt(index: number): Rect | null;
44
+ /** 像素缓存 = 每个节点的矩形中心。 */
45
+ protected rebuildPixels(): void;
46
+ hitTestIndex(localX: number, localY: number): number;
47
+ protected doRender(): void;
48
+ }
@@ -0,0 +1,17 @@
1
+ import { BarSeries } from './BarSeries.mjs';
2
+ import type { SeriesType } from '../../types.mjs';
3
+ /**
4
+ * 瀑布图:在柱状图之上做两件事 ——
5
+ * 1. 每根柱子的颜色按「增 / 减 / 合计」区分;
6
+ * 2. 相邻柱子之间画一条连接虚线,标出累计值的传递。
7
+ *
8
+ * base/top 的累计在归一化阶段算好(见 applyWaterfall),所以几何直接复用柱状图。
9
+ */
10
+ export declare class WaterfallSeries extends BarSeries {
11
+ seriesType: SeriesType;
12
+ private isTotalItem;
13
+ private isIncrease;
14
+ /** 每根柱子的颜色:增(success)/ 减(danger)/ 合计(primary),可配置。 */
15
+ protected barColorAt(index: number): string;
16
+ protected doRender(): void;
17
+ }
@@ -0,0 +1,17 @@
1
+ import { BarSeries } from './BarSeries';
2
+ import type { SeriesType } from '../../types';
3
+ /**
4
+ * 瀑布图:在柱状图之上做两件事 ——
5
+ * 1. 每根柱子的颜色按「增 / 减 / 合计」区分;
6
+ * 2. 相邻柱子之间画一条连接虚线,标出累计值的传递。
7
+ *
8
+ * base/top 的累计在归一化阶段算好(见 applyWaterfall),所以几何直接复用柱状图。
9
+ */
10
+ export declare class WaterfallSeries extends BarSeries {
11
+ seriesType: SeriesType;
12
+ private isTotalItem;
13
+ private isIncrease;
14
+ /** 每根柱子的颜色:增(success)/ 减(danger)/ 合计(primary),可配置。 */
15
+ protected barColorAt(index: number): string;
16
+ protected doRender(): void;
17
+ }
@@ -0,0 +1,10 @@
1
+ import type { InternalSeries } from '../../internal.mjs';
2
+ import { SeriesBase } from './SeriesBase.mjs';
3
+ /** 按系列类型创建对应的渲染组件(工厂,便于后续扩展 candlestick / pie 等)。 */
4
+ export declare function createSeriesComponent(series: InternalSeries, props: {
5
+ left: number;
6
+ top: number;
7
+ width: number;
8
+ height: number;
9
+ zIndex?: number;
10
+ }): SeriesBase;
@@ -0,0 +1,10 @@
1
+ import type { InternalSeries } from '../../internal';
2
+ import { SeriesBase } from './SeriesBase';
3
+ /** 按系列类型创建对应的渲染组件(工厂,便于后续扩展 candlestick / pie 等)。 */
4
+ export declare function createSeriesComponent(series: InternalSeries, props: {
5
+ left: number;
6
+ top: number;
7
+ width: number;
8
+ height: number;
9
+ zIndex?: number;
10
+ }): SeriesBase;
@@ -0,0 +1,29 @@
1
+ export { SeriesBase } from './SeriesBase.mjs';
2
+ export type { SeriesCoord, BarSlot } from './SeriesBase.mjs';
3
+ export { LineSeries } from './LineSeries.mjs';
4
+ export { AreaSeries } from './AreaSeries.mjs';
5
+ export { ScatterSeries } from './ScatterSeries.mjs';
6
+ export { PieSeries } from './PieSeries.mjs';
7
+ export type { PolarSeriesCoord } from './PieSeries.mjs';
8
+ export { RadarSeries } from './RadarSeries.mjs';
9
+ export type { RadarSeriesCoord } from './RadarSeries.mjs';
10
+ export { CandlestickSeries } from './CandlestickSeries.mjs';
11
+ export { HeatmapSeries, mixColors } from './HeatmapSeries.mjs';
12
+ export { SankeySeries } from './SankeySeries.mjs';
13
+ export type { SankeySeriesCoord } from './SankeySeries.mjs';
14
+ export { FunnelSeries } from './FunnelSeries.mjs';
15
+ export type { FunnelSeriesCoord } from './FunnelSeries.mjs';
16
+ export { GaugeSeries } from './GaugeSeries.mjs';
17
+ export type { GaugeSeriesCoord } from './GaugeSeries.mjs';
18
+ export { BoxplotSeries } from './BoxplotSeries.mjs';
19
+ export { WaterfallSeries } from './WaterfallSeries.mjs';
20
+ export { TreemapSeries } from './TreemapSeries.mjs';
21
+ export type { TreemapSeriesCoord } from './TreemapSeries.mjs';
22
+ export { GraphSeries } from './GraphSeries.mjs';
23
+ export type { GraphSeriesCoord } from './GraphSeries.mjs';
24
+ export { CurveSeriesBase } from './CurveSeriesBase.mjs';
25
+ export { FunctionSeries } from './FunctionSeries.mjs';
26
+ export { ParametricSeries } from './ParametricSeries.mjs';
27
+ export { LiquidSeries } from './LiquidSeries.mjs';
28
+ export type { LiquidSeriesCoord } from './LiquidSeries.mjs';
29
+ export { BarSeries } from './BarSeries.mjs';
@@ -0,0 +1,29 @@
1
+ export { SeriesBase } from './SeriesBase';
2
+ export type { SeriesCoord, BarSlot } from './SeriesBase';
3
+ export { LineSeries } from './LineSeries';
4
+ export { AreaSeries } from './AreaSeries';
5
+ export { ScatterSeries } from './ScatterSeries';
6
+ export { PieSeries } from './PieSeries';
7
+ export type { PolarSeriesCoord } from './PieSeries';
8
+ export { RadarSeries } from './RadarSeries';
9
+ export type { RadarSeriesCoord } from './RadarSeries';
10
+ export { CandlestickSeries } from './CandlestickSeries';
11
+ export { HeatmapSeries, mixColors } from './HeatmapSeries';
12
+ export { SankeySeries } from './SankeySeries';
13
+ export type { SankeySeriesCoord } from './SankeySeries';
14
+ export { FunnelSeries } from './FunnelSeries';
15
+ export type { FunnelSeriesCoord } from './FunnelSeries';
16
+ export { GaugeSeries } from './GaugeSeries';
17
+ export type { GaugeSeriesCoord } from './GaugeSeries';
18
+ export { BoxplotSeries } from './BoxplotSeries';
19
+ export { WaterfallSeries } from './WaterfallSeries';
20
+ export { TreemapSeries } from './TreemapSeries';
21
+ export type { TreemapSeriesCoord } from './TreemapSeries';
22
+ export { GraphSeries } from './GraphSeries';
23
+ export type { GraphSeriesCoord } from './GraphSeries';
24
+ export { CurveSeriesBase } from './CurveSeriesBase';
25
+ export { FunctionSeries } from './FunctionSeries';
26
+ export { ParametricSeries } from './ParametricSeries';
27
+ export { LiquidSeries } from './LiquidSeries';
28
+ export type { LiquidSeriesCoord } from './LiquidSeries';
29
+ export { BarSeries } from './BarSeries';
@@ -0,0 +1,45 @@
1
+ /**
2
+ * 表达式诊断:回答「用户是不是胡乱输入了公式」这个问题。
3
+ *
4
+ * 编译错误只是第一层。真实场景里更常见、也更难自己发现的是**能编译但画不出来**:
5
+ * `b*x`(b 没定义)、`sqrt(-x)`(整段都是 NaN)、`sin(0)`(画出来是一条常数线
6
+ * ——不一定是错,但通常不是本意)。这些以前都是静默的,用户只看到「一片空白」。
7
+ *
8
+ * 这里把三层检查合成一份结构化结果,交给表单去标红 / 提示:
9
+ * 1. **语法层**:编译失败(含位置),由 `ExpressionError.code` 分类;
10
+ * 2. **静态层**:变量没定义(对比「自变量 + params」)、参数定义了却没用上;
11
+ * 3. **运行层**:在当前区间内没有任何有限值、输出恒定。
12
+ *
13
+ * 纯函数、不依赖 DOM,因此可以被完整单测。
14
+ */
15
+ export type ExpressionDiagnosticCode = 'empty' | 'syntax' | 'unknown-character' | 'unknown-function' | 'arity' | 'unknown-variable' | 'unused-parameter' | 'no-finite-values' | 'constant-value';
16
+ export interface ExpressionDiagnostic {
17
+ code: ExpressionDiagnosticCode;
18
+ /** error = 画不出来;warning = 画出来了但多半不是本意。 */
19
+ severity: 'error' | 'warning';
20
+ /** 人类可读的说明(含「怎么改」)。 */
21
+ message: string;
22
+ /** 出错字符位置(仅语法类)。 */
23
+ position?: number;
24
+ }
25
+ export interface DiagnoseExpressionOptions {
26
+ /** 自变量名:`function` 图是 `x`,参数曲线是 `t`。 */
27
+ variable: string;
28
+ /** 表达式里可以引用的参数(来自 `series.params`)。 */
29
+ params?: Record<string, number>;
30
+ /**
31
+ * 同一条系列里其它表达式用到的变量(参数曲线的 x(t) / y(t) 是两条表达式,
32
+ * 参数只要被任意一条用到就不该报「没用上」)。
33
+ */
34
+ additionalVariables?: string[];
35
+ /**
36
+ * 当前区间内的采样值(用于运行层检查)。
37
+ * 不传就只做静态检查;传了才有「整段画不出来 / 输出恒定」这两条。
38
+ */
39
+ values?: number[];
40
+ }
41
+ export declare function diagnoseExpression(source: string, options: DiagnoseExpressionOptions): ExpressionDiagnostic[];
42
+ /** 只取错误(表单标红用)。 */
43
+ export declare function errorsOf(diagnostics: ExpressionDiagnostic[]): ExpressionDiagnostic[];
44
+ /** 只取警告(表单提示用)。 */
45
+ export declare function warningsOf(diagnostics: ExpressionDiagnostic[]): ExpressionDiagnostic[];
@@ -0,0 +1,45 @@
1
+ /**
2
+ * 表达式诊断:回答「用户是不是胡乱输入了公式」这个问题。
3
+ *
4
+ * 编译错误只是第一层。真实场景里更常见、也更难自己发现的是**能编译但画不出来**:
5
+ * `b*x`(b 没定义)、`sqrt(-x)`(整段都是 NaN)、`sin(0)`(画出来是一条常数线
6
+ * ——不一定是错,但通常不是本意)。这些以前都是静默的,用户只看到「一片空白」。
7
+ *
8
+ * 这里把三层检查合成一份结构化结果,交给表单去标红 / 提示:
9
+ * 1. **语法层**:编译失败(含位置),由 `ExpressionError.code` 分类;
10
+ * 2. **静态层**:变量没定义(对比「自变量 + params」)、参数定义了却没用上;
11
+ * 3. **运行层**:在当前区间内没有任何有限值、输出恒定。
12
+ *
13
+ * 纯函数、不依赖 DOM,因此可以被完整单测。
14
+ */
15
+ export type ExpressionDiagnosticCode = 'empty' | 'syntax' | 'unknown-character' | 'unknown-function' | 'arity' | 'unknown-variable' | 'unused-parameter' | 'no-finite-values' | 'constant-value';
16
+ export interface ExpressionDiagnostic {
17
+ code: ExpressionDiagnosticCode;
18
+ /** error = 画不出来;warning = 画出来了但多半不是本意。 */
19
+ severity: 'error' | 'warning';
20
+ /** 人类可读的说明(含「怎么改」)。 */
21
+ message: string;
22
+ /** 出错字符位置(仅语法类)。 */
23
+ position?: number;
24
+ }
25
+ export interface DiagnoseExpressionOptions {
26
+ /** 自变量名:`function` 图是 `x`,参数曲线是 `t`。 */
27
+ variable: string;
28
+ /** 表达式里可以引用的参数(来自 `series.params`)。 */
29
+ params?: Record<string, number>;
30
+ /**
31
+ * 同一条系列里其它表达式用到的变量(参数曲线的 x(t) / y(t) 是两条表达式,
32
+ * 参数只要被任意一条用到就不该报「没用上」)。
33
+ */
34
+ additionalVariables?: string[];
35
+ /**
36
+ * 当前区间内的采样值(用于运行层检查)。
37
+ * 不传就只做静态检查;传了才有「整段画不出来 / 输出恒定」这两条。
38
+ */
39
+ values?: number[];
40
+ }
41
+ export declare function diagnoseExpression(source: string, options: DiagnoseExpressionOptions): ExpressionDiagnostic[];
42
+ /** 只取错误(表单标红用)。 */
43
+ export declare function errorsOf(diagnostics: ExpressionDiagnostic[]): ExpressionDiagnostic[];
44
+ /** 只取警告(表单提示用)。 */
45
+ export declare function warningsOf(diagnostics: ExpressionDiagnostic[]): ExpressionDiagnostic[];
@@ -0,0 +1,44 @@
1
+ /**
2
+ * 数学表达式引擎(迷你 MATLAB 的核心)。
3
+ *
4
+ * 为什么不用 `eval` / `new Function`:表达式是**用户输入**,而且可能来自 URL / 存盘配置。
5
+ * 这里用「词法 → 递归下降语法分析 → 编译成闭包」三步,既不依赖 eval(CSP 安全),
6
+ * 也能在编译期把错误位置报出来(`sin(x` 会告诉你缺右括号、在第几个字符)。
7
+ *
8
+ * 支持:
9
+ * - 运算符 `+ - * / % ^`(`^` 右结合),一元正负,括号;
10
+ * - 常量 `pi / e / tau`;
11
+ * - 函数:三角 / 反三角 / 双曲 / 指数对数 / 取整 / 绝对值 / min / max / pow / mod / hypot / clamp;
12
+ * - 变量:调用方通过 scope 提供(`x`、`t`、以及用户自定义参数 `a`、`k`…);
13
+ * - **隐式乘法**:`2x`、`3sin(x)`、`2(x+1)`、`2pi`(MATLAB 习惯)。
14
+ */
15
+ /** 编译失败的原因分类:调用方可以据此做不同的提示(不用解析错误文本)。 */
16
+ export type ExpressionErrorCode = 'empty' | 'syntax' | 'unknown-character' | 'unknown-function' | 'arity';
17
+ export declare class ExpressionError extends Error {
18
+ position: number;
19
+ code: ExpressionErrorCode;
20
+ constructor(message: string, position: number, source: string, code?: ExpressionErrorCode);
21
+ }
22
+ export interface CompiledExpression {
23
+ /** 原始表达式。 */
24
+ source: string;
25
+ /** 表达式里出现的自由变量(不含常量与函数名),例如 ['x', 'a']。 */
26
+ variables: string[];
27
+ /** 求值;scope 里缺少的变量按 NaN 处理(曲线断开,而不是静默算成 0)。 */
28
+ evaluate(scope?: Record<string, number>): number;
29
+ }
30
+ /** 编译表达式(带缓存:同一串表达式在参数扫动时每帧都会用到)。 */
31
+ export declare function compileExpression(source: string): CompiledExpression;
32
+ /** 一次性求值(少量调用用这个;高频采样请先 compileExpression 再复用)。 */
33
+ export declare function evaluateExpression(source: string, scope?: Record<string, number>): number;
34
+ export interface CompiledSampler {
35
+ /** 更新参数(复用内部 scope,参数扫动时每帧调用)。 */
36
+ setParams(params: Record<string, number>): void;
37
+ /** 求值:`name` 是自变量名(function 图是 'x',参数曲线是 't')。 */
38
+ evaluate(variableName: string, value: number): number;
39
+ }
40
+ /**
41
+ * 生成一个采样器:绑定表达式与参数,复用内部 scope。
42
+ * 采样是每帧上万次的热路径,这里既不能每次新建对象,也不能每次重新编译。
43
+ */
44
+ export declare function compileSampler(source: string, baseScope?: Record<string, number>): CompiledSampler;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * 数学表达式引擎(迷你 MATLAB 的核心)。
3
+ *
4
+ * 为什么不用 `eval` / `new Function`:表达式是**用户输入**,而且可能来自 URL / 存盘配置。
5
+ * 这里用「词法 → 递归下降语法分析 → 编译成闭包」三步,既不依赖 eval(CSP 安全),
6
+ * 也能在编译期把错误位置报出来(`sin(x` 会告诉你缺右括号、在第几个字符)。
7
+ *
8
+ * 支持:
9
+ * - 运算符 `+ - * / % ^`(`^` 右结合),一元正负,括号;
10
+ * - 常量 `pi / e / tau`;
11
+ * - 函数:三角 / 反三角 / 双曲 / 指数对数 / 取整 / 绝对值 / min / max / pow / mod / hypot / clamp;
12
+ * - 变量:调用方通过 scope 提供(`x`、`t`、以及用户自定义参数 `a`、`k`…);
13
+ * - **隐式乘法**:`2x`、`3sin(x)`、`2(x+1)`、`2pi`(MATLAB 习惯)。
14
+ */
15
+ /** 编译失败的原因分类:调用方可以据此做不同的提示(不用解析错误文本)。 */
16
+ export type ExpressionErrorCode = 'empty' | 'syntax' | 'unknown-character' | 'unknown-function' | 'arity';
17
+ export declare class ExpressionError extends Error {
18
+ position: number;
19
+ code: ExpressionErrorCode;
20
+ constructor(message: string, position: number, source: string, code?: ExpressionErrorCode);
21
+ }
22
+ export interface CompiledExpression {
23
+ /** 原始表达式。 */
24
+ source: string;
25
+ /** 表达式里出现的自由变量(不含常量与函数名),例如 ['x', 'a']。 */
26
+ variables: string[];
27
+ /** 求值;scope 里缺少的变量按 NaN 处理(曲线断开,而不是静默算成 0)。 */
28
+ evaluate(scope?: Record<string, number>): number;
29
+ }
30
+ /** 编译表达式(带缓存:同一串表达式在参数扫动时每帧都会用到)。 */
31
+ export declare function compileExpression(source: string): CompiledExpression;
32
+ /** 一次性求值(少量调用用这个;高频采样请先 compileExpression 再复用)。 */
33
+ export declare function evaluateExpression(source: string, scope?: Record<string, number>): number;
34
+ export interface CompiledSampler {
35
+ /** 更新参数(复用内部 scope,参数扫动时每帧调用)。 */
36
+ setParams(params: Record<string, number>): void;
37
+ /** 求值:`name` 是自变量名(function 图是 'x',参数曲线是 't')。 */
38
+ evaluate(variableName: string, value: number): number;
39
+ }
40
+ /**
41
+ * 生成一个采样器:绑定表达式与参数,复用内部 scope。
42
+ * 采样是每帧上万次的热路径,这里既不能每次新建对象,也不能每次重新编译。
43
+ */
44
+ export declare function compileSampler(source: string, baseScope?: Record<string, number>): CompiledSampler;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * 曲线采样:均匀打底 + 按曲率自适应细分。
3
+ *
4
+ * 为什么不能只均匀采样:`tan(x)` 在极点附近、`exp(-x^2)` 在峰顶附近,
5
+ * 均匀采样的折线要么「削平峰顶」要么「漏掉极点」。自适应细分只在折线与真实曲线
6
+ * 偏差大的地方加点,点数可控(有 maxSamples 上限,不会因为奇异点爆掉)。
7
+ *
8
+ * 非有限值(NaN / ±Inf / 过大)一律写成 `[x, NaN]` 作为**断点**,
9
+ * 渲染时按断点分段 —— 这样 `tan(x)`、`1/x` 会画出真正的渐近线缺口,而不是连一条竖线。
10
+ */
11
+ export interface SampleOptions {
12
+ /** 基础均匀采样点数(至少 2),默认 240。 */
13
+ base?: number;
14
+ /** 是否做自适应细分,默认 true。 */
15
+ adaptive?: boolean;
16
+ /** 相对 y 跨度的偏差阈值:越小越精细,默认 0.0025。 */
17
+ tolerance?: number;
18
+ /** 采样点总数上限,默认 6000(奇异点附近会疯狂细分,必须有闸)。 */
19
+ maxSamples?: number;
20
+ /** 递归深度上限,默认 7。 */
21
+ maxDepth?: number;
22
+ }
23
+ export type CurvePoint = [number, number];
24
+ /**
25
+ * 稳健取值范围:用四分位距(IQR)丢掉离群点。
26
+ *
27
+ * 为什么不用 min/max:`1/x`、`tan(x)` 的尖峰能把 y 轴拉到 ±2500,
28
+ * 整条曲线会被压成一条直线。用 IQR 之外的数值剪掉之后,画面才像 MATLAB。
29
+ */
30
+ export declare function robustRange(values: number[], k?: number): [number, number];
31
+ /** 采样 y = f(x)。返回按 x 升序的点列,断点用 y = NaN 表示。 */
32
+ export declare function sampleFunctionCurve(fn: (x: number) => number, x0: number, x1: number, options?: SampleOptions): CurvePoint[];
33
+ /** 采样参数曲线 (x(t), y(t)):偏差按平面距离算(曲线可能拐回来,不能只看 y)。 */
34
+ export declare function sampleParametricCurve(fx: (t: number) => number, fy: (t: number) => number, t0: number, t1: number, options?: SampleOptions): CurvePoint[];