11vue项目-echarts

1 销量趋势图标(折线图)

 

 1.1 通用代码的编写

 Trend.vue:

通用代码: 直接复制即可

<template>
  <div class="com-container">
    <div class="com-chart" ref="trend_ref"></div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      chartInstane: null,
      allData: null, // 从服务器中获取的所有数据
    }
  },
  mounted () {
    this.initChart()
    this.getData()
    window.addEventListener('resize', this.screenAdapter)
    this.screenAdapter()
  },
  destroyed () {
    window.removeEventListener('resize', this.screenAdapter)
  },
  methods: {
    initChart () {
      this.chartInstane = this.$echarts.init(this.$refs.trend_ref, 'chalk')
      const initOption = {}
      this.chartInstane.setOption(initOption)
    },
    async getData () {
      this.updateChart()
    },
    updateChart () {
      const dataOption = {}
      this.chartInstane.setOption(dataOption)
    },
    screenAdapter () {
      const adapterOption = { }
      this.chartInstane.setOption(adapterOption)
      this.chartInstane.resize()
    }
  }
}
</script>

1.2 折线图基本功能实现

1 调接口 ,处理数据

 

 

 

 2图例的数据

 

 

 1.3 ui调整

1 添加主题

 

2 坐标轴大小配置

3 紧挨边缘

 

4 工具提示

 

 

5 图例位置和形状

 

 

6区域面积

 

 

 

7 颜色渐变

 

 1.4 切换图标

1 编写一个下拉框

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值