vue -02 How to make the report function displayed by echarts more perfect in vue

Use the merge function in lodash How to
use:
1. Import in the vue file

import _ from 'lodash'

2. Define your own options configuration items to be merged in the data field

 options: {
        title: {
          text: '用户来源'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#E9EEF3'
            }
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            boundaryGap: false
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ]
      }

3. Merge in the mounted domain using echarts

 _.merge(res.data, this.options)

4. Use the merged result when specifying the configuration items and data of the report
(merge returns the first parameter: res.data)

    myChart.setOption(res.data)

5. The result of the merge: the line chart has the information of the data point displayed after the mouse is placed
Insert picture description here

Guess you like

Origin blog.csdn.net/Forest_2Cat/article/details/113454842