电脑知识|欧美黑人一区二区三区|软件|欧美黑人一级爽快片淫片高清|系统|欧美黑人狂野猛交老妇|数据库|服务器|编程开发|网络运营|知识问答|技术教程文章 - 好吧啦网

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

vue中使用echarts的示例

瀏覽:5日期:2022-10-13 10:57:53

1:首先要用到echarts

2:在vue中安裝這個依賴

3:引入要用的頁面

import echarts from ’echarts’;

4:然后初始化

<template> <a-col span='12' ref='getwidth' :style='’display:’+ model'> <div > <div class='layui-card'> <div class='layui-card-header panel-title'> <span >統(tǒng)計(jì)更新及時率</span> <a @click='onHide'><a-icon type='close' /> </a> <div style='color: #b0b0b0;'><span v-for='(item,index) in activeList' :key='index' : @click.stop='Onactive(item,index)' ref='alist'>{{item.name}}</span><!-- <span class='month'>本月</span><span class='year'>本年</span> --> </div> </div> <div class='layui-card-body common-height'> <echartsModal:Maxwidths ='widths':MinHeight='MHeight':echartsColor='xAxis.color':legendWAndH='legendWAndH':xAxisData='xAxis.data':seriesData='xAxis.x.data':SerNameValue='xAxis.SerNameValue':echartsName='xAxis.name' /> <!-- <div : ></div> --> </div> </div> </div> </a-col></template><script>import echartsModal from ’../../viewModal/Echarts’// import echarts from ’echarts’;export default { components:{ echartsModal }, data(){ return{ model:’block’, widths:’’, legendWAndH:[15,15,18], MHeight:’’, xAxis:{ data: [’廣州’, ’深圳’, ’珠?!? ’汕頭’, ’佛山’, ’韶關(guān)’, ’湛江’, ’肇慶’, ’江門’, ’茂名’, ’惠州’, ’梅州’, ’汕尾’, ’河源’, ’陽江’, ’清遠(yuǎn)’, ’東莞’, ’中山’, ’潮州’, ’揭陽’, ’云浮’], x:{ data: [7.9, 2, 6, 5, 7, 5, 7, 80, 6, 7, 6, 86, 6, 56, 7, 6, 8, 5, 4, 7, 8], // data: [87.9, 58, 67, 56, 72, 54, 74, 59, 64, 75, 68, 47, 63, 89, 78, 64, 82, 56, 40, 73, 80], }, name:’及時率’, //圖表名稱 SerNameValue:{ position:’top’, color:’#3398DB’, // }, // color:’’ //圖表顏色 color:’#3398DB’ //圖表顏色 }, activeList:[ { name:’本周’, is_active:true, }, { name:’本月’, is_active:false, }, { name:’本年’, is_active:false, }, ] } }, mounted(){ this.widths = String((this.$refs.getwidth.$el.clientWidth) - 30) ; //畫布寬度 this.MHeight =String((this.$refs.getwidth.$el.clientHeight) - 68) //畫布高度 }, methods:{ onHide(){ const _this = this; _this.model = ’none’; _this.$emit(’isHide’, _this.model,0) }, Onactive(val,index){ const _this = this let Alist = _this.activeList let Length = _this.$refs.alist.length let axis = _this.xAxis let sumber = 0; let arr = []; for( let t = 0; t < Length; t++ ){ Alist[t].is_active = false; } if( val.name == ’本周’ ){ sumber = 1 }else if ( val.name ==’本月’ ){ sumber = 1 }else if( val.name == ’本年’ ){ sumber = 1 } Alist[index].is_active = true; axis.x.data.map(item=>{ item += sumber arr.push(item) }) axis.x.data = arr _this.xAxis = axis _this.activeList = Alist } }}</script><style scoped>/* .week{ padding: 0 1%;} */.layui-card-header { position: relative; height: 42px; line-height: 42px; padding: 0 15px; border-bottom: 1px solid #f6f6f6; color: #333; border-radius: 2px 2px 0 0; font-size: 14px;}.common-height { height: 280px;}.layui-card { margin-bottom: 15px; border-radius: 2px; background-color: #fff; box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);}.layui-card-body { position: relative; padding: 10px 15px; line-height: 24px;} .layui-col-md20 { width: 20%; } .time-city-panel { display: flex !important; justify-content: space-between; align-items: center; } .time-city-panel img { width: 73px !important; height: 61px !important; padding: 0 10px 10px !important; } .time-city-panel .one-row, .time-city-panel .two-row { padding: 0 10px; } .time-city-panel .one-row p:first-of-type { font-size: 18px; font-weight: bold; padding: 0 0 10px; text-align: left; } .time-city-panel .two-row p:first-of-type { padding: 0 0 10px; color: #96acbc; font-weight: bold; line-height: 22px; } .db_img { width: 20px; height: 22px; margin: 0 5px; vertical-align: middle; } .panel-title .left-text { padding-left: 10px; border-left: 8px solid #239fe6; font-size: 20px; display: inline-block; height: 30px; line-height: 30px; vertical-align: middle; } .panel-title .right-text { float: right; color: #239fe6; font-size: 14px; margin-left: 15px; } /*筒高度*/ .common-height { height: 280px; } .text-overflow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .tjgx-panel .right-text span, .ajtj-panel .right-text span { display: inline-block; color: #b0b0b0; } .tjgx-panel .right-text span.acitive, .ajtj-panel .right-text span.acitive { color: #239fe6; } #chart, #ajtjChart { width: 100%; height: 90%; } </style>

