I use Google Charts for my site and parse.com for the server side. I have one <div id="chart_div"> </div> that draws a chart. For a chart, this is part of Javascript:
$( document ).ready(function() { var currentUser = Parse.User.current(); console.log( currentUser ); var stepcount = Parse.Object.extend("stepCount"); var query = new Parse.Query(stepcount); query.equalTo("user", currentUser); query.find({ success: function(results) { for (var i = 0; i < results.length; i++) { var object = results[i]; alert(object.id + ' - ' + object.get('numberOfSteps')); } }, error: function(error) { alert("Error: " + error.code + " " + error.message); } }); }); function drawMultSeries() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Day'); data.addColumn('number', 'Motivation Level'); data.addColumn('number', 'Energy Level'); data.addRows([ ['Monday', 1, .25], ['Monday', 1, .25], ['Monday', 1, .25], ['Monday', 1, .25], ['Monday', 1, .25], ['Monday', 1, .25], ['Monday', 1, .25], ]); var options = { title: 'Motivation and Energy Level Throughout the Day', hAxis: { title: 'Time of Day', format: 'h:mm a', viewWindow: { min: [7, 30, 0], max: [17, 30, 0] } }, vAxis: { title: 'Steps' } }; var chart = new google.visualization.ColumnChart( document.getElementById('chart_div')); chart.draw(data, options); }
I am trying to get the number of steps for the current user, but I do not know how to insert it into the diagram.