question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dynamic bar with sorting process negative value as postive

See original GitHub issue

Version

5.2.2

Steps to reproduce

https://echarts.apache.org/examples/zh/editor.html?c=bar-race

const data = [];
for (let i = 0; i < 5;  ++i) {
  data.push(Math.round(Math.random() * 200));
}
option = {
  xAxis: {
    max: 'dataMax'
  },
  yAxis: {
    type: 'category',
    data: ['A', 'B', 'C', 'D', 'E'],
    inverse: true,
    animationDuration: 300,
    animationDurationUpdate: 300,
    max: 2 // only the largest 3 bars will be displayed
  },
  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() * 1000 -500);
    } else {
      data[i]  = Math.round(Math.random() * 200-140);
    }
  }
  myChart.setOption({
    series: [
      {
        type: 'bar',
        data
      }
    ]
  });
}
setTimeout(function () {
  run();
}, 0);
setInterval(function () {
  run();
}, 3000);

What is expected?

negative will not great than postive

What is actually happening?

echarts use abs() value to compare

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
li942475402commented, May 26, 2022

you can change source code by patch-package to support negative values detail like this, but i’m not sure if it will bring new problems

step 1, change this part, use value instand of barHeight,it’s the reason why not support negative.

image

setp 2, add some handle for extreme case

image

step 3, complete the remainder part image

0reactions
abitwhycommented, May 6, 2022

QQ.20211129182030.mp4

建议你使用 gif 格式的图片(而不是视频)重现视效,推荐使用类似 ScreenToGif 之类的录屏工具。

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to separate colors for positive and negative bars in ...
In Excel, when we create a chart with both positive numbers and negative numbers, all the series data bars are the same color...
Read more >
Matplotlib - Updating bar graph with positive and negative ...
I am using the method described in this answer to dynamically update a bar graph. The bar graph I want however should show...
Read more >
Diverging Bar Chart using Python - GeeksforGeeks
Diverging Bar Charts are used to ease the comparison of multiple groups. Its design allows us to compare numerical values in various groups....
Read more >
Create a Dynamic Diverging Stacked Bar Chart in Power BI ...
This measure will handle both the positive (selected) category while also dynamically handling negative (non-selected) values.
Read more >
Bar Chart with Positive and Negatives but Sort by Absolute.
We have bar chart with positive and negatives showing. Fairly simple but they want it sorting by absolute. I attached a picture of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found