Anonymous avatar Anonymous committed 0789fd9 Draft

draw line chart with online status

Comments (0)

Files changed (1)

       google.load("visualization", "1", {packages:["corechart"]});
       google.setOnLoadCallback(drawChart);
       function drawChart() {
-        var data = google.visualization.arrayToDataTable([
-          ['Year', 'Sales', 'Expenses'],
-          ['2004',  1000,      400],
-          ['2005',  1170,      460],
-          ['2006',  660,       1120],
-          ['2007',  1030,      540]
+
+        var dataTable = new google.visualization.DataTable();
+        dataTable.addColumn('datetime', 'Дата');
+        dataTable.addColumn('number', 'В сети');
+        dataTable.addRows([
+          {% for status in statuses %}
+          [new Date('{{ status.time }}'), {{ status.online }}],
+          {% endfor %}
         ]);
 
-        var options = {
-          title: 'Company Performance'
-        };
+        var dataView = new google.visualization.DataView(dataTable);
+        dataView.setColumns([{calc: function(data, row) { return data.getFormattedValue(row, 0); }, type:'string'}, 1]);
 
         var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
-        chart.draw(data, options);
+        var options = {
+          //width: 400, height: 240,
+          legend: 'none',
+          pointSize: 5,
+          title: 'Title online'
+        };
+        chart.draw(dataView, options);
       }
     </script>
 </head>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.