@@ -66,8 +66,8 @@ export const echartsConfigOmitChildren = [
6666type EchartsConfigProps = Omit < ChartCompPropsType , typeof echartsConfigOmitChildren [ number ] > ;
6767
6868
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 ;
7171}
7272
7373export function getSeriesConfig ( props : EchartsConfigProps ) {
@@ -79,27 +79,11 @@ export function getSeriesConfig(props: EchartsConfigProps) {
7979 }
8080 const seriesLength = visibleSeries . length ;
8181 return visibleSeries . map ( ( s , index ) => {
82- if ( isAxisChart ( props . chartConfig . type , props . chartConfig . subtype ) ) {
82+ if ( isAxisChart ( props . chartConfig . type , props . chartConfig . polarData . polar ) ) {
8383 let encodeX : string , encodeY : string ;
8484 const horizontalX = props . xAxisDirection === "horizontal" ;
8585 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- }
9586
96- if ( props . chartConfig . subtype === "waterfall" && index === 0 ) {
97- itemStyle = {
98- borderColor : 'transparent' ,
99- color : 'transparent'
100- }
101- }
102- }
10387 if ( horizontalX ) {
10488 encodeX = props . xAxisKey ;
10589 encodeY = s . getView ( ) . columnName ;
@@ -112,7 +96,7 @@ export function getSeriesConfig(props: EchartsConfigProps) {
11296 position : horizontalX ?"top" :"right" ,
11397 } } , { [ horizontalX ?"xAxis" :"yAxis" ] : area . getView ( ) . to } ] ) ) ;
11498 return {
115- name : props . chartConfig . subtype === "waterfall" && index === 0 ? " " : s . getView ( ) . seriesName ,
99+ name : s . getView ( ) . seriesName ,
116100 selectedMode : "single" ,
117101 select : {
118102 itemStyle : {
@@ -166,7 +150,7 @@ export function getEchartsConfig(
166150 theme ?: any ,
167151) : EChartsOptionWithMap {
168152 // axisChart
169- const axisChart = isAxisChart ( props . chartConfig . type , props . chartConfig . subtype ) ;
153+ const axisChart = isAxisChart ( props . chartConfig . type , props . chartConfig . polarData . polar ) ;
170154 const gridPos = {
171155 left : `${ props ?. left } %` ,
172156 right : `${ props ?. right } %` ,
@@ -246,34 +230,20 @@ export function getEchartsConfig(
246230 let transformedData =
247231 yAxisConfig . type === "category" || yAxisConfig . type === "time" ? props . data : transformData ( props . data , props . xAxisKey , seriesColumnNames ) ;
248232
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 ) {
264234 config = {
265235 ...config ,
266236 polar : {
267237 radius : [ props . chartConfig . polarData . polarRadiusStart , props . chartConfig . polarData . polarRadiusEnd ] ,
268238 } ,
269239 radiusAxis : {
270240 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 ,
272242 max : props . chartConfig . polarData . polarIsTangent ?undefined :props . chartConfig . polarData . radiusAxisMax || undefined ,
273243 } ,
274244 angleAxis : {
275245 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 ,
277247 max : props . chartConfig . polarData . polarIsTangent ?props . chartConfig . polarData . radiusAxisMax || undefined :undefined ,
278248 startAngle : props . chartConfig . polarData . polarStartAngle ,
279249 endAngle : props . chartConfig . polarData . polarEndAngle ,
@@ -364,6 +334,7 @@ export function getEchartsConfig(
364334 }
365335 }
366336 }
337+ console . log ( "config" , config ) ;
367338
368339 // log.log("Echarts transformedData and config", transformedData, config);
369340 return config ;
0 commit comments