
import * as echarts from 'echarts'
function goverChartConfig() {
const dom = 800
const barWidth = dom / 20
const xAxisData = ['国境内婚生子女出生登记', '购买成套住房落户', '大中专学生毕业就业落户', '夫妻投靠落户', '务工落户(市外)']
const yAxisData = [31212, 25634, 22156, 18647, 15608]
const option = {
grid: {
left: '10%',
right: '10%',
top: '10%',
bottom: '10%'
},
xAxis: [{
data: xAxisData,
type: 'category',
show: true,
axisLine: {
show: false,
lineStyle: {
color: '#ffffff'
}
},
splitLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
margin: 20
}
}],
yAxis: {
show: true,
splitNumber: 4,
axisLine: {
show: false
},
splitLine: {
show: true,
lineStyle: {
type: 'dashed',
color: '#3B69FF'
}
},
axisLabel: {
show: false
}
},
series: [
{
type: 'bar',
barWidth: barWidth,
showBackground: true,
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[
{ offset: 0, color: '#988F2C' },
{ offset: 1, color: '#FFF26D' }
]
)
}
},
label: {
show: true,
position: [barWidth / 2, -(barWidth + 20)],
color: '#FFE000 ',
fontSize: 33,
fontStyle: 'bold',
align: 'center'
},
data: yAxisData
},
{
z: 2,
type: 'pictorialBar',
data: yAxisData,
symbol: 'diamond',
symbolOffset: [0, '50%'],
symbolSize: [barWidth, barWidth * 0.5],
itemStyle: {
normal: {
color: '#FFF26D'
}
}
},
{
z: 3,
type: 'pictorialBar',
symbolPosition: 'end',
data: yAxisData,
symbol: 'diamond',
symbolOffset: [0, '-50%'],
symbolSize: [barWidth, barWidth * 0.5],
itemStyle: {
normal: {
borderWidth: 0,
color: '#FFF26D'
}
}
}
]
}
return option
}
<div id="goverEchart" class="efficientEchart"></div>
import * as echarts from 'echarts'
import { efficientChartConfig, trafficChartConfig, goverChartConfig } from '../config'
mounted() {
this.paintGoverEchart()
window.addEventListener('resize', () => {
this.goverEchart.resize()
})
},
methods: {
paintGoverEchart() {
this.goverEchart = echarts.init(document.getElementById('goverEchart'))
this.goverEchart.setOption({}, true)
const goverConfig = goverChartConfig()
this.goverEchart.setOption(goverConfig, true)
}
}