日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

前端vue显示柱状图_Vue—Echarts 柱状图

發布時間:2024/7/23 vue 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 前端vue显示柱状图_Vue—Echarts 柱状图 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

使用Vue做后臺管理系統的時候避免不了使用Echarts來展示對應的數據,下面是使用Echarts柱狀圖來展示對應數據的實例。

ee05abaf9633184a9c012631b642d970.png

使用npm安裝Echarts

npm install echarts --save

在man.js中引入對應的echarts

import ECharts from 'vue-echarts' // 在 webpack 環境下指向 components/ECharts.vue

/* 引入echarts工具 */

import 'echarts/lib/component/tooltip'

import 'echarts/lib/component/title'

import 'echarts/lib/component/legend'

在vue文件下的編寫

data() {

return {

optionTrend: {

color: ['#2860fc'],

tooltip: {

trigger: 'axis',

axisPointer: { // 坐標軸指示器,坐標軸觸發有效

type: 'shadow' // 默認為直線,可選為:'line' | 'shadow'|'none'

}

},

title: {

text: '金額數量',

top: '15',

left: '-3',

textStyle:{

fontSize: 14, //字體大小

color: '#666666', //字體顏色

fontWeight: '500'

},

},

grid: {

left: '-27',

right: '4',

bottom: '0%',

containLabel: true

},

xAxis: [ {

type: 'category',

data: ['0-5K', '5K-3W', '3W-5W', '5W-10W', '10W以上',],

axisLine: { // 改變x軸顏色

lineStyle: {

color: '#c1c1c1',

width: '1',

}

},

axisLabel: { // 改變x軸字體顏色和大小

textStyle: {

color: "#666666",

fontSize: 12,

},

},

} ],

yAxis: [ {

type: 'value',

axisTick: 'none', // 右邊軸樣式的顯示

axisLine: 'none', // 右邊軸樣式的顯示

// 修改網格的顏色

splitLine: {

show: true,

lineStyle: {

type: 'solid',

color: '#f5f5f5'

}

},

} ],

series: [ {

name: '',

type: 'bar',

barWidth: '50%',

data: [10, 52, 200, 334, 390,]

} ]

},

}

},

beforeDestroy() {

window.removeEventListener("resize", this.resizeTheChart);

},

mounted(){

window.addEventListener("resize", this.resizeTheChart);

},

methods:{

resizeTheChart() {

if (this.$refs.TrendChart) {

this.$refs.TrendChart.resize();

}

},

27c1eac97e42e440849ac938a0bc4574.png

應為上面已經貼過template、beforeDestroy、mounted和methods里面的代碼了這里只貼對應options里面的代碼

dataRecordOptions: {

grid: {

left: '40',

right: '20',

bottom: '30',

top: '30',

},

tooltip : {

trigger: 'axis',

axisPointer: {

type: 'none', // 中間橫線

},

},

xAxis: {

data: ['數字身份','存證','數據報送','電子合同',],

axisLine: 'none',

axisLabel: {

color: '#fff',

fontSize: 12,

fontWeight: 500,

}

},

yAxis: {

type : 'value',

axisLabel: {

textStyle: {

fontSize: 12, //字體大小

color: '#137cf2', //字體顏色

},

formatter: function (value, index) {

if (value >= 10000 && value < 10000000) {

value = value / 10000 + "萬";

} else if (value >= 10000000 && value < 100000000) {

value = value / 10000000 + "千萬";

} else if (value >= 100000000) {

value = value / 100000000 + "億";

}

return value;

}

},

splitLine: {

show:true,

lineStyle: {

color: '#737f8d',

type: 'dashed', // 背景為虛線

}

},

axisTick: 'none', // 右邊軸樣式的顯示

axisLine: 'none', // 右邊軸樣式的顯示

},

series: [{

type: 'bar',

barWidth: 30,

smooth:false,

itemStyle:{

normal: {

color: function(params) {

var colorList = ['#137cf2','#f89009','#f8d909','#01cc78',];

var colorListr = ['#137cf2','#f8d909','#f89009','#5e00a6',];

return colorListr[params.dataIndex]

},

},

},

label: {

normal: {

show: true,

fontSize: 12,

fontWeight: '500',

color: '#ffffff',

position: 'top',

}

},

data: [10000,12000,8000,14000],

}],

}

總結

以上是生活随笔為你收集整理的前端vue显示柱状图_Vue—Echarts 柱状图的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。