The use of echarts in the vue project

  1. Download echarts, import echarts file
npm i echarts
-----------
import echarts from "echarts";
  1. Place a box with width and height on the page, and place echarts.
    insert image description here
    【Notice】:The box where echarts is placed must have width and height, otherwise the chart is not displayed.
    insert image description here

  2. Start instantiating the graph.
    insert image description here
    【Notice】:Be sure to clear before instantiating the graph, otherwise after multiple requests, the data will stack and the page will freeze.

  3. After instantiating the chart is the normal chart configuration. Common configuration items
    insert image description here

  4. Points to note when getting data from the background to render the chart
    ①Instantiate the timing of calling the initchartDealLine() function of the chart:After getting the chart data
    insert image description here
    ② Clear the chart data in the beforeDestroy function
    insert image description here

  5. Page rendering chart optimization points
    ①v-loading: After getting the chart data, close it, so that once you enter the page, it will show that the chart is always loading.
    ②If there is no chart data, it will display a picture without data instead. el-empty empty state
    insert image description here

Guess you like

Origin blog.csdn.net/qq_43483403/article/details/122113283