| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catalyst::View::PNGTTGraph; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
27563
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
32
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
25
|
|
|
5
|
1
|
|
|
1
|
|
373
|
use Image::LibRSVG; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use base qw(Catalyst::View::SVGTTGraph); |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
my($Revision) = '$Id: PNGTTGraph.pm,v 1.1.1.1 2006/02/11 17:54:15 terence Exp $'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.021'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Catalyst::View::PNGTTGraph - PNG Graph View Component for Catalyst |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
In your View. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
package MyApp::View::PNGTTGraph; |
|
21
|
|
|
|
|
|
|
use base 'Catalyst::View::PNGTTGraph'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
In your controller. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub pie_graph : Local { |
|
26
|
|
|
|
|
|
|
my @fields = qw(Jan Feb Mar); |
|
27
|
|
|
|
|
|
|
my @data_sales_02 = qw(12 45 21); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$c->svgttg->create('Pie', |
|
30
|
|
|
|
|
|
|
{'height' => '500', |
|
31
|
|
|
|
|
|
|
'width' => '300', |
|
32
|
|
|
|
|
|
|
'fields' => \@fields, |
|
33
|
|
|
|
|
|
|
}); |
|
34
|
|
|
|
|
|
|
$c->svgttg->graph_obj->add_data({ |
|
35
|
|
|
|
|
|
|
'data' => \@data_sales_02, |
|
36
|
|
|
|
|
|
|
'title' => 'Sales 2002', |
|
37
|
|
|
|
|
|
|
}); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub end : Private { |
|
41
|
|
|
|
|
|
|
my ( $self, $c ) = @_; |
|
42
|
|
|
|
|
|
|
$c->forward($c->view('PNGTTGraph')); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
and see L<SVG::TT::Graph>. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Catalyst::View::PNGTTGraph is Catalyst PNG view handler of SVG::TT::Graph. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 METHODS |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 new |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This method makes method named $c->svgttg. |
|
58
|
|
|
|
|
|
|
$c->svgttg is an accessor to the object of Catalyst::View::SVGTTGraphObj. |
|
59
|
|
|
|
|
|
|
$c->svgttg uses $c->stash->{'Catalyst::View::SVGTTGraph'}. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#my $rsvg; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub new { |
|
66
|
|
|
|
|
|
|
my $class = shift; |
|
67
|
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
|
68
|
|
|
|
|
|
|
my $rsvg = new Image::LibRSVG(); |
|
69
|
|
|
|
|
|
|
$self->{rsvg} = $rsvg; |
|
70
|
|
|
|
|
|
|
return $self; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 process |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Create PNG Graph |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub process { |
|
80
|
|
|
|
|
|
|
my $self = shift; |
|
81
|
|
|
|
|
|
|
my $c = shift; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $go; |
|
84
|
|
|
|
|
|
|
die "Catalyst::View::PNGTTGraph : graph object is undefined !" |
|
85
|
|
|
|
|
|
|
unless($go = $c->svgttg->graph_obj); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
$go->compress(0) if ( $go->VERSION >= 0.13 ); |
|
88
|
|
|
|
|
|
|
my $svg_graph = $c->svgttg->burn; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $rsvg = $self->{rsvg}; |
|
91
|
|
|
|
|
|
|
$rsvg->loadImageFromString($svg_graph); |
|
92
|
|
|
|
|
|
|
my $png_graph = $rsvg->getImageBitmap('png'); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
$c->res->header('Content-Type' => 'image/png'); |
|
95
|
|
|
|
|
|
|
$c->res->body($png_graph); |
|
96
|
|
|
|
|
|
|
return 1; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L<Catalyst::View::SVGTTGraph>, L<SVG::TT::Graph> |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHORS |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Terence Monteiro, C<terencemo@cpan.org> |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Copyright (c) by DeepRoot Linux Pvt Ltd. L<http://deeproot.co.in> |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
112
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |