summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9b0038d)
raw | patch | inline | side by side (parent: 9b0038d)
author | Florian Forster <octo@huhu.verplant.org> | |
Fri, 31 Oct 2008 17:05:39 +0000 (18:05 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Fri, 31 Oct 2008 17:05:39 +0000 (18:05 +0100) |
With this parameter one can specify the file format the graph is returned in,
for example `format=SVG' for an SVG image.
for example `format=SVG' for an SVG image.
contrib/collection3/bin/graph.cgi | patch | blob | history |
index 1524a660f33b0b53bffdd5679c27dc847921a70e..7fe20871a20ccd7eee60bbf11837e9ec0a6968ed 100755 (executable)
our $Begin = param ('begin');
our $End = param ('end');
our $GraphWidth = param ('width');
+our $OutputFormat = 'PNG';
+our $ContentType = 'image/png';
+
+if (param ('format'))
+{
+ my $temp = param ('format') || '';
+ $temp = uc ($temp);
+
+ if ($temp =~ m/^(PNG|SVG|EPS|PDF)$/)
+ {
+ $OutputFormat = $temp;
+
+ if ($OutputFormat eq 'SVG') { $ContentType = 'image/svg+xml'; }
+ elsif ($OutputFormat eq 'EPS') { $ContentType = 'image/eps'; }
+ elsif ($OutputFormat eq 'PDF') { $ContentType = 'application/pdf'; }
+ }
+}
if ($Debug)
{
addr => gc_get_scalar ('UnixSockAddr', undef),
interval => gc_get_scalar ('Interval', 10));
-print STDOUT header (-Content_type => 'image/png',
+print STDOUT header (-Content_type => $ContentType,
-Last_Modified => epoch_to_rfc1123 ($obj->getLastModified ()),
-Expires => epoch_to_rfc1123 ($expires));
}
$| = 1;
- RRDs::graph ('-', '-a', 'PNG', '--width', $GraphWidth, @timesel, @$args);
+ RRDs::graph ('-', '-a', $OutputFormat, '--width', $GraphWidth, @timesel, @$args);
if (my $err = RRDs::error ())
{
print STDERR "RRDs::graph failed: $err\n";