只有一个series.data数据怎么生成图例
配置项如下
option = {
legend: {
data: ["党政机关", "事业单位", "科研单位", "金融单位", "国有企业", "军队武警", "学校", "民营私营企业", "中外合资", "外资", "自主创业"],
},
xAxis: {
data: ["党政机关", "事业单位", "科研单位", "金融单位", "国有企业", "军队武警", "学校", "民营私营企业", "中外合资", "外资", "自主创业"],
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
show: false
}
},
yAxis: {
type: 'value',
splitLine: {
show: false
},
boundaryGap: [0, 0.01],
axisTick: {
inside: true
},
axisLabel: {
formatter: function(value) {
return (value * 100).toFixed(1) + '%'
}
}
},
series: [{
barWidth: 20,
data: ["0", "0.137931034", "0", "0.103448276", "0.034482759", "0", "0", "0.689655172", "0", "0", "0.034482759"],
type: 'bar',
itemStyle: {
normal: {
color: function(params) {
return "#" + Math.floor(Math.random() * (256 * 256 * 256 - 1)).toString(16);
},
label: {
show: true,
position: 'top',
formatter: function(params) {
return (params.value * 100).toFixed(1) + '%'
}
}
}
}
}]
};