@cryptotaxi247 / netdata-1 / commits / 52c4fee13

now using datetime instead of timeofday for charts to fix the midnight issue.

Costa Tsaousis (ktsaou) committed Mar 23, 2014 at 23:04 UTC 52c4fee133b5bd2928420c05d10d93ad7c99bc39
2 files changed +20 -10
netdata.c
+3 -3
@@ -499,7 +499,7 @@ size_t rrd_stats_json(RRD_STATS *st, char *b, size_t length, size_t entries_to_s
499 group_values[c] = group_counts[c] = 0;
500
501 i += sprintf(&b[i], "{\n \"cols\":\n [\n");
502 - i += sprintf(&b[i], " {\"id\":\"\",\"label\":\"time\",\"pattern\":\"\",\"type\":\"timeofday\"},\n");
502 + i += sprintf(&b[i], " {\"id\":\"\",\"label\":\"time\",\"pattern\":\"\",\"type\":\"datetime\"},\n");
503
504 for( rd = st->dimensions, c = 0 ; rd && c < dimensions ; rd = rd->next, c++)
505 i += sprintf(&b[i], " {\"id\":\"\",\"label\":\"%s\",\"pattern\":\"\",\"type\":\"number\"}%s\n", rd->name, rd->next?",":"");
@@ -548,8 +548,8 @@ size_t rrd_stats_json(RRD_STATS *st, char *b, size_t length, size_t entries_to_s
548 struct tm *tm = localtime(&st->times[t].tv_sec);
549 if(!tm) { error("localtime() failed."); continue; }
550
551 - // strftime(dtm, 200, "[%Y, %m, %d, %H, %M, %S, 0]", tm); // datetime
552 - strftime(dtm, 200, "[%H, %M, %S, 0]", tm); // timeofday
551 + strftime(dtm, 200, "\"Date(%Y, %m, %d, %H, %M, %S)\"", tm); // datetime
552 + // strftime(dtm, 200, "[%H, %M, %S, 0]", tm); // timeofday
553 i += sprintf(&b[i], "%s {\"c\":[{\"v\":%s},", printed?"]},\n":"", dtm);
554
555 printed++;
netdata.js
+17 -7
@@ -7,17 +7,17 @@
7 function refreshChart(index) {
8 if(index >= charts.length) return;
9
10 - var jsonData = $.ajax({
10 + charts[index].jsondata = $.ajax({
11 url: charts[index].url,
12 dataType:"json",
13 async: false,
14 cache: false
15 }).responseText;
16
17 - if(!jsonData || jsonData.length == 0) return;
17 + if(!charts[index].jsondata || charts[index].jsondata.length == 0) return;
18
19 // Create our data table out of JSON data loaded from server.
20 - charts[index].data = new google.visualization.DataTable(jsonData);
20 + charts[index].datatable = new google.visualization.DataTable(charts[index].jsondata);
21
22 // Instantiate and draw our chart, passing in some options.
23 if(!charts[index].chart) {
@@ -40,7 +40,16 @@
40 if(height >= 200) hAxisTitle = "Time of Day";
41 if(width >= 400) vAxisTitle = charts[index].vtitle;
42
43 - if(charts[index].chart) charts[index].chart.draw(charts[index].data, {width: width, height: height, title: charts[index].title, hAxis: {title: hAxisTitle}, vAxis: {title: vAxisTitle, minValue: 10}});
43 + var options = {
44 + width: width,
45 + height: height,
46 + title: charts[index].title,
47 + hAxis: {title: hAxisTitle},
48 + vAxis: {title: vAxisTitle, minValue: 10},
49 + // animation: {duration: 1000, easing: 'inAndOut'},
50 + };
51 +
52 + if(charts[index].chart) charts[index].chart.draw(charts[index].datatable, options);
53 else console.log('Cannot create chart for ' + charts[index].url);
54 }
55
@@ -55,7 +64,8 @@
64 console.log('Creating new objects for chart ' + name);
65 charts[i] = [];
66 charts[i].chart = null;
58 - charts[i].data = null;
67 + charts[i].jsondata = null;
68 + charts[i].datatable = null;
69 charts[i].name = name;
70 charts[i].div = div;
71 charts[i].width = width;
@@ -73,7 +83,7 @@
83 }
84 }
85
76 - var charts_last_drawn = 99;
86 + var charts_last_drawn = 999999999;
87 function refreshCharts(howmany) {
88
89 if(charts.length == 0) return;
@@ -93,7 +103,7 @@
103 refreshChart(charts_last_drawn);
104 }
105 catch(err) {
96 - console.log('Cannot refresh chart for ' + jsonurl);
106 + console.log('Cannot refresh chart for ' + charts[charts_last_drawn].url);
107 }
108 }
109 return 0;