国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁/技術文章
文章詳情頁

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

瀏覽:3日期:2022-10-09 15:30:11
1.在html文件導入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.頁面結構

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

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

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

<!-- 引入主題 --> <script src='http://www.cgvv.com.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: ’| 商家銷售統計’, textStyle: { fontSize: 66 }, left: 20, top: 20 }, // 坐標軸配置 grid: { top: ’20%’, left: ’3%’, right: ’6%’, bottom: ’3%’, // 距離包含坐標軸文字 containLabel: true }, xAxis: { type: ’value’ }, yAxis: { type: ’category’, // y軸坐標軸使用遍歷出來的name data: sellerNames }, series: [ { // 類型為柱狀圖 type: ’bar’, // x軸數據需要設置在series的data類型為遍歷的value data: sellerValues, // 柱的寬度 barWidth: 66, // 柱文字 默認不展示 label: { show: true, // 文字靠右顯示 position: ’right’, textStyle: {// 顏色為白色color: ’white’ } }, // 控制柱的每一項 itemStyle: { // 控制柱的圓角半徑 barBorderRadius: [0, 33, 33, 0], // 線性漸變 // 指定不同百分比的顏色數值 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’, // 默認為直線,可選為:’line’ | ’shadow’ z: 0, // 背景層級 lineStyle: { width: 66, // 背景寬度 color: ’#2D3443’ // 背景顏色 } } } } ```

以上就是如何在vue 中使用柱狀圖 并自修改配置的詳細內容,更多關于vue 中使用柱狀圖 的資料請關注好吧啦網其它相關文章!

標簽: Vue
相關文章:
主站蜘蛛池模板: 韩国一级片在线观看 | 国产90后美女露脸在线观看 | 欧美视频在线网站 | 欧美一区二区aa大片 | 国产精品自拍在线观看 | 一级毛片欧美大片 | 亚洲欧美精品中文字幕 | 亚洲男人精品 | 香蕉久久网站 | 一级做a爰片久久毛片看看 一级做a爰片久久毛片鸭王 | 国产一二三区精品 | 99成人免费视频 | 看国产一级毛片 | 欧美大陆日韩 | 成人精品在线视频 | 欧美aaaaaa| 日本高清色本在线www游戏 | 国产精品制服 | 国产精选在线视频 | 特黄特色三级在线播放 | 欧美人成毛片在线播放 | 免费欧洲毛片a级视频无风险 | 欧美亚洲91| 久久精品国产国产 | 在线视频久 | 91精品欧美一区二区综合在线 | 中国美女牲交一级毛片 | 香蕉视频在线观看黄 | 亚洲视频精选 | 久久久久久久99久久久毒国产 | 欧美三级做爰全过程 | 国产精品久久国产精品99 | 国产免费久久精品99久久 | 欧美a在线看 | 99热久久精品免费精品 | 欧美日一级 | 全部在线美女网站免费观看 | 欧美一级毛片欧美一级 | 国产成人亚洲欧美三区综合 | 九九精品国产兔费观看久久 | 男女乱淫真视频免费一级毛片 |