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

Allow arbitrary values #28

Open
slavkoja opened this issue Sep 16, 2018 · 2 comments
Open

Allow arbitrary values #28

slavkoja opened this issue Sep 16, 2018 · 2 comments

Comments

@slavkoja
Copy link

Current implementation uses normalized values (constrained inside min/max), but this is not always desired. Eg. i use it for displaying sensor values, the gauges are constrained to display interested range, but values sometime goes out of these boundaries. All works OK, but the gauge stays to display normalized (min or max) value in label, which is false value of course.

Please, use normalized values only for internal calculations (drawing) and allow to show real values for label.

@naikus
Copy link
Owner

naikus commented Nov 14, 2018

@slavkoja Okay, I'll start working on this. Thanks!

@Scrandre
Copy link

To achieve this effect (when the numbers in the center can go beyond the limits but the gauge doesn't break) you can modify the "normalize" function to:

        function normalize(value, min, limit) {
            var val = Number(value);
            // if (val > limit) return limit;
            // if (val < min) return min;
            return val;
        }

And the "getAngle" function to:

        function getAngle(percentage, gaugeSpanAngle) {
            percentage = (percentage > 100) ? 100 : (percentage < 0) ? 0 : percentage;
            return percentage * gaugeSpanAngle / 100;
        }

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