xiabin
This commit is contained in:
		
							parent
							
								
									33956d49cb
								
							
						
					
					
						commit
						07dbd6398d
					
				| @ -88,37 +88,37 @@ export default { | ||||
|         Object.assign(option, cloneDeep(props.option)); | ||||
|       } else { | ||||
|         Object.assign(option, cloneDeep(props.option)); | ||||
|       } | ||||
|       let typeArr = Array.from(new Set(props.chartData.map((item) => item.type))); | ||||
|       let xAxisData = Array.from(new Set(props.chartData.map((item) => item.name))); | ||||
|       let seriesData = []; | ||||
|       typeArr.forEach((type, index) => { | ||||
|         const barStyle = props.option?.barStyle ?? {}; | ||||
|         let obj = { name: type, type: props.type, ...barStyle }; | ||||
|         let data = []; | ||||
|         xAxisData.forEach((x) => { | ||||
|           let dataArr = props.chartData.filter((item) => type === item.type && item.name == x); | ||||
|           if (dataArr && dataArr.length > 0) { | ||||
|             data.push(dataArr[0].value); | ||||
|           } else { | ||||
|             data.push(null); | ||||
|         let typeArr = Array.from(new Set(props.chartData.map((item) => item.type))); | ||||
|         let xAxisData = Array.from(new Set(props.chartData.map((item) => item.name))); | ||||
|         let seriesData = []; | ||||
|         typeArr.forEach((type, index) => { | ||||
|           const barStyle = props.option?.barStyle ?? {}; | ||||
|           let obj = { name: type, type: props.type, ...barStyle }; | ||||
|           let data = []; | ||||
|           xAxisData.forEach((x) => { | ||||
|             let dataArr = props.chartData.filter((item) => type === item.type && item.name == x); | ||||
|             if (dataArr && dataArr.length > 0) { | ||||
|               data.push(dataArr[0].value); | ||||
|             } else { | ||||
|               data.push(null); | ||||
|             } | ||||
|           }); | ||||
|           obj['data'] = data; | ||||
|           if (props.option?.color) { | ||||
|             obj.color = props.option?.color[index]; | ||||
|           } | ||||
|           if (props.option.series && props.option.series.length > 0) { | ||||
|             obj.stack = props.option.series[index].stack ? props.option.series[index].stack : ''; | ||||
|           } | ||||
|           seriesData.push(obj); | ||||
|         }); | ||||
|         obj['data'] = data; | ||||
|         if (props.option?.color) { | ||||
|           obj.color = props.option?.color[index]; | ||||
|         option.series = props.isSeries && option.series.length > 0 ? option.series : seriesData; | ||||
|         if (props.isHorizontal) { | ||||
|           option.yAxis.data = xAxisData; | ||||
|           option.xAxis.data = []; | ||||
|         } else { | ||||
|           option.xAxis.data = xAxisData; | ||||
|         } | ||||
|         if (props.option.series && props.option.series.length > 0) { | ||||
|           obj.stack = props.option.series[index].stack ? props.option.series[index].stack : ''; | ||||
|         } | ||||
|         seriesData.push(obj); | ||||
|       }); | ||||
|       option.series = props.isSeries && option.series.length > 0 ? option.series : seriesData; | ||||
|       if (props.isHorizontal) { | ||||
|         option.yAxis.data = xAxisData; | ||||
|         option.xAxis.data = []; | ||||
|       } else { | ||||
|         option.xAxis.data = xAxisData; | ||||
|       } | ||||
|       console.log(option); | ||||
|       setOptions(option); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user