ashish-chopra / angular-gauge

A reusable gauge directive for Angular 1.x apps and dashboards
https://ashish-chopra.github.io/angular-gauge/
MIT License
95 stars 36 forks source link

It should be converted to number first before sort #38

Closed donghopark closed 6 years ago

donghopark commented 7 years ago

Hi. Ashish. Your plugin is really nice. Thanks a lot. I'm using this plugin and found one bug. When I set thresholds with various values, it just didn't recognize well. Please see my pull request.

ashish-chopra commented 7 years ago

Thanks @donghopark for using it. I am glad that you found it useful. I saw your modifications in the pull request. But can you please explain and write some cases which you tried so that i can reproduce the issue at my side?

Thanks Ashish

donghopark commented 7 years ago

You may try with below configuration

$scope.gaugeThreshold = {
'0': {color: '#228B22'}, '8': {color: "#AABC22"}, '21': {color: '#FFF54C'},
'31': {color: '#DF9111'}, '41': {color: '#FF0000'}, }

$scope.value = 22;

It should be third option to be selected, but once it go over 8, it always select the second option.

ashish-chopra commented 7 years ago

46

ashish-chopra commented 7 years ago

Hi @donghopark

I tested your code, its working fine, with one simple change that you need to push in your pull request, so that build will pass.

change

.sort((a,b) => {Number(a) > Number(b)})

to

.sort(function(a,b) {return Number(a) > Number(b);}
donghopark commented 6 years ago

Re-commited as you recommend