Vue?Echarts實(shí)現(xiàn)帶滾動(dòng)效果的柱形圖
本文實(shí)例為大家分享了Vue Echarts實(shí)現(xiàn)帶滾動(dòng)效果柱形圖的具體代碼,供大家參考,具體內(nèi)容如下
代碼
<template> ? <div class="timeLineview"> ? ? <div v-bind:style="{ height: heightData + 'px' }" ref="categoryChart"></div> ? ? <div v-bind:style="{ height: noHeight + 'px' }" class="nomore"> ? ? ? {{ noData }} ? ? </div> ? </div> </template> <script> import echarts from "echarts"; export default { ? components: {}, ? name: "timeLine", ? props: { ? ? question: {} ? }, ? data() { ? ? return { ? ? ? datainfo: [], ? ? ? datatitle: [], ? ? ? chart: null, ? ? ? heightData: 300, ? ? ? noHeight: 0, ? ? ? noData: "" ? ? }; ? }, ? methods: { ? ? resize() { ? ? ? this.chart.resize(); ? ? }, ? ? find() { ? ? //獲取數(shù)據(jù) ? ? ? if (this.question) { ? ? ? ? for (let index = 0; index < this.question.length; index++) { ? ? ? ? ? if (this.question[index].statValue > 0) { ? ? ? ? ? //y軸 ? ? ? ? ? ? this.datainfo.push(this.question[index].statValue); ? ? ? ? ? ? //X軸 ? ? ? ? ? ? this.datatitle.push(this.question[index].statLabel); ? ? ? ? ? } ? ? ? ? } ? ? ? } ? ? ? this.chart = echarts.init(this.$refs.categoryChart); ? ? ? const option = { ? ? ? ? tooltip: { ? ? ? ? ? trigger: "axis", ? ? ? ? ? axisPointer: { ? ? ? ? ? ? type: "shadow" ? ? ? ? ? } ? ? ? ? }, ? ? ? ? title: {}, ? ? ? ? legend: {}, ? ? ? ? dataZoom: [ ? ? ? ? ? { ? ? ? ? ? ? type: "slider", ? ? ? ? ? ? start: 0, ? ? ? ? ? ? end: (100 / this.datainfo.length) * 5 ? //顯示五個(gè) ? ? ? ? ? }, ? ? ? ? ? { ? ? ? ? ? ? type: "inside", ? ? ? ? ? ? start: 0, ? ? ? ? ? ? end: (100 / this.datainfo.length) * 5//顯示五個(gè) ? ? ? ? ? } ? ? ? ? ], ? ? ? ? xAxis: { ? ? ? ? ? data: this.datatitle ? ? ? ? }, ? ? ? ? yAxis: { minInterval: 1 }, ? //顯示為整數(shù) 最小間距1 ? ? ? ? series: [ ? ? ? ? ? { ? ? ? ? ? ? type: "bar", ? ? ? ? ? ? name: "數(shù)量", ? ? ? ? ? ? data: this.datainfo, ? ? ? ? ? ? itemStyle: { ? ? ? ? ? ? ? color: "#77bef7" ? ? ? ? ? ? } ? ? ? ? ? } ? ? ? ? ] ? ? ? }; ? ? ? this.chart.setOption(option); ? ? ? if (this.datainfo.length > 0) { ? ? ? ? this.heightData = 300; ? ? ? } else { ? ? ? ? this.heightData = 0; ? ? ? ? this.noHeight = 300; ? ? ? ? this.noData = "暫無(wú)數(shù)據(jù)"; ? ? ? } ? ? } ? }, ? mounted() { ? ? this.find(); ? }, ? created() {} }; </script> <style ?lang="less" scoped> .nomore { ? display: flex; ? justify-content: center; ? align-items: center; ? font-size: 18px; } </style>
效果圖
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- vue+echarts實(shí)現(xiàn)3D柱形圖
- vue基于echarts實(shí)現(xiàn)立體柱形圖
- vue使用echarts實(shí)現(xiàn)水平柱形圖實(shí)例
- 使用D3.js+Vue實(shí)現(xiàn)一個(gè)簡(jiǎn)單的柱形圖
- Vue使用Echarts實(shí)現(xiàn)立體柱狀圖
- vue echarts實(shí)現(xiàn)橫向柱狀圖
- vue echarts實(shí)現(xiàn)柱狀圖動(dòng)態(tài)展示
- vue+echarts實(shí)現(xiàn)堆疊柱狀圖
- 如何在vue 中使用柱狀圖 并自修改配置
- vue使用echarts實(shí)現(xiàn)立體柱形圖
相關(guān)文章
Vue3使用Swiper實(shí)現(xiàn)輪播圖示例詳解
這篇文章主要為大家介紹了Vue3使用Swiper實(shí)現(xiàn)輪播圖示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02vue項(xiàng)目中定義全局變量、函數(shù)的幾種方法
這篇文章主要介紹了vue項(xiàng)目中定義全局變量、函數(shù)的幾種方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11vue實(shí)現(xiàn)全選組件封裝實(shí)例詳解
這篇文章主要介紹了vue?全選組件封裝,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-02-02Element?plus中el-input框回車觸發(fā)頁(yè)面刷新問(wèn)題以及解決辦法
在el-form表單組件中el-input組件輸入內(nèi)容后按下Enter鍵刷新了整個(gè)頁(yè)面,下面這篇文章主要給大家介紹了關(guān)于Element?plus中el-input框回車觸發(fā)頁(yè)面刷新問(wèn)題以及解決辦法,需要的朋友可以參考下2024-03-03Vue實(shí)現(xiàn)返回頂部按鈕實(shí)例代碼
這篇文章主要給大家介紹了關(guān)于Vue實(shí)現(xiàn)返回頂部按鈕的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-10-10