4
4
ChartSize ,
5
5
noDataAxisConfig ,
6
6
noDataPieChartConfig ,
7
- } from "comps/basicChartComp/chartConstants " ;
7
+ } from "comps/barChartComp/barChartConstants " ;
8
8
import { getPieRadiusAndCenter } from "comps/basicChartComp/chartConfigs/pieChartConfig" ;
9
9
import { EChartsOptionWithMap } from "../basicChartComp/reactEcharts/types" ;
10
10
import _ from "lodash" ;
@@ -56,6 +56,7 @@ export function transformData(
56
56
}
57
57
58
58
const notAxisChartSet : Set < CharOptionCompType > = new Set ( [ "pie" ] as const ) ;
59
+ const notAxisChartSubtypeSet : Set < string > = new Set ( [ "polar" ] as const ) ;
59
60
export const echartsConfigOmitChildren = [
60
61
"hidden" ,
61
62
"selectedPoints" ,
@@ -65,8 +66,8 @@ export const echartsConfigOmitChildren = [
65
66
type EchartsConfigProps = Omit < ChartCompPropsType , typeof echartsConfigOmitChildren [ number ] > ;
66
67
67
68
68
- export function isAxisChart ( type : CharOptionCompType ) {
69
- return ! notAxisChartSet . has ( type ) ;
69
+ export function isAxisChart ( type : CharOptionCompType , subtype : string ) {
70
+ return ! notAxisChartSet . has ( type ) && ! notAxisChartSubtypeSet . has ( subtype ) ;
70
71
}
71
72
72
73
export function getSeriesConfig ( props : EchartsConfigProps ) {
@@ -78,7 +79,7 @@ export function getSeriesConfig(props: EchartsConfigProps) {
78
79
}
79
80
const seriesLength = visibleSeries . length ;
80
81
return visibleSeries . map ( ( s , index ) => {
81
- if ( isAxisChart ( props . chartConfig . type ) ) {
82
+ if ( isAxisChart ( props . chartConfig . type , props . chartConfig . subtype ) ) {
82
83
let encodeX : string , encodeY : string ;
83
84
const horizontalX = props . xAxisDirection === "horizontal" ;
84
85
let itemStyle = props . chartConfig . itemStyle ;
@@ -151,7 +152,7 @@ export function getEchartsConfig(
151
152
theme ?: any ,
152
153
) : EChartsOptionWithMap {
153
154
// axisChart
154
- const axisChart = isAxisChart ( props . chartConfig . type ) ;
155
+ const axisChart = isAxisChart ( props . chartConfig . type , props . chartConfig . subtype ) ;
155
156
const gridPos = {
156
157
left : `${ props ?. left } %` ,
157
158
right : `${ props ?. right } %` ,
@@ -222,7 +223,7 @@ export function getEchartsConfig(
222
223
config = {
223
224
...config ,
224
225
polar : {
225
- radius : [ props . chartConfig . polarData . polarRadiusDeg , ` ${ props . chartConfig . polarData . polarRadiusSize } %` ] ,
226
+ radius : [ props . chartConfig . polarData . polarRadiusStart , props . chartConfig . polarData . polarRadiusEnd ] ,
226
227
} ,
227
228
radiusAxis : {
228
229
type : props . chartConfig . polarData . polarIsTangent ?'category' :undefined ,
@@ -233,7 +234,8 @@ export function getEchartsConfig(
233
234
type : props . chartConfig . polarData . polarIsTangent ?undefined :'category' ,
234
235
data : props . chartConfig . polarData . polarIsTangent ?undefined :props . chartConfig . polarData . labelData ,
235
236
max : props . chartConfig . polarData . polarIsTangent ?props . chartConfig . polarData . radiusAxisMax || undefined :undefined ,
236
- startAngle : 75
237
+ startAngle : props . chartConfig . polarData . polarStartAngle ,
238
+ endAngle : props . chartConfig . polarData . polarEndAngle ,
237
239
} ,
238
240
}
239
241
}
@@ -305,27 +307,26 @@ export function getEchartsConfig(
305
307
}
306
308
} ,
307
309
} ;
310
+ }
308
311
309
- //Waterfall x-label initialization
310
- if ( props . chartConfig ?. subtype === "waterfall" && props . xAxisData . length === 0 ) {
311
- //default labels
312
- config . xAxis . data = [ "Total" ] ;
313
- for ( let i = 1 ; i < transformedData . length ; i ++ )
314
- config . xAxis . data . push ( `Column${ i } ` ) ;
315
- }
312
+ //Waterfall x-label initialization
313
+ if ( props . chartConfig ?. subtype === "waterfall" && props . xAxisData . length === 0 ) {
314
+ //default labels
315
+ config . xAxis . data = [ "Total" ] ;
316
+ for ( let i = 1 ; i < transformedData . length ; i ++ )
317
+ config . xAxis . data . push ( `Column${ i } ` ) ;
318
+ }
316
319
317
- //Polar x-label initialization
318
- if ( props . chartConfig ?. subtype === "polar" && props . chartConfig . polarData . labelData . length === 0 ) {
319
- //default labels
320
- let labelData = [ ] ;
321
- for ( let i = 0 ; i < transformedData . length ; i ++ )
322
- labelData . push ( `C${ i + 1 } ` ) ;
323
- if ( props . chartConfig . polarData . polarIsTangent && config . radiusAxis . data . length === 0 ) config . radiusAxis . data = labelData ;
324
- if ( ! props . chartConfig . polarData . polarIsTangent && config . angleAxis . data . length === 0 ) config . angleAxis . data = labelData ;
325
- }
326
- console . log ( "Config" , config ) ;
327
- console . log ( "Props" , props ) ;
320
+ //Polar x-label initialization
321
+ if ( props . chartConfig ?. subtype === "polar" && props . chartConfig . polarData . labelData . length === 0 ) {
322
+ //default labels
323
+ let labelData = [ ] ;
324
+ for ( let i = 0 ; i < transformedData . length ; i ++ )
325
+ labelData . push ( `C${ i + 1 } ` ) ;
326
+ if ( props . chartConfig . polarData . polarIsTangent && config . radiusAxis . data . length === 0 ) config . radiusAxis . data = labelData ;
327
+ if ( ! props . chartConfig . polarData . polarIsTangent && config . angleAxis . data . length === 0 ) config . angleAxis . data = labelData ;
328
328
}
329
+ console . log ( "Config" , config ) ;
329
330
// log.log("Echarts transformedData and config", transformedData, config);
330
331
return config ;
331
332
}
0 commit comments