本篇文章為大家展示了python中怎么利用Element 實(shí)現(xiàn)折線圖和餅圖,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、成都微信小程序、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了寧化免費(fèi)建站歡迎大家使用!
<div class="row charts" id="app"> <div class="col-md-8 col-md-offset-2" v-loading="loading"> <div class="king-block king-block-bordered mb30"> <div class="king-block-header"> <h4 class="king-block-title">近7天各類型告警趨勢(shì)</h4> </div> <div class="king-block-content"> <div id="chart1" ></div> </div> </div> </div> <br> <div class="col-md-4 col-md-offset-2" v-loading="loading"> <div class="king-block king-block-bordered mb30"> <div class="king-block-header"> <h4 class="king-block-title">告警類型分布</h4> </div> <div class="king-block-content"> <div id="chart2" ></div> </div> </div> </div> <div class="col-md-4" v-loading="loading"> <div class="king-block king-block-bordered mb30"> <div class="king-block-header"> <h4 class="king-block-title">告警等級(jí)分布</h4> </div> <div class="king-block-content"> <div id="chart3" ></div> </div> </div> </div> </div>
<script>
new Vue({
el: '#app',
data: {
chartLine: null,
loading: false
},
mounted() {
// 頁(yè)面加載就獲取所有模板
this.init()
},
methods: {
init() {
this.loading = true;
axios.get(site_url + "overview/").then(res => {
if (res.data.result){
this.loading = false;
this.chart1 = echarts.init(document.getElementById('chart1'));
this.chart1.setOption({
tooltip: {
trigger: 'axis'
},
legend: {
data: res.data.data.day_count.type_list
// data: ['郵件營(yíng)銷', '聯(lián)盟廣告', '搜索引擎']
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
boundaryGap: false,
data: res.data.data.day_count.day_str_list
// data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
},
yAxis: {
type: 'value'
},
series: res.data.data.day_count.day_count_list
});
this.chart2 = echarts.init(document.getElementById('chart2'));
this.chart2.setOption({
title: {
x: 'center'
},
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} (6666666%)'
},
legend: {
orient: 'vertical',
left: 'left',
data: res.data.data.alarm_device.device_list
},
series: [
{
name: '告警設(shè)備分布',
type: 'pie',
radius: '55%',
center: ['50%', '60%'],
// data: res.data2,
data: res.data.data.alarm_device.data_list,
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
});
this.chart3 = echarts.init(document.getElementById('chart3'));
this.chart3.setOption({
title: {
x: 'center'
},
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} (6666666%)'
},
legend: {
orient: 'vertical',
right: 'right',
data: res.data.data.alarm_level.level_list
},
series: [
{
name: '告警等級(jí)分布',
type: 'pie',
radius: '55%',
center: ['50%', '60%'],
data: res.data.data.alarm_level.data_list,
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
});
} else{
this.loading = false;
this.$message.error('請(qǐng)求失敗')
}
},'json');
}
}
})
</script>overview/接口返回?cái)?shù)據(jù)
{
"day_count": {
"type_list": ["基本警報(bào)", "中央處理器", "內(nèi)存", "系統(tǒng)環(huán)境", "自定義腳本", "硬盤", "硬件監(jiān)控"],
"day_str_list": ["2019-10-04", "2019-10-05", "2019-10-06", "2019-10-07", "2019-10-08", "2019-10-09"],
"day_count_list": [
{
"type": "line", "name": "基本警報(bào)", "stack": "數(shù)量",
"data": [111, 487, 933, 1793, 1834, 1832],
},
{
"type": "line", "name": "中央處理器", "stack": "數(shù)量",
"data": [54, 0, 0, 0, 0, 0],
},
{
"type": "line", "name": "內(nèi)存", "stack": "數(shù)量",
"data": [35, 0, 0, 0, 0, 0],
},
{
"type": "line", "name": "系統(tǒng)環(huán)境", "stack": "數(shù)量",
"data": [18, 0, 16, 12, 2, 1],
},
{
"type": "line", "name": "自定義腳本", "stack": "數(shù)量",
"data": [2, 1, 1, 1, 1, 1],
},
{
"type": "line", "name": "硬盤", "stack": "數(shù)量",
"data": [6, 4, 4, 5, 4, 9],
},
{
"type": "line", "name": "硬件監(jiān)控", "stack": "數(shù)量",
"data": [31, 3, 3, 6, 10, 4],
}
]
},
"alarm_device": {
"data_list": [
{"name": "基本警報(bào)", "value": 88},
{"name": "中央處理器", "value": 54},
{"name": "內(nèi)存", "value": 35},
{"name": "系統(tǒng)環(huán)境", "value": 51},
{"name": "自定義腳本", "value": 8},
{"name": "硬盤", "value": 37},
{"name": "硬件監(jiān)控", "value": 57}
],
"device_list": ["基本警報(bào)", "中央處理器", "內(nèi)存", "系統(tǒng)環(huán)境", "自定義腳本", "硬盤", "硬件監(jiān)控"]
},
"alarm_level": {
"data_list": [
{"name": "一般", "value": 90},
{"name": "嚴(yán)重", "value": 85},
{"name": "輕微", "value": 36}
],
"level_list": ["一般", "嚴(yán)重", "輕微"]
}
}實(shí)現(xiàn)效果


上述內(nèi)容就是python中怎么利用Element 實(shí)現(xiàn)折線圖和餅圖,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
網(wǎng)頁(yè)標(biāo)題:python中怎么利用Element實(shí)現(xiàn)折線圖和餅圖
鏈接地址:http://chinadenli.net/article28/ihpccp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、軟件開發(fā)、網(wǎng)站設(shè)計(jì)、關(guān)鍵詞優(yōu)化、建站公司、
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)