HELLO im drawing a google line chart and it is working with only one 
variable/line with a name zadnjiBroj, i want to add 2 more variables into 
chart, 2 more lines named zadnjiBrojy and zadnjiBrojz that will work on the 
same graph. Can anyone help me to implement that 2 more lines?

There is a code:

google.charts.load('current', {'packages':['corechart']});
var numbersFromLabView = [];
var time = [];



$('.viewbutton').click(function() {
  // Zovi api poziv i dohvati podatke svako 2 sec
  $('#portfolio').addClass('hidden');
  $('#element-di-zivi-aplikacija').removeClass('hidden');
  setInterval(getDataFromLabView, 2000);
});


function getDataFromLabView() {
  var jsonData = $.ajax({
    url: 'projectXHTTP',
    dataType: 'json',
    success: function (jsonArray) {
      
      var zadnjiBroj = jsonArray.slice(0,1).pop();
      var zadnjiBrojy = jsonArray.slice(0,2).pop();
      var zadnjiBrojz = jsonArray.slice(0,3).pop();
   
      drawChart(zadnjiBroj);
   
   
      $(document.querySelector('.current-number')).text(zadnjiBroj);
      $(document.querySelector('.current-numbery')).text(zadnjiBrojy);
      $(document.querySelector('.current-numberz')).text(zadnjiBrojz);
  
    }
  });
}


function drawChart(number) {
  var data = new google.visualization.DataTable();
  
  moment.locale('hr');
  time.push(moment());
  numbersFromLabView.push(number);


  // kako ce se zvati x i y osi na grafu
  data.addColumn('string', 'Time of Day');
  data.addColumn('number', 'Current');
  


  numbersFromLabView.forEach((number, key) =>  {
    // za svaki broj koji dohvati ubaci njega i vrijeme u data Objekt
    data.addRow([time[key].format('LTS'), number]);
  });


  // stilovi i izgled grafa se ovdje definiraju
  var options = {
    background: 'transparent',
    title: 'Numeric values from LabView on time scale',
    height: 500,
    width: '100%',
    hAxis: {
      title: 'Vrijeme',
    },
    vAxis: {
      title: 'I',
      
    }
  }


  
  var chart = new google.visualization.LineChart(document.querySelector(
'#chart_div'));
  
  
  chart.draw(data, options);
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/4901afa7-b07e-4b2d-b698-76226b8f51b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to