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

Pointer disapear after speed > 1 #124

Closed
luizhdinizf opened this Issue Feb 17, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@luizhdinizf

I am using 6 Gauges to show analogs value from arduino, using ajax to get XML from Django.

the ajax script is this
`t = setInterval(loadDoc,200);
function loadDoc() {
var xhttp, xmlDoc, x, i;
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
xmlDoc = this.responseXML;
x = xmlDoc.getElementsByTagName("A");
gauge0.set(x[0].childNodes[0].nodeValue);
gauge1.set(x[1].childNodes[0].nodeValue);
gauge2.set(x[2].childNodes[0].nodeValue);
gauge3.set(x[3].childNodes[0].nodeValue);
gauge4.set(x[4].childNodes[0].nodeValue);
gauge5.set(x[5].childNodes[0].nodeValue);

}
};
xhttp.open("GET", "/atualiza/", true);
xhttp.send();
}`
this script makes a request from a server and extracts the XML response then calls gauge.set to insert the value, but when i set the gauge speed to more than 1 the pointers desapear

gauge

this is the Django template loop which generates the JS with gauges

{% for valor, entrada in teste %}

var target{{ valor }} = document.getElementById('A{{ valor }}'); // your canvas element
var gauge{{ valor }} = new Gauge(target{{ valor }} ).setOptions(opts); // create sexy gauge!
gauge{{ valor }}.maxValue = 1000; // set max gauge value
gauge{{ valor }}.setMinValue(0); // Prefer setter over gauge.minValue = 0
gauge{{ valor }}.animationSpeed = 32 // set animation speed (32 is default value)
gauge{{ valor }}.set({{entrada}}); // set actual value

{% endfor %}

@kplindegaard

This comment has been minimized.

Show comment
Hide comment
@kplindegaard

kplindegaard Feb 27, 2017

Collaborator

@luizhdinizf
I don't necessarily think this is related to the .animationSpeed option. I suspect it's caused by insufficient protection in the .set() function for arguments not being actual numbers.

Could you please try to enforce the protection we should have had by modifying the last line in your for-loop for me? What I mean is

gauge{{ valor }}.set(Number({{entrada}})); // set actual value

If that works, patching is straight-forward.

Collaborator

kplindegaard commented Feb 27, 2017

@luizhdinizf
I don't necessarily think this is related to the .animationSpeed option. I suspect it's caused by insufficient protection in the .set() function for arguments not being actual numbers.

Could you please try to enforce the protection we should have had by modifying the last line in your for-loop for me? What I mean is

gauge{{ valor }}.set(Number({{entrada}})); // set actual value

If that works, patching is straight-forward.

@luizhdinizf

This comment has been minimized.

Show comment
Hide comment
@luizhdinizf

luizhdinizf Mar 4, 2017

it not solved the problem, the requested webpage already returns a number ,
Like gauge1.set(Number(743)); // set actual value

it not solved the problem, the requested webpage already returns a number ,
Like gauge1.set(Number(743)); // set actual value

@matthias-herrmann

This comment has been minimized.

Show comment
Hide comment
@matthias-herrmann

matthias-herrmann Mar 24, 2017

@luizhdinizf @kplindegaard gauge.set(Number({{value}})) worked for me - I had the same issue. You should propably include that in the documentation.

@luizhdinizf @kplindegaard gauge.set(Number({{value}})) worked for me - I had the same issue. You should propably include that in the documentation.

@luizhdinizf

This comment has been minimized.

Show comment
Hide comment
@luizhdinizf

luizhdinizf Mar 24, 2017

perharps my problem should be in the ajax response callback function
like this part
gauge1.set(x[1].childNodes[0].nodeValue);
how do i enforce the protection in this section of code?

perharps my problem should be in the ajax response callback function
like this part
gauge1.set(x[1].childNodes[0].nodeValue);
how do i enforce the protection in this section of code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment