中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

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

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

python中怎么利用Element顯示柱狀圖

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

今天就跟大家聊聊有關python中怎么利用Element顯示柱狀圖,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。

1.前端HTML和CSS

<div id="app">
    <div class="row charts"  v-loading.fullscreen.lock="fullscreenLoading" element-loading-text="拼命加載中" element-loading-spinner="el-icon-loading">
        <div class="col-md-6 col-md-offset-3">
            <div class="king-block king-block-bordered mb30">
                <div class="king-block-header">
                    <h2 class="king-block-title">告警事件TOP 5</h2>
                </div>
                <div class="king-block-content">
                    <div id="chart1" ></div>
                </div>
            </div>
        </div>
    </div>
    <div class="row charts" >
        <div class="col-md-6 col-md-offset-3">
            <div class="king-block king-block-bordered mb30">
                <div class="king-block-header">
                    <h2 class="king-block-title">設備類型告警TOP 5</h2>
                </div>
                <div class="king-block-content">
                    <div id="chart2" ></div>
                </div>
            </div>
        </div>
    </div>
</div>

2.前端JS

<script type="text/javascript">
    new Vue({
        el: '#app',
        data: {
            fullscreenLoading: false
        },
        mounted() {
            // 頁面加載就獲取所有模板
            this.init()
        },
        methods: {
            init() {
                this.fullscreenLoading = true;
                axios.get(site_url + "top5_data/").then(res => {
                    if (res.data.result) {
                        this.fullscreenLoading = false;
                        this.chart1 = echarts.init(document.getElementById('chart1'));
                        this.chart1.setOption({
                            tooltip : {
                                trigger: 'axis',
                                axisPointer : {            // 坐標軸指示器,坐標軸觸發有效
                                    type : 'shadow'        // 默認為直線,可選為:'line' | 'shadow'
                                }
                            },
                            grid: {
                                left: '3%',
                                right: '4%',
                                bottom: '3%',
                                containLabel: true
                            },
                            xAxis : [
                                {
                                    type : 'value'
                                }
                            ],
                            yAxis : [
                                {
                                    type : 'category',
                                    data : res.data.data.top5_title_res.title_list,
                                    axisTick: {
                                        alignWithLabel: true
                                    }
                                }
                            ],
                            series : [
                                {
                                    name:'數量',
                                    type:'bar',
                                    barWidth: '40%',
                                    data: res.data.data.top5_title_res.count_list
                                }
                            ]
                        });

                        this.chart2 = echarts.init(document.getElementById('chart2'));
                        this.chart2.setOption({
                            tooltip : {
                                trigger: 'axis',
                                axisPointer : {            // 坐標軸指示器,坐標軸觸發有效
                                    type : 'shadow'        // 默認為直線,可選為:'line' | 'shadow'
                                }
                            },
                            grid: {
                                left: '3%',
                                right: '4%',
                                bottom: '3%',
                                containLabel: true
                            },
                            xAxis : [
                                {
                                    type : 'value'
                                }
                            ],
                            yAxis : [
                                {
                                    type : 'category',
                                    data : res.data.data.top5_device_type_res.type_list,
                                    axisTick: {
                                        alignWithLabel: true
                                    }
                                }
                            ],
                            series : [
                                {
                                    name:'數量',
                                    type:'bar',
                                    barWidth: '40%',
                                    data: res.data.data.top5_device_type_res.count_list
                                }
                            ]
                        });
                    } else {
                        this.fullscreenLoading = false;
                        this.$message.error('請求失敗')
                    }
                },'json');
            }
        }
    })
</script>

3.Django代碼

top5_data/接口返回數據

{
    "top5_title_res": {
        "count_list": [18268, 18273, 18309, 30361, 30398],
        "title_list": [
            "1.18.6.11發生進程端口告警",
            "1.18.6.20發生進程端口告警",
            "1.18.6.13發生進程端口告警",
            "1.18.6.18發生進程端口告警",
            "1.18.6.9發生進程端口告警"
        ]
    },
    "top5_device_type_res": {
        "type_list": ["中央處理器", "內存", "硬盤", "基本警報", "端口"],
        "count_list": [16029, 24217, 51166, 140975, 170223]
    }
}

實現效果

python中怎么利用Element顯示柱狀圖

python中怎么利用Element顯示柱狀圖

看完上述內容,你們對python中怎么利用Element顯示柱狀圖有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注億速云行業資訊頻道,感謝大家的支持。

向AI問一下細節

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

AI

莱阳市| 清水县| 灯塔市| 黄骅市| 七台河市| 香河县| 凌云县| 平潭县| 镇沅| 北安市| 元谋县| 时尚| 滨州市| 阳春市| 商洛市| 康乐县| 镇宁| 新营市| 安宁市| 滦南县| 贵溪市| 泰顺县| 大名县| 凉城县| 大化| 临沧市| 莱阳市| 通辽市| 从江县| 桓台县| 新营市| 珠海市| 容城县| 工布江达县| 长沙市| 博客| 华容县| 侯马市| 自治县| 南江县| 梅河口市|