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

Axis Value Range Inconsistent #106

Closed
benjamin-swain opened this issue Apr 8, 2020 · 2 comments
Closed

Axis Value Range Inconsistent #106

benjamin-swain opened this issue Apr 8, 2020 · 2 comments

Comments

@benjamin-swain
Copy link

Sometimes the Y-Axis range is not being set in a way that fits the data in the center of the plot.

I attached 2 images. They have the same chart configuration. The only difference is in the data provided in the series parameter of the X and Y axis.

The problem here is that Y-axis starts at 0. This causes the plotted line to be squeezed into the top of the plot.
image

Somehow for this other data on the same plot, it knows to not start the Y-axis at 0, and it looks better.
image

@benjamin-swain
Copy link
Author

benjamin-swain commented Apr 9, 2020

I made an algorithm to determine the min and max y for the viewable axis range:

var valueRange = (yValMax - yValMin).round();
var divideAmount = pow(10, valueRange.toString().length-1);

var yViewMin = ((yValMin / divideAmount).floor()).toDouble()*divideAmount;
var yViewMax = ((yValMax / divideAmount).ceil()).toDouble()*divideAmount;

After setting minimum and maximum to yViewMin and yViewMax in NumericAxis:
image

Just need some slight changes to deal with negative values

@dharanidharandharmasivam
Copy link
Contributor

Hi @opalr ,

Greetings from Syncfusion. We have analyzed the requirement with the provide screenshots. We would like to let you know that for line type series, the ranges will be calculated from zero and it also depends upon the data sources. If you wish to change this, you can either specify the ranges to minimum/maximum properties of the axis or you can use the rangePadding option. For more information on rangePadding, find the user guide below.

https://help.syncfusion.com/flutter/chart/axis-types#applying-padding-to-the-range

We have prepared a sample based on this, which can be found below.
https://www.syncfusion.com/downloads/support/directtrac/general/ze/rangepadding746100398

Code snippet:

SfCartesianChart(
                  primaryYAxis: NumericAxis(
                    rangePadding: ChartRangePadding.round
                  ),
              )

Thanks,
Dharani.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants