Jump to content
Fórum Script Brasil
  • 0

A variável javaScript não atualiza.


eucyelle

Question

Olá,

Alguém pode me ajuda?? To desenvolvendo um gráfico em Php, no qual eu pego os valores do BD e coloco em um script pronto que eu encontrei, muito bom bor sinal.

O problema é quando eu vou pegar o próximo valor de y. Eu tento atualizar o valor de y e ele me retorna o mesmo.

Ai vai o código:

chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                type: 'spline',
                marginRight: 10,
                events: {
                    load: function() {
    
                        // set up the updating of the chart each second
                        var series = this.series[0];
                        setInterval(function() {
         <?php
            $sql="SELECT * FROM leituras WHERE sensor LIKE '%$iLeitor%' order by id DESC";
            $linha=mysql_query($sql,$conexao);
            $campo = mysql_fetch_row($linha);               
                     ?>
                            var x = (new Date()).getTime(), // current time
                                y = <?php    
                              echo $campo[3]
                           ?>;
                            series.addPoint([x, y], true, true);
                        }, 10000);// tempo q sera exibido
                    }
                }
            },

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...