vue echarts 柱形图

<style>
  @import '../../css/style.css';
</style>
<style>
  @import "../../css/vue_single_bar.css";
</style>
<template>

    <div class="single_bar">
        <chart class="bar" :options="singleBar"></chart>
      <div class="space"></div>
      <div class="barBtn">
        <button @click="goBar">goBar</button>
        <button @click="goShadowLine">goShadowLine</button>
      </div>
    </div>

</template>



<script>
  import eCharts from 'vue-echarts/components/ECharts'
    export default {
        data() {
            return {
              data_val1: [],
              _boyActual: [],
              _college:[]}
        },
      created(){
        this._boyActual = [100, 100, 150];
        this._college = ['3', '2', '1'];
      },
      methods:{
        goBar(){
          this.$router.push({path:'/single_line'})
        },
        goShadowLine(){
          this.$router.push({path:'/shadow_line'})
        },
      },
      computed:{
        singleBar(){
          return{
            tooltip: {
                  show:"true",
                  trigger: 'item',
                  axisPointer: {
                    type: 'shadow'
                  }
                },
            legend:{
              show: true,
              data: ['支出' ,'收入'],
              bottom: 'bottom'

            },
            grid: {
              left: '12%',
              right: '2%',
              bottom: '3%',
              top:"10%",
              containLabel: false
            },
             calculable: true,
              xAxis: {
                type: 'value',
                show: true,
                max: 150,
                axisLine: {
                  show: false
                },
                axisTick: {
                  show: false
                },
                axisLabel: {
                  show: false
                },
                splitLine: {
                  show: false
                }
              },
              yAxis: [
                {
                type: 'category',
                position: "left",
                data: this._college,
                  axisLine: {
                  show: false
                },
                axisTick: {
                  show: false
                },
                axisLabel: {
                  show: true,
                  color:'#fff'
                },
                splitLine: {
                  show: false
                }
              },
                {
                type: 'category',
                position: "left",
                data: this._college,
                  axisLine: {
                  show: false
                },
                axisTick: {
                  show: false
                },
                axisLabel: {
                  show: true,
                  color:'#fff'
                },
                splitLine: {
                  show: false
                }
              }],
              series: [
                {
                name: '支出',
                type: 'bar',
                barWidth: 25,
                silent: true,
                yAxisIndex: 1,
                label: {
                  normal: {
                    show: true,
                    color:'#fff',
                    formatter: function(data) {
                      return [120,100,90][data.dataIndex] ;
                    },
                    position: 'insideRight'
                  }
                },
                itemStyle: {
                  normal: {
               color: new eCharts.graphic.LinearGradient(0, 0, 1, 0, [
                 {
                   offset: 0,
                   color: '#F4FDFF'
                 },
                 {
                 offset: 0.5,
                 color: 'rgb(5,250,238,0.4)'
               },
                 {
                   offset: 1,
                   color: '#05FAEE'
                 }
               ]),
                  }
                },
                data:[120,100,90]
              },
                {
                  z: 10,
                  name: '',
                  type: 'bar',
                  barWidth: 1,
                  silent: false,
                  yAxisIndex: 0,
                  itemStyle: {
                    normal: {
                      color: '#05FAEE'
                    }
                  },
                  data:  [120,100,90]
                },

                {
                  name: '收入',
                  type: 'bar',
                  barWidth: 25,
                  silent: true,
                  yAxisIndex:1,
                  label: {
                    normal: {
                      show: true,
                      color:'#fff',
                      formatter: function(data) {
                        return [150,120,110][data.dataIndex] ;
                      },
                      position: 'insideRight'
                    }
                  },
                  itemStyle: {
                    normal: {
                      color: new eCharts.graphic.LinearGradient(0, 0, 1, 0, [
                        {
                          offset: 0,
                          color: '#FFFFFF'
                        },
                        {
                          offset: 0.5,
                          color: 'rgb(254,254,0,0.4)'
                        },
                        {
                          offset: 1,
                          color: '#FEFE00'
                        }
                      ]),
                    }
                  },
                  data: [150,120,110],
                  z: 0,
                },

                {
                  z: 2,
                  name: '',
                  type: 'bar',
                  barWidth: 1,
                  silent: false,
                  yAxisIndex: 0,
                  barGap: 35,
                  itemStyle: {
                    normal: {
                      color: '#FEFE00',
                    }
                  },
                  data:  [150,120,110]
                }
              ]
          }
        }
      }
    }

</script>

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值