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