Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can Bar racing Chart (realtimeSort) be sorted by the y-axis? #19913

Closed
ecmap opened this issue May 9, 2024 · 4 comments
Closed

Can Bar racing Chart (realtimeSort) be sorted by the y-axis? #19913

ecmap opened this issue May 9, 2024 · 4 comments
Labels
bug en This issue is in English pending We are not sure about whether this is a bug/new feature. topic: bar

Comments

@ecmap
Copy link

ecmap commented May 9, 2024

Version

5.5.0

Link to Minimal Reproduction

No link as the project is not opensource

Steps to Reproduce

  1. 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

@ecmap ecmap added the bug label May 9, 2024
@echarts-bot echarts-bot bot added en This issue is in English pending We are not sure about whether this is a bug/new feature. labels May 9, 2024
@Ovilia
Copy link
Contributor

Ovilia commented May 9, 2024

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.

@ecmap
Copy link
Author

ecmap commented May 10, 2024

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?

@Ovilia
Copy link
Contributor

Ovilia commented May 10, 2024

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.

@ecmap
Copy link
Author

ecmap commented May 16, 2024

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

@ecmap ecmap closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug en This issue is in English pending We are not sure about whether this is a bug/new feature. topic: bar
Projects
None yet
Development

No branches or pull requests

2 participants