5:Echarts 組件

<template> <div> <!-- --> <div : ></div> <!-- <div v-if='Isgrid == false' : ></div> --> </div></template><script>import echarts from ’echarts’;import { number } from ’echarts/lib/export’;export default { props:{ Isgrid:{ type:Boolean, default:()=> true //默認(rèn)顯示柱狀圖 }, ss:{ type:Object, default:()=>{} }, Maxwidths:{ type:String, //整個容器的寬度 default:’’ }, MinHeight:{ type:String, //最小高度 default:’’ }, echartsColor:{ //圖像的顏色 type:String, default:’’ }, legendWAndH:{ //圖例的寬高位置等 type:Array, default:()=>[15,15,18] }, legendColor:{ type:String, default:()=>’’ //圖例的顏色,如果不加則默認(rèn)是圖形顏色 }, xAxisData:{ //圖形X軸的數(shù)據(jù) type:Array, default:()=>[] }, YAxisName:{ //圖形y軸的名稱設(shè)置 數(shù)組或者百分比 type:Object, default:()=>{} // default:{name:’111’,formatter: ’{value}%’} }, seriesData:{ type:Array, // 顯示圖像的數(shù)據(jù) 占據(jù)的多少 default:()=>[] }, SerNameValue:{ //圖形數(shù)據(jù)分析的占據(jù)的位置 left right top bottom 和顯示的顏色 type:Object, default:()=>{} // default:{position:top,color: ’#3398DB’,formatter: ’{c}%’} }, echartsName:{ //圖形的名稱 type:String, default:()=>’柱狀圖’ }, XorYatter:{ type:Array, default:()=>[’{value}%’,’{c}%’] //默認(rèn)為百分比 }, //雷達(dá)圖的參數(shù) gWidth:{ //寬度默認(rèn)為百分百 type:String, default:()=>’100’ }, gHeight:{ type:String, default:()=> ’90’ //高度默認(rèn)為90 }, gridValue:{ /// 雷達(dá)圖的名稱等等 格式[{text:11}] type:Array, default:()=>[] }, gridraius:{ //圓圈大小 type:Number, default:()=> 80 //默認(rèn)為80 }, gridTextStyle:{ //名稱的默認(rèn)顏色 text type:String, default:()=>’#6bbcef’ }, symbolSize:{ // 圓點(diǎn)的大小 type:Number, default:()=> 10 }, SerValue:{ type:Array, default:()=>[] //網(wǎng)格里面對應(yīng)的數(shù)值 }, serVcolor:{ type:String, default:()=> ’#1bbdf8’ //數(shù)值的默認(rèn)顏色 SerValue的 }, lineStyleColor:{ type:String, default:()=> ’#1cbdf8’ //連接線的顏色 }, itemStyleColor:{ type:String, default:()=> ’#1cbdf8’ //連接圓點(diǎn)的默認(rèn)顏色 }, BgColor:{ type:String, default:()=> ’rgba(189, 230, 249, 0.5)’ } }, data(){ return{ option:{ color:[], //圖例顏色 legend:{ data:[], //圖例名稱 itemWidth:0, //圖例的寬度 itemHeight:0, //圖例的高度 right:0, textStyle:{ color:’’ } }, xAxis:{ data:[] //x軸數(shù)據(jù) }, yAxis:{ name:’’, //名稱 axisLabel:{ formatter:’’ //是否顯示百分比 } }, series:[ { name:’’, type:’bar’, //類型 data:[], //X軸顯示的數(shù)據(jù) label:{ normal:{show:true,position:’’,color:’’,formatter:’’ } } } ] }, options:{ radar:[ { indicator:[], // 顯示的名稱的字段只能是text ps:[{text:’aaa’}] radius:0, //園角 name:{ textStyle:{color:’’ //顏色 } }, symbolSize:0, //圓點(diǎn)大小 } ], series:[ { type:’radar’, data:[{ value:[], //對應(yīng)的數(shù)據(jù) label:{normal:{ show:true, color:’’, //選中的時候顏色 formatter:(params)=>{ return params.value; }} }, //連接線顏色 lineStyle:{color:’’, }, // 連接圓點(diǎn)顏色 itemStyle:{color:’’ }, // 圖表背景網(wǎng)格的顏色 areaStyle:{normal:{ opacity:0.9, color:’’ } } }] } ] } } }, created(){ const _this = this; console.log(_this.Isgrid) console.log(this.ECharts) if( _this.Isgrid ){ _this.onloads() //初始化數(shù)據(jù) }else{ _this.isInitGrid() } }, mounted(){ const _this = this; if(_this.ss){ _this.option = {} _this.option = _this.ss; } setTimeout(()=>{ _this.$nextTick(()=>{ let Echarts = echarts.init(document.getElementById(’Echarts’)) Echarts.setOption(_this.option,true) }) },500) }, watch:{ seriesData(val){ this.seriesData = val this.onloads(true) } }, methods:{ onloads(is){ const _this = this; let op = _this.option op.color = [_this.echartsColor] op.legend.data = [_this.echartsName] op.legend.itemWidth =_this.legendWAndH[0] op.legend.itemHeight =_this.legendWAndH[1] op.legend.right =_this.legendWAndH[2] op.legend.textStyle.color =_this.legendColor == ’’ ? _this.echartsColor:’’ op.xAxis.data = _this.xAxisData op.yAxis.name = _this.echartsName op.yAxis.axisLabel.formatter = _this.XorYatter[0] op.series[0].data = _this.seriesData op.series[0].name = _this.echartsName op.series[0].label.normal.position = _this.SerNameValue.position op.series[0].label.normal.formatter = _this.XorYatter[1] op.series[0].label.normal.color = _this.SerNameValue.color == ’’ ? _this.echartsColor:_this.SerNameValue.color _this.option = op; if( is ){ _this.$nextTick(()=>{ let Echarts = echarts.init(document.getElementById(’Echarts’)) Echarts.setOption(op,true) }) } }, isInitGrid(){ const _this = this; let g = _this.options; g.radar[0].indicator = _this.gridValue g.radar[0].radius = _this.gridraius g.radar[0].name.textStyle.color = _this.gridTextStyle g.radar[0].symbolSize = _this.symbolSize g.series[0].data[0].value = _this.SerValue g.series[0].data[0].label.normal.color = _this.serVcolor g.series[0].data[0].lineStyle.color = _this.lineStyleColor g.series[0].data[0].itemStyle.color = _this.itemStyleColor g.series[0].data[0].areaStyle.normal.color = _this.BgColor } }}</script>

6:效果圖

vue中使用echarts的示例

以上就是vue中使用echarts的步驟的詳細(xì)內(nèi)容,更多關(guān)于vue 使用echarts的資料請關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 长城人品牌官网 | 磁力反应釜,高压釜,实验室反应釜,高温高压反应釜-威海自控反应釜有限公司 | 产业规划_产业园区规划-产业投资选址及规划招商托管一体化服务商-中机院产业园区规划网 | 双舌接地线-PC68数字式高阻计-ZC36|苏海百科 | 蒸压釜_蒸养釜_蒸压釜厂家-山东鑫泰鑫智能装备有限公司 | 求是网 - 思想建党 理论强党 | 实验室装修_实验室设计_实验室规划设计- 上海广建净化工程公司 | 蚂蚁分类信息系统 - PHP同城分类信息系统 - MayiCMS | 煤矿支护网片_矿用勾花菱形网_缝管式_管缝式锚杆-邯郸市永年区志涛工矿配件有限公司 | 楼承板-开口楼承板-闭口楼承板-无锡海逵| 磁力抛光机_磁力研磨机_磁力去毛刺机-冠古设备厂家|维修|租赁【官网】 | 注塑_注塑加工_注塑模具_塑胶模具_注塑加工厂家_深圳环科 | PC构件-PC预制构件-构件设计-建筑预制构件-PC构件厂-锦萧新材料科技(浙江)股份有限公司 | 澳洁干洗店加盟-洗衣店干洗连锁「澳洁干洗免费一对一贴心服务」 干洗加盟网-洗衣店品牌排行-干洗设备价格-干洗连锁加盟指南 | 武汉刮刮奖_刮刮卡印刷厂_为企业提供门票印刷_武汉合格证印刷_现金劵代金券印刷制作 - 武汉泽雅印刷有限公司 | 外观设计_设备外观设计_外观设计公司_产品外观设计_机械设备外观设计_东莞工业设计公司-意品深蓝 | 压力控制器,差压控制器,温度控制器,防爆压力控制器,防爆温度控制器,防爆差压控制器-常州天利智能控制股份有限公司 | 武汉森源蓝天环境科技工程有限公司-为环境污染治理提供协同解决方案 | 盘装氧量分析仪-防爆壁挂氧化锆分析仪-安徽吉帆仪表有限公司 | 大连海岛旅游网>>大连旅游,大连海岛游,旅游景点攻略,海岛旅游官网 | 强效碱性清洗剂-实验室中性清洗剂-食品级高纯氮气发生器-上海润榕科学器材有限公司 | 涿州网站建设_网站设计_网站制作_做网站_固安良言多米网络公司 | 洛阳防爆合格证办理-洛阳防爆认证机构-洛阳申请国家防爆合格证-洛阳本安防爆认证代办-洛阳沪南抚防爆电气技术服务有限公司 | 北京燃气公司 用户服务中心 | 北京开业庆典策划-年会活动策划公司-舞龙舞狮团大鼓表演-北京盛乾龙狮鼓乐礼仪庆典策划公司 | IWIS链条代理-ALPS耦合透镜-硅烷预处理剂-上海顶楚电子有限公司 lcd条形屏-液晶长条屏-户外广告屏-条形智能显示屏-深圳市条形智能电子有限公司 | 土壤肥料养分速测仪_测土配方施肥仪_土壤养分检测仪-杭州鸣辉科技有限公司 | 风淋室生产厂家报价_传递窗|送风口|臭氧机|FFU-山东盛之源净化设备 | 高压油管,液压接头,液压附件-烟台市正诚液压附件 | 2025福建平潭岛旅游攻略|蓝眼泪,景点,住宿攻略-趣平潭网 | 旋振筛|圆形摇摆筛|直线振动筛|滚筒筛|压榨机|河南天众机械设备有限公司 | 上海刑事律师|刑事辩护律师|专业刑事犯罪辩护律师免费咨询-[尤辰荣]金牌上海刑事律师团队 | 合肥弱电工程_安徽安防工程_智能化工程公司-合肥雷润 | 广州番禺搬家公司_天河黄埔搬家公司_企业工厂搬迁_日式搬家_广州搬家公司_厚道搬迁搬家公司 | 房在线-免费房产管理系统软件-二手房中介房屋房源管理系统软件 | pbootcms网站模板|织梦模板|网站源码|jquery建站特效-html5模板网 | 懂研帝_专业SCI论文润色机构_SCI投稿发表服务公司 | 环讯传媒,永康网络公司,永康网站建设,永康小程序开发制作,永康网站制作,武义网页设计,金华地区网站SEO优化推广 - 永康市环讯电子商务有限公司 | 板框压滤机-隔膜压滤机配件生产厂家-陕西华星佳洋装备制造有限公司 | 磁力反应釜,高压釜,实验室反应釜,高温高压反应釜-威海自控反应釜有限公司 | HDPE土工膜,复合土工膜,防渗膜价格,土工膜厂家-山东新路通工程材料有限公司 |