in reply to Generating graphs and tables for admins - templates, frameworks, files or what?
because what wasn't happening, and therefore wasn't in the log, was also importantThis should be able to be done in SQL as well, making the db do all the work. Mysql provides the ifnull(colname, 0) command, which I'm sure there is an equivalent to in sqlite.
To assemble the data into arrays for graphing, and:# Your SQL here. while (my ($timestamp, $field1, $field2, $field3)=$sth->fetchrow_array +() { push @timeline, $timestamp; push @data1, $field1; push @data2, $field2; push @data3, $field3; }
to graph it. Wrap it all in a CGI where you can input the necessary values (start time, end time, what kind of data you want, etc. ).my $graph = GD::Graph::mixed->new($x_size, $height); my @data=([@timeline],[@data1],[@data2],[@data3]); $graph->set( y_label => 'Your graph title', title => "$title", line_width =>2, line_types =>[1,1], skip_undef =>1, box_axis =>1, correct_width =>1, fgclr =>"black", legendclr =>"black", x_label_skip =>$x_skip ) or die $graph->error; $graph->set_text_clr('black'); $graph->set( 'y_number_format' => \&y_format ); $graph->set_title_font(GD::gdSmallFont,12); $graph->set( types => ['area', 'lines','lines'] ); $graph->set( dclrs => ['pink','blue','green'] ); $graph->set_legend('your legend1', 'your legend2', 'your legen +d 3'); $graph->set(y_max_value=>($y_max)); $graph->set(y_min_value=>(0.1)); } my $gd = $graph->plot(\@data) or die $graph->error; binmode STDOUT; print $gd->jpeg(100); }
|
|---|