-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Let the user decide the beginning of the interval #893
Comments
I just noticed that the interval is also used for the grid lines. So this change should probably also apply to the grid lines, since they are currently placed on the same interval as the titles. |
Yes, you're right! |
At the moment we have a function called /// Finds the best initial interval value
///
/// If there is a zero point in the axis, we a value that passes through it.
/// For example if we have -3 to +3, with interval 2. if we start from -3, we get something like this: -3, -1, +1, +3
/// But the most important point is zero in most cases. with this logic we get this: -2, 0, 2
double getBestInitialIntervalValue(double min, double max, double interval) {
if (min > 0 || max < 0) {
return min;
}
if (max - min <= interval) {
return min;
}
return interval * (min ~/ interval).toDouble();
} It tries to find a value as an initial value based on the interval, we wanted to make sure that this value goes through the zero when zero is between in Maybe you can work on this function to fix this issue without adding any parameters. BTW your second solution makes sense to me. |
Without changing the parameters there isn't much flexibility. Option 1 would be possible with the limitation that we can't make it optional (if I am not mistaken). Meaning it would change the behavior of existing charts, which would have to be mentioned as a breaking change. In this case we could remove the if conditions and only use return interval * (min ~/ interval).toDouble(); to always have the interval zero aligned. |
@joeldomke You're right we need to add that option. I'm working on it right now. |
What is your suggestion for name of that optional value? |
I think that's a great idea! |
This way, it should cover your example. (with baseline Correct? |
Yes, this would fix it |
Yaay! simplescreenrecorder-2022-02-04_18.53.47.mp4 |
…rts (Line, Bar, Scatter). default is zero, #893.
…rts (Line, Bar, Scatter). default is zero, #893.
…zero (#894) * Fix getBestInitialIntervalValue() problem with values above or below zero, #893. * Add `baselineX` and `baselineY` property to all of our axis-based charts (Line, Bar, Scatter). default is zero, #893. * Remove all linux/flutter/ephemeral files from example directory * Update CHANGELOG.md, bar_chart.md, and line_chart.md * Update line_chart.md * Update CHANGELOG.md
…zero (#894) * Fix getBestInitialIntervalValue() problem with values above or below zero, #893. * Add `baselineX` and `baselineY` property to all of our axis-based charts (Line, Bar, Scatter). default is zero, #893. * Remove all linux/flutter/ephemeral files from example directory * Update CHANGELOG.md, bar_chart.md, and line_chart.md * Update line_chart.md * Update CHANGELOG.md
Hi. |
Looks good, thanks! |
When I choose an intervall of 50, I always want my titles to be at 0, 50, 100, ... This is what happens, if I set my minY to a multiple of 50, or if 0 is between minY and maxY.
But if I select something like minY = 35 and maxY = 130, I will get titles at 35 and 85.
The user should have more control over the beginning of the interval. I would like to implement this feature, and there are two solutions that come to my mind:
This could be either set for horizontal and vertical, or for left, top, right and bottom.
The text was updated successfully, but these errors were encountered: