echarts

echarts在这里插入图片描述

<template>
  <div style="width: 100%; height: 100%" ref="chart" v-loading="loading"></div>
</template>
<script>
export default {
  data () {
    return {
      chart: null,
      loading: false
    }
  },
  mounted () {
  },
  methods: {
    openLoading () {
      this.loading = true
    },
    closeLoading () {
      this.loading = false
    },
    drawEchart ({ nameData = [], leftData = [], leftLabel = [], rightData = [], rightLable = [] }) {
      var name = nameData
      var options = {
        backgroundColor: '#02030c',
        tooltip: {
          trigger: 'item',
          axisPointer: { // 坐标轴指示器,坐标轴触发有效
            type: 'line' // 默认为直线,可选为:'line' | 'shadow'
          },
          textStyle: {
            fontSize: 24
          }
        },
        'legend': {
          'left': 'center',
          'top': '5%',
          'show': true,
          'type': 'scroll',
          'data': name,
          'itemWidth': 20,
          'itemHeight': 15,
          'itemGap': 30,
          'textStyle': {
            'fontSize': 14,
            'color': '#fff',
            'fontFamily': 'Microsoft YaHei'
          }
        },
        'grid': [
          {
            'left': '80px',
            'right': '50%',
            'top': 60,
            'bottom': '30'
          }, {
            'left': '50%',
            'right': '80px',
            'top': 60,
            'bottom': '30'
          }],
        'xAxis': [
          {
            'type': 'value',
            'gridIndex': 0,
            'inverse': true,
            'axisLine': {
              'show': false
            },
            'splitLine': {
              'show': false
            },
            'axisTick': {
              'show': true
            },
            'axisLabel': {
              'show': true,
              'color': 'rgba(255,250,255,0.7)'
            },
            'data': []
          },
          {
            'type': 'value',
            'gridIndex': 1,
            'inverse': false,
            'axisLine': {
              'show': true
            },
            'splitLine': {
              'show': false
            },
            'axisTick': {
              'show': true
            },
            'axisLabel': {
              'show': true,
              'color': 'rgba(255,250,255,0.7)'
            },
            'data': []
          }],
        'yAxis': [
          {
            'type': 'category',
            // offset: -20,
            'axisLine': {
              'show': true
            },
            'splitLine': {
              'show': false
            },
            'axisTick': {
              'show': false
            },
            'axisLabel': {
              'show': true,
              'fontSize': 14,
              'color': 'rgba(65,250,240,0.7)'
            },
            'data': leftLabel,
            position: 'left'
          },
          {
            'type': 'category',
            // offset: -20,
            'gridIndex': 1,
            'axisLine': {
              'show': false
            },
            'splitLine': {
              'show': false
            },
            'axisTick': {
              'show': true
            },
            'axisLabel': {
              'show': true,
              'fontSize': 14,
              'color': 'rgba(265,242,53,0.7)'
            },
            'data': rightLable,
            position: 'right'

          }],
        'series': [
          {
            'colId': 'col402utokg',
            'name': name[0],
            'type': 'bar',
            'data': leftData,
            barWidth: 15,
            color: '#00f3df',
            'xAxisIndex': 0,
            'yAxisIndex': 0,
            itemStyle: {
              normal: {
                // barBorderRadius: [10, 10, 10, 10],
                color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [{
                  offset: 0,
                  color: 'rgba(65,250,240,1)'
                },
                {
                  offset: 1,
                  color: 'rgba(43,163,205,1)'
                }
                ])
              }
            },
            'label': {
              'position': 'left',
              'fontFamily': 'Microsoft YaHei',
              'show': true,
              'fontSize': 14,
              'color': '#fff'
            }
          },
          {
            'colId': 'col3kkgr6h9',
            'name': name[1],
            'type': 'bar',
            'data': rightData,
            barWidth: 15,
            color: '#01b3e0',
            'xAxisIndex': 1,
            'yAxisIndex': 1,
            itemStyle: {
              normal: {
                // barBorderRadius: [10, 10, 10, 10],
                color: new this.$echarts.graphic.LinearGradient(1, 0, 0, 0, [{
                  offset: 0,
                  color: 'rgba(265,242,53,1)'
                },
                {
                  offset: 1,
                  color: 'rgba(265,242,53,1)'
                }
                ])
              }
            },
            'label': {
              'position': 'right',
              'fontFamily': 'Microsoft YaHei',
              'show': true,
              'fontSize': 14,
              'color': '#fff'
            }
          }]
      }
      this.chart = this.$echarts.init(this.$refs.chart)
      this.chart.setOption(options)
    }
  }
}
</script>
<style lang="scss" scoped>
</style>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值