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

Logaritmic scale #164

Open
brechtvhb opened this issue May 31, 2023 · 0 comments
Open

Logaritmic scale #164

brechtvhb opened this issue May 31, 2023 · 0 comments

Comments

@brechtvhb
Copy link

It would be nice to be able to set the scale of the bar card to logaritmic.

Eg: when showing power usage of devices right now when you have a device using 10w, one using 100w, one using 1000w and one using 3000w (assuming min is 1 and max is 3000).
It would resolve in having the devices being 0.3% wide, 3% wide, 30% wide and 100% wide.

Being able to set a logarithmic scale (example below) would result in these widths: 28.7%, 57.5%, 86.2% and 100%.

var minval = 1,
    maxval = 3000,
    minlog = Math.log10(minval),
    maxlog = Math.log10(maxval),
    range = maxlog - minlog,
    lineartolog = function(n){
        return (Math.log10(n) - minlog) / range;
    },
    logplots = [
        10,
        100,
        1000,
        3000
    ].map(lineartolog);

console.log(logplots );
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

1 participant