温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

vue echarts实现的柱状图动态效果代码分享

发布时间:2021-09-06 11:26:31 阅读:347 作者:chen 栏目:开发技术
Vue开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

这篇文章主要介绍“vue echarts实现的柱状图动态效果代码分享”,在日常操作中,相信很多人在vue echarts实现的柱状图动态效果代码分享问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”vue echarts实现的柱状图动态效果代码分享”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

本文实例为大家分享了vue echarts实现柱状图动态展示的具体代码,供大家参考,具体内容如下

vue echarts实现的柱状图动态效果代码分享

轮播图形式展现

<template>
  <div class="dan">
    <div id="scalesize" :></div>
  </div>
</template>
<script>
import echarts from "echarts";
export default {
  data() {
    return {
      texts111
    };
  },
  mounted() {
    this.drawLine();
  },
  methods: {
    drawLine() {
      // 基于准备好的dom,初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById("scalesize"));
      var fanfa = [
        {
          name"育苗基地",
          type"bar",
          barWidth"15%",
          itemStyle: {
            normal: {
              colornew echarts.graphic.LinearGradient(0001, [
                {
                  offset0,
                  color"#fccb05"
                },
                {
                  offset1,
                  color"#f5804d"
                }
              ]),
              barBorderRadius12
            }
          },
          data: [100120160180220400]
        },
        {
          name"种植基地",
          type"bar",
          barWidth"15%",
          itemStyle: {
            normal: {
              colornew echarts.graphic.LinearGradient(0001, [
                {
                  offset0,
                  color"#8bd46e"
                },
                {
                  offset1,
                  color"#09bcb7"
                }
              ]),
              barBorderRadius11
            }
          },
          data: [270320420650821,907]
        },
        {
          name"托管面积",
          type"bar",
          barWidth"15%",
          itemStyle: {
            normal: {
              colornew echarts.graphic.LinearGradient(0001, [
                {
                  offset0,
                  color"#248ff7"
                },
                {
                  offset1,
                  color"#6851f1"
                }
              ]),
              barBorderRadius11
            }
          },
          data: [140180215320396520]
        },
        {
          name"联建基地",
          type"bar",
          barWidth"15%",
          itemStyle: {
            normal: {
              colornew echarts.graphic.LinearGradient(0001, [
                {
                  offset0,
                  color"#B88080"
                },
                {
                  offset1,
                  color"#983A3A"
                }
              ]),
              barBorderRadius11
            }
          },
          data: [140180215320396420]
        }
      ];
      myChart.setOption({
        tooltip: {
          trigger"axis",
          axisPointer: {
            // 坐标轴指示器,坐标轴触发有效
            type"shadow" // 默认为直线,可选为:'line' | 'shadow'
          }
        },
        grid: {
          left"2%",
          right"4%",
          bottom"14%",
          top"16%",
          containLabeltrue
        },
        legend: {
          data: ["育苗基地""种植基地""托管面积""联建基地"],
          right10,
          top12,
          textStyle: {
            color"#fff"
          },
          itemWidth12,
          itemHeight10
          // itemGap: 35
        },
        xAxis: {
          type"category",
          data: [
            "2014",
            "2015",
            "2016",
            "2017",
            "2018",
            "2019"
          ],
          axisLine: {
            lineStyle: {
              color"white"
            }
          },
          axisLabel: {
            // interval: 0,
            // rotate: 40,
            textStyle: {
              fontFamily"Microsoft YaHei"
            }
          }
        },
        yAxis: {
          type"value",
          axisLine: {
            showfalse,
            lineStyle: {
              color"white"
            }
          },
          splitLine: {
            showtrue,
            lineStyle: {
              color"rgba(255,255,255,0.3)"
            }
          },
          axisLabel: {}
        },
        dataZoom: [
          {
            showtrue,
            height12,
            xAxisIndex: [0],
            bottom"8%",
            handleIcon:
              "path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h69.8c2.2,0,4,1.8,4,4V413z",
            handleSize"110%",
            handleStyle: {
              color"#d3dee5"
            },
            textStyle: {
              color"#fff"
            },
            borderColor"#90979c"
          },
          {
            type"inside",
            showtrue,
            height15,
            start1,
            end35
          }
        ],
        series: fanfa
      });
      let app = {
        currentIndex: -1
      };
      setInterval(function() {
        let dataLen = fanfa[1].data.length;
        // 取消之前高亮的图形
        myChart.dispatchAction({
          type"downplay",
          seriesIndex0,
          dataIndex: app.currentIndex
        });
        app.currentIndex = (app.currentIndex + 1) % dataLen;
        //console.log(app.currentIndex);
        // 高亮当前图形
        myChart.dispatchAction({
          type"highlight",
          seriesIndex0,
          dataIndex: app.currentIndex
        });
        // 显示 tooltip
        myChart.dispatchAction({
          type"showTip",
          seriesIndex0,
          dataIndex: app.currentIndex
        });
      }, 1000);
      window.onresize = myChart.resize;
    }
  }
};
</script>
<style lang="less" scoped>
.dan {
  height90%;
}
</style>

到此,关于“vue echarts实现的柱状图动态效果代码分享”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×