]> Pileus Git - ~andy/fetchmail/blob - growthplot
1cf0de8360811545b5594212591ccb130cb70ddc
[~andy/fetchmail] / growthplot
1 #!/bin/sh
2 #
3 # growthplot -- plot the fetchmail project's growth as a function of time
4 #
5
6 # Get data from the NEWS file
7 timeseries >/tmp/growthplot$$
8 grep "^[0-9]" /tmp/growthplot$$ >/tmp/growthnumbers$$
9 grep "^[0-9.]*.[05].0   " /tmp/growthplot$$ >/tmp/growthmajors$$
10 sed '/^4.2.9/,$d' </tmp/growthnumbers$$ >/tmp/growthannounce$$
11
12 # gnuplot line styles.  These occasionally change (like beteween 3.5 and 3.7);
13 # use "echo "set terminal png color; test" | gnuplot | display - to check.
14 blue_boxes=3
15 green_crosses=2
16 cyan_diamonds=37        # Once purple triangles, but we can't do that anymore
17 brown_triangles=23
18
19 cat >/tmp/growthimage$$ <<EOF
20 set title "Fetchmail project growth history"
21 set xlabel 'Days since baseline'
22 set ylabel 'Participants'
23 set y2label 'Lines of code'
24 set ytics nomirror
25 set y2tics
26 set tics out
27 set autoscale y
28 set y2range [5000:50000]
29 set key bottom right box
30 set terminal png color
31
32 EOF
33
34 # OK, now write the event labels
35 (
36         count=0
37         lastday=0
38         breakheight=510
39         while read version legend
40         do
41                 if [ "$version" = '%' ]
42                 then
43                         echo "# Associate $lastday to '$legend'"
44                         count=$((count+1))
45                         lastday=$(($lastday-5))
46                         endy=$((breakheight+50+count*50))
47                         if ((endy>lasttotal))
48                         then
49                             # Label over curve hanging right, arrow down
50                             arrowhead=$((lasttotal+50))
51                             echo "set label '$legend' at $lastday-10, $endy+15"
52                         else
53                             # Label under curve hanging left, arrow up
54                             arrowhead=$((lasttotal-5))
55                             strlen=`python -c "print len('$legend')"`
56                             lablen=$((strlen*22))
57                             echo "set label '$legend' at $lastday-$lablen+10, $endy-15"
58                         fi
59                         echo set arrow \
60                                 from $lastday, $endy \
61                                 to $lastday, $arrowhead \
62                                 head
63                 else
64                         set -- $legend
65                         size=$1 
66                         friends=$2
67                         announce=$3
68                         total=$4
69                         days=$5 
70                         date=$6
71                         lastday=$days
72                         lasttotal=$total
73                 fi
74         done
75 ) </tmp/growthplot$$ >>/tmp/growthimage$$ 
76
77 # OK, now write the major-release labels
78 (
79         while read version size friends announce total days date
80         do
81             echo "set arrow from $days, $total - 55 to $days, $total - 15 head"
82             echo "set label '$version' at $days - 5, $total - 65"
83         done
84 ) </tmp/growthmajors$$ >>/tmp/growthimage$$ 
85
86 cat >>/tmp/growthimage$$ <<EOF
87 plot [] [0:] '/tmp/growthnumbers$$' using 6:5 \
88                 title "Both lists" with points $blue_boxes, \
89      '/tmp/growthannounce$$' using 6:4 \
90                 title "fetchmail-announce" with points $cyan_diamonds, \
91      '/tmp/growthannounce$$' using 6:3 \
92                 title "fetchmail-friends" with points $green_crosses, \
93      '/tmp/growthnumbers$$' using 6:2 axes x1y2 \
94                 title "Lines of code" with points $brown_triangles
95 EOF
96
97 gnuplot /tmp/growthimage$$ >growth.png
98
99 rm -f /tmp/growth*
100
101 # growthplot ends here
102
103
104
105
106
107
108