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

Redrawing issue if value change to zero #34

Closed peppinho89 closed 7 years ago

peppinho89 commented 7 years ago

The second if statement prevent redraw if the new value (nv param) is zero.

function watchData(nv, ov) {
                    if (!gauge) return;
                    if (!nv  || angular.equals(nv, ov)) return;
                    gauge.update();
                }

This could fix it

function watchData(nv, ov) {
                    if (!gauge) return;
                     if ((!nv && nv != 0) || angular.equals(nv, ov)) return;
                    gauge.update();
                }
ashish-chopra commented 7 years ago

Thanks for pointing this out. I will use native angular.isDefined() call to identify undefined ness of nv. I will fix this up. Thanks!

samdanishaik commented 7 years ago

Hi,

One more query on this.

I modify the guage value dynamically on the same screen/page on selection of an element from dropdown. Lets say by default, I have a process in 100%/50% completion state. Now if I change the dropdown to an element which has 0% completion then this doesnt refresh the guage.

In my controller this is the code I have:

$scope.perc = 0;

onboardServices.getOpenOnboardingStatus($scope.process.processkey).then(function(response) { console.log("Status: ", JSON.stringify(response.data)); $scope.obcase = response.data.items[0]; $scope.perc = Math.round(($scope.obcase.complete_count/$scope.obcase.total_count)*100); },function(error) { alert("OB Status request failed. Please try again."); });

This happens only when binding the guage with 0% from any higher value.

Looks like I am also hitting this issue #34. Is there a work around?

samdanishaik commented 7 years ago

BTW, following the solution proposed by peppinho89 helped fixing this temporarily.

ashish-chopra commented 7 years ago

Hi @samdanishaik, yes, @peppinho89 proposed one solution and in my comment also i mentioned to use angular.isDefined() to check nv. However, i have fixed this bug, will release it as 2.0.1 version. You may take the update then.

Thanks!

ashish-chopra commented 7 years ago

@samdanishaik, @peppinho89

2.0.1 is published to npm. You can take an update. Let me know if you find any other or related issue.

Thanks! Ashish