色综合图-色综合图片-色综合图片二区150p-色综合图区-玖玖国产精品视频-玖玖香蕉视频

您的位置:首頁技術(shù)文章
文章詳情頁

如何在vue 中使用柱狀圖 并自修改配置

瀏覽:3日期:2022-10-09 15:30:11
1.在html文件導(dǎo)入echart

<!-- 引入echarts --> <script src='https://cdn.bootcdn.net/ajax/libs/echarts/4.8.0/echarts.min.js'></script>2.在main.js上掛載echarts對象

Vue.prototype.$echarts = window.echarts// 使用時直接使用this.$echarts3.頁面結(jié)構(gòu)

<template> <div class='com-container'> <div ref='sellerRef'></div> </div></template>4.data中的數(shù)據(jù)

export default { data () { return { // 初始化的圖表 chartInstance: null, allDate: null, // 服務(wù)器返回的數(shù)據(jù) } },}```js##### 5.methods中的邏輯```jsmethods: { // 初始化echarts對象 initEchart(){ // 獲取dom對象 this.chartInstance = this.$echarts.init(this.$refs.sellerRef) }, // 獲取服務(wù)器的數(shù)據(jù) async getData(){ const {data:res} = await this.$http.get(’seller’) this.allDate = res // 返會的數(shù)據(jù)結(jié)構(gòu)是 name商家 value數(shù)值 // 對返回的數(shù)據(jù)進(jìn)行從小打到排序 sort方法 this.allDate.sort((a, b) => { return a.value - b.value }) // 調(diào)用更新視方法 this.updateChart() }, // 更新圖表 updateChart(){ // y軸類目軸的數(shù)據(jù) const sellerNames = this.allDate.map(item=>{ // 根據(jù)你的需求調(diào)整 return item.name }) // x軸數(shù)值軸的數(shù)據(jù) const sellerValues = this.allDate.map(item=>{ return item.value }) const option = { xAxis: { type: ’value’ }, yAxis: { type: ’category’, // y軸坐標(biāo)軸使用遍歷出來的name data: sellerNames }, series: [ { // 類型為柱狀圖 type: ’bar’, // x軸數(shù)據(jù)需要設(shè)置在series的data類型為遍歷的value data: sellerValues } ] } // 渲染optio數(shù)據(jù)給dom對象 this.chartInstance.setOption(option)},mounted鉤子函數(shù)調(diào)用

// dom加載完成調(diào)用 mounted () { this.initChart() this.getData() },更改柱形圖配置1.在index.html 引入主題配置文件

<!-- 引入主題 --> <script src='http://www.lshqa.cn/bcjs/static/lib/theme/chalk.js'></script>2.在需要使用主題的地方使用 初始化獲取dom傳入chalk

this.chartInstance = this.$echarts.init(this.$refs.sellerRef, ’chalk’)3.option的配置 LinearGradient(x1,x2,y1,y2)線性漸變

const option = { title: { text: ’| 商家銷售統(tǒng)計’, textStyle: { fontSize: 66 }, left: 20, top: 20 }, // 坐標(biāo)軸配置 grid: { top: ’20%’, left: ’3%’, right: ’6%’, bottom: ’3%’, // 距離包含坐標(biāo)軸文字 containLabel: true }, xAxis: { type: ’value’ }, yAxis: { type: ’category’, // y軸坐標(biāo)軸使用遍歷出來的name data: sellerNames }, series: [ { // 類型為柱狀圖 type: ’bar’, // x軸數(shù)據(jù)需要設(shè)置在series的data類型為遍歷的value data: sellerValues, // 柱的寬度 barWidth: 66, // 柱文字 默認(rèn)不展示 label: { show: true, // 文字靠右顯示 position: ’right’, textStyle: {// 顏色為白色color: ’white’ } }, // 控制柱的每一項 itemStyle: { // 控制柱的圓角半徑 barBorderRadius: [0, 33, 33, 0], // 線性漸變 // 指定不同百分比的顏色數(shù)值 color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [{ // 百分之0的樣式 offset: 0, color: ’#5052EE’},{ // 百分之百 offset: 1, color: ’#AB6EE5’} ]) } } ], tooltip: { trigger: ’axis’, axisPointer: { type: ’line’, // 默認(rèn)為直線,可選為:’line’ | ’shadow’ z: 0, // 背景層級 lineStyle: { width: 66, // 背景寬度 color: ’#2D3443’ // 背景顏色 } } } } ```

以上就是如何在vue 中使用柱狀圖 并自修改配置的詳細(xì)內(nèi)容,更多關(guān)于vue 中使用柱狀圖 的資料請關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 91香焦国产线观看看免费 | 亚洲国产成人在人网站天堂 | 欧美一级鲁丝片 | 欧美另类激情 | 天堂8中文在线最新版在线 天堂8资源8在线 | 欧洲女同互慰在线视频 | 亚洲精品国产精品国自产观看 | 国产日本三级欧美三级妇三级四 | 亚洲欧美视频一级 | 日本亚洲欧美高清专区vr专区 | 久久久久亚洲精品影视 | 免费三级网 | 日韩性大片免费 | 日韩欧美成末人一区二区三区 | 免费在线黄色网址 | 日本视频播放免费线上观看 | 国内精品久久久久久野外 | 91久久精品一区二区 | 99久久香蕉 | 国产2021中文天码字幕 | 日本不卡免费高清视频 | 欧美一级特黄特色大片 | 精品国产乱码久久久久久一区二区 | 免费一级在线 | 亚洲线精品一区二区三区 | 国产一区二区三区四区五区 | 91大神在线精品视频一区 | 在线观看亚洲欧美 | 免费看一级欧美毛片视频 | 最近中文字幕免费视频 | 综合刺激网| 国产精品亚洲第一区柳州莫青 | 亚洲日本视频 | 中文字幕久久亚洲一区 | 8888奇米四色在线 | 亚洲免费视频在线 | 成年人免费在线视频 | 黄色网址在线免费观看 | 久久网免费视频 | 欧美日韩亚洲一区二区三区 | 手机看片福利在线 |