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

Support negative values #2

Closed
tobiasht opened this issue Feb 1, 2023 · 5 comments
Closed

Support negative values #2

tobiasht opened this issue Feb 1, 2023 · 5 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@tobiasht
Copy link

tobiasht commented Feb 1, 2023

The package currently does not support negative values. I would be great to add some scaling to the inputs to support this.

The example values that i used:
min: -3000,
max: 3000,
value: -750,

@tobiasht
Copy link
Author

tobiasht commented Feb 2, 2023

It also struggles a lot, when you toggle between different min and max ranges. I think both of these issues can be fixed by scaling this values better. I attahced the formula i used in my code. Maybe you can implement this within the widget itself?

double normalize(
  double oldMin,
  double oldMax,
  double? value, {
  double newMin = 0,
  double newMax = 100,
}) {
  if (value == null) return newMin;
  if (oldMax - oldMin == 0) return 0;

  return (((value - oldMin) * (newMax - newMin)) / (oldMax - oldMin)) + newMin;
}

@gonuit
Copy link
Owner

gonuit commented Jun 27, 2023

Thank you @tobiasht for that 💪🏻
I will try to make some improvements in the upcoming version.

I will post updates here.

@gonuit gonuit self-assigned this Jun 27, 2023
@gonuit gonuit added bug Something isn't working enhancement New feature or request labels Jun 27, 2023
@JPFrancoia
Copy link

That would be awesome. I'm in a situation where I'd need to set the max value to 0 and dynamically change the min value. The min value needs to be negative.

@gonuit
Copy link
Owner

gonuit commented Jul 25, 2023

This was implemented/fixed by @dino-keskic in #7 and released in version 0.4.3 💪🏻.

If there are further problems, please reopen this issue.

@gonuit gonuit closed this as completed Jul 25, 2023
@JPFrancoia
Copy link

Awesome! thank you very much! I'll test it now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants