@@ -66,8 +66,8 @@ export const echartsConfigOmitChildren = [
66
66
type EchartsConfigProps = Omit < ChartCompPropsType , typeof echartsConfigOmitChildren [ number ] > ;
67
67
68
68
69
- export function isAxisChart ( type : CharOptionCompType , subtype : string ) {
70
- return ! notAxisChartSet . has ( type ) && ! notAxisChartSubtypeSet . has ( subtype ) ;
69
+ export function isAxisChart ( type : CharOptionCompType , polar : boolean ) {
70
+ return ! notAxisChartSet . has ( type ) && ! polar ;
71
71
}
72
72
73
73
export function getSeriesConfig ( props : EchartsConfigProps ) {
@@ -79,27 +79,11 @@ export function getSeriesConfig(props: EchartsConfigProps) {
79
79
}
80
80
const seriesLength = visibleSeries . length ;
81
81
return visibleSeries . map ( ( s , index ) => {
82
- if ( isAxisChart ( props . chartConfig . type , props . chartConfig . subtype ) ) {
82
+ if ( isAxisChart ( props . chartConfig . type , props . chartConfig . polarData . polar ) ) {
83
83
let encodeX : string , encodeY : string ;
84
84
const horizontalX = props . xAxisDirection === "horizontal" ;
85
85
let itemStyle = props . chartConfig . itemStyle ;
86
- // FIXME: need refactor... chartConfig returns a function with paramters
87
- if ( props . chartConfig . type === "bar" ) {
88
- // barChart's border radius, depend on x-axis direction and stack state
89
- const borderRadius = horizontalX ? [ 2 , 2 , 0 , 0 ] : [ 0 , 2 , 2 , 0 ] ;
90
- if ( props . chartConfig . stack && index === visibleSeries . length - 1 ) {
91
- itemStyle = { ...itemStyle , borderRadius : borderRadius } ;
92
- } else if ( ! props . chartConfig . stack ) {
93
- itemStyle = { ...itemStyle , borderRadius : borderRadius } ;
94
- }
95
86
96
- if ( props . chartConfig . subtype === "waterfall" && index === 0 ) {
97
- itemStyle = {
98
- borderColor : 'transparent' ,
99
- color : 'transparent'
100
- }
101
- }
102
- }
103
87
if ( horizontalX ) {
104
88
encodeX = props . xAxisKey ;
105
89
encodeY = s . getView ( ) . columnName ;
@@ -112,7 +96,7 @@ export function getSeriesConfig(props: EchartsConfigProps) {
112
96
position : horizontalX ?"top" :"right" ,
113
97
} } , { [ horizontalX ?"xAxis" :"yAxis" ] : area . getView ( ) . to } ] ) ) ;
114
98
return {
115
- name : props . chartConfig . subtype === "waterfall" && index === 0 ? " " : s . getView ( ) . seriesName ,
99
+ name : s . getView ( ) . seriesName ,
116
100
selectedMode : "single" ,
117
101
select : {
118
102
itemStyle : {
@@ -166,7 +150,7 @@ export function getEchartsConfig(
166
150
theme ?: any ,
167
151
) : EChartsOptionWithMap {
168
152
// axisChart
169
- const axisChart = isAxisChart ( props . chartConfig . type , props . chartConfig . subtype ) ;
153
+ const axisChart = isAxisChart ( props . chartConfig . type , props . chartConfig . polarData . polar ) ;
170
154
const gridPos = {
171
155
left : `${ props ?. left } %` ,
172
156
right : `${ props ?. right } %` ,
@@ -246,34 +230,20 @@ export function getEchartsConfig(
246
230
let transformedData =
247
231
yAxisConfig . type === "category" || yAxisConfig . type === "time" ? props . data : transformData ( props . data , props . xAxisKey , seriesColumnNames ) ;
248
232
249
- if ( props . chartConfig . subtype === "waterfall" ) {
250
- config . legend = undefined ;
251
- let sum = transformedData . reduce ( ( acc , item ) => {
252
- if ( typeof item [ seriesColumnNames [ 0 ] ] === 'number' ) return acc + item [ seriesColumnNames [ 0 ] ] ;
253
- else return acc ;
254
- } , 0 )
255
- const total = sum ;
256
- transformedData . map ( d => {
257
- d [ ` ` ] = sum - d [ seriesColumnNames [ 0 ] ] ;
258
- sum = d [ ` ` ] ;
259
- } )
260
- transformedData = [ { [ seriesColumnNames [ 0 ] + "_placeholder" ] : 0 , [ seriesColumnNames [ 0 ] ] : total } , ...transformedData ]
261
- }
262
-
263
- if ( props . chartConfig . subtype === "polar" ) {
233
+ if ( props . chartConfig . polarData . polar ) {
264
234
config = {
265
235
...config ,
266
236
polar : {
267
237
radius : [ props . chartConfig . polarData . polarRadiusStart , props . chartConfig . polarData . polarRadiusEnd ] ,
268
238
} ,
269
239
radiusAxis : {
270
240
type : props . chartConfig . polarData . polarIsTangent ?'category' :undefined ,
271
- data : props . chartConfig . polarData . polarIsTangent ?props . chartConfig . polarData . labelData :undefined ,
241
+ data : props . chartConfig . polarData . polarIsTangent && props . chartConfig . polarData . labelData . length !== 0 ?props . chartConfig . polarData . labelData :undefined ,
272
242
max : props . chartConfig . polarData . polarIsTangent ?undefined :props . chartConfig . polarData . radiusAxisMax || undefined ,
273
243
} ,
274
244
angleAxis : {
275
245
type : props . chartConfig . polarData . polarIsTangent ?undefined :'category' ,
276
- data : props . chartConfig . polarData . polarIsTangent ? undefined : props . chartConfig . polarData . labelData ,
246
+ data : ! props . chartConfig . polarData . polarIsTangent && props . chartConfig . polarData . labelData . length !== 0 ? props . chartConfig . polarData . labelData : undefined ,
277
247
max : props . chartConfig . polarData . polarIsTangent ?props . chartConfig . polarData . radiusAxisMax || undefined :undefined ,
278
248
startAngle : props . chartConfig . polarData . polarStartAngle ,
279
249
endAngle : props . chartConfig . polarData . polarEndAngle ,
@@ -364,6 +334,7 @@ export function getEchartsConfig(
364
334
}
365
335
}
366
336
}
337
+ console . log ( "config" , config ) ;
367
338
368
339
// log.log("Echarts transformedData and config", transformedData, config);
369
340
return config ;
0 commit comments