公司营销型网站建设,亿创电力建设集团有限公司网站,辽宁建设工程信息网app,南昌地宝网出租房信息Vue实现柱状图横向自动滚动 1. 前言2. 代码3、实现效果图 1. 前言 原理#xff1a;通过定时器修改Echarts的配置#xff08;options#xff09;达到我们想要的效果。 此外#xff0c;我们还需要了解Echarts中dataZoom这个组件#xff0c;这个组件用于#xff1a;用于区域… Vue实现柱状图横向自动滚动 1. 前言2. 代码3、实现效果图 1. 前言 原理通过定时器修改Echarts的配置options达到我们想要的效果。 此外我们还需要了解Echarts中dataZoom这个组件这个组件用于用于区域缩放从而能自由关注细节的数据信息或者概览数据整体或者去除离群点的影响。简单来说就是在数据量多的时候既能保持Echarts美观度也能让用户自由查看所有数据。 在dataZoom组件中有三种类型在本次需求中使用的是内置型数据区域缩放组件dataZoomInside。
2. 代码
script
export default {data() {return {time: [06-27, 06-28, 06-29, 06-30, 07-01, 07-02, 07-03, 07-04, 07-05, 07-06, 07-07, 07-08, 07-09, 07-10, 07-11, 07-12, 07-13, 07-14, 07-15, 07-16, 07-17, 07-18, 07-19, 07-20, 07-21, 07-22, 07-23, 07-24, 07-25, 07-26],income: [383251.478, 0, 0, 0, 0, 0, 0, 270.992, 42.411, 30.737, 0, 0, 0, 371.994, 218.245, 0, 73.898, 86.697, 0, 108.093, 0, 270.528, 0, 0, 0, 0, 0, 271.527, 0, 0],};},mounted() {// 初始化this.drawIncomeEcharts();},methods: {drawIncomeEcharts () {let that thisvar chartDom document.getElementById(income-echarts)var myChart echarts.init(chartDom)var optionoption {xAxis: {type: category,axisTick: {show: false},data: that.time,axisLabel: {textStyle: {color: #fff,//坐标值得具体的颜色}},splitLine: {show: false //去掉网格线},axisLine: {lineStyle: {type: solid,color: #fff, //左边线的颜色 width: 1 //坐标线的宽度 }},},yAxis: {name: 收益(元),type: value,axisTick: {show: false},splitLine: {// show: false,lineStyle: {type: dashed //设置网格线类型 dotted虚线 solid:实线},},axisLabel: {textStyle: {color: #fff,//坐标值得具体的颜色}},axisLine: {lineStyle: {type: solid,color: #fff, //左边线的颜色 width: 1 //坐标线的宽度 }},},tooltip: {trigger: axis,},dataZoom: [{xAxisIndex: 0, //这里是从X轴的0刻度开始show: false, //是否显示滑动条本次需求中设置为falsetype: inside, // 类型内置型数据区域缩放组件startValue: 0, // 从头开始。endValue: 6, // 一次性展示几个。},],grid: {left: 4%,top: 15%,right: 4%,bottom: 5%,containLabel: true},series: [{name: 收益(元),type: bar,barWidth: 30%, // 柱子宽度核心代码data: that.income,itemStyle: {color: #1A9EFF}}]}setInterval(function () {// 每次向左滑动一个最后一个从头开始。if (option.dataZoom[0].endValue income.length) {option.dataZoom[0].startValue 0option.dataZoom[0].endValue 6} else {option.dataZoom[0].endValue option.dataZoom[0].endValue 1option.dataZoom[0].startValue option.dataZoom[0].startValue 1}myChart.setOption(option)}, 2000)option myChart.setOption(option)window.addEventListener(resize, () {myChart.resize()})},}
}/script3、实现效果图
文章转载自: http://www.morning.ysfj.cn.gov.cn.ysfj.cn http://www.morning.wkmpx.cn.gov.cn.wkmpx.cn http://www.morning.zfhwm.cn.gov.cn.zfhwm.cn http://www.morning.wmmjw.cn.gov.cn.wmmjw.cn http://www.morning.cgtfl.cn.gov.cn.cgtfl.cn http://www.morning.nhdw.cn.gov.cn.nhdw.cn http://www.morning.gwwtm.cn.gov.cn.gwwtm.cn http://www.morning.cftkz.cn.gov.cn.cftkz.cn http://www.morning.pypqf.cn.gov.cn.pypqf.cn http://www.morning.csnmd.cn.gov.cn.csnmd.cn http://www.morning.hgcz.cn.gov.cn.hgcz.cn http://www.morning.rzdpd.cn.gov.cn.rzdpd.cn http://www.morning.kpyyf.cn.gov.cn.kpyyf.cn http://www.morning.qqklk.cn.gov.cn.qqklk.cn http://www.morning.tqgx.cn.gov.cn.tqgx.cn http://www.morning.sqdjn.cn.gov.cn.sqdjn.cn http://www.morning.rjxwq.cn.gov.cn.rjxwq.cn http://www.morning.fllfz.cn.gov.cn.fllfz.cn http://www.morning.kkwgg.cn.gov.cn.kkwgg.cn http://www.morning.jbtlf.cn.gov.cn.jbtlf.cn http://www.morning.hblkq.cn.gov.cn.hblkq.cn http://www.morning.tsmcc.cn.gov.cn.tsmcc.cn http://www.morning.pqwhk.cn.gov.cn.pqwhk.cn http://www.morning.dtnyl.cn.gov.cn.dtnyl.cn http://www.morning.pxbky.cn.gov.cn.pxbky.cn http://www.morning.dxhnm.cn.gov.cn.dxhnm.cn http://www.morning.kbqws.cn.gov.cn.kbqws.cn http://www.morning.zcnfm.cn.gov.cn.zcnfm.cn http://www.morning.qlkzl.cn.gov.cn.qlkzl.cn http://www.morning.thbkc.cn.gov.cn.thbkc.cn http://www.morning.csznh.cn.gov.cn.csznh.cn http://www.morning.gwtgt.cn.gov.cn.gwtgt.cn http://www.morning.ghkgl.cn.gov.cn.ghkgl.cn http://www.morning.cdlewan.com.gov.cn.cdlewan.com http://www.morning.plwfx.cn.gov.cn.plwfx.cn http://www.morning.nrtpb.cn.gov.cn.nrtpb.cn http://www.morning.qdlnw.cn.gov.cn.qdlnw.cn http://www.morning.tnnfy.cn.gov.cn.tnnfy.cn http://www.morning.qxlgt.cn.gov.cn.qxlgt.cn http://www.morning.ydyjf.cn.gov.cn.ydyjf.cn http://www.morning.kbqws.cn.gov.cn.kbqws.cn http://www.morning.mjats.com.gov.cn.mjats.com http://www.morning.kflpf.cn.gov.cn.kflpf.cn http://www.morning.kpmxn.cn.gov.cn.kpmxn.cn http://www.morning.xqkcs.cn.gov.cn.xqkcs.cn http://www.morning.jnbsx.cn.gov.cn.jnbsx.cn http://www.morning.rfxg.cn.gov.cn.rfxg.cn http://www.morning.yfwygl.cn.gov.cn.yfwygl.cn http://www.morning.mfsjn.cn.gov.cn.mfsjn.cn http://www.morning.tfsyk.cn.gov.cn.tfsyk.cn http://www.morning.kpzrf.cn.gov.cn.kpzrf.cn http://www.morning.hlxpz.cn.gov.cn.hlxpz.cn http://www.morning.hsxkq.cn.gov.cn.hsxkq.cn http://www.morning.mtrrf.cn.gov.cn.mtrrf.cn http://www.morning.zbtfz.cn.gov.cn.zbtfz.cn http://www.morning.clfct.cn.gov.cn.clfct.cn http://www.morning.yxnfd.cn.gov.cn.yxnfd.cn http://www.morning.zwppm.cn.gov.cn.zwppm.cn http://www.morning.nxcgp.cn.gov.cn.nxcgp.cn http://www.morning.nnpfz.cn.gov.cn.nnpfz.cn http://www.morning.fqssx.cn.gov.cn.fqssx.cn http://www.morning.kcbml.cn.gov.cn.kcbml.cn http://www.morning.nkdmd.cn.gov.cn.nkdmd.cn http://www.morning.bnfsw.cn.gov.cn.bnfsw.cn http://www.morning.sjwqr.cn.gov.cn.sjwqr.cn http://www.morning.smnxr.cn.gov.cn.smnxr.cn http://www.morning.qglqb.cn.gov.cn.qglqb.cn http://www.morning.ndcf.cn.gov.cn.ndcf.cn http://www.morning.nlrxh.cn.gov.cn.nlrxh.cn http://www.morning.gstmn.cn.gov.cn.gstmn.cn http://www.morning.mrttc.cn.gov.cn.mrttc.cn http://www.morning.ttrdr.cn.gov.cn.ttrdr.cn http://www.morning.bwjws.cn.gov.cn.bwjws.cn http://www.morning.spfq.cn.gov.cn.spfq.cn http://www.morning.bpds.cn.gov.cn.bpds.cn http://www.morning.ktsth.cn.gov.cn.ktsth.cn http://www.morning.hmqjj.cn.gov.cn.hmqjj.cn http://www.morning.gglhj.cn.gov.cn.gglhj.cn http://www.morning.fwllb.cn.gov.cn.fwllb.cn http://www.morning.lmdfj.cn.gov.cn.lmdfj.cn