Line.vue 2.4 KB
Newer Older
shabai517's avatar
shabai517 committed
1 2 3 4 5 6 7 8 9 10 11 12 13
<template>
  <div>
        <chart class="test" :options="options" :auto-resize="true"></chart>
  </div>
    
</template>
<script>
export default {
  data: function () {
    //let data = 
    return {
      options: {
        title: {
shabai517's avatar
shabai517 committed
14
            /*text: 'Beijing AQI'*/
shabai517's avatar
shabai517 committed
15 16 17 18 19 20 21
        },
        tooltip: {
            trigger: 'axis'
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
shabai517's avatar
shabai517 committed
22
            //name:'Years',
shabai517's avatar
shabai517 committed
23
            data: ['null','null']
shabai517's avatar
shabai517 committed
24 25
        },
        yAxis: {
shabai517's avatar
shabai517 committed
26
            //name:'Num',
shabai517's avatar
shabai517 committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
            splitLine: {
                show: false
            }
        },
        /*
        toolbox: {
            left: 'center',
            feature: {
                dataZoom: {
                    yAxisIndex: 'none'
                },
                restore: {},
                saveAsImage: {}
            }
        },*/
        dataZoom: [{
            startValue: '2014-06-01'
        }, {
            type: 'inside'
        }],
        /*
        visualMap: {
            top: 10,
            right: 10,
            pieces: [{
                gt: 0,
                lte: 50,
                color: '#096'
            }, {
                gt: 50,
                lte: 100,
                color: '#ffde33'
            }, {
                gt: 100,
                lte: 150,
                color: '#ff9933'
            }, {
                gt: 150,
                lte: 200,
                color: '#cc0033'
            }, {
                gt: 200,
                lte: 300,
                color: '#660099'
            }, {
                gt: 300,
                color: '#7e0023'
            }],
            outOfRange: {
                color: '#999'
            }
        },*/
        series: [
              {
shabai517's avatar
shabai517 committed
81
                  name:'SUBMISSIONS_PER_YEAR',
shabai517's avatar
shabai517 committed
82
                  type:'line',
shabai517's avatar
shabai517 committed
83
                  data:[0,0]
shabai517's avatar
shabai517 committed
84 85 86 87 88 89
              }
        ]
      }
    }
  },
  methods:{
shabai517's avatar
shabai517 committed
90 91 92 93 94 95 96 97 98 99 100 101 102
      setOptions(data){
        let xValue = [];
        let yValue = [];
        for(let i=0; i<data.length; i++){
          xValue.push(data[i].key);
          yValue.push(data[i].value);
        }
        this.options.xAxis.data = xValue;
        this.options.series[0].data = yValue;
    }
  },
  created(){
    this.$bus.$on('show-line', this.setOptions);
shabai517's avatar
shabai517 committed
103
  },
shabai517's avatar
shabai517 committed
104 105 106
  beforeCreate:function(){
    this.$bus.$off('show-line');
  }
shabai517's avatar
shabai517 committed
107 108 109 110 111 112 113 114 115
}
</script>

<style>
.echarts.test  {
  height: 400px !important;
  width: auto !important;
}
</style>