请教echarts像这种的柱状图该怎么配置,翻阅了资料也没有达到这个效果
使用这个barGap属性实现,
具体参考官网的堆叠图:、
网址:
https://echarts.apache.org/examples/zh/editor.html?c=bar-labe...
效果图:
option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [
{
type: 'category',
data: ['2021', '2022', '2023']
}
],
yAxis: [
{
type: 'value'
}
],
series: [
{
name: '火电固定成本',
type: 'bar',
stack: 'Ad',
color: '#ed7d31',
data: [40, 40, 40]
},
{
name: '火电可变燃煤成本',
type: 'bar',
stack: 'Ad',
label:{
show:true,
position:'top',
fontSize:18
},
color: '#f3a875',
data: [120, 132, 101]
},
{
name: '新能源上网均价',
type: 'bar',
label:{
show:true,
position:'top',
fontSize:18
},
color: '#70ad47',
data: [220, 182, 191]
},
{
name: '全国均价',
type: 'bar',
label:{
show:true,
position:'top',
fontSize:18
},
color: '#357aff',
barGap:0,
data: [350, 332, 301]
},
]
};
10 回答11.1k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.7k 阅读✓ 已解决
3 回答5.1k 阅读✓ 已解决
3 回答1.9k 阅读✓ 已解决
2 回答4.7k 阅读✓ 已解决
以下代码演示了如何在 ECharts 中绘制多个柱子,并显示相应的图例: