vue+echarts實(shí)現(xiàn)條紋柱狀橫向圖
本文實(shí)例為大家分享了vue+echarts實(shí)現(xiàn)條紋柱狀橫向圖的具體代碼,供大家參考,具體內(nèi)容如下
實(shí)現(xiàn)效果:
<template> ? <div id="BusinessTop5Chart" style="flex: 1; height: 300px; width: 614px; margin-left: 10px"></div> </template> <script> import { getNoteMatters } from '@/api/government'; const colors = [ ? ?'rgba(248, 75, 110, 1)', ? ?'rgba(239, 142, 47, 1)', ? ?'rgba(234, 202, 4, 1)', ? ?'rgba(79, 224, 255, 1)', ? ?'rgba(106, 196, 255, 1)', ?]; export default { ? data() { ? ? return { ? ? ? list: [], ? ? ? list1: [], ? ? ? list2: [], ? ? ? Top5ListName: [], ? ? ? Top5ListValue:[] ? ? }; ? }, ? mounted() { ? ? this.getNoteMatters(); ? }, ? methods: { ? ? initMap() { ? ? ? var myChart = this.$echarts.init(document.getElementById('BusinessTop5Chart')); ? ? ? const option = { ? ? ? ? grid: { ? ? ? ? ? top: 20, ? ? ? ? ? bottom: 30, ? ? ? ? ? left: 10, ? ? ? ? ? right: 150, ? ? ? ? ? containLabel: true, ? ? ? ? }, ? ? ? ? tooltip: { ? ? ? ? ? show: true, ? ? ? ? ? trigger: 'axis', ? ? ? ? ? axisPointer: { ? ? ? ? ? ? type: 'shadow', ? ? ? ? ? }, ? ? ? ? }, ? ? ? ? xAxis: { ? ? ? ? ? type: 'value', ? ? ? ? ? splitLine: { ? ? ? ? ? ? show: false, ? ? ? ? ? }, ? ? ? ? ? axisLine: { ? ? ? ? ? ? show: false, ? ? ? ? ? }, ? ? ? ? ? axisLabel: { ? ? ? ? ? ? show: false, ? ? ? ? ? }, ? ? ? ? ? axisTick: { ? ? ? ? ? ? show: false, ? ? ? ? ? }, ? ? ? ? ? position: 'top', ? ? ? ? }, ? ? ? ? yAxis: { ? ? ? ? ? type: 'category', ? ? ? ? ? data: this.Top5ListName, ? ? ? ? ? inverse: true, //倒敘 ? ? ? ? ? axisLine: { ? ? ? ? ? ? show: false, ? ? ? ? ? }, ? ? ? ? ? axisTick: { ? ? ? ? ? ? show: false, ? ? ? ? ? }, ? ? ? ? ? axisLabel: { ? ? ? ? ? ? textStyle: { ? ? ? ? ? ? ? color: 'rgba(255,255,255,0.85)', ? ? ? ? ? ? ? fontSize: 14, ? ? ? ? ? ? ? fontFamily: 'TencentSans', ? ? ? ? ? ? }, ? ? ? ? ? ? padding: [0, 0, 20, 0], ? ? ? ? ? ? inside: true, ? ? ? ? ? ? verticalAlign: 'bottom', ? ? ? ? ? }, ? ? ? ? }, ? ? ? ? series: [ ? ? ? ? ? { ? ? ? ? ? ? type: 'bar', ? ? ? ? ? ? barGap: '-90%', ? ? ? ? ? ? barMaxWidth: 14, ? ? ? ? ? ? z: 0, ? ? ? ? ? ? label: { ? ? ? ? ? ? ? normal: { ? ? ? ? ? ? ? ? show: false, ? ? ? ? ? ? ? ? position: 'right', ? ? ? ? ? ? ? ? fontSize: 14, ? ? ? ? ? ? ? ? offset: [16, 0], ? ? ? ? ? ? ? }, ? ? ? ? ? ? }, ? ? ? ? ? ? data: this.list, ? ? ? ? ? }, ? ? ? ? ? { ? ? ? ? ? ? type: 'bar', ? ? ? ? ? ? barGap: '-90%', ? ? ? ? ? ? barMaxWidth: 14, ? ? ? ? ? ? itemStyle: { ? ? ? ? ? ? ? color: 'rgba(26, 49, 99, 0.5)', ? ? ? ? ? ? }, ? ? ? ? ? ? tooltip: { ? ? ? ? ? ? ? show: false, ? ? ? ? ? ? }, ? ? ? ? ? ? data: this.list1, ? ? ? ? ? }, ? ? ? ? ? { ? ? ? ? ? ? type: 'pictorialBar', ? ? ? ? ? ? symbolRepeat: 'fixed', ? ? ? ? ? ? symbolMargin: 4, ? ? ? ? ? ? symbol: 'rect', ? ? ? ? ? ? symbolClip: true, ? ? ? ? ? ? symbolSize: [1, 14], ? ? ? ? ? ? symbolPosition: 'start', ? ? ? ? ? ? itemStyle: { ? ? ? ? ? ? ? color: 'rgba(0,0,0,1)', ? ? ? ? ? ? }, ? ? ? ? ? ? data: this.list2, ? ? ? ? ? }, ? ? ? ? ], ? ? ? }; ? ? ? myChart.setOption(option); ? ? }, ? ? getNoteMatters() { ? ? ? getNoteMatters().then((res) => { ? ? ? ? const { status, data } = res; ? ? ? ? const { businessTpo5 } = JSON.parse(data); ? ? ? ? if (status === 200) { ? ? ? ? // this.Top5ListName=[ ? ? ? ? // ? ? ?{0: "三亞市稅務(wù)局",? ? ? ? ? // ? ? ? 1: "三亞市市場(chǎng)監(jiān)督管理局",? ? ? ? ? // ? ? ? 2: "三亞市公安局",? ? ? ? ? // ? ? ? 3: "三亞市郵政管理局",? ? ? ? ? // ? ? ? 4: "三亞市社會(huì)保險(xiǎn)服務(wù)中心窗口"}] ? ? ? ? ? this.Top5ListName = businessTpo5.map((item) => { ? ? ? ? ? ? return item.agencies; ? ? ? ? ? }); ? ? ? ? // this.Top5ListValue=[{0: 189354, 1: 56933, 2: 13267, 3: 10979, 4: 9054}] ? ? ? ? ? this.Top5ListValue = businessTpo5.map((item) => { ? ? ? ? ? ? return Number(item.num); ? ? ? ? ? }); ? ? ? ? ? const max = Math.max.apply(null, this.Top5ListValue); ? ? ? ?// this.list=[{itemStyle: ?? ? ? // ?? ??? ?color: "rgba(248, 75, 110, 1)" ? ? ? ?//?? ? ?? ?name: "三亞市稅務(wù)局" ? ? ? ?//?? ? ?? ?num: "189354" ? ? ? ?//?? ? ?? ?rate: "57.03%" ? ? ? ?//?? ? ?? ?value: 189354}] ? ? ? ? ? this.list = businessTpo5.map((item, index) => { ? ? ? ? ? ? let obj = { ? ? ? ? ? ? ? name: item.agencies, ? ? ? ? ? ? ? value: Number(item.num), ? ? ? ? ? ? ? num: item.num, ? ? ? ? ? ? ? rate: item.rate, ? ? ? ? ? ? ? itemStyle: { ? ? ? ? ? ? ? ? color: colors[index], ? ? ? ? ? ? ? }, ? ? ? ? ? ? }; ? ? ? ? ? ? return obj; ? ? ? ? ? }); ? ? ? ?// this.list1=[ ? ? ? ?// label:{ ?? ? ? // normal:{ ? ? ? ?// color: colors[index], ? ? ? ?// fontSize: 14 ? ? ? ?// position: "right" ? ? ? ?// show: true ? ? ? ?// offset:[16,0] ? ? ? ?// name: "三亞市稅務(wù)局" ? ? ? ?// formatter(){return(item.num+'單位'+''+item.rate)} ? ? ? ?// rate: "57.03%" ? ? ? ?// value: 189354}} ? ? ? ? ? this.list1 = businessTpo5.map((item, index) => { ? ? ? ? ? ? let obj = { ? ? ? ? ? ? ? name: item.agencies, ? ? ? ? ? ? ? value: max, ? ? ? ? ? ? ? label: item.num, ? ? ? ? ? ? ? rate: item.rate, ? ? ? ? ? ? ? label: { ? ? ? ? ? ? ? ? normal: { ? ? ? ? ? ? ? ? ? show: true, ? ? ? ? ? ? ? ? ? position: 'right', ? ? ? ? ? ? ? ? ? fontSize: 14, ? ? ? ? ? ? ? ? ? color: colors[index], ? ? ? ? ? ? ? ? ? offset: [16, 0], ? ? ? ? ? ? ? ? ? formatter() { ? ? ? ? ? ? ? ? ? ? return ( ? ? ? ? ? ? ? ? ? ? ? item.num + '件' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + ' ' + item.rate ? ? ? ? ? ? ? ? ? ? ); ? ? ? ? ? ? ? ? ? }, ? ? ? ? ? ? ? ? }, ? ? ? ? ? ? ? }, ? ? ? ? ? ? }; ? ? ? ? ? ? return obj; ? ? ? ? ? }); ? ? ? // this.list2=[{label: "189354" ?? ? ?// name: "三亞市稅務(wù)局" ?? ? ?// rate: "57.03%" ?? ? ?// value: 189354}] ? ? ? ? ? ? this.list2 = businessTpo5.map((item) => { ? ? ? ? ? ? let obj = { ? ? ? ? ? ? ? name: item.agencies, ? ? ? ? ? ? ? value: Number(item.num), ? ? ? ? ? ? ? label: item.num, ? ? ? ? ? ? ? rate: item.rate, ? ? ? ? ? ? }; ? ? ? ? ? ? return obj; ? ? ? ? ? }); ? ? ? ? } ? ? ? ? this.initMap(); ? ? ? }); ? ? }, ? }, }; </script>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- vue+echarts實(shí)現(xiàn)3D柱形圖
- Vue+Echarts實(shí)現(xiàn)柱狀折線圖
- 詳解vue使用Echarts畫柱狀圖
- vue echarts實(shí)現(xiàn)橫向柱狀圖
- vue echarts實(shí)現(xiàn)柱狀圖動(dòng)態(tài)展示
- vue+echarts實(shí)現(xiàn)堆疊柱狀圖
- vue+echarts實(shí)現(xiàn)進(jìn)度條式柱狀圖
- vue3.0+echarts實(shí)現(xiàn)立體柱圖
- vue基于echarts實(shí)現(xiàn)立體柱形圖
- Vue?Echarts實(shí)現(xiàn)帶滾動(dòng)效果的柱形圖
相關(guān)文章
在vue中使用inheritAttrs實(shí)現(xiàn)組件的擴(kuò)展性介紹
這篇文章主要介紹了在vue中使用inheritAttrs實(shí)現(xiàn)組件的擴(kuò)展性介紹,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-12-12Vue3?<script?setup?lang=“ts“>?的基本使用
<script setup>?是在單文件組件 (SFC) 中使用?composition api?的編譯時(shí)語(yǔ)法糖,本文主要講解<script setup>?與?TypeScript?的基本使用,感興趣的朋友跟隨小編一起看看吧2022-12-12vue中for循環(huán)更改數(shù)據(jù)的實(shí)例代碼(數(shù)據(jù)變化但頁(yè)面數(shù)據(jù)未變)
這篇文章主要介紹了vue中for循環(huán)更改數(shù)據(jù)的實(shí)例代碼(數(shù)據(jù)變化但頁(yè)面數(shù)據(jù)未變)的相關(guān)資料,需要的朋友可以參考下2017-09-09基于Vue技術(shù)實(shí)現(xiàn)遞歸組件的方法
這篇文章主要為大家詳細(xì)介紹了基于Vue技術(shù)實(shí)現(xiàn)遞歸組件的方法 ,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-08-08Vue實(shí)現(xiàn)登錄保存token并校驗(yàn)實(shí)現(xiàn)保存登錄狀態(tài)的操作代碼
這篇文章主要介紹了Vue實(shí)現(xiàn)登錄保存token并校驗(yàn)實(shí)現(xiàn)保存登錄狀態(tài),本文通過(guò)示例代碼給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧2024-02-02vue3.0 proxy設(shè)置代理不成功的問(wèn)題及解決方案
這篇文章主要介紹了vue3.0 proxy設(shè)置代理不成功的問(wèn)題及解決方案,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2023-12-12vue?cli3?項(xiàng)目中如何使用axios發(fā)送post請(qǐng)求
這篇文章主要介紹了vue?cli3?項(xiàng)目中如何使用axios發(fā)送post請(qǐng)求,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-04-04Vue ECharts簡(jiǎn)易實(shí)現(xiàn)雷達(dá)圖
這篇文章主要介紹了基于Vue ECharts簡(jiǎn)易實(shí)現(xiàn)雷達(dá)圖,本文通過(guò)實(shí)例代碼圖文相結(jié)合給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-12-12Vue v-for循環(huán)之@click點(diǎn)擊事件獲取元素示例
今天小編就為大家分享一篇Vue v-for循環(huán)之@click點(diǎn)擊事件獲取元素示例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-11-11