amcharts / amcharts3

JavaScript Charts V3
Other
395 stars 129 forks source link

Amchart Compare #188

Open Shanison opened 6 years ago

Shanison commented 6 years ago

Hi,

I want to compare two data sets and was testing it out using this script from Amcharts demo https://codepen.io/team/amcharts/pen/c471b46a08ebc38d105f6b38a7bcee1e

However, I noticed that the compare function doesn't work for dataset that contains negative value.

Look at the attached screenshot. The smaller negative value is plotted on top and the larger one plotted on bottom. The chart is upside down. Is there any solution to this?

screen shot 2018-07-15 at 7 18 16 pm screen shot 2018-07-15 at 7 18 10 pm
amcharts commented 6 years ago

New comment from Zendesk by Anthony Piris on ticket 38127. (replying here will automatically notify amCharts support agent)

Hi there,

The stock chart comparison function plots a percentage change against the first point in your chart, so the position of the values are likely correct in the context of your data. There isn't a way to change how the percent change is calculated outside of providing your own percent change data as the raw data and disabling the internal comparison feature.

You can disable the stock chart comparison function by setting recalculateToPercents to "never" in your panel settings:

panels: [{
  recalculateToPercents: "never",
  // ...
}]

// or if you have multiple panels and want this applied globally without repeating the setting:
panelsSettings: {
  recalculateToPercents: "never",
  // ...
}

This will make the compare function simply plot the raw values in your datasets when the comparison function is used, rather than calculating a percent change.

Documentation: http://docs.amcharts.com/3/javascriptstockchart/StockPanel#recalculateToPercents

I hope this helps.

Best,

Anthony Piris amCharts

Shanison commented 6 years ago

Thanks for the reply. I think the negative value doesn't make sense for comparison as well when in terms of percentage.

amcharts commented 6 years ago

New comment from Zendesk by Anthony Piris on ticket 38127. (replying here will automatically notify amCharts support agent)

Hi,

I'm afraid we're not making any changes to how the percent change calculation works. Sorry. You'll have to use the workaround(s) provided in my previous comment.

Best,

Anthony Piris amCharts