Version
5.4.2
Link to Minimal Reproduction
https://echarts.apache.org/examples/en/editor.html?c=line-stack
Steps to Reproduce
series: [ { name: 'Email', type: 'line', stack: 'Total', data: [1, 1, 1, 1, 1, 1, 1] }, { name: 'Union Ads', type: 'line', stack: 'Total', data: [0.1, 0.2, 0.3, 0.1, 0.1, 0.1, 0.2] }, { name: 'Video Ads', type: 'line', stack: 'Total', data: [0.1, 0.1, 0.1, 0.1, 0.1, 0.7, 0.7] }, { name: 'Direct', type: 'line', stack: 'Total', data: [0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3] }, { name: 'Search Engine', type: 'line', stack: 'Total', data: [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2] } ]
- These are the values I changed in this example.
The value of Email is 1, why is it below?
Are the values on the y-axis unaffected by the values on the x-axis?
Then, I wonder if it is possible to set the y-axis according to the value of the x-axis and sort it.
Sorry if I didn't understand the stack chart.
I'm always grateful for your projects.
Current Behavior
I think it's better to read if Email is stacked at the top.
Expected Behavior
But now Email with a value of 1 is below those with a value less than 1.
Environment
- OS:
- Browser:
- Framework:
Any additional comments?
No response
3条答案
按热度按时间66bbxpm51#
Series are stacked based on the order defined in
series
. So the first seriesemail
should be stacked at the bottom.bweufnob2#
@Ovilia
시리즈는 에 정의된 순서에 따라 누적됩니다
series
. 따라서 첫 번째 시리즈는email
맨 아래에 쌓아야 합니다.So I tried to define the series by pre-sorting the desired values.
If the series has a time value and a count value
The time value is the x-axis and the count value is the cumulative value.
series = [{time: 6:00, value: '1'}, {time: 7:00, value: '1'}, {time: 8:00, value: '2'}, {time: 9:00, value: '6'}, {time: 10:00, value: '7'}, {time: 11:00, value: '1'}, ]
It seems to me that it is not possible to sort according to the value of count (the lower the count, the lower it is) in the stack chart.
When I tried, some got sorted, but that's because time values sort first, count values second.
And that's the correct behavior.
Is my understanding correct?
stszievb3#
In most cases, one series probably contains multiple data, so how should it be like if it can be sorted based on one data? In your case, you can simply write a sort function before passing it to series.