linechart.vue 3.27 KB
<template>
<div id="echartId_3" class="chart-line"></div>
</template>

<script>
import * as echarts from 'echarts'
export default {
  name: 'linechart',
  data() {
    return {
      status: true
    }
  },
  props: {
    echartId: {
      type: String,
      default: ''
    },
    echartData: {
      type: Array
    },
  },

  watch: {
    echartData: {
      handler(value) {
        console.log(value)
        let data = value.map(item => {
          return item.billNum
        })
        let dateTime = value.map(item => {
          return item.timeStr
        })
       this.status = data.some(item=>item)
        this.getChartTotal(dateTime, data)
      },
      deep: true
    }
  },

  methods: {
    getChartTotal(dateTime, lineData) {
      var chartDom = document.getElementById('echartId_3')
      var myChart = echarts.init(chartDom)
      var option
      option = {
        xAxis: {
          type: 'category',
          data: dateTime
        },
        yAxis: {
          type: 'value',
           minInterval: 1,
        },
         tooltip: {
          trigger: "axis",
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: 0,
            containLabel: true
          },
        series: [
          {
            data: lineData,
            smooth: true,
            type: 'line',
            symbol: 'none',
            name: '提单数',
            color: '#5850FF',
            areaStyle: {
              color: {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: '#5850FF' // 100% 处的颜色
                  },
                  {
                    offset: 1,
                    color: '#FFFFFF' //   0% 处的颜色
                  }
                ],
                global: false // 缺省为 false
              }
            }
          }
        ]
      }

      option && myChart.setOption(option)
      window.addEventListener('resize', myChart.resize)
    }
  }
}
</script> 

<style scoped lang="scss">
.summary-header {
  display: flex;
  color: #3a3a3a;
  justify-content: space-between;
}
.summary-customer-panel {
  display: flex;
  .summary-item {
    width: 25%;
    box-sizing: border-box;
    padding-right: 20px;
    margin-right: 20px;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    &:last-of-type {
      border: none;
    }
    .summary-item-title {
      .item {
        background: #ffffff;
        box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.06);
        border: 1px solid #e4e7ed;
      }
      i {
        color: #999999;
        background: none;
      }
    }
    .summary-item-total {
      font-size: 30px;
      color: rgba(0, 0, 0, 0.85);
      line-height: 38px;
      margin: 20px 0px 10px 0px;
    }
    .summary-item-number {
      font-size: 12px;
      font-weight: 400;
      color: #666666;
      line-height: 20px;
      margin-bottom: 20px;
    }
    #main-total {
      height: 60px;
    }
  }
}
.expand-more {
  margin-bottom: 20px;
  text-align: center;
  height: 56px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 0px 0px 2px 2px;
  font-size: 14px;
  line-height: 56px;
  color: #000000;
}
.chart-line {
  height: 260px;
}
</style>