@@ -55,8 +55,6 @@ export function transformData(
55
55
return transformedData ;
56
56
}
57
57
58
- const notAxisChartSet : Set < CharOptionCompType > = new Set ( [ "pie" ] as const ) ;
59
- const notAxisChartSubtypeSet : Set < string > = new Set ( [ "polar" ] as const ) ;
60
58
export const echartsConfigOmitChildren = [
61
59
"hidden" ,
62
60
"selectedPoints" ,
@@ -65,81 +63,23 @@ export const echartsConfigOmitChildren = [
65
63
] as const ;
66
64
type EchartsConfigProps = Omit < ChartCompPropsType , typeof echartsConfigOmitChildren [ number ] > ;
67
65
68
-
69
- export function isAxisChart ( type : CharOptionCompType , polar : boolean ) {
70
- return ! notAxisChartSet . has ( type ) && ! polar ;
71
- }
72
-
73
66
export function getSeriesConfig ( props : EchartsConfigProps ) {
74
67
let visibleSeries = props . series . filter ( ( s ) => ! s . getView ( ) . hide ) ;
75
- if ( props . chartConfig . subtype === "waterfall" ) {
76
- const seriesOn = visibleSeries [ 0 ] ;
77
- const seriesPlaceholder = visibleSeries [ 0 ] ;
78
- visibleSeries = [ seriesPlaceholder , seriesOn ] ;
79
- }
80
68
const seriesLength = visibleSeries . length ;
81
69
return visibleSeries . map ( ( s , index ) => {
82
- if ( isAxisChart ( props . chartConfig . type , props . chartConfig . polarData ?. polar ) ) {
83
- let encodeX : string , encodeY : string ;
84
- const horizontalX = props . xAxisDirection === "horizontal" ;
85
- let itemStyle = props . chartConfig . itemStyle ;
86
-
87
- if ( horizontalX ) {
88
- encodeX = props . xAxisKey ;
89
- encodeY = s . getView ( ) . columnName ;
90
- } else {
91
- encodeX = s . getView ( ) . columnName ;
92
- encodeY = props . xAxisKey ;
93
- }
94
- const markLineData = s . getView ( ) . markLines . map ( line => ( { type : line . getView ( ) . type } ) ) ;
95
- const markAreaData = s . getView ( ) . markAreas . map ( area => ( [ { name : area . getView ( ) . name , [ horizontalX ?"xAxis" :"yAxis" ] : area . getView ( ) . from , label : {
96
- position : horizontalX ?"top" :"right" ,
97
- } } , { [ horizontalX ?"xAxis" :"yAxis" ] : area . getView ( ) . to } ] ) ) ;
98
- return {
99
- name : s . getView ( ) . seriesName ,
100
- selectedMode : "single" ,
101
- select : {
102
- itemStyle : {
103
- borderColor : "#000" ,
104
- } ,
105
- } ,
106
- step : s . getView ( ) . step ,
107
- encode : {
108
- x : encodeX ,
109
- y : encodeY ,
110
- } ,
111
- markLine : {
112
- data : markLineData ,
113
- } ,
114
- markArea : {
115
- itemStyle : {
116
- color : 'rgba(255, 173, 177, 0.4)' ,
117
- } ,
118
- data : markAreaData ,
119
- } ,
120
- // each type of chart's config
121
- ...props . chartConfig ,
122
- itemStyle : itemStyle ,
123
- label : {
124
- ...props . chartConfig . label ,
125
- ...( ! horizontalX && { position : "outside" } ) ,
126
- } ,
127
- } ;
128
- } else {
129
- // pie
130
- const radiusAndCenter = getPieRadiusAndCenter ( seriesLength , index , props . chartConfig ) ;
131
- return {
132
- ...props . chartConfig ,
133
- radius : radiusAndCenter . radius ,
134
- center : radiusAndCenter . center ,
135
- name : s . getView ( ) . seriesName ,
136
- selectedMode : "single" ,
137
- encode : {
138
- itemName : props . xAxisKey ,
139
- value : s . getView ( ) . columnName ,
140
- } ,
141
- } ;
142
- }
70
+ // pie
71
+ const radiusAndCenter = getPieRadiusAndCenter ( seriesLength , index , props . chartConfig ) ;
72
+ return {
73
+ ...props . chartConfig ,
74
+ radius : radiusAndCenter . radius ,
75
+ center : radiusAndCenter . center ,
76
+ name : s . getView ( ) . seriesName ,
77
+ selectedMode : "single" ,
78
+ encode : {
79
+ itemName : props . xAxisKey ,
80
+ value : s . getView ( ) . columnName ,
81
+ } ,
82
+ } ;
143
83
} ) ;
144
84
}
145
85
@@ -149,8 +89,6 @@ export function getEchartsConfig(
149
89
chartSize ?: ChartSize ,
150
90
theme ?: any ,
151
91
) : EChartsOptionWithMap {
152
- // axisChart
153
- const axisChart = isAxisChart ( props . chartConfig . type , props . chartConfig . polarData ?. polar ) ;
154
92
const gridPos = {
155
93
left : `${ props ?. left } %` ,
156
94
right : `${ props ?. right } %` ,
@@ -189,38 +127,13 @@ export function getEchartsConfig(
189
127
...gridPos ,
190
128
containLabel : true ,
191
129
} ,
192
- animationDuration : props . animationDuration ,
193
130
} ;
194
- if ( props . areaPieces . length > 0 ) {
195
- config . visualMap = {
196
- type : 'piecewise' ,
197
- show : false ,
198
- dimension : 0 ,
199
- seriesIndex : 0 ,
200
- pieces : props . areaPieces ?. filter ( p => p . getView ( ) . from && p . getView ( ) . to && p . getView ( ) . color ) ?. map ( p => (
201
- {
202
- ...( p . getView ( ) . from ?{ min : parseInt ( p . getView ( ) . from ) } :{ } ) ,
203
- ...( p . getView ( ) . to ?{ max : parseInt ( p . getView ( ) . to ) } :{ } ) ,
204
- ...( p . getView ( ) . color ?{ color : p . getView ( ) . color } :{ } ) ,
205
- }
206
- ) )
207
- }
208
- }
209
- if ( props . chartConfig . race ) {
210
- config = {
211
- ...config ,
212
- // Disable init animation.
213
- animationDuration : 0 ,
214
- animationDurationUpdate : 2000 ,
215
- animationEasing : 'linear' ,
216
- animationEasingUpdate : 'linear' ,
217
- }
218
- }
131
+
219
132
if ( props . data . length <= 0 ) {
220
133
// no data
221
134
return {
222
135
...config ,
223
- ...( axisChart ? noDataAxisConfig : noDataPieChartConfig ) ,
136
+ ...noDataPieChartConfig ,
224
137
} ;
225
138
}
226
139
const yAxisConfig = props . yConfig ( ) ;
@@ -231,27 +144,6 @@ export function getEchartsConfig(
231
144
let transformedData =
232
145
yAxisConfig . type === "category" || yAxisConfig . type === "time" ? props . data : transformData ( props . data , props . xAxisKey , seriesColumnNames ) ;
233
146
234
- if ( props . chartConfig . polarData ?. polar ) {
235
- config = {
236
- ...config ,
237
- polar : {
238
- radius : [ props . chartConfig . polarData . polarRadiusStart , props . chartConfig . polarData . polarRadiusEnd ] ,
239
- } ,
240
- radiusAxis : {
241
- type : props . chartConfig . polarData . polarIsTangent ?'category' :undefined ,
242
- data : props . chartConfig . polarData . polarIsTangent && props . chartConfig . polarData . labelData . length !== 0 ?props . chartConfig . polarData . labelData :undefined ,
243
- max : props . chartConfig . polarData . polarIsTangent ?undefined :props . chartConfig . polarData . radiusAxisMax || undefined ,
244
- } ,
245
- angleAxis : {
246
- type : props . chartConfig . polarData . polarIsTangent ?undefined :'category' ,
247
- data : ! props . chartConfig . polarData . polarIsTangent && props . chartConfig . polarData . labelData . length !== 0 ?props . chartConfig . polarData . labelData :undefined ,
248
- max : props . chartConfig . polarData . polarIsTangent ?props . chartConfig . polarData . radiusAxisMax || undefined :undefined ,
249
- startAngle : props . chartConfig . polarData . polarStartAngle ,
250
- endAngle : props . chartConfig . polarData . polarEndAngle ,
251
- } ,
252
- }
253
- }
254
-
255
147
config = {
256
148
...config ,
257
149
dataset : [
@@ -273,70 +165,10 @@ export function getEchartsConfig(
273
165
lineStyle : {
274
166
...chartStyleWrapper ( props ?. chartStyle , theme ?. chartStyle )
275
167
} ,
276
- data : transformedData . map ( ( i : any ) => i [ series . name ] )
277
168
} ) ) ,
278
169
} ;
279
- if ( axisChart ) {
280
- // pure chart's size except the margin around
281
- let chartRealSize ;
282
- if ( chartSize ) {
283
- const rightSize =
284
- typeof gridPos . right === "number"
285
- ? gridPos . right
286
- : ( chartSize . w * parseFloat ( gridPos . right ) ) / 100.0 ;
287
- chartRealSize = {
288
- // actually it's self-adaptive with the x-axis label on the left, not that accurate but work
289
- w : chartSize . w - gridPos . left - rightSize ,
290
- // also self-adaptive on the bottom
291
- h : chartSize . h - gridPos . top - gridPos . bottom ,
292
- right : rightSize ,
293
- } ;
294
- }
295
- const finalXyConfig = calcXYConfig (
296
- props . xConfig ,
297
- yAxisConfig ,
298
- props . xAxisDirection ,
299
- transformedData . map ( ( d ) => d [ props . xAxisKey ] ) ,
300
- chartRealSize
301
- ) ;
302
- config = {
303
- ...config ,
304
- // @ts -ignore
305
- xAxis : {
306
- ...finalXyConfig . xConfig ,
307
- axisLabel : {
308
- ...styleWrapper ( props ?. xAxisStyle , theme ?. xAxisStyle , 11 )
309
- } ,
310
- data : finalXyConfig . xConfig . type === "category" && ( props . xAxisData as [ ] ) . length !== 0 ?props ?. xAxisData :transformedData . map ( ( i : any ) => i [ props . xAxisKey ] ) ,
311
- } ,
312
- // @ts -ignore
313
- yAxis : {
314
- ...finalXyConfig . yConfig ,
315
- axisLabel : {
316
- ...styleWrapper ( props ?. yAxisStyle , theme ?. yAxisStyle , 11 )
317
- } ,
318
- data : finalXyConfig . yConfig . type === "category" && ( props . xAxisData as [ ] ) . length !== 0 ?props ?. xAxisData :transformedData . map ( ( i : any ) => i [ props . xAxisKey ] ) ,
319
- } ,
320
- } ;
321
-
322
- if ( props . chartConfig . race ) {
323
- config = {
324
- ...config ,
325
- xAxis : {
326
- ...config . xAxis ,
327
- animationDuration : 300 ,
328
- animationDurationUpdate : 300
329
- } ,
330
- yAxis : {
331
- ...config . yAxis ,
332
- animationDuration : 300 ,
333
- animationDurationUpdate : 300
334
- } ,
335
- }
336
- }
337
- }
338
170
339
- // log .log("Echarts transformedData and config", transformedData, config);
171
+ // console .log("Echarts transformedData and config", transformedData, config);
340
172
return config ;
341
173
}
342
174
0 commit comments