echart graph--x-axis, y-axis data corresponding mapping

question:

When using the echart chart, the x-axis and y-axis data do not correspond, as shown in the figure below:
insert image description here
In fact, the y-axis data corresponding to Mon is 0, and the y-axis data should be the data of Tue at this moment. The reason for this is that there is no mapping relationship between the x-axis and y-axis data.

Solution

(1) Assign a value of 0 to the x-axis point without data in the background, but it is troublesome, and it is necessary to check whether each point has data.
(2) Use the echart attribute:
a. Fix the x-axis data. Put all the x-axis points into an array for filtering and sorting.
b. Using the series attributes of echart, directly put the x-axis data and y-axis data in the series data.

series: [{
    
    
 name: 'Email',
  type: 'line',
  stack: 'Total',
  data: [['Tue',120], ['Wed',220], ['Thu',182]]
}]

insert image description here

Guess you like

Origin blog.csdn.net/weixin_43883951/article/details/132223942