echarts折线阴影波浪图 (vue v-chart)

在这里插入图片描述
1.echarts的版本是4.7的
在这里插入图片描述
html书写方式

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/echarts@4.7.0/dist/echarts.js"></script>
  </head> 
  <body>
    <div id="main" style="width: 600px; height: 400px"></div>
    <script>
      var mychart = echarts.init(document.getElementById("main")); 
    var option = {
      title: {},
      xAxis: { type: "category",
       show: false , 
       boundaryGap: false,//false紧贴着y轴的刻度线 true离开y轴刻度线 
      },
      yAxis: { show: false },
      series: [
        {
          itemStyle: {
            opacity: 0,
          },
          areaStyle: { color: "purple" },
          lineStyle: { width: 0 },
          smooth: true,
          type: "line",
          grid: {
            top: 0,
            left: 0,
            bottom: 0,
            right: 0,
          },
          data: [
            620, 434, 220, 534, 790, 430, 220, 320, 532, 320, 834, 690, 530,
            220, 250, 330, 450,
          ],
        },
      ],
    };
      mychart.setOption(option);
    </script>
  </body>
</html>

vue的echarts书写方式

cnpm 安装

cnpm  install echarts@4.7.0

main.js引入

import echarts   from 'echarts' 
Vue.prototype.$echarts=echarts ;
<template>
  <div id="main" style="width: 50%; height: 200px; border: 1px solid red"></div>
</template>

<script>
export default {
  data() {
    return {};
  },
  mounted() {
   this.setchart()
  },
  methods:{
    setchart(){
       var myecharts = this.$echarts.init(document.getElementById("main"));
       var option = {
       title: {},
       xAxis: { 
        type: "category",
        show: false,
		boundaryGap: false,//false紧贴着y轴的刻度线 true离开y轴刻度线 
	  },
       yAxis: { show: false },
       series: [
        {
          itemStyle: {
            opacity: 0,
          },
          areaStyle: { color: "purple" },
          lineStyle: { width: 0 },
          smooth: true,
          type: "line",
          grid: {
            top: 0,
            left: 0,
            bottom: 0,
            right: 0,
          },
          data: [
            620, 434, 220, 534, 790, 430, 220, 320, 532, 320, 834, 690, 530,
            220, 250, 330, 450,
          ],
        },
      ],
    };
    myecharts.setOption(option);
	}
  }
};
</script>

<style lang="scss" scoped></style>

v-chart的用法(vue-echarts)
安装:

 "vue-echarts": "^5.0.0-beta.0",
 cnpm  install vue-echarts@5.0.0-beta.0

引入

import VueECharts from 'vue-echarts' 
Vue.component('v-chart', VueECharts)
<template>
  <div id="main" style="width: 50%; height: 200px; border: 1px solid red">
    <v-chart :options="add()"></v-chart>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  methods: {
    add() {
      return {
        title: {},
        xAxis: { 
         type: "category",
         show: false,
		 boundaryGap: false,//false紧贴着y轴的刻度线 true离开y轴刻度线 
	   },
        yAxis: { show: false },
        series: [
          {
            itemStyle: {
              opacity: 0,
            },
            areaStyle: { color: "purple" },
            lineStyle: { width: 0 },
            smooth: true,
            type: "line",
            grid: {
              top: 0,
              left: 0,
              bottom: 0,
              right: 0,
            },
            data: [
              620, 434, 220, 534, 790, 430, 220, 320, 532, 320, 834, 690, 530,
              220, 250, 330, 450,
            ],
          },
        ],
      };
    },
  },
 
};
</script>

<style lang="scss" scoped>
/* 设置修改vue-charts的宽高 */
.echarts {
    width: 100% !important;
    height: 100% !important;
}

</style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值