vue3.0+echarts實(shí)現(xiàn)立體柱圖
前言:
vue3.0實(shí)現(xiàn)echarts立體柱圖
實(shí)現(xiàn)效果:
實(shí)現(xiàn)步驟:
1、安裝echarts
cnpm i --save echarts
2、頁面定義容器
<template> <div ref="echart" class="echartDiv"></div> </template>
3、js中引入echarts
import * as echarts from 'echarts';
組件完整源碼:
<template> <div ref="echart" class="echartDiv"></div> </template> <script> import * as echarts from 'echarts'; import { onMounted,toRefs, ref,reactive } from 'vue'; export default { setup(){ let state = reactive({ xAxisData:['浩星','妍仔','哆啦a夢','李李','王穎','老王'], yAxisData:[4,22,1,11,23,11], yAxisData1:[1,1,1,1,1,1], echart: ref(), }) const echartInit = () =>{ var myChart = echarts.init(state.echart); // 指定圖表的配置項(xiàng)和數(shù)據(jù) var option = { tooltip: { trigger: "axis", axisPointer: { type: "shadow", // 默認(rèn)為直線,可選為:'line' | 'shadow' }, formatter: function(parms) { var str = parms[0].axisValue + "</br>" + parms[0].marker + "今天登錄:" + parms[0].value + '次' return str; }, }, textStyle: { color: "#333", }, color: ["#7BA9FA", "#4690FA"], grid: { containLabel: true, left: "10%", top: "20%", bottom: "10%", right: "10%", }, xAxis: { type: "category", data: state.xAxisData, axisLine: { lineStyle: { color: "#333", }, }, axisTick: { show: false, }, axisLabel: { margin: 20, //刻度標(biāo)簽與軸線之間的距離。 textStyle: { color: "#000", }, }, }, yAxis: { type: "value", axisLine: { show: true, lineStyle: { color: "#B5B5B5", }, }, splitLine: { lineStyle: { // 使用深淺的間隔色 color: ["#B5B5B5"], type: "dashed", opacity: 0.5, }, }, axisLabel: {}, }, series: [{ data: state.yAxisData, stack: "zs", type: "bar", barMaxWidth: "auto", barWidth: 60, itemStyle: { color: { x: 0, y: 0, x2: 0, y2: 1, type: "linear", global: false, colorStops: [{ offset: 0, color: "#5EA1FF", }, { offset: 1, color: "#90BEFF", }, ], }, }, }, //下面的立體,控制顏色是color第一個(gè) { data: state.yAxisData1, type: "pictorialBar", barMaxWidth: "20", symbol: "diamond", symbolOffset: [0, "50%"], symbolSize: [60, 15], zlevel: 2, }, //上面的立體,控制顏色是color第二個(gè) { data: state.yAxisData, type: "pictorialBar", barMaxWidth: "20", symbolPosition: "end", symbol: "diamond", symbolOffset: [0, "-50%"], symbolSize: [60, 12], zlevel: 2, } ], }; // 使用剛指定的配置項(xiàng)和數(shù)據(jù)顯示圖表。 myChart.setOption(option); } //掛載 onMounted(()=>{ echartInit() }) return { ...toRefs(state), echartInit }; } } </script> <style lang='scss' scoped> .echartDiv{ width: 100%; height: 400px; } </style>
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- vue+echarts實(shí)現(xiàn)3D柱形圖
- Vue+Echarts實(shí)現(xiàn)柱狀折線圖
- 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)度條式柱狀圖
- vue基于echarts實(shí)現(xiàn)立體柱形圖
- Vue?Echarts實(shí)現(xiàn)帶滾動(dòng)效果的柱形圖
相關(guān)文章
vue與electron實(shí)現(xiàn)進(jìn)程間的通信詳情
這篇文章主要介紹了vue與electron實(shí)現(xiàn)進(jìn)程間的通信詳情,本文主要介紹electron渲染進(jìn)程和主進(jìn)程間的通信,以及在渲染進(jìn)程和主進(jìn)程中常用的配置項(xiàng),需要的朋友可以參考一下2022-09-09用v-html解決Vue.js渲染中html標(biāo)簽不被解析的問題
這篇文章主要給大家介紹了如何利用v-html解決Vue.js渲染過程中html標(biāo)簽不能被解析,html標(biāo)簽顯示為字符串的問題,文中通過圖文介紹的很詳細(xì),有需要的朋友們可以參考借鑒,下面來一起看看吧。2016-12-12Vue按回車鍵進(jìn)行搜索的實(shí)現(xiàn)方式
這篇文章主要介紹了Vue按回車鍵進(jìn)行搜索的實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-01-01這15個(gè)Vue指令,讓你的項(xiàng)目開發(fā)爽到爆
這篇文章主要介紹了這15個(gè)Vue指令,讓你的項(xiàng)目開發(fā)爽到爆,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-10-10使用Vue.js和MJML創(chuàng)建響應(yīng)式電子郵件
這篇文章主要介紹了使用Vue.js和MJML創(chuàng)建響應(yīng)式電子郵件,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03vue router自動(dòng)判斷左右翻頁轉(zhuǎn)場動(dòng)畫效果
最近公司項(xiàng)目比較少終于有空來記錄一下自己對(duì)vue-router的一些小小的使用心得,本文給大家分享vue router自動(dòng)判斷左右翻頁轉(zhuǎn)場動(dòng)畫效果,感興趣的朋友一起看看吧2017-10-10Vue新手指南之創(chuàng)建第一個(gè)vue-cli腳手架程序
vue-cli 是一個(gè)官方發(fā)布 vue.js 項(xiàng)目腳手架,使用 vue-cli 可以快速創(chuàng)建 vue 項(xiàng)目。這篇文章主要給大家介紹了關(guān)于Vue新手指南之創(chuàng)建第一個(gè)vue-cli程序的相關(guān)資料,需要的朋友可以參考下2021-05-05