Good morning, when I show this gauge Chart and I pass a value of a php variable through javascript, it does not graph it, the strange thing is that if it prints it on the screen with an echo, that is, the value of the php variable is stored in the javascript variable that I am creating but it does not graph it and if I put a direct value in the js variable it does graph it, could you help me?
//this is the value to pass for idEmp (variable of
javascript el cual si imprime pero no grafica)
<?php
$idEmpleado= 99;
?>
<!DOCTYPE html>
<html lang="es">
<!--variable de php a javascript-->
<script type="text/javascript">
var idEmp = "<?php echo $idEmpleado; ?>";
document.write("idEmpleado = " + idEmp);
</script>
var hand = chart.hands.push(new am4charts.ClockHand());
chart.setTimeout(valPregGraf, 2000);
> //aquí se pasan los datos a la gráfica en la variable de java idEmp es el dato que necesito herede del echo de php.
function valPregGraf() {
hand.showValue(idEmp, 1000, am4core.ease.cubicOut);
chart.setTimeout(valPregGraf, 2000);
}
});
I share the link of the complete code for you to check, thank you.
https://drive.google.com/open?id=1zvB8g0ni-csYKn9p0VeBfBsFxJ3yjdIm
The error is in the data type.
If you put ...
With parseInt() the problem is solved. Transforms the variable to INT.
More information: https://developer.mozilla.org/es/docs/Web/JavaScript/Referencia/Objetos_globales/parseInt