Can Bar racing Chart (realtimeSort) be sorted by the y-axis?
Version
5.5.0
Link to Minimal Reproduction
No link as the project is not opensource
Steps to Reproduce
- paste the code to https://echarts.apache.org/examples/en/editor.html?c=bar-race
const data = [];
const tempValue = [1, 2, 3, 4, 5]
for (let i = 0; i < 5; ++i) {
data.push(Math.round(Math.random() * 200));
}
option = {
xAxis: {
max: 'dataMax'
},
yAxis: {
type: 'category',
data: tempValue,
inverse: true,
animationDuration: 300,
animationDurationUpdate: 300,
},
series: [
{
realtimeSort: true,
name: 'X',
type: 'bar',
data: data,
label: {
show: true,
position: 'right',
valueAnimation: true
}
}
],
legend: {
show: true
},
animationDuration: 0,
animationDurationUpdate: 3000,
animationEasing: 'linear',
animationEasingUpdate: 'linear'
};
function run() {
for (var i = 0; i < data.length; ++i) {
if (Math.random() > 0.9) {
data[i] += Math.round(Math.random() * 2000);
} else {
data[i] += Math.round(Math.random() * 200);
}
tempValue[i] += Math.round(0.1 + Math.random() * 2.9);
}
myChart.setOption({
yAxis: {
data: tempValue,
},
series: [
{
type: 'bar',
data
}
]
});
}
setTimeout(function () {
run();
}, 0);
setInterval(function () {
run();
}, 3000);
Current Behavior
realtimeSort is based on the series data rather than yAxis.
Expected Behavior
Chart sorted by y-axis data
Environment
- OS: -
- Browser: Chrome
- Framework: -
Any additional comments?
No response
I’m afraid I may not fully understand your requirement. Bar-racing charts are typically designed to sort by the value of the bars, which in your case would be the x value. If you’re interested in sorting by the y-axis, you might need to sort the data yourself before inputting it into setOption.
I’m afraid I may not fully understand your requirement. Bar-racing charts are typically designed to sort by the value of the bars, which in your case would be the x value. If you’re interested in sorting by the y-axis, you might need to sort the data yourself before inputting it into setOption.
So, whenever realtimeSort is used, the chart will only be sorted based on the data of the series? It cannot be changed to sort based on the yAxis data?
I’m afraid I may not fully understand your requirement. Bar-racing charts are typically designed to sort by the value of the bars, which in your case would be the x value. If you’re interested in sorting by the y-axis, you might need to sort the data yourself before inputting it into setOption.
So, whenever realtimeSort is used, the chart will only be sorted based on the data of the series? It cannot be changed to sort based on the yAxis data?
Yes, realtimeSort has nothing to do with that.
I’m afraid I may not fully understand your requirement. Bar-racing charts are typically designed to sort by the value of the bars, which in your case would be the x value. If you’re interested in sorting by the y-axis, you might need to sort the data yourself before inputting it into setOption.
So, whenever realtimeSort is used, the chart will only be sorted based on the data of the series? It cannot be changed to sort based on the yAxis data?
Yes, realtimeSort has nothing to do with that.
ok