File tree 4 files changed +49
-0
lines changed
examples/component/legend/demo
4 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 6
6
7
7
_ Marker_ The supported tag types are: _ circle | square | line | diamond | triangle | triangle-down | hexagon | bowtie | cross | tick | plus | hyphen_ ;
8
8
_ MarkerCallback_ is ` (x: number, y: number, r: number) => PathCommand ` ;
9
+
10
+ [ DEMO] ( zh/examples/component/legend#legend-marker-customize ) of ` Customize legend marker ` .
Original file line number Diff line number Diff line change 14
14
15
15
回调的方式为:` (x: number, y: number, r: number) => PathCommand ` ;
16
16
17
+ 自定义图例 marker [ DEMO] ( zh/examples/component/legend#legend-marker-customize )
18
+
17
19
<!-- 这里可以插入一个代码示例-->
Original file line number Diff line number Diff line change
1
+ import { Column } from '@antv/g2plot' ;
2
+
3
+ fetch ( 'https://gw.alipayobjects.com/os/antfincdn/P14mCvkybz/large-datra.json' )
4
+ . then ( ( data ) => data . json ( ) )
5
+ . then ( ( data ) => {
6
+ const plot = new Column ( 'container' , {
7
+ data,
8
+ xField : 'product_box' ,
9
+ yField : 'value' ,
10
+ seriesField : 'province' ,
11
+ isGroup : 'true' ,
12
+ legend : {
13
+ flipPage : true ,
14
+ maxRow : 2 ,
15
+ marker : {
16
+ // 把 marker 从 square 变成线条
17
+ symbol : ( x , y , r ) => {
18
+ return [
19
+ [ 'M' , x - r / 2 , y ] ,
20
+ [ 'L' , x + r / 2 , y ] ,
21
+ ] ;
22
+ } ,
23
+ style : ( oldStyle ) => {
24
+ return {
25
+ ...oldStyle ,
26
+ r : 4 ,
27
+ lineWidth : 2 ,
28
+ // square marker 只有填充色,赋给 line 的 stroke
29
+ stroke : oldStyle . stroke || oldStyle . fill ,
30
+ } ;
31
+ } ,
32
+ } ,
33
+ } ,
34
+ } ) ;
35
+
36
+ plot . render ( ) ;
37
+ } ) ;
Original file line number Diff line number Diff line change 43
43
"en" : " Legend flip-page configuration"
44
44
},
45
45
"screenshot" : " https://gw.alipayobjects.com/zos/antfincdn/W6n7yMd5lw/0a28a2bd-e5f3-4756-8fda-d8e2faf79076.png"
46
+ },
47
+ {
48
+ "filename" : " legend-marker-customize.ts" ,
49
+ "title" : {
50
+ "zh" : " 图例 marker 自定义" ,
51
+ "en" : " Customize legend marker"
52
+ },
53
+ "screenshot" : " https://gw.alipayobjects.com/zos/antfincdn/w87M340IdH/5f2f2e58-8426-4f6e-8100-7529ed57b5ed.png"
46
54
}
47
55
]
48
56
}
You can’t perform that action at this time.
0 commit comments