Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 494 lines (438 sloc) 12.757 kb
f3522c9 Remove Base to Module.
Martijn Koedam authored
1 using GLib;
2 using Gtk;
3
bd7354a Use Plotting module.
Martijn Koedam authored
4 class Plotting : Module
f3522c9 Remove Base to Module.
Martijn Koedam authored
5 {
bd7354a Use Plotting module.
Martijn Koedam authored
6 private enum PlotType {
2363f05 @DaveDavenport Add comments.
authored
7 POINTS, // Draw all the data points. (1 per minute).
8 AVG_WEEKDAY, // Draw the average usage per day in a week.
9 AVG_HOURS, // Draw the average usage per hour in a day.
10 DAYS, // Plot energy consumed per measured day.
11 WEEKS, // Plot energy consumed per measured week.
12 MONTHS, // Plot energy consumed per measured month.
13 NUM_PLOT_TYPES
f3522c9 Remove Base to Module.
Martijn Koedam authored
14 }
15
2363f05 @DaveDavenport Add comments.
authored
16 // Backend pointer.
17 private EnergyStorage es = null;
f3522c9 Remove Base to Module.
Martijn Koedam authored
18
4671174 @DaveDavenport Add day plot. fix small things.
authored
19 // config options.
20 private bool do_svg = false;
21 private string output_filename = "output.svg";
22 private uint output_width = 800;
23 private uint output_height = 600;
24 private bool do_average = false;
25 private PlotType plot_type = PlotType.POINTS;
26
2363f05 @DaveDavenport Add comments.
authored
27 // Start stop
bd7354a Use Plotting module.
Martijn Koedam authored
28 private DateTime tstart;
29 private DateTime tstop;
f3522c9 Remove Base to Module.
Martijn Koedam authored
30
2363f05 @DaveDavenport Add comments.
authored
31 // Constructor
bd7354a Use Plotting module.
Martijn Koedam authored
32 public Plotting(EnergyStorage es)
f3522c9 Remove Base to Module.
Martijn Koedam authored
33 {
bd7354a Use Plotting module.
Martijn Koedam authored
34 this.es = es;
f3522c9 Remove Base to Module.
Martijn Koedam authored
35 }
36
2363f05 @DaveDavenport Add comments.
authored
37 // Help function.
7b8e920 @DaveDavenport Add Status.vala
authored
38 public void print_help()
bd7354a Use Plotting module.
Martijn Koedam authored
39 {
2363f05 @DaveDavenport Add comments.
authored
40 stdout.printf(
41 """
51df54e @DaveDavenport Fix average drawing. more updates.
authored
42 Usage plot:
2363f05 @DaveDavenport Add comments.
authored
43 ep plot <options> <commands>
f3522c9 Remove Base to Module.
Martijn Koedam authored
44
bd7354a Use Plotting module.
Martijn Koedam authored
45 commands:
46 points: Plot all the data points. (use in combination with range)
4671174 @DaveDavenport Add day plot. fix small things.
authored
47 dayhours: Shows the average power consumption for each hour of the day.
d412d65 @DaveDavenport weekday -> weekdays.
authored
48 weekdays: Shows the average power consumption for each day of the week.
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
49 weeks: Shows the energy consumption for each week of the year.
4671174 @DaveDavenport Add day plot. fix small things.
authored
50 days: Shows the energy consumption for each day of the year.
51df54e @DaveDavenport Fix average drawing. more updates.
authored
51 months: Shows the energy consumption for each month of the year.
bd7354a Use Plotting module.
Martijn Koedam authored
52
53 Options:
d412d65 @DaveDavenport weekday -> weekdays.
authored
54 --help, help print this help message.
55 range <start date> <end date> Limit the evaluated data to a certain range.
56 svg <filename> Outputs the graph to an SVG file.
57 average Plot an average line.
58 width <width in px> The width of the output.
59 height <height in px> The height of the output.
bd7354a Use Plotting module.
Martijn Koedam authored
60
61 Example:
d412d65 @DaveDavenport weekday -> weekdays.
authored
62 ep plot days range 4/9/2012 4/16/2012 average output days.svg width 1024 height 600
bd7354a Use Plotting module.
Martijn Koedam authored
63 """);
64 }
f3522c9 Remove Base to Module.
Martijn Koedam authored
65
bd7354a Use Plotting module.
Martijn Koedam authored
66 public override bool parse_arguments(string[] argv)
f3522c9 Remove Base to Module.
Martijn Koedam authored
67 {
bd7354a Use Plotting module.
Martijn Koedam authored
68 tstart = es.get_starting_datetime();
69 tstop = es.get_stopping_datetime();
70 for(uint i = 0; i < argv.length; i++)
f3522c9 Remove Base to Module.
Martijn Koedam authored
71 {
bd7354a Use Plotting module.
Martijn Koedam authored
72 if(argv[i] == "help" || argv[i] == "--help") {
73 print_help();
74 return false;
75 } else if (argv[i] == "range") {
76 i += parse_range(argv, i+1, ref tstart, ref tstop);
d412d65 @DaveDavenport weekday -> weekdays.
authored
77 } else if (argv[i] == "weekdays") {
bd7354a Use Plotting module.
Martijn Koedam authored
78 plot_type = PlotType.AVG_WEEKDAY;
79 }else if (argv[i] == "points") {
80 plot_type = PlotType.POINTS;
35c423f @DaveDavenport Add plots, statistics
authored
81 }else if (argv[i] == "weeks") {
82 plot_type = PlotType.WEEKS;
51df54e @DaveDavenport Fix average drawing. more updates.
authored
83 }else if (argv[i] == "months") {
84 plot_type = PlotType.MONTHS;
bd7354a Use Plotting module.
Martijn Koedam authored
85 }else if (argv[i] == "days") {
86 plot_type = PlotType.DAYS;
4671174 @DaveDavenport Add day plot. fix small things.
authored
87 }else if (argv[i] == "dayhours") {
88 plot_type = PlotType.AVG_HOURS;
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
89 }else if (argv[i] == "svg") {
90 do_svg = true;
4671174 @DaveDavenport Add day plot. fix small things.
authored
91 i++;
92 if(i >= argv.length)
93 {
94 stdout.printf("Expected filename after svg.\n");
95 return false;
96 }
97 output_filename = argv[i];
98 }else if (argv[i] == "width") {
99 i++;
100 if(i >= argv.length)
101 {
102 stdout.printf("Expected size after width.\n");
103 return false;
104 }
105 output_width = (uint)uint64.parse(argv[i]);
106 if(output_width < 100) {
107 stdout.printf("The output should be atleast 100px width.\n");
108 return false;
109 }
110 }else if (argv[i] == "height") {
111 i++;
112 if(i >= argv.length)
113 {
114 stdout.printf("Expected size after height.\n");
115 return false;
116 }
117 output_height = (uint)uint64.parse(argv[i]);
118 if(output_height < 100) {
119 stdout.printf("The output should be atleast 100px heigh.\n");
120 return false;
121 }
51df54e @DaveDavenport Fix average drawing. more updates.
authored
122 }else if (argv[i] == "average") {
123 do_average = true;
bd7354a Use Plotting module.
Martijn Koedam authored
124 } else {
125 print_help();
126 return false;
127 }
f3522c9 Remove Base to Module.
Martijn Koedam authored
128 }
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
129 if(!do_svg)
130 {
131 Gtk.init(ref argv);
132 }
bd7354a Use Plotting module.
Martijn Koedam authored
133 return true;
134 }
135 public override int execute()
136 {
fff4b27 Add debug
Martijn Koedam authored
137 stdout.printf("Range: %s --> %s\n", tstart.format("%d/%m/%Y - %H:%M"),tstop.format("%d/%m/%Y - %H:%M"));
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
138
139 Graph.Widget widget = null;
140 Graph.Svg svg_plot = null;
141 Graph.Graph graph = null;
142 if(do_svg)
143 {
144 svg_plot = new Graph.Svg();
145 graph = svg_plot.graph;
146 }else{
147 widget = new Graph.Widget();
148 graph = widget.graph;
149 }
bd7354a Use Plotting module.
Martijn Koedam authored
150 if(plot_type == PlotType.POINTS)
f3522c9 Remove Base to Module.
Martijn Koedam authored
151 {
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
152 plot_graph(graph);
f3522c9 Remove Base to Module.
Martijn Koedam authored
153 }
bd7354a Use Plotting module.
Martijn Koedam authored
154 else if (plot_type == PlotType.AVG_WEEKDAY)
f3522c9 Remove Base to Module.
Martijn Koedam authored
155 {
d412d65 @DaveDavenport weekday -> weekdays.
authored
156 plot_weekdays(graph);
f3522c9 Remove Base to Module.
Martijn Koedam authored
157 }
35c423f @DaveDavenport Add plots, statistics
authored
158 else if (plot_type == PlotType.WEEKS)
159 {
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
160 plot_weeks(graph);
35c423f @DaveDavenport Add plots, statistics
authored
161 }
51df54e @DaveDavenport Fix average drawing. more updates.
authored
162 else if (plot_type == PlotType.MONTHS)
163 {
164 plot_months(graph);
165 }
4671174 @DaveDavenport Add day plot. fix small things.
authored
166 else if (plot_type == PlotType.DAYS)
167 {
168 plot_days(graph);
169 }
170 else if (plot_type == PlotType.AVG_HOURS)
171 {
172 plot_dayhours(graph);
173 }
bd7354a Use Plotting module.
Martijn Koedam authored
174
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
175 if(!do_svg)
176 {
177 Gtk.Window win = new Gtk.Window();
178
179 win.delete_event.connect((source) =>{
180 Gtk.main_quit();
181 return false;
182 });
183 // Set default size
4671174 @DaveDavenport Add day plot. fix small things.
authored
184 win.set_default_size((int)output_width, (int)output_height);
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
185 win.add(widget);
186 win.show_all();
187 Gtk.main();
188 }else{
4671174 @DaveDavenport Add day plot. fix small things.
authored
189 svg_plot.output(output_filename, output_width, output_height);
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
190 }
bd7354a Use Plotting module.
Martijn Koedam authored
191 return 0;
192 }
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
193 private void plot_weeks(Graph.Graph graph)
35c423f @DaveDavenport Add plots, statistics
authored
194 {
195 var start = tstart;
196 var stop = start.add_minutes(-start.get_minute());
197 stop = stop.add_hours(-stop.get_hour());
198 stop = stop.add_days(-stop.get_day_of_week()+1);
199
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
200 graph.title_label = "Power consumption";
201 graph.y_axis_label = "Energy (kWh)";
202 graph.x_axis_label = "Week";
35c423f @DaveDavenport Add plots, statistics
authored
203
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
204 var ds3 = graph.create_data_set_bar();
51df54e @DaveDavenport Fix average drawing. more updates.
authored
205 ds3.min_y_point = 0;
35c423f @DaveDavenport Add plots, statistics
authored
206 ds3.set_color(0.5,0.2,0.2);
207 while(stop.compare(tstop)< 0)
208 {
209 start = stop;
210 stop = start.add_days(7);
211
212 stdout.printf("Range: %s --> %s\n", start.format("%V %d/%m/%Y - %H:%M"),stop.format("%d/%m/%Y - %H:%M"));
213 var avg = es.get_average_energy(start,stop)*24*7/1000.0;
51df54e @DaveDavenport Fix average drawing. more updates.
authored
214
35c423f @DaveDavenport Add plots, statistics
authored
215 stdout.printf("power: %.2f kWh\n", avg);
51df54e @DaveDavenport Fix average drawing. more updates.
authored
216 ds3.add_point((double)stop.to_unix()-3.5*24*60*60, avg);
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
217 graph.add_xticks((double)start.to_unix()+(3.5*24*60*60), start.format("%V"));
35c423f @DaveDavenport Add plots, statistics
authored
218 }
51df54e @DaveDavenport Fix average drawing. more updates.
authored
219
220 // if we need average.
221 if(do_average)
222 {
223 var ds2 = new Graph.DataSetAverage(ds3);
224 graph.add_data_set(ds2);
225 ds2.set_color(0.2,0.2,0.4);
226 }
227 }
4671174 @DaveDavenport Add day plot. fix small things.
authored
228 private void plot_days(Graph.Graph graph)
229 {
230 var start = tstart;
231 var stop = start.add_minutes(-start.get_minute());
232 stop = stop.add_hours(-stop.get_hour());
233
234 graph.title_label = "Power consumption";
235 graph.y_axis_label = "Energy (kWh)";
236 graph.x_axis_label = "Day";
237
238 var ds3 = graph.create_data_set_bar();
239 ds3.set_color(0.2,0.5,0.2);
240 // Graph 0 point to 0
241 ds3.min_y_point = 0;
242
243 graph.add_xticks((double)stop.to_unix(),"");
244 while(stop.compare(tstop)< 0)
245 {
246 start = stop;
247 stop = start.add_days(1);
248
7610346 @DaveDavenport Add days to statistics
authored
249 var day = start.get_day_of_year();
4671174 @DaveDavenport Add day plot. fix small things.
authored
250
251 stdout.printf("Range:%u %s --> %s\n",day, start.format("%B %d/%m/%Y - %H:%M"),stop.format("%d/%m/%Y - %H:%M"));
252 var avg = es.get_average_energy(start,stop)*24/1000.0;
253
254 stdout.printf("power: %.2f kWh\n", avg);
255 ds3.add_point((double)start.to_unix()+(0.5*24*60*60), avg);
256 graph.add_xticks((double)start.to_unix()+(0.5*24*60*60), "%03d".printf(day));
257 }
258 graph.add_xticks((double)stop.to_unix(),"");
259 // if we need average.
260 if(do_average)
261 {
262 var ds2 = new Graph.DataSetAverage(ds3);
263 graph.add_data_set(ds2);
264 ds2.set_color(0.2,0.2,0.4);
265 }
266 }
51df54e @DaveDavenport Fix average drawing. more updates.
authored
267 private void plot_months(Graph.Graph graph)
268 {
269 var start = tstart;
270 var stop = start.add_minutes(-start.get_minute());
271 stop = stop.add_hours(-stop.get_hour());
272 stop = stop.add_days(-stop.get_day_of_month()+1);
273
274 graph.title_label = "Power consumption";
275 graph.y_axis_label = "Energy (kWh)";
276 graph.x_axis_label = "Month";
277
278 var ds3 = graph.create_data_set_bar();
279 ds3.set_color(0.5,0.2,0.2);
280 // Graph 0 point to 0
281 ds3.min_y_point = 0;
282
283 graph.add_xticks((double)stop.to_unix(),"");
284 while(stop.compare(tstop)< 0)
285 {
286 start = stop;
287 stop = start.add_months(1);
288
289 var num_days = stop.add_seconds(-1).get_day_of_month();
290
291 stdout.printf("Range:%u %s --> %s\n",num_days, start.format("%B %d/%m/%Y - %H:%M"),stop.format("%d/%m/%Y - %H:%M"));
292 var avg = es.get_average_energy(start,stop)*num_days*24/1000.0;
293
294 stdout.printf("power: %.2f kWh\n", avg);
295 ds3.add_point((double)start.to_unix()+(num_days*0.5*24*60*60), avg);
296 graph.add_xticks((double)start.to_unix()+(num_days*0.5*24*60*60), start.format("%B"));
297 }
298 graph.add_xticks((double)stop.to_unix(),"");
299 // if we need average.
300 if(do_average)
301 {
302 var ds2 = new Graph.DataSetAverage(ds3);
303 graph.add_data_set(ds2);
304 ds2.set_color(0.2,0.2,0.4);
305 }
35c423f @DaveDavenport Add plots, statistics
authored
306 }
d412d65 @DaveDavenport weekday -> weekdays.
authored
307 private void plot_weekdays(Graph.Graph graph)
bd7354a Use Plotting module.
Martijn Koedam authored
308 {
309 double week[7] = {0};
310 int num_week[7] = {0};
311
312 var start = tstart;
313 var stop = start.add_minutes(-start.get_minute());
314 stop = stop.add_hours(-stop.get_hour());
315 while(stop.compare(tstop)< 0)
f3522c9 Remove Base to Module.
Martijn Koedam authored
316 {
bd7354a Use Plotting module.
Martijn Koedam authored
317 start = stop;
318 int d = start.get_day_of_week();
319 stop = start.add_days(1);
320
321 week[d-1] += es.get_average_energy(start, stop);
322 num_week[d-1]++;
323
f3522c9 Remove Base to Module.
Martijn Koedam authored
324 }
bd7354a Use Plotting module.
Martijn Koedam authored
325
326
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
327 graph.title_label = "Power consumption";
328 graph.y_axis_label = "Energy (kWh)";
329 graph.x_axis_label = "Week day";
bd7354a Use Plotting module.
Martijn Koedam authored
330
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
331 graph.min_y_point = 0;
332 var ds = graph.create_data_set_bar();
bd7354a Use Plotting module.
Martijn Koedam authored
333 ds.set_color(0.4,0.5,0.3);
51df54e @DaveDavenport Fix average drawing. more updates.
authored
334 ds.min_y_point = 0;
335 graph.add_xticks(0.0, "");
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
336 graph.add_xticks(0.5, "Monday");
337 graph.add_xticks(1.5, "Tuesday");
338 graph.add_xticks(2.5, "Wednesday");
339 graph.add_xticks(3.5, "Thursday");
340 graph.add_xticks(4.5, "Friday");
341 graph.add_xticks(5.5, "Saturday");
342 graph.add_xticks(6.5, "Sunday");
51df54e @DaveDavenport Fix average drawing. more updates.
authored
343 graph.add_xticks(7.0, "");
2363f05 @DaveDavenport Add comments.
authored
344 // ds.add_point(0, 0);
bd7354a Use Plotting module.
Martijn Koedam authored
345 for(uint i = 0; i < 7; i++)
f3522c9 Remove Base to Module.
Martijn Koedam authored
346 {
bd7354a Use Plotting module.
Martijn Koedam authored
347 if(num_week[i] > 0)
348 {
51df54e @DaveDavenport Fix average drawing. more updates.
authored
349 stdout.printf("%u %f %i\n",i, 24/1000.0*week[i]/(double)num_week[i], num_week[i]);
350 ds.add_point(i+0.5,
bd7354a Use Plotting module.
Martijn Koedam authored
351 24/1000.0*week[i]/(double)num_week[i]);
352 }else{
51df54e @DaveDavenport Fix average drawing. more updates.
authored
353 ds.add_point(i+0.5, 0);
bd7354a Use Plotting module.
Martijn Koedam authored
354 }
f3522c9 Remove Base to Module.
Martijn Koedam authored
355 }
51df54e @DaveDavenport Fix average drawing. more updates.
authored
356 // if we need average.
357 if(do_average)
358 {
359 var ds2 = new Graph.DataSetAverage(ds);
360 graph.add_data_set(ds2);
361 ds2.set_color(0.2,0.2,0.4);
362 }
f3522c9 Remove Base to Module.
Martijn Koedam authored
363 }
4671174 @DaveDavenport Add day plot. fix small things.
authored
364 private void plot_dayhours(Graph.Graph graph)
365 {
366 double hour[24] = {0};
367 int num_hour[24] = {0};
368
369 var start = tstart;
370 var stop = start.add_minutes(-start.get_minute());
371 while(stop.compare(tstop)< 0)
372 {
373 start = stop;
374 int d = start.get_hour();
375 stop = start.add_hours(1);
376
377 hour[d] += es.get_average_energy(start, stop);
378 num_hour[d]++;
379
380 }
381
382
383 graph.title_label = "Power consumption";
384 graph.y_axis_label = "Energy (kWh)";
385 graph.x_axis_label = "Hour";
386
387 graph.min_y_point = 0;
388 var ds = graph.create_data_set_bar();
389 ds.set_color(0.4,0.5,0.3);
390 ds.min_y_point = 0;
391 // Add X-grid points.
392 graph.add_xticks(0.0, "");
393 for(uint i = 0 ; i < 24; i++)
394 {
395 graph.add_xticks(0.5+i, "%2u".printf(i));
396 }
397 graph.add_xticks(24.0, "");
398
399 for(uint i = 0; i < 24; i++)
400 {
401 if(num_hour[i] > 0)
402 {
403 stdout.printf("%u %f %i\n",i, 24/1000.0*hour[i]/(double)num_hour[i], num_hour[i]);
404 ds.add_point(i+0.5,
405 1/1000.0*hour[i]/(double)num_hour[i]);
406 }else{
407 ds.add_point(i+0.5, 0);
408 }
409 }
410 // if we need average.
411 if(do_average)
412 {
413 var ds2 = new Graph.DataSetAverage(ds);
414 graph.add_data_set(ds2);
415 ds2.set_color(0.2,0.2,0.4);
416 }
417 }
f3522c9 Remove Base to Module.
Martijn Koedam authored
418
bd7354a Use Plotting module.
Martijn Koedam authored
419 /**
420 * Plotting graph
421 */
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
422 void plot_graph(Graph.Graph graph)
bd7354a Use Plotting module.
Martijn Koedam authored
423 {
2363f05 @DaveDavenport Add comments.
authored
424 // bool do_bars = false;
51df54e @DaveDavenport Fix average drawing. more updates.
authored
425 bool do_points = true;
f3522c9 Remove Base to Module.
Martijn Koedam authored
426
2363f05 @DaveDavenport Add comments.
authored
427 // if(!do_bars) do_points = true;
bd7354a Use Plotting module.
Martijn Koedam authored
428 tstart = es.get_starting_datetime(tstart);
429 tstop = es.get_stopping_datetime(tstop);
f3522c9 Remove Base to Module.
Martijn Koedam authored
430
bd7354a Use Plotting module.
Martijn Koedam authored
431 double avg = es.get_average_energy(tstart, tstop);
432 //double eng = es.get_energy(tstart, tstop);
f3522c9 Remove Base to Module.
Martijn Koedam authored
433
434
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
435 graph.title_label = "Power consumption";
436 graph.y_axis_label = "Power (W)";
437 graph.x_axis_label = "Time (HH:MM)";
f3522c9 Remove Base to Module.
Martijn Koedam authored
438
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
439 graph.min_y_point = 0;
440 var ds = graph.create_data_set_area();
bd7354a Use Plotting module.
Martijn Koedam authored
441 ds.set_color(0.4,0.5,0.3);
2363f05 @DaveDavenport Add comments.
authored
442 /*
443 if (do_bars)
444 {
445 var ds3 = graph.create_data_set_bar();
446 ds3.set_color(0.5,0.2,0.2);
447
448
449 var start = tstart;
450 var stop = start.add_minutes(-start.get_minute());
451 ds3.add_point((double)stop.to_unix(), 0);
452
453 while(stop.compare(tstop)< 0)
454 {
455 start = stop;
456 stop = start.add_hours(1);
457
458 avg = es.get_energy(start,stop);
459 ds3.add_point((double)stop.to_unix(), avg);
460 }
461 }
462 */
bd7354a Use Plotting module.
Martijn Koedam authored
463 // add zero point.
464 if(do_points)
f3522c9 Remove Base to Module.
Martijn Koedam authored
465 {
bd7354a Use Plotting module.
Martijn Koedam authored
466 ds.add_point((double)tstart.to_unix(), 0);
467 foreach ( EnergyPoint ep in es.get_data(tstart, tstop))
468 {
469 ds.add_point((double)ep.time.to_unix(), ep.power);
470 }
f3522c9 Remove Base to Module.
Martijn Koedam authored
471 }
51df54e @DaveDavenport Fix average drawing. more updates.
authored
472 // if we need average.
473 if(do_average)
474 {
475 var ds2 = new Graph.DataSetAverage(ds);
476 graph.add_data_set(ds2);
477 ds2.set_color(0.2,0.2,0.4);
478 ds2.average = avg;
479 }
f3522c9 Remove Base to Module.
Martijn Koedam authored
480
bd7354a Use Plotting module.
Martijn Koedam authored
481 var start = tstart;
482 var stop = start.add_minutes(-start.get_minute());
483 // ticks.
484 while(stop.compare(tstop)< 0)
485 {
486 start = stop;
487 stop = start.add_hours(1);
488 string sa = "%02d:%02d".printf(start.get_hour(), start.get_minute());
fa51d54 @DaveDavenport Allow graphs to be written to svg.
authored
489 graph.add_xticks((double)start.to_unix(),sa);
f3522c9 Remove Base to Module.
Martijn Koedam authored
490
bd7354a Use Plotting module.
Martijn Koedam authored
491 }
492 }
f3522c9 Remove Base to Module.
Martijn Koedam authored
493 }
Something went wrong with that request. Please try again.