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