jmchart 1.2.19 → 1.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +253 -20
- package/dist/jmchart.amd.js +3136 -678
- package/dist/jmchart.cjs.js +3136 -678
- package/dist/jmchart.esm.js +3136 -678
- package/dist/jmchart.iife.js +3136 -678
- package/dist/jmchart.system.js +3136 -678
- package/index.d.ts +553 -32
- package/package.json +2 -2
- package/server.js +3 -0
- package/src/common/tooltip.js +3 -3
- package/src/common/utils.js +1 -1
- package/src/core/axis/axis.js +2 -2
- package/src/core/legend/legend.js +106 -108
- package/src/core/markLine/manager.js +2 -0
- package/src/core/markLine/markLine.js +3 -2
- package/src/jmChart.js +2 -5
- package/src/series/areaSeries.js +6 -6
- package/src/series/boxPlotSeries.js +2 -4
- package/src/series/bubbleSeries.js +3 -8
- package/src/series/candlestickSeries.js +1 -5
- package/src/series/funnelSeries.js +1 -3
- package/src/series/gaugeSeries.js +3 -7
- package/src/series/heatmapSeries.js +3 -8
- package/src/series/lineSeries.js +7 -10
- package/src/series/pieSeries.js +36 -31
- package/src/series/radarSeries.js +30 -51
- package/src/series/rangeSeries.js +9 -12
- package/src/series/ringProgressSeries.js +0 -2
- package/src/series/scatterSeries.js +3 -8
- package/src/series/stackBarSeries.js +3 -2
- package/src/series/stackLineSeries.js +0 -4
- package/src/series/waterfallSeries.js +0 -4
- package/src/series/wordCloudSeries.js +2 -4
package/index.d.ts
CHANGED
|
@@ -15,6 +15,10 @@ import type {
|
|
|
15
15
|
Bounds,
|
|
16
16
|
} from 'jmgraph';
|
|
17
17
|
|
|
18
|
+
// 导出公共常量
|
|
19
|
+
export const ANIMATION_DATA_THRESHOLD: 100;
|
|
20
|
+
export const DEFAULT_ANIMATION_COUNT: 10;
|
|
21
|
+
|
|
18
22
|
/**
|
|
19
23
|
* 图表系列类型
|
|
20
24
|
*/
|
|
@@ -54,6 +58,15 @@ export interface AxisOptions {
|
|
|
54
58
|
maxXValue?: number;
|
|
55
59
|
minYValue?: number;
|
|
56
60
|
maxYValue?: number;
|
|
61
|
+
radarOption?: {
|
|
62
|
+
center: Point;
|
|
63
|
+
radius: number;
|
|
64
|
+
yCount: number;
|
|
65
|
+
rotate: number;
|
|
66
|
+
cos: number;
|
|
67
|
+
sin: number;
|
|
68
|
+
yAxises?: any[];
|
|
69
|
+
};
|
|
57
70
|
[key: string]: any;
|
|
58
71
|
}
|
|
59
72
|
|
|
@@ -80,6 +93,42 @@ export interface DataPoint {
|
|
|
80
93
|
m?: boolean;
|
|
81
94
|
}>;
|
|
82
95
|
m?: boolean;
|
|
96
|
+
/** 饼图专用:扇形占比 */
|
|
97
|
+
step?: number;
|
|
98
|
+
/** 饼图专用:扇形形状 */
|
|
99
|
+
shape?: any;
|
|
100
|
+
/** 饼图专用:起始角度 */
|
|
101
|
+
startAngle?: number;
|
|
102
|
+
/** 饼图专用:结束角度 */
|
|
103
|
+
endAngle?: number;
|
|
104
|
+
/** 饼图专用:半径 */
|
|
105
|
+
radius?: number;
|
|
106
|
+
/** 饼图专用:最大半径 */
|
|
107
|
+
maxRadius?: number;
|
|
108
|
+
/** 饼图专用:最小半径 */
|
|
109
|
+
minRadius?: number;
|
|
110
|
+
/** 饼图专用:中心点 */
|
|
111
|
+
center?: Point;
|
|
112
|
+
/** 饼图专用:是否逆时针 */
|
|
113
|
+
anticlockwise?: boolean;
|
|
114
|
+
/** 雷达图专用:关联轴对象 */
|
|
115
|
+
axis?: any;
|
|
116
|
+
/** 雷达图专用:数据点半径 */
|
|
117
|
+
radiusValue?: number;
|
|
118
|
+
/** 散点图/气泡图:点大小 */
|
|
119
|
+
size?: number;
|
|
120
|
+
/** 散点图/气泡图:点颜色 */
|
|
121
|
+
color?: string;
|
|
122
|
+
/** 气泡图:透明度 */
|
|
123
|
+
opacity?: number;
|
|
124
|
+
/** 热力图:数值 */
|
|
125
|
+
value?: number;
|
|
126
|
+
/** 瀑布图:原始值 */
|
|
127
|
+
originalValue?: number;
|
|
128
|
+
/** 瀑布图:起始累计值 */
|
|
129
|
+
startValue?: number;
|
|
130
|
+
/** 瀑布图:结束累计值 */
|
|
131
|
+
endValue?: number;
|
|
83
132
|
}
|
|
84
133
|
|
|
85
134
|
/**
|
|
@@ -99,8 +148,10 @@ export interface SeriesOptions {
|
|
|
99
148
|
graph?: jmChart;
|
|
100
149
|
label?: {
|
|
101
150
|
show?: boolean;
|
|
102
|
-
fill?: string;
|
|
151
|
+
fill?: string | ((point: DataPoint) => string);
|
|
103
152
|
font?: string;
|
|
153
|
+
position?: 'top' | 'bottom' | 'left' | 'right' | 'inside';
|
|
154
|
+
offset?: number;
|
|
104
155
|
[key: string]: any;
|
|
105
156
|
};
|
|
106
157
|
itemLabelFormat?: (point: DataPoint) => string;
|
|
@@ -111,9 +162,33 @@ export interface SeriesOptions {
|
|
|
111
162
|
maxYValue?: number;
|
|
112
163
|
yLabelFormat?: (value: any) => string;
|
|
113
164
|
lockSide?: Bounds;
|
|
165
|
+
/** 饼图专用:起始角度,支持函数 */
|
|
166
|
+
startAngle?: number | ((data: any[]) => number);
|
|
167
|
+
/** 饼图专用:逆时针绘图 */
|
|
168
|
+
anticlockwise?: boolean;
|
|
169
|
+
/** 饼图专用:半径,支持函数 */
|
|
170
|
+
radius?: number | ((point: DataPoint, radius: number, index: number) => number);
|
|
171
|
+
/** 饼图专用:最大半径 */
|
|
172
|
+
maxRadius?: number | ((point: DataPoint, radius: number, index: number) => number);
|
|
173
|
+
/** 饼图专用:最小半径 */
|
|
174
|
+
minRadius?: number | ((point: DataPoint, radius: number, index: number) => number);
|
|
175
|
+
/** 饼图专用:中心点,支持函数 */
|
|
176
|
+
center?: Point | ((point: DataPoint, center: Point, index: number) => Point);
|
|
177
|
+
/** 交互事件 */
|
|
178
|
+
onClick?: (point: DataPoint, event?: any) => void;
|
|
179
|
+
onOver?: (point: DataPoint, event?: any) => void;
|
|
180
|
+
onLeave?: (point: DataPoint, event?: any) => void;
|
|
114
181
|
[key: string]: any;
|
|
115
182
|
}
|
|
116
183
|
|
|
184
|
+
/**
|
|
185
|
+
* 图例附加选项
|
|
186
|
+
*/
|
|
187
|
+
export interface LegendAppendOptions {
|
|
188
|
+
name?: string;
|
|
189
|
+
data?: any;
|
|
190
|
+
}
|
|
191
|
+
|
|
117
192
|
/**
|
|
118
193
|
* 图表构造选项
|
|
119
194
|
*/
|
|
@@ -139,6 +214,14 @@ export interface jmChartOptions extends jmGraphOptions {
|
|
|
139
214
|
[key: string]: any;
|
|
140
215
|
}
|
|
141
216
|
|
|
217
|
+
/**
|
|
218
|
+
* 仪表盘渐变色配置
|
|
219
|
+
*/
|
|
220
|
+
export interface GaugeGradientColor {
|
|
221
|
+
offset: number;
|
|
222
|
+
color: string;
|
|
223
|
+
}
|
|
224
|
+
|
|
142
225
|
/**
|
|
143
226
|
* 图表默认样式
|
|
144
227
|
*/
|
|
@@ -155,6 +238,11 @@ export interface jmChartStyle extends jmStyle {
|
|
|
155
238
|
x?: boolean;
|
|
156
239
|
y?: boolean;
|
|
157
240
|
radius?: number;
|
|
241
|
+
longtap?: boolean;
|
|
242
|
+
lock?: {
|
|
243
|
+
x?: number;
|
|
244
|
+
y?: number;
|
|
245
|
+
};
|
|
158
246
|
};
|
|
159
247
|
legend?: jmStyle & {
|
|
160
248
|
margin?: {
|
|
@@ -198,23 +286,147 @@ export interface jmChartStyle extends jmStyle {
|
|
|
198
286
|
};
|
|
199
287
|
};
|
|
200
288
|
chartColors?: string[];
|
|
201
|
-
line?: jmStyle
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
289
|
+
line?: jmStyle & {
|
|
290
|
+
lineWidth?: number;
|
|
291
|
+
radius?: number;
|
|
292
|
+
showItem?: boolean;
|
|
293
|
+
curve?: boolean;
|
|
294
|
+
area?: boolean | jmStyle;
|
|
295
|
+
perWidth?: number;
|
|
296
|
+
aniCount?: number;
|
|
297
|
+
item?: jmStyle;
|
|
298
|
+
};
|
|
299
|
+
stackLine?: jmStyle & {
|
|
300
|
+
lineWidth?: number;
|
|
301
|
+
radius?: number;
|
|
302
|
+
showItem?: boolean;
|
|
303
|
+
curve?: boolean;
|
|
304
|
+
area?: boolean | jmStyle;
|
|
305
|
+
aniCount?: number;
|
|
306
|
+
item?: jmStyle;
|
|
307
|
+
};
|
|
308
|
+
range?: jmStyle & {
|
|
309
|
+
lineWidth?: number;
|
|
310
|
+
radius?: number;
|
|
311
|
+
showItem?: boolean;
|
|
312
|
+
curve?: boolean;
|
|
313
|
+
lineType?: 'dotted' | 'solid';
|
|
314
|
+
area?: jmStyle;
|
|
315
|
+
aniCount?: number;
|
|
316
|
+
item?: jmStyle;
|
|
317
|
+
};
|
|
318
|
+
bar?: jmStyle & {
|
|
319
|
+
lineWidth?: number;
|
|
320
|
+
perWidth?: number;
|
|
321
|
+
barWidth?: number;
|
|
322
|
+
aniCount?: number;
|
|
323
|
+
item?: jmStyle;
|
|
324
|
+
};
|
|
325
|
+
pie?: jmStyle & {
|
|
326
|
+
marginAngle?: number;
|
|
327
|
+
arcWidth?: number;
|
|
328
|
+
isHollow?: boolean;
|
|
329
|
+
margin?: { left?: number; top?: number; right?: number; bottom?: number };
|
|
330
|
+
};
|
|
331
|
+
radar?: jmStyle & {
|
|
332
|
+
margin?: { left?: number; top?: number; right?: number; bottom?: number };
|
|
333
|
+
};
|
|
334
|
+
candlestick?: jmStyle & {
|
|
335
|
+
perWidth?: number;
|
|
336
|
+
barWidth?: number;
|
|
337
|
+
masculineColor?: string;
|
|
338
|
+
negativeColor?: string;
|
|
339
|
+
};
|
|
340
|
+
scatter?: jmStyle & {
|
|
341
|
+
radius?: number;
|
|
342
|
+
item?: jmStyle;
|
|
343
|
+
};
|
|
344
|
+
bubble?: jmStyle & {
|
|
345
|
+
radius?: number;
|
|
346
|
+
radiusScale?: number;
|
|
347
|
+
opacity?: number;
|
|
348
|
+
item?: jmStyle;
|
|
349
|
+
};
|
|
350
|
+
heatmap?: jmStyle & {
|
|
351
|
+
cellWidth?: number;
|
|
352
|
+
cellHeight?: number;
|
|
353
|
+
defaultColor?: string;
|
|
354
|
+
colorGradient?: string[];
|
|
355
|
+
item?: jmStyle;
|
|
356
|
+
};
|
|
357
|
+
gauge?: jmStyle & {
|
|
358
|
+
min?: number;
|
|
359
|
+
max?: number;
|
|
360
|
+
startAngle?: number;
|
|
361
|
+
endAngle?: number;
|
|
362
|
+
radiusScale?: number;
|
|
363
|
+
lineWidth?: number;
|
|
364
|
+
backgroundStroke?: string;
|
|
365
|
+
backgroundFill?: string;
|
|
366
|
+
backgroundLineWidth?: number;
|
|
367
|
+
gradient?: boolean;
|
|
368
|
+
gradientColors?: GaugeGradientColor[];
|
|
369
|
+
tickCount?: number;
|
|
370
|
+
tickColor?: string;
|
|
371
|
+
tickLabelColor?: string;
|
|
372
|
+
pointerColor?: string;
|
|
373
|
+
pointerWidth?: number;
|
|
374
|
+
centerColor?: string;
|
|
375
|
+
centerRadius?: number;
|
|
376
|
+
valueColor?: string;
|
|
377
|
+
valueFont?: string;
|
|
378
|
+
unit?: string;
|
|
379
|
+
unitColor?: string;
|
|
380
|
+
unitFont?: string;
|
|
381
|
+
};
|
|
382
|
+
area?: jmStyle & {
|
|
383
|
+
lineWidth?: number;
|
|
384
|
+
radius?: number;
|
|
385
|
+
showItem?: boolean;
|
|
386
|
+
curve?: boolean;
|
|
387
|
+
area?: jmStyle;
|
|
388
|
+
aniCount?: number;
|
|
389
|
+
item?: jmStyle;
|
|
390
|
+
};
|
|
391
|
+
waterfall?: jmStyle & {
|
|
392
|
+
perWidth?: number;
|
|
393
|
+
increaseColor?: string;
|
|
394
|
+
decreaseColor?: string;
|
|
395
|
+
connectorColor?: string;
|
|
396
|
+
aniCount?: number;
|
|
397
|
+
};
|
|
398
|
+
funnel?: jmStyle & {
|
|
399
|
+
align?: 'center' | 'left' | 'right';
|
|
400
|
+
gap?: number;
|
|
401
|
+
stroke?: string;
|
|
402
|
+
label?: jmStyle;
|
|
403
|
+
colors?: string[];
|
|
404
|
+
};
|
|
405
|
+
ringProgress?: jmStyle & {
|
|
406
|
+
lineWidth?: number;
|
|
407
|
+
startAngle?: number;
|
|
408
|
+
max?: number;
|
|
409
|
+
ringGap?: number;
|
|
410
|
+
backgroundColor?: string;
|
|
411
|
+
showLabel?: boolean;
|
|
412
|
+
labelColor?: string;
|
|
413
|
+
labelFont?: string;
|
|
414
|
+
progressStyle?: jmStyle;
|
|
415
|
+
colors?: string[];
|
|
416
|
+
};
|
|
417
|
+
boxPlot?: jmStyle & {
|
|
418
|
+
boxWidth?: number | null;
|
|
419
|
+
whiskerWidth?: number;
|
|
420
|
+
whiskerLength?: number;
|
|
421
|
+
boxFill?: string;
|
|
422
|
+
label?: jmStyle;
|
|
423
|
+
};
|
|
424
|
+
wordCloud?: jmStyle & {
|
|
425
|
+
minFontSize?: number;
|
|
426
|
+
maxFontSize?: number;
|
|
427
|
+
spiral?: boolean;
|
|
428
|
+
colors?: string[];
|
|
429
|
+
};
|
|
218
430
|
}
|
|
219
431
|
|
|
220
432
|
/**
|
|
@@ -225,10 +437,12 @@ export declare class jmAxis extends jmControl {
|
|
|
225
437
|
|
|
226
438
|
field: string;
|
|
227
439
|
dataType: 'number' | 'date' | 'string';
|
|
228
|
-
min(): number;
|
|
229
|
-
max(value?: number): number;
|
|
230
|
-
step(): number;
|
|
231
440
|
labelStart: number;
|
|
441
|
+
radarOption?: any;
|
|
442
|
+
|
|
443
|
+
min(m?: any): number;
|
|
444
|
+
max(value?: any): number;
|
|
445
|
+
step(): number;
|
|
232
446
|
clear(): void;
|
|
233
447
|
reset(): void;
|
|
234
448
|
init(options?: AxisOptions): void;
|
|
@@ -240,20 +454,49 @@ export declare class jmAxis extends jmControl {
|
|
|
240
454
|
export declare class jmLegend extends jmControl {
|
|
241
455
|
constructor(options?: { style?: jmStyle });
|
|
242
456
|
|
|
457
|
+
legendPosition: string;
|
|
458
|
+
|
|
459
|
+
append(series: jmSeries, shape: jmControl, options?: LegendAppendOptions): void;
|
|
243
460
|
init(): void;
|
|
244
461
|
reset(): void;
|
|
245
|
-
append(series: jmSeries, shape: jmControl): void;
|
|
246
462
|
}
|
|
247
463
|
|
|
248
464
|
/**
|
|
249
465
|
* 标线管理器
|
|
466
|
+
*
|
|
467
|
+
* 管理图表中的 X/Y 标线,支持鼠标/触摸拖拽移动和长按触发。
|
|
468
|
+
* 标线事件通过 jmChart 实例触发。
|
|
250
469
|
*/
|
|
251
470
|
export declare class jmMarkLineManager {
|
|
252
471
|
constructor(chart: jmChart);
|
|
472
|
+
|
|
473
|
+
chart: jmChart;
|
|
474
|
+
xMarkLine?: any;
|
|
475
|
+
yMarkLine?: any;
|
|
476
|
+
|
|
477
|
+
/** 初始化标线,绑定 mousedown/touchstart/mousemove/touchmove/mouseup/touchend 事件 */
|
|
478
|
+
init(chart: jmChart): void;
|
|
479
|
+
/** 开始移动标线,markLineType: 'xy' | 'x' | 'y' */
|
|
480
|
+
startMove(args: any, markLineType?: string): void;
|
|
481
|
+
/** 移动标线到当前位置 */
|
|
482
|
+
move(args: any): void;
|
|
483
|
+
/** 终止移动标线 */
|
|
484
|
+
endMove(args: any): void;
|
|
253
485
|
}
|
|
254
486
|
|
|
255
487
|
/**
|
|
256
488
|
* 图表系列基类
|
|
489
|
+
*
|
|
490
|
+
* 所有图表类型的基类,提供通用的数据点生成、坐标轴管理、动画控制和图例生成功能。
|
|
491
|
+
* 子类需要实现 init() 方法来定义具体的图表绘制逻辑。
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* class MySeries extends jmSeries {
|
|
495
|
+
* init() {
|
|
496
|
+
* const { points } = this.initDataPoint();
|
|
497
|
+
* // 绘制图形...
|
|
498
|
+
* }
|
|
499
|
+
* }
|
|
257
500
|
*/
|
|
258
501
|
export declare class jmSeries extends jmPath {
|
|
259
502
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
@@ -275,155 +518,406 @@ export declare class jmSeries extends jmPath {
|
|
|
275
518
|
dataPoints: DataPoint[];
|
|
276
519
|
curve?: boolean;
|
|
277
520
|
chartInfo?: { xAxis: jmAxis; yAxis: jmAxis };
|
|
521
|
+
barWidth?: number;
|
|
522
|
+
barTotalWidth?: number;
|
|
523
|
+
barIndex?: number;
|
|
524
|
+
pointsLen?: number;
|
|
525
|
+
lastPoints?: DataPoint[];
|
|
278
526
|
|
|
527
|
+
/** 初始化数据点,支持动画效果 */
|
|
279
528
|
initDataPoint(...args: any[]): { points: DataPoint[]; dataChanged: boolean };
|
|
529
|
+
/** 根据 X 轴坐标获取最近的数据点 */
|
|
280
530
|
getDataPointByX(x: number): DataPoint | null;
|
|
531
|
+
/** 根据 X 轴值获取数据点 */
|
|
281
532
|
getDataPointByXValue(xValue: any): DataPoint | null;
|
|
533
|
+
/** 重置系列,清除所有形状,重新初始化轴和图例 */
|
|
282
534
|
reset(): { xAxis: jmAxis; yAxis: jmAxis };
|
|
535
|
+
/** 初始化坐标轴的值范围 */
|
|
283
536
|
initAxisValue(): void;
|
|
537
|
+
/** 根据数据源创建数据点,计算屏幕坐标 */
|
|
284
538
|
createPoints(data?: any[]): DataPoint[];
|
|
539
|
+
/** 获取颜色 */
|
|
285
540
|
getColor(p?: DataPoint): string;
|
|
541
|
+
/** 生成图例 */
|
|
286
542
|
createLegend(): jmControl;
|
|
543
|
+
/** 生成数据项标签 */
|
|
287
544
|
createItemLabel(point: DataPoint, position?: string): void;
|
|
288
|
-
|
|
545
|
+
/** 子类可重写的数据项创建方法 */
|
|
546
|
+
createPointItem?(p: DataPoint): jmControl;
|
|
547
|
+
/** 初始化图表绘制,子类必须实现 */
|
|
289
548
|
init?(): void;
|
|
549
|
+
/** 添加形状到图表 */
|
|
290
550
|
addShape(shape: jmControl): jmControl;
|
|
291
551
|
}
|
|
292
552
|
|
|
293
553
|
/**
|
|
294
554
|
* 柱图系列
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* chart.createSeries('bar', {
|
|
558
|
+
* field: 'value',
|
|
559
|
+
* xField: 'name',
|
|
560
|
+
* style: { perWidth: 0.5 }
|
|
561
|
+
* });
|
|
295
562
|
*/
|
|
296
563
|
export declare class jmBarSeries extends jmSeries {
|
|
297
564
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
565
|
+
|
|
298
566
|
barIndex: number;
|
|
299
567
|
barWidth: number;
|
|
300
568
|
barTotalWidth: number;
|
|
569
|
+
|
|
301
570
|
init(): void;
|
|
302
|
-
|
|
571
|
+
/** 计算柱子宽度 */
|
|
572
|
+
initWidth(count: number): void;
|
|
573
|
+
addShape(shape: jmControl): jmControl;
|
|
303
574
|
}
|
|
304
575
|
|
|
305
576
|
/**
|
|
306
|
-
*
|
|
577
|
+
* 堆叠柱状图系列
|
|
578
|
+
*
|
|
579
|
+
* 数据格式:field 为数组,如 ['value1', 'value2', 'value3']
|
|
580
|
+
* 支持正负值堆叠,正值向上,负值向下。
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* chart.createSeries('stackBar', {
|
|
584
|
+
* field: ['sales', 'profit'],
|
|
585
|
+
* xField: 'month',
|
|
586
|
+
* style: { color: ({index}) => chart.getColor(index) }
|
|
587
|
+
* });
|
|
307
588
|
*/
|
|
308
589
|
export declare class jmStackBarSeries extends jmBarSeries {
|
|
309
590
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
591
|
+
|
|
592
|
+
init(): void;
|
|
593
|
+
/** 计算所有字段的累加值作为轴范围 */
|
|
594
|
+
initAxisValue(): void;
|
|
310
595
|
}
|
|
311
596
|
|
|
312
597
|
/**
|
|
313
598
|
* 线图系列
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* chart.createSeries('line', {
|
|
602
|
+
* field: 'value',
|
|
603
|
+
* xField: 'name',
|
|
604
|
+
* style: { curve: true, showItem: true }
|
|
605
|
+
* });
|
|
314
606
|
*/
|
|
315
607
|
export declare class jmLineSeries extends jmSeries {
|
|
316
608
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
609
|
+
|
|
610
|
+
curve?: boolean;
|
|
611
|
+
|
|
317
612
|
init(): void;
|
|
613
|
+
/** 创建平滑曲线路径点 */
|
|
318
614
|
createCurePoints(shapePoints: Point[], p: DataPoint): Point[];
|
|
319
615
|
}
|
|
320
616
|
|
|
321
617
|
/**
|
|
322
|
-
*
|
|
618
|
+
* 堆叠线图系列(已废弃)
|
|
619
|
+
*
|
|
620
|
+
* @deprecated 请使用 jmRangeSeries(范围图)代替
|
|
323
621
|
*/
|
|
324
|
-
export declare class jmStackLineSeries extends
|
|
325
|
-
constructor(options: SeriesOptions & { graph: jmChart });
|
|
326
|
-
}
|
|
622
|
+
export declare class jmStackLineSeries extends jmRangeSeries;
|
|
327
623
|
|
|
328
624
|
/**
|
|
329
625
|
* 面积图系列
|
|
626
|
+
*
|
|
627
|
+
* 继承自折线图,默认启用区域填充。
|
|
628
|
+
*
|
|
629
|
+
* @example
|
|
630
|
+
* chart.createSeries('area', {
|
|
631
|
+
* field: 'value',
|
|
632
|
+
* xField: 'name',
|
|
633
|
+
* style: { curve: true }
|
|
634
|
+
* });
|
|
330
635
|
*/
|
|
331
636
|
export declare class jmAreaSeries extends jmLineSeries {
|
|
332
637
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
333
|
-
|
|
638
|
+
|
|
639
|
+
createLegend(): jmControl;
|
|
334
640
|
}
|
|
335
641
|
|
|
336
642
|
/**
|
|
337
643
|
* 饼图系列
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* chart.createSeries('pie', {
|
|
647
|
+
* field: 'value',
|
|
648
|
+
* xField: 'name',
|
|
649
|
+
* style: { isHollow: false, marginAngle: 0.1 }
|
|
650
|
+
* });
|
|
338
651
|
*/
|
|
339
652
|
export declare class jmPieSeries extends jmSeries {
|
|
340
653
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
654
|
+
|
|
341
655
|
totalValue: number;
|
|
656
|
+
startAngle: number | ((data: any[]) => number);
|
|
657
|
+
|
|
342
658
|
init(): void;
|
|
659
|
+
createPoints(center?: Point, radius?: number): DataPoint[];
|
|
660
|
+
createLabel(point: DataPoint): jmControl;
|
|
661
|
+
createLegend(): void;
|
|
343
662
|
}
|
|
344
663
|
|
|
345
664
|
/**
|
|
346
665
|
* 雷达图系列
|
|
666
|
+
*
|
|
667
|
+
* 数据格式:field 为多维字段数组,如 ['语文', '数学', '英语', '物理', '化学']
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
* chart.createSeries('radar', {
|
|
671
|
+
* fields: ['语文', '数学', '英语', '物理', '化学'],
|
|
672
|
+
* style: { lineWidth: 2, fill: 'rgba(0,0,0,0.2)' }
|
|
673
|
+
* });
|
|
347
674
|
*/
|
|
348
675
|
export declare class jmRadarSeries extends jmSeries {
|
|
349
676
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
677
|
+
|
|
678
|
+
axises: jmAxis[];
|
|
679
|
+
center: Point;
|
|
680
|
+
radius: number;
|
|
681
|
+
|
|
682
|
+
createAxises(center: Point, radius: number): jmAxis[];
|
|
683
|
+
initAxisValue(): void;
|
|
684
|
+
init(): void;
|
|
685
|
+
createPoints(center?: Point, radius?: number): DataPoint[];
|
|
686
|
+
createLabel(point: DataPoint): void;
|
|
687
|
+
createLegend(point?: DataPoint): void;
|
|
350
688
|
}
|
|
351
689
|
|
|
352
690
|
/**
|
|
353
691
|
* 范围图系列
|
|
692
|
+
*
|
|
693
|
+
* 继承自折线图,显示数据的上下限范围。
|
|
694
|
+
* 数据格式:field 为数组,如 ['min', 'max']
|
|
695
|
+
*
|
|
696
|
+
* @example
|
|
697
|
+
* chart.createSeries('range', {
|
|
698
|
+
* fields: ['min', 'max'],
|
|
699
|
+
* xField: 'date',
|
|
700
|
+
* style: { curve: true }
|
|
701
|
+
* });
|
|
354
702
|
*/
|
|
355
|
-
export declare class jmRangeSeries extends
|
|
703
|
+
export declare class jmRangeSeries extends jmLineSeries {
|
|
356
704
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
705
|
+
|
|
706
|
+
points?: any[];
|
|
707
|
+
|
|
708
|
+
init(): void;
|
|
709
|
+
createLegend(): jmControl;
|
|
357
710
|
}
|
|
358
711
|
|
|
359
712
|
/**
|
|
360
|
-
* K
|
|
713
|
+
* K线图(蜡烛图)系列
|
|
714
|
+
*
|
|
715
|
+
* 数据格式:field 为数组,如 ['open', 'close', 'high', 'low']
|
|
716
|
+
*
|
|
717
|
+
* @example
|
|
718
|
+
* chart.createSeries('candlestick', {
|
|
719
|
+
* field: ['open', 'close', 'high', 'low'],
|
|
720
|
+
* xField: 'date',
|
|
721
|
+
* style: { masculineColor: 'red', negativeColor: 'green' }
|
|
722
|
+
* });
|
|
361
723
|
*/
|
|
362
724
|
export declare class jmCandlestickSeries extends jmSeries {
|
|
363
725
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
726
|
+
|
|
727
|
+
init(): void;
|
|
728
|
+
/** 计算 K 线宽度 */
|
|
729
|
+
initWidth(count: number): void;
|
|
364
730
|
}
|
|
365
731
|
|
|
366
732
|
/**
|
|
367
733
|
* 散点图系列
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* chart.createSeries('scatter', {
|
|
737
|
+
* field: 'y',
|
|
738
|
+
* xField: 'x',
|
|
739
|
+
* style: { radius: 5 }
|
|
740
|
+
* });
|
|
368
741
|
*/
|
|
369
742
|
export declare class jmScatterSeries extends jmSeries {
|
|
370
743
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
744
|
+
|
|
745
|
+
init(): void;
|
|
746
|
+
createPointItem(p: DataPoint): jmControl;
|
|
747
|
+
createLegend(): void;
|
|
371
748
|
}
|
|
372
749
|
|
|
373
750
|
/**
|
|
374
751
|
* 气泡图系列
|
|
752
|
+
*
|
|
753
|
+
* @example
|
|
754
|
+
* chart.createSeries('bubble', {
|
|
755
|
+
* field: 'y',
|
|
756
|
+
* xField: 'x',
|
|
757
|
+
* style: { radius: 5, radiusScale: 1, opacity: 0.6 }
|
|
758
|
+
* });
|
|
375
759
|
*/
|
|
376
760
|
export declare class jmBubbleSeries extends jmSeries {
|
|
377
761
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
762
|
+
|
|
763
|
+
init(): void;
|
|
764
|
+
createBubbleItem(p: DataPoint): jmControl;
|
|
765
|
+
createLegend(): void;
|
|
378
766
|
}
|
|
379
767
|
|
|
380
768
|
/**
|
|
381
769
|
* 热力图系列
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
* chart.createSeries('heatmap', {
|
|
773
|
+
* field: 'value',
|
|
774
|
+
* xField: 'x',
|
|
775
|
+
* style: { cellWidth: 20, cellHeight: 20 }
|
|
776
|
+
* });
|
|
382
777
|
*/
|
|
383
778
|
export declare class jmHeatmapSeries extends jmSeries {
|
|
384
779
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
780
|
+
|
|
781
|
+
minValue: number;
|
|
782
|
+
maxValue: number;
|
|
783
|
+
|
|
784
|
+
init(): void;
|
|
785
|
+
createHeatmapCell(p: DataPoint, minValue: number, maxValue: number): jmControl;
|
|
786
|
+
getHeatmapColor(value: number, minValue: number, maxValue: number): string;
|
|
787
|
+
createLegend(): void;
|
|
385
788
|
}
|
|
386
789
|
|
|
387
790
|
/**
|
|
388
791
|
* 仪表盘系列
|
|
792
|
+
*
|
|
793
|
+
* @example
|
|
794
|
+
* chart.createSeries('gauge', {
|
|
795
|
+
* field: 'value',
|
|
796
|
+
* style: { min: 0, max: 100, startAngle: -150, endAngle: 150 }
|
|
797
|
+
* });
|
|
389
798
|
*/
|
|
390
799
|
export declare class jmGaugeSeries extends jmSeries {
|
|
391
800
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
801
|
+
|
|
802
|
+
init(): void;
|
|
803
|
+
createGaugeBackground(centerX: number, centerY: number, radius: number, startAngle: number, endAngle: number): void;
|
|
804
|
+
createGaugeTicks(centerX: number, centerY: number, radius: number, startAngle: number, endAngle: number, min: number, max: number): void;
|
|
805
|
+
createGaugePointer(centerX: number, centerY: number, radius: number, angle: number): void;
|
|
806
|
+
createGaugeCenter(centerX: number, centerY: number, radius: number): void;
|
|
807
|
+
createGaugeValueLabel(centerX: number, centerY: number, radius: number, value: number): void;
|
|
808
|
+
createLegend(): void;
|
|
392
809
|
}
|
|
393
810
|
|
|
394
811
|
/**
|
|
395
812
|
* 瀑布图系列
|
|
813
|
+
*
|
|
814
|
+
* @example
|
|
815
|
+
* chart.createSeries('waterfall', {
|
|
816
|
+
* field: 'value',
|
|
817
|
+
* xField: 'name',
|
|
818
|
+
* style: { increaseColor: '#52c41a', decreaseColor: '#f5222d' }
|
|
819
|
+
* });
|
|
396
820
|
*/
|
|
397
821
|
export declare class jmWaterfallSeries extends jmSeries {
|
|
398
822
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
823
|
+
|
|
824
|
+
pointsLen?: number;
|
|
825
|
+
|
|
826
|
+
init(): void;
|
|
827
|
+
createWaterfallBar(p: DataPoint, startY: number, endY: number, height: number, color: string): void;
|
|
828
|
+
createConnectorLine(currentPoint: DataPoint, nextPoint: DataPoint, chartHeight: number, minY: number, ystep: number): void;
|
|
829
|
+
createLegend(): void;
|
|
399
830
|
}
|
|
400
831
|
|
|
401
832
|
/**
|
|
402
833
|
* 漏斗图系列
|
|
834
|
+
*
|
|
835
|
+
* @example
|
|
836
|
+
* chart.createSeries('funnel', {
|
|
837
|
+
* field: 'value',
|
|
838
|
+
* xField: 'name',
|
|
839
|
+
* style: { align: 'center', gap: 2 }
|
|
840
|
+
* });
|
|
403
841
|
*/
|
|
404
842
|
export declare class jmFunnelSeries extends jmSeries {
|
|
405
843
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
844
|
+
|
|
845
|
+
init(): void;
|
|
846
|
+
createFunnelLabel(item: any, leftX: number, rightX: number, y: number, height: number, index: number, field: string, xField: string): void;
|
|
847
|
+
getColor(item: any, index: number): string;
|
|
848
|
+
createLegend(): void;
|
|
406
849
|
}
|
|
407
850
|
|
|
408
851
|
/**
|
|
409
852
|
* 环形进度图系列
|
|
853
|
+
*
|
|
854
|
+
* @example
|
|
855
|
+
* chart.createSeries('ringProgress', {
|
|
856
|
+
* field: 'value',
|
|
857
|
+
* style: { lineWidth: 20, max: 100, startAngle: -90 }
|
|
858
|
+
* });
|
|
410
859
|
*/
|
|
411
860
|
export declare class jmRingProgressSeries extends jmSeries {
|
|
412
861
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
862
|
+
|
|
863
|
+
placedWords?: Array<{ x: number; y: number; width: number; height: number }>;
|
|
864
|
+
|
|
865
|
+
init(): void;
|
|
866
|
+
createRingBackground(centerX: number, centerY: number, radius: number, lineWidth: number, index: number): void;
|
|
867
|
+
createRingProgress(centerX: number, centerY: number, radius: number, lineWidth: number, startAngle: number, ratio: number, index: number): void;
|
|
868
|
+
createRingLabel(centerX: number, centerY: number, radius: number, value: number, maxValue: number, index: number, item: any): void;
|
|
869
|
+
getColor(point: DataPoint | null, index: number): string;
|
|
870
|
+
createLegend(): void;
|
|
413
871
|
}
|
|
414
872
|
|
|
415
873
|
/**
|
|
416
874
|
* 箱线图系列
|
|
875
|
+
*
|
|
876
|
+
* 数据格式:field 为数组,如 ['min', 'q1', 'median', 'q3', 'max']
|
|
877
|
+
*
|
|
878
|
+
* @example
|
|
879
|
+
* chart.createSeries('boxPlot', {
|
|
880
|
+
* field: ['min', 'q1', 'median', 'q3', 'max'],
|
|
881
|
+
* xField: 'category'
|
|
882
|
+
* });
|
|
417
883
|
*/
|
|
418
884
|
export declare class jmBoxPlotSeries extends jmSeries {
|
|
419
885
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
886
|
+
|
|
887
|
+
init(): void;
|
|
888
|
+
createBox(leftX: number, rightX: number, q1Y: number, q3Y: number, color: string): void;
|
|
889
|
+
createMedianLine(leftX: number, rightX: number, medianY: number, color: string): void;
|
|
890
|
+
createWhisker(centerX: number, minY: number, q1Y: number, maxY: number, q3Y: number, color: string, whiskerWidth: number): void;
|
|
891
|
+
createBoxLabel(item: any, centerX: number, medianY: number, xField: string): void;
|
|
892
|
+
getColor(item: any, index: number): string;
|
|
893
|
+
createLegend(): void;
|
|
420
894
|
}
|
|
421
895
|
|
|
422
896
|
/**
|
|
423
897
|
* 词云图系列
|
|
898
|
+
*
|
|
899
|
+
* 数据格式:field 为权重字段,xField 为词语字段
|
|
900
|
+
*
|
|
901
|
+
* @example
|
|
902
|
+
* chart.createSeries('wordCloud', {
|
|
903
|
+
* field: 'weight',
|
|
904
|
+
* xField: 'word',
|
|
905
|
+
* style: { minFontSize: 12, maxFontSize: 60, spiral: true }
|
|
906
|
+
* });
|
|
424
907
|
*/
|
|
425
908
|
export declare class jmWordCloudSeries extends jmSeries {
|
|
426
909
|
constructor(options: SeriesOptions & { graph: jmChart });
|
|
910
|
+
|
|
911
|
+
placedWords: Array<{ x: number; y: number; width: number; height: number }>;
|
|
912
|
+
|
|
913
|
+
init(): void;
|
|
914
|
+
findPosition(centerX: number, centerY: number, text: string, fontSize: number, chartWidth: number, chartHeight: number): { x: number; y: number; width: number; height: number } | null;
|
|
915
|
+
findSpiralPosition(centerX: number, centerY: number, width: number, height: number, chartWidth: number, chartHeight: number): { x: number; y: number; width: number; height: number } | null;
|
|
916
|
+
findGridPosition(centerX: number, centerY: number, width: number, height: number, chartWidth: number, chartHeight: number): { x: number; y: number; width: number; height: number } | null;
|
|
917
|
+
canPlace(x: number, y: number, width: number, height: number, chartWidth: number, chartHeight: number): boolean;
|
|
918
|
+
createWordLabel(text: string, x: number, y: number, fontSize: number, color: string, item: any): void;
|
|
919
|
+
getColor(item: any, index: number): string;
|
|
920
|
+
createLegend(): void;
|
|
427
921
|
}
|
|
428
922
|
|
|
429
923
|
/**
|
|
@@ -463,6 +957,23 @@ export declare const vChart: {
|
|
|
463
957
|
|
|
464
958
|
/**
|
|
465
959
|
* jmChart 图表主类
|
|
960
|
+
*
|
|
961
|
+
* @example
|
|
962
|
+
* import jmChart from 'jmchart';
|
|
963
|
+
*
|
|
964
|
+
* const chart = new jmChart(document.getElementById('container'), {
|
|
965
|
+
* width: 800,
|
|
966
|
+
* height: 400,
|
|
967
|
+
* enableAnimate: true
|
|
968
|
+
* });
|
|
969
|
+
*
|
|
970
|
+
* chart.data = [
|
|
971
|
+
* { name: '一月', value: 100 },
|
|
972
|
+
* { name: '二月', value: 200 }
|
|
973
|
+
* ];
|
|
974
|
+
*
|
|
975
|
+
* chart.createSeries('line', { field: 'value', xField: 'name' });
|
|
976
|
+
* chart.refresh();
|
|
466
977
|
*/
|
|
467
978
|
export declare class jmChart extends jmGraph {
|
|
468
979
|
constructor(container: HTMLElement | string, options?: jmChartOptions);
|
|
@@ -483,15 +994,25 @@ export declare class jmChart extends jmGraph {
|
|
|
483
994
|
barSeriesCount: number;
|
|
484
995
|
serieTypes: Record<string, new (...args: any[]) => jmSeries>;
|
|
485
996
|
|
|
997
|
+
/** 初始化图表 */
|
|
486
998
|
init(options: jmChartOptions): void;
|
|
999
|
+
/** 重置图表,清除所有系列和轴 */
|
|
487
1000
|
reset(): void;
|
|
1001
|
+
/** 获取配色数组中的颜色 */
|
|
488
1002
|
getColor(index: number): string;
|
|
1003
|
+
/** 绘制图表前的前置处理 */
|
|
489
1004
|
beginDraw(): void;
|
|
1005
|
+
/** 重置画图区域位置 */
|
|
490
1006
|
resetAreaPosition(): void;
|
|
1007
|
+
/** 创建轴 */
|
|
491
1008
|
createAxis(options: AxisOptions): jmAxis;
|
|
1009
|
+
/** 创建 X 轴 */
|
|
492
1010
|
createXAxis(options?: AxisOptions): jmAxis;
|
|
1011
|
+
/** 创建 Y 轴 */
|
|
493
1012
|
createYAxis(options?: AxisOptions): jmAxis;
|
|
1013
|
+
/** 创建图表系列 */
|
|
494
1014
|
createSeries(type: SeriesType | (new (...args: any[]) => jmSeries), options?: SeriesOptions): jmSeries;
|
|
1015
|
+
/** 销毁图表 */
|
|
495
1016
|
destroy(): void;
|
|
496
1017
|
}
|
|
497
1018
|
|