91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

python中怎么利用Element 實現折線圖和餅圖

發布時間:2021-06-18 17:36:22 來源:億速云 閱讀:189 作者:Leah 欄目:大數據

本篇文章為大家展示了python中怎么利用Element 實現折線圖和餅圖,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

1.前端HTML和CSS

<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天各類型告警趨勢</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">告警等級分布</h4>
            </div>
            <div class="king-block-content">
                <div id="chart3" ></div>
            </div>
        </div>
    </div>
</div>

2.前端JS

<script>
    new Vue({
        el: '#app',
        data: {
            chartLine: null,
            loading: false
        },
        mounted() {
            // 頁面加載就獲取所有模板
            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: ['郵件營銷', '聯盟廣告', '搜索引擎']
                            },
                            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} (aegqsqibtmh%)'
                            },
                            legend: {
                                orient: 'vertical',
                                left: 'left',
                                data: res.data.data.alarm_device.device_list
                            },
                            series: [
                                {
                                    name: '告警設備分布',
                                    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} (aegqsqibtmh%)'
                            },
                            legend: {
                                orient: 'vertical',
                                right: 'right',
                                data: res.data.data.alarm_level.level_list
                            },
                            series: [
                                {
                                    name: '告警等級分布',
                                    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('請求失敗')
                    }
                },'json');
            }
        }
    })
</script>

3.Django代碼

overview/接口返回數據

{
    "day_count": {
        "type_list": ["基本警報", "中央處理器", "內存", "系統環境", "自定義腳本", "硬盤", "硬件監控"],
        "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": "基本警報", "stack": "數量",
                "data": [111, 487, 933, 1793, 1834, 1832],
            },
            {
                "type": "line", "name": "中央處理器", "stack": "數量",
                "data": [54, 0, 0, 0, 0, 0],
            },
            {
                "type": "line", "name": "內存", "stack": "數量",
                "data": [35, 0, 0, 0, 0, 0],
            },
            {
                "type": "line", "name": "系統環境", "stack": "數量",
                "data": [18, 0, 16, 12, 2, 1],
            },
            {
                "type": "line", "name": "自定義腳本", "stack": "數量",
                "data": [2, 1, 1, 1, 1, 1],
            },
            {
                "type": "line", "name": "硬盤", "stack": "數量",
                "data": [6, 4, 4, 5, 4, 9],
            },
            {
                "type": "line", "name": "硬件監控", "stack": "數量",
                "data": [31, 3, 3, 6, 10, 4],
            }
        ]
    },
    "alarm_device": {
        "data_list": [
            {"name": "基本警報", "value": 88},
            {"name": "中央處理器", "value": 54},
            {"name": "內存", "value": 35},
            {"name": "系統環境", "value": 51},
            {"name": "自定義腳本", "value": 8},
            {"name": "硬盤", "value": 37},
            {"name": "硬件監控", "value": 57}
        ],
        "device_list": ["基本警報", "中央處理器", "內存", "系統環境", "自定義腳本", "硬盤", "硬件監控"]
    },
    "alarm_level": {
        "data_list": [
            {"name": "一般", "value": 90},
            {"name": "嚴重", "value": 85},
            {"name": "輕微", "value": 36}
        ],
        "level_list": ["一般", "嚴重", "輕微"]
    }
}

實現效果

python中怎么利用Element 實現折線圖和餅圖

python中怎么利用Element 實現折線圖和餅圖

上述內容就是python中怎么利用Element 實現折線圖和餅圖,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

右玉县| 赤水市| 巩留县| 资源县| 五寨县| 丽水市| 屏南县| 罗田县| 德清县| 江山市| 玉龙| 天峻县| 双峰县| 汨罗市| 丰镇市| 乐亭县| 什邡市| 沙洋县| 台东县| 福清市| 留坝县| 马边| 吉林市| 公安县| 大英县| 永仁县| 砚山县| 土默特左旗| 文水县| 宝应县| 井冈山市| 得荣县| 荆州市| 鄄城县| 华安县| 重庆市| 措美县| 贵州省| 永泰县| 通河县| 若羌县|