1 |
package Frey::CSS::Area; |
2 |
use Moose; |
3 |
|
4 |
extends 'Frey'; |
5 |
with 'Frey::Web'; |
6 |
|
7 |
=head1 DESCRIPTION |
8 |
|
9 |
CSS area graph based on example from L<http://www.khanate.co.uk/graph/> |
10 |
|
11 |
=cut |
12 |
|
13 |
has sponge => ( |
14 |
is => 'rw', |
15 |
isa => 'Sponge', |
16 |
required => 1, |
17 |
); |
18 |
|
19 |
sub as_markup { |
20 |
my ($self) = @_; |
21 |
|
22 |
$self->add_css( 'static/Frey/CSS/Area.css' ); |
23 |
$self->add_js ( 'static/Frey/CSS/Area.js' ); |
24 |
|
25 |
my $html |
26 |
= qq|<ul class="graph" onclick="gr.makeGraphs(); return false;">| |
27 |
. join("\n", |
28 |
map { |
29 |
my ( $val, $name ) = ( $_->[0], $_->[1] ); |
30 |
die "first column data isn't numeric ", $self->dump( $_ ) unless $val =~ m{^\d+$}; |
31 |
qq|<li><span class="name">$name</span> <span class="val">$val</span></li>|; |
32 |
} @{ $self->sponge->{rows} } |
33 |
) |
34 |
. qq|</ul>| |
35 |
; |
36 |
|
37 |
$html .= qq| |
38 |
<br style="clear:both" /> |
39 |
<div class="note"> |
40 |
Click on the table or graph to switch view |
41 |
</div> |
42 |
|; |
43 |
|
44 |
return $html; |
45 |
} |
46 |
|
47 |
__PACKAGE__->meta->make_immutable; |
48 |
no Moose; |
49 |
|
50 |
1; |