-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathechartsfroceDemo.html
More file actions
2475 lines (2463 loc) · 157 KB
/
echartsfroceDemo.html
File metadata and controls
2475 lines (2463 loc) · 157 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta charset="utf-8">
</head>
<body style="height: 100%; margin: 0;background: #FDF6E3;">
<div id="container" style="height: 100%"></div>
<!--<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts.min.js"></script>-->
<!--<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts-gl/echarts-gl.min.js"></script>-->
<!--<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts-stat/ecStat.min.js"></script>-->
<!--<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/dataTool.min.js"></script>-->
<!--<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script>-->
<!--<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/world.js"></script>-->
<!--<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=ZUONbpqGBsYGXNIYHicvbAbM"></script>-->
<!--<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/bmap.min.js"></script>-->
<!--<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/simplex.js"></script>-->
<script src="js/echarts.js"></script>
<script src="../../js/jQuery/jquery.min.js"></script>
<script type="text/javascript">
var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var app = {};
option = null;
app.title = '力引导布局';
myChart.showLoading();
var nodes = [];
var numNodes = 225;
for (var x = 0; x < numNodes; x++) {
var targetAry = [];
var connections = (Math.round(Math.random() * 5));
for (var y = 0; y < connections; y++) {
targetAry.push(Math.round(Math.random() * numNodes))
}
nodes.push({
id: x,
name: "Node " + x,
target: targetAry,
value:15
})
}
var links = [];
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].target !== undefined) {
for (var j = 0; j < nodes[i].target.length; j++) {
links.push({
source: nodes[i].id,
target: nodes[i].target[j],
linkStyle:{
color:"#6CFFCB",
width:1
}
});
}
}
}
/* var nodes = [
{name:"0",value:"val0"},
{name:"1",value:"val1"},
{name:"2",value:"val2"},
{name:"3",value:"val3"},
{name:"4",value:"val4"},
{name:"5",value:"val5"},
{name:"6",value:"val6"}
];
var links = [
{source:0,target:1,value:"link0"},
{source:1,target:0,value:"link2"},
{source:0,target:1,value:"link3"},
{source:1,target:0,value:"link4"},
{source:0,target:2,value:"link5"},
{source:0,target:3,value:"link6"},
{source:1,target:4,value:"link7"},
{source:1,target:5,value:"link8"},
{source:1,target:6,value:"link9"}
];*/
option = {
title: {
text: 'echarts拓朴图demo',
subtext: '**科技',
top: 'top',
left: 'left'
},
tooltip: {},
animation: true,
series : [
{
type: 'graph',//string 默认必写
id:"",// string 组件 ID。默认不指定。指定则可用于在 option 或者 API 中引用组件。
name: '**科技',//string系列名称,用于tooltip的显示,legend 的图例筛选,在 setOption 更新数据和配置项时用于指定对应的系列。
legendHoverLink:true,//boolean是否启用图例 hover 时的联动高亮。
coordinateSystem:null,//
/**
* string
该系列使用的坐标系,可选:
null 或者 'none'
无坐标系。
'cartesian2d'
使用二维的直角坐标系(也称笛卡尔坐标系),通过 xAxisIndex, yAxisIndex指定相应的坐标轴组件。
'polar'
使用极坐标系,通过 polarIndex 指定相应的极坐标组件
'geo'
使用地理坐标系,通过 geoIndex 指定相应的地理坐标系组件。
'none'
不使用坐标系。
*/
xAxisIndex:0,// number 使用的 x 轴的 index,在单个图表实例中存在多个 x 轴的时候有用。
yAxisIndex:0,//number 使用的 y 轴的 index,在单个图表实例中存在多个 y轴的时候有用。
polarIndex:0,//number 使用的极坐标系的 index,在单个图表实例中存在多个极坐标系的时候有用。
geoIndex:0,// number 使用的地理坐标系的 index,在单个图表实例中存在多个地理坐标系的时候有用。
calendarIndex:0,//number使用的日历坐标系的 index,在单个图表实例中存在多个日历坐标系的时候有用。
hoverAnimation:true,//boolean是否开启鼠标 hover 节点的提示动画效果。
layout: 'force',// string none不采用任何布局,使用节点中提供的 x, y 作为节点的位置。
//'circular' 采用环形布局 'force' 采用力引导布局
circular:{ // Object 环形布局相关配置
rotateLabel:false//boolean是否旋转标签,默认不旋转
},
force: {
/**
* Object
* 力引导布局相关的配置项,力引导布局是模拟弹簧电荷模型在每两个节点之间添加一个斥力,
* 每条边的两个节点之间添加一个引力,每次迭代节点会在各个斥力和引力的作用下移动位置,
* 多次迭代后节点会静止在一个受力平衡的位置,达到整个模型的能量最小化。
* 力引导布局的结果有良好的对称性和局部聚合性,也比较美观。
*/
initLayout:"",
/**
* string
* 进行力引导布局前的初始化布局,初始化布局会影响到力引导的效果。
*默认不进行任何布局,使用节点中提供的 x, y 作为节点的位置。如果不存在的话会随机生成一个位置。
*也可以选择使用环形布局 'circular'。
*/
repulsion: 100,
/**
* Array, number
* [ default: 50 ]
节点之间的斥力因子。
支持设置成数组表达斥力的范围,此时不同大小的值会线性映射到不同的斥力。值越大则斥力越大
*/
gravity:0.1, // number [ default: 0.1 ] 节点受到的向中心的引力因子。该值越大节点越往中心点靠拢。
edgeLength:30,
/**
* Array, number
* [ default: 30 ]
边的两个节点之间的距离,这个距离也会受 repulsion。
支持设置成数组表达边长的范围,此时不同大小的值会线性映射到不同的长度。值越小则长度越长。如下示例
// 值最大的边长度会趋向于 10,值最小的边长度会趋向于 50
edgeLength: [10, 50]
*/
layoutAnimation:true
/**
* boolean
* [ default: true ]
* 因为力引导布局会在多次迭代后才会稳定,
* 这个参数决定是否显示布局的迭代动画,在浏览器端节点数据较多(>100)的时候不建议关闭,布局过程会造成浏览器假死。
*/
},
roam: true,
/**
* boolean
* [ default: false ]
* 是否开启鼠标缩放和平移漫游。默认不开启。如果只想要开启缩放或者平移,可以设置成 'scale' 或者 'move'。设置成 true 为都开启
*/
nodeScaleRatio:0.6,//number [ default: 0.6 ] 鼠标漫游缩放时节点的相应缩放比例,当设为0时节点不随着鼠标的缩放而缩放
draggable:true,//boolean [ default: false ] 节点是否可拖拽,只在使用力引导布局的时候有用。
focusNodeAdjacency:true,//boolean [ default: false ] 是否在鼠标移到节点上的时候突出显示节点以及节点的边和邻接节点。
symbol:"circle",
/**
* string
* [ default: 'circle' ]
* 关系图节点标记的图形。
* ECharts 提供的标记类型包括 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow'
* 可以通过 'image://url' 设置为图片,其中 URL 为图片的链接,或者 dataURI。
* URL 为图片链接例如:
* 'image://http://xxx.xxx.xxx/a/b.png'
* URL 为 dataURI 例如:
* 'image://data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy
* 7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlC
* QAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7'
* 可以通过 'path://' 将图标设置为任意的矢量路径。这种方式相比于使用图片的方式,
* 不用担心因为缩放而产生锯齿或模糊,而且可以设置为任意颜色。路径图形会自适应调整为合适的大小。
* 路径的格式参见 SVG PathData。可以从 Adobe Illustrator 等工具编辑导出。
* 例如:
* 'path://M30.9,53.2C16.8,53.2,5.3,41.7,5.3,27.6S16.8,2,30.9,2C45,2,56.4,1
* 3.5,56.4,27.6S45,53.2,30.9,53.2z M30.9,3.5C17.6,3.5,6.8,14.4,6.8,27.6c0,13
* .3,10.8,24.1,24.101,24.1C44.2,51.7,55,40.9,55,27.6C54.9,14.4,44.1,3.5,30.9,3.
* 5z M36.9,35.8c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.
* 4-1,0.9-1H36c0.5,0,0.9,0.4,0.9,1V35.8z M27.8,35.8 c0,0.601-0.4,1-0.9,1h-1.3c-
* 0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H27c0.5,0,0.9,0.4,0.9,1L27.8,35.8L27.8,35.8z'
*/
symbolSize:10,
/**
* number, Array, Function
* [ default: 10 ]
* 关系图节点标记的大小,可以设置成诸如 10 这样单一的数字,也可以用数组分开表示宽和高,例如 [20, 10] 表示标记宽为20,高为10。
* 如果需要每个数据的图形大小不一样,可以设置为如下格式的回调函数:
* (value: Array|number, params: Object) => number|Array
* 其中第一个参数 value 为 data 中的数据值。第二个参数params 是其它的数据项参数。
*/
symbolRotate:undefined,//number 关系图节点标记的旋转角度。注意在 markLine 中当 symbol 为 'arrow' 时会忽略 symbolRotate 强制设置为切线的角度。
symbolKeepAspect:false,//boolean [ default: false ] 如果 symbol 是 path:// 的形式,是否在缩放时保持该图形的长宽比
symbolOffset:[0,0],
/**
* Array
* [ default: [0, 0] ]
* 关系图节点标记相对于原本位置的偏移。默认情况下,标记会居中置放在数据对应的位置,但是如果 symbol 是自定义的矢量路径或者图片,就有可能不希望 symbol 居中。这时候可以使用该配置项配置 symbol 相对于原本居中的偏移,可以是绝对的像素值,也可以是相对的百分比。
* 例如 [0, '50%'] 就是把自己向上移动了一半的位置,在 symbol 图形是气泡的时候可以让图形下端的箭头对准数据点。
*/
edgeSymbol:['none','none'],
/**
* Array, string
* [ default: ['none', 'none'] ]
* 边两端的标记类型,可以是一个数组分别指定两端,也可以是单个统一指定。默认不显示标记,常见的可以设置为箭头,如下:
* edgeSymbol: ['circle', 'arrow']
*/
edgeSymbolSize:10,//Array, number [ default: 10 ] 边两端的标记大小,可以是一个数组分别指定两端,也可以是单个统一指定。
cursor:"none",// string [ default: 'pointer' ] 鼠标悬浮时在图形元素上时鼠标的样式是什么。同 CSS 的 cursor。
itemStyle:{
/**
* Object
* 图形样式。
* 折叠详情
*/
color:undefined,
/**
* Color, Function
* [ default: 自适应 ]
图形的颜色。 默认从全局调色盘 option.color 获取颜色
颜色可以使用 RGB 表示,比如 'rgb(128, 128, 128)',如果想要加上 alpha 通道表示不透明度,可以使用 RGBA,比如 'rgba(128, 128, 128, 0.5)',也可以使用十六进制格式,比如 '#ccc'。除了纯色之外颜色也支持渐变色和纹理填充
// 线性渐变,前四个参数分别是 x0, y0, x2, y2, 范围从 0 - 1,相当于在图形包围盒中的百分比,如果 globalCoord 为 `true`,则该四个值是绝对的像素位置
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [{
offset: 0, color: 'red' // 0% 处的颜色
}, {
offset: 1, color: 'blue' // 100% 处的颜色
}],
globalCoord: false // 缺省为 false
}
// 径向渐变,前三个参数分别是圆心 x, y 和半径,取值同线性渐变
color: {
type: 'radial',
x: 0.5,
y: 0.5,
r: 0.5,
colorStops: [{
offset: 0, color: 'red' // 0% 处的颜色
}, {
offset: 1, color: 'blue' // 100% 处的颜色
}],
globalCoord: false // 缺省为 false
}
// 纹理填充
color: {
image: imageDom, // 支持为 HTMLImageElement, HTMLCanvasElement,不支持路径字符串
repeat: 'repeat' // 是否平铺, 可以是 'repeat-x', 'repeat-y', 'no-repeat'
}
支持使用回调函数。回调函数格式如下:
(params: Object) => Color
传入的是数据项 seriesIndex, dataIndex, data, value 等各个参数。
*/
borderColor:"#000",// Color [ default: "#000" ] 图形的描边颜色。支持的颜色格式同 color,不支持回调函数
borderWidth:0,//number [ default: 0 ] 描边线宽。为 0 时无描边。
borderType:"solid",//string[ default: 'solid' ] 柱条的描边类型,默认为实线,支持 'solid', 'dashed', 'dotted'。
shadowBlur:undefined,
/**
* number
* 图形阴影的模糊大小。该属性配合 shadowColor,shadowOffsetX, shadowOffsetY 一起设置图形的阴影效果。
示例:
{
shadowColor: 'rgba(0, 0, 0, 0.5)',
shadowBlur: 10
}
*/
shadowColor:undefined,//Color 阴影颜色。支持的格式同color。
shadowOffsetX:0,//number[ default: 0 ] 阴影水平方向上的偏移距离。
shadowOffsetY:0,//number[ default: 0 ] 阴影垂直方向上的偏移距离。
opacity:undefined,//number 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
},
lineStyle:{
/**
* Object
* 关系边的公用线条样式。
* 其中 lineStyle.color 支持设置为'source'或者'target'特殊值,
* 此时边会自动取源节点或目标节点的颜色作为自己的颜色。
*/
color:"#aaa",
/**
* Color
[ default: '#aaa' ]
线的颜色。
颜色可以使用 RGB 表示,比如 'rgb(128, 128, 128)',如果想要加上 alpha 通道表示不透明度,可以使用 RGBA,比如 'rgba(128, 128, 128, 0.5)',也可以使用十六进制格式,比如 '#ccc'。除了纯色之外颜色也支持渐变色和纹理填充
// 线性渐变,前四个参数分别是 x0, y0, x2, y2, 范围从 0 - 1,相当于在图形包围盒中的百分比,如果 globalCoord 为 `true`,则该四个值是绝对的像素位置
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [{
offset: 0, color: 'red' // 0% 处的颜色
}, {
offset: 1, color: 'blue' // 100% 处的颜色
}],
globalCoord: false // 缺省为 false
}
// 径向渐变,前三个参数分别是圆心 x, y 和半径,取值同线性渐变
color: {
type: 'radial',
x: 0.5,
y: 0.5,
r: 0.5,
colorStops: [{
offset: 0, color: 'red' // 0% 处的颜色
}, {
offset: 1, color: 'blue' // 100% 处的颜色
}],
globalCoord: false // 缺省为 false
}
// 纹理填充
color: {
image: imageDom, // 支持为 HTMLImageElement, HTMLCanvasElement,不支持路径字符串
repeat: 'repeat' // 是否平铺, 可以是 'repeat-x', 'repeat-y', 'no-repeat'
}
*/
width:1,//number [ default: 1 ] 线宽。
type:"solid",//string [ default: solid ]线的类型。可选:'solid''dashed''dotted'
shadowBlur:undefined,
/**
* number
图形阴影的模糊大小。该属性配合 shadowColor,shadowOffsetX, shadowOffsetY 一起设置图形的阴影效果。
示例:
{
shadowColor: 'rgba(0, 0, 0, 0.5)',
shadowBlur: 10
}
*/
shadowColor:undefined,//Color 阴影颜色。支持的格式同color。
shadowOffsetX:0,//number[ default: 0 ] 阴影水平方向上的偏移距离。
shadowOffsetY:0,//number[ default: 0 ] 阴影垂直方向上的偏移距离。
opacity:0.5,//number [ default: 0.5 ] 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
curveness:0,// number [ default: 0 ] 边的曲度,支持从 0 到 1 的值,值越大曲度越大。
},
label:{
/**
* 图形上的文本标签,可用于说明图形的一些数据信息,
* 比如值,名称等,label选项在 ECharts 2.x 中放置于itemStyle下,
* 在 ECharts 3 中为了让整个配置项结构更扁平合理,label 被拿出来跟
* itemStyle 平级,并且跟 itemStyle 一样拥有 emphasis 状态。
*/
show:false,//boolean[ default: false ] 是否显示标签。
position:"inside",
/**
* string, Array
[ default: 'inside' ]
标签的位置。
可选:
[x, y]
通过相对的百分比或者绝对像素值表示标签相对于图形包围盒左上角的位置。 示例:
// 绝对的像素值
position: [10, 10],
// 相对的百分比
position: ['50%', '50%']
*/
distance:5,
/**
* number
[ default: 5 ]
距离图形元素的距离。当 position 为字符描述值(如 'top'、'insideRight')时候有效。
参见:label position。
*/
rotate:undefined,// number 标签旋转。从 -90 度到 90 度。正值是逆时针。参见:label rotation。
offset:[0,0],//Array 是否对文字进行偏移。默认不偏移。例如:[30, 40] 表示文字在横向上偏移 30,纵向上偏移 40。
color:"#fff",//Color[ default: "#fff" ] 文字的颜色。 如果设置为 'auto',则为视觉映射得到的颜色,如系列色。
fontStyle:"normal",//string [ default: 'normal' ] 文字字体的风格 可选:'normal''italic' 'oblique'
fontWeight:"normal",//string [ default: normal ] 文字字体的粗细 可选:'normal''bold''bolder''lighter' 100 | 200 | 300 | 400...
fontFamily:"sans-serif",//string [ default: 'sans-serif' ] 文字的字体系列 还可以是 'serif' , 'monospace', 'Arial', 'Courier New', 'Microsoft YaHei', ...
fontSize:12,//number [ default: 12 ] 文字的字体大小
align:undefined,
/**
* string
文字水平对齐方式,默认自动。
可选:
'left'
'center'
'right'
rich 中如果没有设置 align,则会取父层级的 align。例如:
{
align: right,
rich: {
a: {
// 没有设置 `align`,则 `align` 为 right
}
}
}
*/
verticalAlign:undefined,
/**
* string
文字垂直对齐方式,默认自动。
可选:
'top'
'middle'
'bottom'
rich 中如果没有设置 verticalAlign,则会取父层级的 verticalAlign。例如:
{
verticalAlign: bottom,
rich: {
a: {
// 没有设置 `verticalAlign`,则 `verticalAlign` 为 bottom
}
}
}
*/
lineHeight:undefined,
/**
* number
行高。
rich 中如果没有设置 lineHeight,则会取父层级的 lineHeight。例如:
{
lineHeight: 56,
rich: {
a: {
// 没有设置 `lineHeight`,则 `lineHeight` 为 56
}
}
}
*/
backgroundColor:"transparent",
/**
* string, Object
[ default: 'transparent' ]
文字块背景色。
可以是直接的颜色值,例如:'#123234', 'red', rgba(0,23,11,0.3)'。
可以支持使用图片,例如:
backgroundColor: {
image: 'xxx/xxx.png'
// 这里可以是图片的 URL,
// 或者图片的 dataURI,
// 或者 HTMLImageElement 对象,
// 或者 HTMLCanvasElement 对象。
}
当使用图片的时候,可以使用 width 或 height 指定高宽,也可以不指定自适应。
如果设置为 'auto',则为视觉映射得到的颜色,如系列色。
*/
borderColor:"transparent",
/**
* string
[ default: 'transparent' ]
文字块边框颜色。
如果设置为 'auto',则为视觉映射得到的颜色,如系列色。
*/
borderWidth:0,//number [ default: 0 ] 文字块边框宽度。
borderRadius:0,//number, Array [ default: 0 ] 文字块的圆角。
padding:0,
/**
* number, Array
[ default: 0 ]
文字块的内边距。例如:
padding: [3, 4, 5, 6]:表示 [上, 右, 下, 左] 的边距。
padding: 4:表示 padding: [4, 4, 4, 4]。
padding: [3, 4]:表示 padding: [3, 4, 3, 4]。
注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。
*/
shadowColor:"transparent",//string [ default: 'transparent' ] 文字块的背景阴影颜色。
shadowBlur:0,//number [ default: 0 ] 文字块的背景阴影长度。
shadowOffsetX:0,//number [ default: 0 ] 文字块的背景阴影 X 偏移。
shadowOffsetY:0,//number [ default: 0 ] 文字块的背景阴影 Y 偏移。
width:undefined,
/**
* number, string
文字块的宽度。一般不用指定,不指定则自动是文字的宽度。在想做表格项或者使用图片(参见 backgroundColor)时,可能会使用它。
注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。
width 也可以是百分比字符串,如 '100%'。表示的是所在文本块的 contentWidth(即不包含文本块的 padding)的百分之多少。之所以以 contentWidth 做基数,因为每个文本片段只能基于 content box 布局。如果以 outerWidth 做基数,则百分比的计算在实用中不具有意义,可能会超出。
注意,如果不定义 rich 属性,则不能指定 width 和 height。
*/
height:undefined,
/**
* number, string
文字块的高度。一般不用指定,不指定则自动是文字的高度。在使用图片(参见 backgroundColor)时,可能会使用它。
注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。
注意,如果不定义 rich 属性,则不能指定 width 和 height。
*/
textBorderColor:"transparent",//string [ default: 'transparent' ] 文字本身的描边颜色。如果设置为 'auto',则为视觉映射得到的颜色,如系列色。
textBorderWidth:0,//number [ default: 0 ] 文字本身的描边宽度。
textShadowColor:0,//string [ default: 'transparent' ] 文字本身的阴影颜色。
textShadowBlur:0,//number [ default: 0 ] 文字本身的阴影长度。
textShadowOffsetX:0,//number [ default: 0 ] 文字本身的阴影 X 偏移。
textShadowOffsetY:0,//number [ default: 0 ] 文字本身的阴影 Y 偏移。
rich:{
/**
* 在 rich 里面,可以自定义富文本样式。利用富文本样式,可以在标签中做出非常丰富的效果。
例如:
label: {
// 在文本中,可以对部分文本采用 rich 中定义样式。
// 这里需要在文本中使用标记符号:
// `{styleName|text content text content}` 标记样式名。
// 注意,换行仍是使用 '\n'。
formatter: [
'{a|这段文本采用样式a}',
'{b|这段文本采用样式b}这段用默认样式{x|这段用样式x}'
].join('\n'),
rich: {
a: {
color: 'red',
lineHeight: 10
},
b: {
backgroundColor: {
image: 'xxx/xxx.jpg'
},
height: 40
},
x: {
fontSize: 18,
fontFamily: 'Microsoft YaHei',
borderColor: '#449933',
borderRadius: 4
},
...
}
}
*/
color:"#fff",
/**
* [ default: "#fff" ]
文字的颜色。
如果设置为 'auto',则为视觉映射得到的颜色,如系列色。
*/
fontStyle:"normal",//string [ default: 'normal' ] 文字字体的风格 可选:'normal' 'italic''oblique'
fontWeight:"normal",//string [ default: normal ] 文字字体的粗细 可选:'normal' 'bold' 'bolder' 'lighter' 100 | 200 | 300 | 400...
fontFamily:"sans-serif",//string [ default: 'sans-serif' ] 文字的字体系列 还可以是 'serif' , 'monospace', 'Arial', 'Courier New', 'Microsoft YaHei', ...
fontSize:12,//number [ default: 12 ] 文字的字体大小
align:undefined,
/**
* string
文字水平对齐方式,默认自动。
可选:
'left'
'center'
'right'
rich 中如果没有设置 align,则会取父层级的 align。例如:
{
align: right,
rich: {
a: {
// 没有设置 `align`,则 `align` 为 right
}
}
}
*/
verticalAlign:undefined,
/**
* string
文字垂直对齐方式,默认自动。
可选:
'top'
'middle'
'bottom'
rich 中如果没有设置 verticalAlign,则会取父层级的 verticalAlign。例如:
{
verticalAlign: bottom,
rich: {
a: {
// 没有设置 `verticalAlign`,则 `verticalAlign` 为 bottom
}
}
}
*/
lineHeight:undefined,
/**
*number
行高。
rich 中如果没有设置 lineHeight,则会取父层级的 lineHeight。例如:
{
lineHeight: 56,
rich: {
a: {
// 没有设置 `lineHeight`,则 `lineHeight` 为 56
}
}
}
*/
backgroundColor:"transparent",
/**
* string, Object
[ default: 'transparent' ]
文字块背景色。
可以是直接的颜色值,例如:'#123234', 'red', rgba(0,23,11,0.3)'。
可以支持使用图片,例如:
backgroundColor: {
image: 'xxx/xxx.png'
// 这里可以是图片的 URL,
// 或者图片的 dataURI,
// 或者 HTMLImageElement 对象,
// 或者 HTMLCanvasElement 对象。
}
当使用图片的时候,可以使用 width 或 height 指定高宽,也可以不指定自适应。
如果设置为 'auto',则为视觉映射得到的颜色,如系列色。
*/
borderColor:"transparent",//string [ default: 'transparent' ] 文字块边框颜色。如果设置为 'auto',则为视觉映射得到的颜色,如系列色。
borderWidth:0,//number [ default: 0 ] 文字块边框宽度。
borderRadius:0,//number, Array [ default: 0 ] 文字块的圆角。
padding:0,
/**
number, Array
[ default: 0 ]
文字块的内边距。例如:
padding: [3, 4, 5, 6]:表示 [上, 右, 下, 左] 的边距。
padding: 4:表示 padding: [4, 4, 4, 4]。
padding: [3, 4]:表示 padding: [3, 4, 3, 4]。
注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。
*/
shadowColor:"transparent",//string [ default: 'transparent' ] 文字块的背景阴影颜色。
shadowBlur:0,//number[ default: 0 ] 文字块的背景阴影长度。
shadowOffsetX:0,//number[ default: 0 ]文字块的背景阴影 X 偏移。
shadowOffsetY:0,//number [ default: 0 ]文字块的背景阴影 Y 偏移。
width:undefined,
/**
* number, string
文字块的宽度。一般不用指定,不指定则自动是文字的宽度。
在想做表格项或者使用图片(参见 backgroundColor)时,可能会使用它。
注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。
width 也可以是百分比字符串,如 '100%'。表示的是所在文本块的
contentWidth(即不包含文本块的 padding)的百分之多少。
之所以以 contentWidth 做基数,因为每个文本片段只能基于
content box 布局。如果以 outerWidth 做基数,则百分比的计算在实用中不具有意义,可能会超出。
注意,如果不定义 rich 属性,则不能指定 width 和 height。
*/
height:undefined,
/**
* number, string
文字块的高度。一般不用指定,不指定则自动是文字的高度。在使用图片(参见 backgroundColor)时,可能会使用它。
注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。
注意,如果不定义 rich 属性,则不能指定 width 和 height。
*/
textBorderColor:"transparent",//string [ default: 'transparent' ] 文字本身的描边颜色。如果设置为 'auto',则为视觉映射得到的颜色,如系列色。
textBorderWidth:0,//number[ default: 0 ]文字本身的描边宽度。
textShadowColor:"transparent",//string[ default: 'transparent' ] 文字本身的阴影颜色。
textShadowBlur:0,//number [ default: 0 ] 文字本身的阴影长度。
textShadowOffsetX:0,//number [ default: 0 ] 文字本身的阴影 X 偏移。
textShadowOffsetY:0,//number [ default: 0 ] 文字本身的阴影 Y 偏移。
}
},
edgeLabel:{
show:false,//boolean [ default: false ] 是否显示标签。
position:"middle",//string [ default: 'middle' ] 标签位置,可选:'start' 线的起始点。'middle' 线的中点。'end' 线的结束点。
formatter:undefined,
/**
* string, Function
标签内容格式器,支持字符串模板和回调函数两种形式,字符串模板与回调函数返回的字符串均支持用 \n 换行。
字符串模板 模板变量有:
{a}:系列名。
{b}:数据名。
{c}:数据值。
{@xxx}:数据中名为'xxx'的维度的值,如{@product}表示名为'product'` 的维度的值。
{@[n]}:数据中维度n的值,如{@[3]}` 表示维度 3 的值,从 0 开始计数。
示例:
formatter: '{b}: {@score}'
回调函数
回调函数格式:
(params: Object|Array) => string
参数 params 是 formatter 需要的单个数据集。格式如下:
{
componentType: 'series',
// 系列类型
seriesType: string,
// 系列在传入的 option.series 中的 index
seriesIndex: number,
// 系列名称
seriesName: string,
// 数据名,类目名
name: string,
// 数据在传入的 data 数组中的 index
dataIndex: number,
// 传入的原始数据项
data: Object,
// 传入的数据值
value: number|Array,
// 数据图形的颜色
color: string,
}
。
*/
color:"#fff",//Color [ default: "#fff" ] 文字的颜色。
fontStyle:"normal",//string[ default: 'normal' ] 文字字体的风格 可选:'normal' 'italic' 'oblique'
fontWeight:"normal",//string [ default: normal ] 文字字体的粗细 可选:'normal' 'bold' 'bolder' 'lighter' 100 | 200 | 300 | 400...
fontFamily:"sans-serif",//string [ default: 'sans-serif' ] 文字的字体系列 还可以是 'serif' , 'monospace', 'Arial', 'Courier New', 'Microsoft YaHei', ...
fontSize:12,//number [ default: 12 ] 文字的字体大小
align:undefined,
/**
* string
文字水平对齐方式,默认自动。
可选:
'left'
'center'
'right'
rich 中如果没有设置 align,则会取父层级的 align。例如:
{
align: right,
rich: {
a: {
// 没有设置 `align`,则 `align` 为 right
}
}
}
*/
verticalAlign:undefined,
/**
* string
文字垂直对齐方式,默认自动。
可选:
'top'
'middle'
'bottom'
rich 中如果没有设置 verticalAlign,则会取父层级的 verticalAlign。例如:
{
verticalAlign: bottom,
rich: {
a: {
// 没有设置 `verticalAlign`,则 `verticalAlign` 为 bottom
}
}
}
*/
lineHeight:undefined,
/**
* number
行高。
rich 中如果没有设置 lineHeight,则会取父层级的 lineHeight。例如:
{
lineHeight: 56,
rich: {
a: {
// 没有设置 `lineHeight`,则 `lineHeight` 为 56
}
}
}
*/
backgroundColor:"transparent",
/**
* string, Object
[ default: 'transparent' ]
文字块背景色。
可以是直接的颜色值,例如:'#123234', 'red', rgba(0,23,11,0.3)'。
可以支持使用图片,例如:
backgroundColor: {
image: 'xxx/xxx.png'
// 这里可以是图片的 URL,
// 或者图片的 dataURI,
// 或者 HTMLImageElement 对象,
// 或者 HTMLCanvasElement 对象。
}
当使用图片的时候,可以使用 width 或 height 指定高宽,也可以不指定自适应。
*/
borderColor:"transparent",//string [ default: 'transparent' ] 文字块边框颜色。
borderWidth:0,//number [ default: 0 ] 文字块边框宽度。
borderRadius:0,//number, Array [ default: 0 ] 文字块的圆角。
padding:0,
/**
* number, Array
[ default: 0 ]
文字块的内边距。例如:
padding: [3, 4, 5, 6]:表示 [上, 右, 下, 左] 的边距。
padding: 4:表示 padding: [4, 4, 4, 4]。
padding: [3, 4]:表示 padding: [3, 4, 3, 4]。
注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。
*/
shadowColor:"transparent",//string[ default: 'transparent' ] 文字块的背景阴影颜色。
shadowBlur:0,//number [ default: 0 ] 文字块的背景阴影长度。
shadowOffsetX:0,//number [ default: 0 ] 文字块的背景阴影 X 偏移。
shadowOffsetY:0,//number [ default: 0 ] 文字块的背景阴影 Y 偏移。
width:undefined,
/**
* number, string
文字块的宽度。一般不用指定,不指定则自动是文字的宽度。在想做表格项或者使用图片(参见 backgroundColor)时,可能会使用它。
注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。
width 也可以是百分比字符串,如 '100%'。表示的是所在文本块的 contentWidth(即不包含文本块的 padding)的百分之多少。之所以以 contentWidth 做基数,因为每个文本片段只能基于 content box 布局。如果以 outerWidth 做基数,则百分比的计算在实用中不具有意义,可能会超出。
注意,如果不定义 rich 属性,则不能指定 width 和 height。
*/
height:undefined,
/**
* number, string
文字块的高度。一般不用指定,不指定则自动是文字的高度。在使用图片(参见 backgroundColor)时,可能会使用它。
注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。
注意,如果不定义 rich 属性,则不能指定 width 和 height。
*/
textBorderColor:"transparent",//string [ default: 'transparent' ] 文字本身的描边颜色。如果设置为 'auto',则为视觉映射得到的颜色,如系列色。
textBorderWidth:0,//number [ default: 0 ] 文字本身的描边宽度。
textShadowColor:0,//string [ default: 'transparent' ] 文字本身的阴影颜色。
textShadowBlur:0,//number [ default: 0 ] 文字本身的阴影长度。
textShadowOffsetX:0,//number [ default: 0 ] 文字本身的阴影 X 偏移。
textShadowOffsetY:0,//number [ default: 0 ] 文字本身的阴影 Y 偏移。
rich:{
/**
* 在 rich 里面,可以自定义富文本样式。利用富文本样式,可以在标签中做出非常丰富的效果。
例如:
label: {
// 在文本中,可以对部分文本采用 rich 中定义样式。
// 这里需要在文本中使用标记符号:
// `{styleName|text content text content}` 标记样式名。
// 注意,换行仍是使用 '\n'。
formatter: [
'{a|这段文本采用样式a}',
'{b|这段文本采用样式b}这段用默认样式{x|这段用样式x}'
].join('\n'),
rich: {
a: {
color: 'red',
lineHeight: 10
},
b: {
backgroundColor: {
image: 'xxx/xxx.jpg'
},
height: 40
},
x: {
fontSize: 18,
fontFamily: 'Microsoft YaHei',
borderColor: '#449933',
borderRadius: 4
},
...
}
}
*/
color:"#fff",
/**
* [ default: "#fff" ]
文字的颜色。
如果设置为 'auto',则为视觉映射得到的颜色,如系列色。
*/
fontStyle:"normal",//string [ default: 'normal' ] 文字字体的风格 可选:'normal' 'italic''oblique'
fontWeight:"normal",//string [ default: normal ] 文字字体的粗细 可选:'normal' 'bold' 'bolder' 'lighter' 100 | 200 | 300 | 400...
fontFamily:"sans-serif",//string [ default: 'sans-serif' ] 文字的字体系列 还可以是 'serif' , 'monospace', 'Arial', 'Courier New', 'Microsoft YaHei', ...
fontSize:12,//number [ default: 12 ] 文字的字体大小
align:undefined,
/**
* string
文字水平对齐方式,默认自动。
可选:
'left'
'center'
'right'
rich 中如果没有设置 align,则会取父层级的 align。例如:
{
align: right,
rich: {
a: {
// 没有设置 `align`,则 `align` 为 right
}
}
}
*/
verticalAlign:undefined,
/**
* string
文字垂直对齐方式,默认自动。
可选:
'top'
'middle'
'bottom'
rich 中如果没有设置 verticalAlign,则会取父层级的 verticalAlign。例如:
{
verticalAlign: bottom,
rich: {
a: {
// 没有设置 `verticalAlign`,则 `verticalAlign` 为 bottom
}
}
}
*/
lineHeight:undefined,
/**
*number
行高。
rich 中如果没有设置 lineHeight,则会取父层级的 lineHeight。例如:
{
lineHeight: 56,
rich: {
a: {
// 没有设置 `lineHeight`,则 `lineHeight` 为 56
}
}
}
*/
backgroundColor:"transparent",
/**
* string, Object
[ default: 'transparent' ]
文字块背景色。
可以是直接的颜色值,例如:'#123234', 'red', rgba(0,23,11,0.3)'。
可以支持使用图片,例如:
backgroundColor: {
image: 'xxx/xxx.png'
// 这里可以是图片的 URL,
// 或者图片的 dataURI,
// 或者 HTMLImageElement 对象,
// 或者 HTMLCanvasElement 对象。
}
当使用图片的时候,可以使用 width 或 height 指定高宽,也可以不指定自适应。
如果设置为 'auto',则为视觉映射得到的颜色,如系列色。
*/
borderColor:"transparent",//string [ default: 'transparent' ] 文字块边框颜色。如果设置为 'auto',则为视觉映射得到的颜色,如系列色。
borderWidth:0,//number [ default: 0 ] 文字块边框宽度。
borderRadius:0,//number, Array [ default: 0 ] 文字块的圆角。
padding:0,
/**
number, Array
[ default: 0 ]
文字块的内边距。例如:
padding: [3, 4, 5, 6]:表示 [上, 右, 下, 左] 的边距。
padding: 4:表示 padding: [4, 4, 4, 4]。
padding: [3, 4]:表示 padding: [3, 4, 3, 4]。
注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。
*/
shadowColor:"transparent",//string [ default: 'transparent' ] 文字块的背景阴影颜色。
shadowBlur:0,//number[ default: 0 ] 文字块的背景阴影长度。
shadowOffsetX:0,//number[ default: 0 ]文字块的背景阴影 X 偏移。
shadowOffsetY:0,//number [ default: 0 ]文字块的背景阴影 Y 偏移。
width:undefined,
/**
* number, string
文字块的宽度。一般不用指定,不指定则自动是文字的宽度。
在想做表格项或者使用图片(参见 backgroundColor)时,可能会使用它。
注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。
width 也可以是百分比字符串,如 '100%'。表示的是所在文本块的
contentWidth(即不包含文本块的 padding)的百分之多少。
之所以以 contentWidth 做基数,因为每个文本片段只能基于
content box 布局。如果以 outerWidth 做基数,则百分比的计算在实用中不具有意义,可能会超出。
注意,如果不定义 rich 属性,则不能指定 width 和 height。
*/
height:undefined,
/**
* number, string
文字块的高度。一般不用指定,不指定则自动是文字的高度。在使用图片(参见 backgroundColor)时,可能会使用它。
注意,文字块的 width 和 height 指定的是内容高宽,不包含 padding。
注意,如果不定义 rich 属性,则不能指定 width 和 height。
*/
textBorderColor:"transparent",//string [ default: 'transparent' ] 文字本身的描边颜色。如果设置为 'auto',则为视觉映射得到的颜色,如系列色。
textBorderWidth:0,//number[ default: 0 ]文字本身的描边宽度。
textShadowColor:"transparent",//string[ default: 'transparent' ] 文字本身的阴影颜色。
textShadowBlur:0,//number [ default: 0 ] 文字本身的阴影长度。
textShadowOffsetX:0,//number [ default: 0 ] 文字本身的阴影 X 偏移。
textShadowOffsetY:0,//number [ default: 0 ] 文字本身的阴影 Y 偏移。
}
},
emphasis:{
//高亮的图形样式。
itemStyle:{
color:undefined,
/**
* Color
[ default: 自适应 ]
图形的颜色。
颜色可以使用 RGB 表示,比如 'rgb(128, 128, 128)',如果想要加上 alpha 通道表示不透明度,可以使用 RGBA,比如 'rgba(128, 128, 128, 0.5)',也可以使用十六进制格式,比如 '#ccc'。除了纯色之外颜色也支持渐变色和纹理填充
// 线性渐变,前四个参数分别是 x0, y0, x2, y2, 范围从 0 - 1,相当于在图形包围盒中的百分比,如果 globalCoord 为 `true`,则该四个值是绝对的像素位置
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [{
offset: 0, color: 'red' // 0% 处的颜色
}, {
offset: 1, color: 'blue' // 100% 处的颜色
}],
globalCoord: false // 缺省为 false
}
// 径向渐变,前三个参数分别是圆心 x, y 和半径,取值同线性渐变
color: {
type: 'radial',
x: 0.5,
y: 0.5,
r: 0.5,
colorStops: [{
offset: 0, color: 'red' // 0% 处的颜色
}, {
offset: 1, color: 'blue' // 100% 处的颜色
}],
globalCoord: false // 缺省为 false
}
// 纹理填充
color: {
image: imageDom, // 支持为 HTMLImageElement, HTMLCanvasElement,不支持路径字符串
repeat: 'repeat' // 是否平铺, 可以是 'repeat-x', 'repeat-y', 'no-repeat'
}
*/
borderColor:"#000",//Color[ default: "#000" ]图形的描边颜色。支持的颜色格式同 color,不支持回调函数。