// 基于准备好的dom,初始化echarts实例
let histogram = echarts.init(document.getElementById('histogram'));
// 指定图表的配置项和数据
let hoption = {
tooltip: {},// 提示框
xAxis: {
data: ["全部","在线","离线","告警"]
},
yAxis: {},
series: [{
type: 'bar',
barWidth:'30%',
itemStyle: {
normal: {
//颜色渐变
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: "#3fA4A6"
}, {
offset: 1,
color: "#BDD1D1"
}])
}
},
data: [21, 6, 15, 0]
}],
};
// 使用刚指定的配置项和数据显示图表。
histogram.setOption(hoption);
let histogramContainer = document.getElementById("histogram");
// 初始化图表
let percentageContainer = document.getElementById('percentage');
// echarts获取不到宽高
let resizePercentageContainer = function(){
percentageContainer.style.width = histogramContainer.offsetWidth + "px";
percentageContainer.style.height = histogramContainer.offsetHeight + "px";
};
resizePercentageContainer();
let percentage = echarts.init(percentageContainer);
let poption = {
series : [
{
type: 'pie',
data:[
{value:6, name:'在线'},
{value:15, name:'离线'},
{value:0, name:'警告'},
]
}
]
};
percentage.setOption(poption);
echarts-en.common.js:28566 Can't get dom width or height
最新推荐文章于 2024-06-03 17:09:30 发布