| | |
| | | shadowBlur: 10, |
| | | formatter: (params) => { |
| | | let strName1 = params[0].name |
| | | let value1 = params[0].value |
| | | let value2 = params[1] ? params[1].value : '未开启' |
| | | return `<div style="color:#fff;font-size:16px;">${strName1}</div> |
| | | <div><span style="color:#fff;display: inline-block;width: 86px;">${ |
| | | this.chartData.barName |
| | | }</span><span style="color:#5DB6FB">${value1} |
| | | </span></div><div><span style="color:#fff;display: inline-block;width: 86px;">${ |
| | | this.chartData.lineName |
| | | }</span><span style="color:#5DB6FB">${value2}${this.showpercent ? '%' : ''}` |
| | | let result = `<div style="color:#fff;font-size:16px;">${strName1}</div>` |
| | | |
| | | if (params[0] && this.chartData.barName) { |
| | | let value1 = params[0].value !== undefined ? params[0].value : 0 |
| | | result += `<div><span style="color:#fff;display: inline-block;width: 86px;">${this.chartData.barName}</span><span style="color:#5DB6FB">${value1}</span></div>` |
| | | } |
| | | |
| | | if (params[1] && this.chartData.lineName) { |
| | | let value2 = params[1].value !== undefined ? params[1].value : 0 |
| | | result += `<div><span style="color:#fff;display: inline-block;width: 86px;">${this.chartData.lineName}</span><span style="color:#5DB6FB">${value2}</span></div>` |
| | | } |
| | | |
| | | if (params[2] && this.chartData.barName2) { |
| | | let value3 = params[2].value !== undefined ? params[2].value : 0 |
| | | result += `<div><span style="color:#fff;display: inline-block;width: 86px;">${this.chartData.barName2}</span><span style="color:#FF6B6B">${value3}</span></div>` |
| | | } |
| | | |
| | | if (params[3] && this.chartData.lineName2) { |
| | | let value4 = params[3].value !== undefined ? params[3].value : 0 |
| | | result += `<div><span style="color:#fff;display: inline-block;width: 86px;">${this.chartData.lineName2}</span><span style="color:#FFD93D">${value4}</span></div>` |
| | | } |
| | | |
| | | return result |
| | | }, |
| | | textStyle: { |
| | | rich: { |
| | |
| | | show: false, |
| | | }, |
| | | }, |
| | | { |
| | | type: 'value', |
| | | nameTextStyle: { |
| | | color: 'rgba(185, 185, 185, 1)', |
| | | }, |
| | | position: 'right', |
| | | axisLine: { |
| | | show: false, |
| | | }, |
| | | splitLine: { |
| | | show: false, |
| | | }, |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | axisLabel: { |
| | | show: true, |
| | | formatter: '{value} %', //右侧Y轴文字显示 |
| | | formatter: (value, index) => { |
| | | return value + (this.showpercent ? '%' : '') |
| | | }, |
| | | textStyle: { |
| | | color: 'rgba(185, 185, 185, 1)', |
| | | }, |
| | | }, |
| | | }, |
| | | ], |
| | | |
| | | series: [ |
| | | { |
| | | name: this.chartData.barName, |
| | | type: 'bar', |
| | | barWidth: '12px', |
| | | itemStyle: { |
| | | normal: { |
| | | color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ |
| | | { |
| | | offset: 0, |
| | | color: '#5B81F9', |
| | | }, |
| | | { |
| | | offset: 1, |
| | | color: '#151A22', |
| | | }, |
| | | ]), |
| | | }, |
| | | }, |
| | | data: this.chartData.barData, |
| | | }, |
| | | |
| | | { |
| | | name: this.chartData.lineName, |
| | | type: 'line', |
| | | // smooth: true, |
| | | yAxisIndex: 1, //使用的 y 轴的 index,在单个图表实例中存在多个 y轴的时候有用 |
| | | |
| | | symbol: 'emptycircle', //标记的图形为实心圆 |
| | | symbolSize: 0, //标记的大小 |
| | | areaStyle: { |
| | | normal: { |
| | | color: { |
| | | type: 'linear', |
| | | x: 0, |
| | | y: 0, |
| | | x2: 0, |
| | | y2: 1, |
| | | colorStops: [ |
| | | { |
| | | offset: 0, |
| | | color: 'rgba(87, 147, 67, .5)', // 0% 处的颜色 |
| | | }, |
| | | { |
| | | offset: 1, |
| | | color: 'rgba(87, 147, 67, 0.1)', // 100% 处的颜色 |
| | | }, |
| | | ], |
| | | global: false, // 缺省为 false |
| | | }, |
| | | }, |
| | | }, |
| | | itemStyle: { |
| | | color: 'rgba(65, 197, 95, 1)', |
| | | }, |
| | | |
| | | data: this.chartData.lineData, |
| | | }, |
| | | ], |
| | | series: [], |
| | | } |
| | | |
| | | if (this.chartData.barData) { |
| | | option.series.push({ |
| | | name: this.chartData.barName, |
| | | type: 'bar', |
| | | barWidth: '12px', |
| | | itemStyle: { |
| | | normal: { |
| | | color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ |
| | | { |
| | | offset: 0, |
| | | color: '#5B81F9', |
| | | }, |
| | | { |
| | | offset: 1, |
| | | color: '#151A22', |
| | | }, |
| | | ]), |
| | | }, |
| | | }, |
| | | data: this.chartData.barData, |
| | | }) |
| | | } |
| | | |
| | | if (this.chartData.lineData) { |
| | | option.series.push({ |
| | | name: this.chartData.lineName, |
| | | type: 'bar', |
| | | barWidth: '12px', |
| | | itemStyle: { |
| | | normal: { |
| | | color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ |
| | | { |
| | | offset: 0, |
| | | color: '#16B777', |
| | | }, |
| | | { |
| | | offset: 1, |
| | | color: '#0D6E4A', |
| | | }, |
| | | ]), |
| | | }, |
| | | }, |
| | | data: this.chartData.lineData, |
| | | }) |
| | | } |
| | | |
| | | if (this.chartData.barData2) { |
| | | option.series.push({ |
| | | name: this.chartData.barName2, |
| | | type: 'bar', |
| | | barWidth: '12px', |
| | | itemStyle: { |
| | | normal: { |
| | | color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ |
| | | { |
| | | offset: 0, |
| | | color: '#FF6B6B', |
| | | }, |
| | | { |
| | | offset: 1, |
| | | color: '#8B0000', |
| | | }, |
| | | ]), |
| | | }, |
| | | }, |
| | | data: this.chartData.barData2, |
| | | }) |
| | | } |
| | | |
| | | if (this.chartData.lineData2) { |
| | | option.series.push({ |
| | | name: this.chartData.lineName2, |
| | | type: 'bar', |
| | | barWidth: '12px', |
| | | itemStyle: { |
| | | normal: { |
| | | color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ |
| | | { |
| | | offset: 0, |
| | | color: '#FFD93D', |
| | | }, |
| | | { |
| | | offset: 1, |
| | | color: '#B8860B', |
| | | }, |
| | | ]), |
| | | }, |
| | | }, |
| | | data: this.chartData.lineData2, |
| | | }) |
| | | } |
| | | |
| | | option && this.chartEntity.setOption(option, true) |
| | | this.bindChartClick() |
| | | }, |