[JavaScript] 纯文本查看 复制代码
// 数据
const arrDateset = [
["部门", "参评率", "满意率", "重复率", "投诉率"],
["广东省", 120.7876, 160.6587, 20.8787, 20.7867, 40.64545],
["台湾省", 80, 20, 0, 0, 100],
["北京市", 60, 40, 40, 40, 180],
["上海市", 20.4678, 80, 60.78754, 80, 240],
["四川省", 40, 60.78455, 80, 100.9787858, 280],
["福建省", 100, 100, 100, 60.47878, 360]
];
// 创建系列
const objSeries = {
type: 'bar', stack: 'total', label: {
show: true
},
emphasis: {
focus: 'series'
}
},
arrSeries = [];
for (let i = 0; i < arrDateset[0].length - 1; i++) {
arrSeries.push(objSeries);
}
// 创建配置
option = {
legend: {
show: true
},
label: {
show: true,
formatter: (params) => {
// if (params.data) return params.data.toFixed(2);
}
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {}
}
},
dataset: {
source: arrDateset
},
xAxis: {},
yAxis: { type: 'category' },
series: arrSeries
};