4
package Jifty::Plugin::Chart::Renderer::GD::Graph;
5
use base qw/ Jifty::Plugin::Chart::Renderer /;
9
Jifty::Plugin::Chart::Renderer::GD::Graph - A chart renderer using GD::Graph
17
DefaultRenderer: Jifty::Plugin::Chart::Renderer::GD::Graph
21
This is a chart renderer that uses L<GD::Graph> to build charts.
27
Adds the F<chart_img_behaviour.js> script to those loaded.
32
Jifty->web->add_javascript('chart_img_behaviour.js');
37
Renders an IMG tag referring to the L<GD::Graph> image view.
45
# GD::Graph types from generic types
49
horizontalbars => 'hbars',
51
linespoints => 'linespoints', # non-standart
54
mixed => 'mixed', # non-standard
57
# Convert the generic type to a GD::Graph type
58
$args{type} = $types{ $args{type} } || undef;
60
# Save the data for retrieval from the session later
61
my $chart_id = Jifty->web->serial;
62
my $session_id = 'chart_' . $chart_id;
63
Jifty->web->session->set( $session_id => Jifty::YAML::Dump(\%args) );
65
# Build up the chart tag
68
$img .= qq{ src="/chart/gd_graph/$chart_id"};
69
$img .= qq{ class="@{[ join ' ', @{ $args{class} } ]}"};
72
push @styles, "width:$args{width}" if defined $args{width};
73
push @styles, "height:$args{height}" if defined $args{height};
75
$img .= qq{ style="@{[ join ';', @styles ]}"} if @styles;
78
# Output the <img> tag and include the chart's configuration key
79
Jifty->web->out($img);
81
# Make sure we don't return anything that will get output
87
Andrew Sterling Hanenkamp C<< <andrew.hanenkamp@boomer.com> >>
89
=head1 COPYRIGHT AND LICENSE
91
Copyright 2007 Boomer Consulting, Inc.
93
This is free software and may be modified and distributed under the same terms as Perl itself.