3 The inspiration came from Brandon Byrd in the form of the topic
4 I<looking at CPAN's Health from a macro-level>
6 And then I said: the most interesting graph we came up with would be a
7 (x-axis: time, y-axis: number of pass/fail/unknown/na(stacked)). Let
8 me try. And this is the result.
10 I used the data I gather from log.txt on analysis and this explains
11 the interval of the chart: I have these data quickly accessible.
17 use Chart
::Clicker
::Axis
::DateTime
;
18 use Chart
::Clicker
::Data
::Series
;
19 use Chart
::Clicker
::Data
::DataSet
;
20 use DateTime
::Format
::Strptime
;
21 use Chart
::Clicker
::Renderer
::StackedArea
;
24 my $chart = Chart
::Clicker
->new(width
=> 650, height
=> 400);
27 $yfile =~ s/.pl$/.yaml/;
29 my $y = YAML
::Syck
::LoadFile
$yfile;
30 my @X = sort keys %$y;
32 my $strp = DateTime
::Format
::Strptime
->new
34 pattern
=> '%Y-%m-%d',
40 my $dt = $strp->parse_datetime($_);
45 for my $state (qw(pass/10 fail unknown na)) {
47 if ($state =~ m!(.+)/(\d+)!) {
48 my($statename,$divisor) = ($1,$2);
49 @v = map {$y->{$_}{$statename}/$divisor} @X;
51 @v = map {$y->{$_}{$state}} @X;
53 push @series, Chart
::Clicker
::Data
::Series
->new
61 my $dataset = Chart
::Clicker
::Data
::DataSet
->new
66 # add the dataset to the chart
67 $chart->add_to_datasets($dataset);
68 my $def = $chart->get_context('default');
69 my $dtaxis = Chart
::Clicker
::Axis
::DateTime
->new
73 orientation
=> 'horizontal'
75 $def->domain_axis($dtaxis);
76 my $yaxis = Chart
::Clicker
::Axis
->new
80 orientation
=> 'vertical',
81 range
=> Chart
::Clicker
::Data
::Range
->new
87 $def->range_axis($yaxis);
89 my $title = "cpan health check";
90 $chart->title->text($title);
91 $chart->legend->visible(1);
92 # $chart->title->font->size(20);
94 # 1351728000,1354320000,1356998400
95 $def->domain_axis->tick_values([$Xepoch[0],grep {
96 my $dt = DateTime
->from_epoch(epoch
=> $_);
100 my $area = Chart
::Clicker
::Renderer
::StackedArea
->new(opacity
=> .6);
101 $area->brush->width(3);
102 $def->renderer($area);
103 $def->renderer->additive(1);
105 # write the chart to a file
107 $png =~ s/\.pl$/.png/;
108 $chart->write_output($png);