Skip to content

Instantly share code, notes, and snippets.

@matael
Created July 15, 2012 13:06
Show Gist options
  • Select an option

  • Save matael/3116824 to your computer and use it in GitHub Desktop.

Select an option

Save matael/3116824 to your computer and use it in GitHub Desktop.
Graphe adhésions pp

Graphe d'évolution des adhésions

Modules requis

  • SVG::TT::Graph
  • IO::File

Config

Tout le fichier graph.pl peut être utile pour la config.

Le fichier auto.sh contient l'url du fichier de données.

License et Copie

Auteur
Mathieu (matael) Gaborit <mathieu@matael.org>
Date
July 2012
License
WTFPL

Aucune garantie de fonctionnement assurée

#!/bin/bash
# File: auto.sh
# Author: Mathieu (matael) Gaborit <mathieu@matael.org>
# Date: July 2012
# License: WTFPL
url=http://partipirate.org/include/stat-mises_a_jour-date-nbadh.csv
curl -s $url | perl graph.pl
#!/usr/bin/env perl
# Create a graph to show subscription progress over time.
# File: graph.pl
# Author: Mathieu (matael) Gaborit <mathieu@matael.org>
# Date: July 2012
# License: WTFPL
use strict;
use warnings;
use SVG::TT::Graph::TimeSeries;
use IO::File;
my @plot_data;
my $date;
my $nb;
while (<STDIN>) {
($date, $nb) = split /;/;
push @plot_data, $date;
push @plot_data, $nb;
}
my $graph = SVG::TT::Graph::TimeSeries->new({
height => 500,
width => 800,
show_y_title => 1,
y_title => "Nombre d'adhérents",
show_x_title => 1,
x_title => "Date",
x_label_formatter => sub {($_) = shift; my ($label) = split / /; return $label},
show_data_values => 0,
rollover_values => 1,
area_fill => 1,
show_graph_title => 1,
graph_title => "Evolution du nombre d'adhésions",
show_graph_subtitle => 1,
graph_subtitle => "Données du PPfr"
});
$graph->add_data({
'data' => \@plot_data,
'title'=> "Nombre d'adhésions"
});
my $file = IO::File->new("pp_adhe.svg", 'w');
$file->print($graph->burn());
$file->close();
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment