Dynamic graphics with google api

Asked

Viewed 242 times

0

I am making a graphic and precise search the data via javascript localStorage, but I am not able to understand the logic, using php to search the page made sense but with javascript I am not able to assemble the array.

I’m doing it this way, but I can’t even get into the app:

   var itens = getData("graficoLinha_");

   function drawChart() {
    var data = google.visualization.arrayToDataTable([
     var variavel = "['Year', 'Membros', 'Visitantes'],";
     for(var i = 0; i < itens.length; i++){
     var objetos = itens[i][0];
     variavel = variavel + "['"+objetos.data+"', "+objetos.membros+", "+objetos.visitantes+"],"
    }
    variavel;
  ]);

    var options = {
     title: 'Membros x Visitantes',
     curveType: 'function',
     legend: { position: 'bottom' }
    };

    var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));

    chart.draw(data, options);

the getData returns to me an array with everything I’m passing by parameter, and in it I have date, member and visitor. On my chart I need to dynamically take all this, how to do this ?

  • Do you use php and getData to bring information and save to localStorage respectively? If so, how are you bringing the information a json, plain text ...

  • @Fernandoandrade not all this in mobile

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.