//获取y坐标数据 获取后 budgetData数据为【831 9031.76 728.81 1580 】
var budgetData = [budget1,budget2,budget3,budget4];
var executeData = [execute1,execute2,execute3,execute4];
var contractData = [contract1,contract2,contract3,contract4];
var paidData = [paid1,paid2,paid3,paid4];
// 指定图表的配置项和数据
var option = {
title: {
text: '预算执行情况',
x:'left',
subtext:'纯属虚构'
},
grid: {
containLabel:true
},
tooltip: {
trigger:'axis'
},
legend: {
data:['预算金额','执行金额','合同金额','付款金额']
},
xAxis: {
type:'category',
data: ['基础设施服务','应用软件开发','基础软件服务','硬件设备采购']
},
yAxis: {
type:'value'
},
series: [{
name: '预算金额',
type: 'bar',
data: budgetData,
color:'#CC0066',
itemStyle: {
normal: {
label: {
show: true, //开启显示
position: 'top', //在上方显示
textStyle: { //数值样式
color: 'black',
fontSize: 15
}
}
}
}
},
{
name: '执行金额',
type: 'bar',
data: executeData,
color:'#009999',
itemStyle: {
normal: {
label: {
show: true, //开启显示
position: 'top', //在上方显示
textStyle: { //数值样式
color: 'black',
fontSize: 15
}
}
}
}
},
{
name: '合同金额',
type: 'bar',
data: contractData,
color:'#FFCC33',
itemStyle: {
normal: {
label: {
show: true, //开启显示
position: 'top', //在上方显示
textStyle: { //数值样式
color: 'black',
fontSize: 15
}
}
}
}
},
{
name: '付款金额',
type: 'bar',
data: paidData,
color:'#F0GGGG',
itemStyle: {
normal: {
label: {
show: true, //开启显示
position: 'top', //在上方显示
textStyle: { //数值样式
color: 'black',
fontSize: 15
}
}
}
}
}
],
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
https://blog.csdn.net/github_38151745/article/details/78980623