var items = {
data: [
{
name: '2013',
value:'123'
},{
name: '2014',
value:'60'
},{
name: '2015',
value:'25'
},{
name: '2016',
value:'18'
},{
name: '2017',
value:'12'
},{
name: '2018',
value:'9'
},{
name: '2019',
value:'2'
},{
name: '2020',
value:'1'
}
]
}
var item = {
xAxisData:[], // ['纺织业', '纺织业', '纺织业', '纺织业', '纺织业', '纺织业', '纺织业', '纺织业', ]
seriesData:[], // [123, 60, 25, 18, 12, 9, 2, 1]
seriesData1: []
}
for(let i in items.data) {
item.xAxisData.push(items.data[i].name)
item.seriesData.push({
value: Number(items.data[i].value),
symbolOffset: [-40, '0%']
})
item.seriesData1.push({
value: Number(items.data[i].value),
symbolOffset: [40, '0%']
})
}
option = {
backgroundColor: "#38445E",
grid: {
left: '4%',
right: '2%',
top: '25%',
bottom: '10%'
},
legend: {
data: ['碳排放量(吨)', '纳入碳交易排放量(吨)']
},
xAxis: {
data: item.xAxisData,
axisTick: {
show: false
},
axisLine: {
lineStyle: {
color: 'rgba(255, 129, 109, 0.1)',
width: 1 //这里是为了突出显示加上的
}
},
axisLabel: {
textStyle: {
color: '#999',
fontSize: 12
}
}
},
yAxis: [
{
splitNumber: 2,
axisTick: {
show: false
},
axisLine: {
lineStyle: {
color: 'rgba(255, 129, 109, 0.1)',
width: 1 //这里是为了突出显示加上的
}
},
axisLabel: {
textStyle: {
color: '#999'
}
},
splitArea: {
areaStyle: {
color: 'rgba(255,255,255,.5)'
}
},
splitLine: {
show: true,
lineStyle: {
color: 'rgba(255, 129, 109, 0.1)',
width: 0.5,
type: 'dashed'
}
}
}
],
series: [
{
name: '碳排放量(吨)',
type: 'pictorialBar',
barCategoryGap: '0%',
barMaxWidth: '60%',
symbol: 'path://M0,10 L10,10 C5.5,10 5.5,5 5,0 C4.5,5 4.5,10 0,10 z',
label: {
show: true,
position: 'top',
distance: 15,
fontWeight: 'bolder',
fontSize: 15,
offset: [-40, 0]
},
itemStyle: {
normal: {
//barBorderRadius: 5,
//渐变色
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: "#01EAED"
},
{
offset: 0.5,
color: "#02C4DD"
},
{
offset: 1,
color: "#029ED9"
}
])
},
emphasis: {
opacity: 1
}
},
data: item.seriesData,
z: 10
},
{
name: '纳入碳交易排放量(吨)',
type: 'pictorialBar',
barCategoryGap: '0%',
barMaxWidth: '60%',
symbol: 'path://M0,10 L10,10 C5.5,10 5.5,5 5,0 C4.5,5 4.5,10 0,10 z',
label: {
show: true,
position: 'top',
distance: 15,
fontWeight: 'bolder',
fontSize: 20,
offset: [40, 0]
},
itemStyle: {
normal: {
//barBorderRadius: 5,
//渐变色
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: "rgba(3,177,219, 0.5)"
},
{
offset: 0.5,
color: "rgba(3,177,219, 0.2)"
},
{
offset: 1,
color: "rgba(3,177,219, 0)"
}
])
},
borderType: 'solid',
shadowBlur: {
shadowColor: 'rgba(0, 0, 0, 0.5)',
shadowBlur: 10
},
emphasis: {
opacity: 1
}
},
data: item.seriesData1,
z: 10
}
]
};