@@ -4,6 +4,21 @@ const CONTAINER_ID = 'vTable';
44
55export function createTable ( ) {
66 const records = [
7+ { category : 'A' , value : 120 } ,
8+ { category : 'B' , value : 90 } ,
9+ { category : 'C' , value : 60 } ,
10+ { category : 'A' , value : 120 } ,
11+ { category : 'B' , value : 90 } ,
12+ { category : 'C' , value : 60 } ,
13+ { category : 'A' , value : 120 } ,
14+ { category : 'B' , value : 90 } ,
15+ { category : 'C' , value : 60 } ,
16+ { category : 'A' , value : 120 } ,
17+ { category : 'B' , value : 90 } ,
18+ { category : 'C' , value : 60 } ,
19+ { category : 'A' , value : 120 } ,
20+ { category : 'B' , value : 90 } ,
21+ { category : 'C' , value : 60 } ,
722 { category : 'A' , value : 120 } ,
823 { category : 'B' , value : 90 } ,
924 { category : 'C' , value : 60 }
@@ -89,11 +104,84 @@ export function createTable() {
89104 }
90105 ]
91106 }
92- ] ,
107+ ]
93108 // ensure title is laid out before legend so legend appears under the title
94- componentLayoutOrder : [ 'title' , 'legend' ]
109+ // componentLayoutOrder: ['title', 'legend']
95110 } ;
96111
97112 const tableInstance = new VTable . ListTable ( option ) ;
98113 ( window as any ) . tableInstance = tableInstance ;
114+ setTimeout ( ( ) => {
115+ tableInstance . updateOption ( {
116+ container : document . getElementById ( CONTAINER_ID ) ,
117+ records,
118+ columns,
119+ // place title and legend both at the top
120+ title : {
121+ text : 'Title above legend (componentLayoutOrder)' ,
122+ orient : 'top' ,
123+ align : 'center'
124+ } ,
125+ legends : [
126+ {
127+ type : 'discrete' ,
128+ orient : 'top' ,
129+ position : 'start' ,
130+ data : [
131+ {
132+ label : 'A' ,
133+ shape : {
134+ fill : '#1664FF' ,
135+ symbolType : 'circle'
136+ }
137+ } ,
138+ {
139+ label : 'B' ,
140+ shape : {
141+ fill : '#1AC6FF' ,
142+ symbolType : 'square'
143+ }
144+ } ,
145+ {
146+ label : 'C' ,
147+ shape : {
148+ fill : '#FFCC00' ,
149+ symbolType : 'triangle'
150+ }
151+ }
152+ ]
153+ } ,
154+ {
155+ type : 'discrete' ,
156+ orient : 'top' ,
157+ position : 'start' ,
158+ data : [
159+ {
160+ label : 'A11' ,
161+ shape : {
162+ fill : '#1664FF' ,
163+ symbolType : 'circle'
164+ }
165+ } ,
166+ {
167+ label : 'B' ,
168+ shape : {
169+ fill : '#1AC6FF' ,
170+ symbolType : 'square'
171+ }
172+ } ,
173+ {
174+ label : 'C' ,
175+ shape : {
176+ fill : '#FFCC00' ,
177+ symbolType : 'triangle'
178+ }
179+ }
180+ ]
181+ }
182+ ] ,
183+ // ensure title is laid out before legend so legend appears under the title
184+ componentLayoutOrder : [ 'title' , 'legend' ]
185+ } ) ;
186+ } , 4000 ) ;
99187}
0 commit comments