Attachment 'moinmoin_stats.patch'

Download

   1 Only in stats.old: chart.py
   2 diff -x '*.pyc' -u stats.old/hitcounts.py stats/hitcounts.py
   3 --- stats.old/hitcounts.py	2009-05-28 09:45:06.000000000 +0200
   4 +++ stats/hitcounts.py	2009-05-28 16:11:58.000000000 +0200
   5 @@ -194,7 +194,7 @@
   6  
   7  def draw(pagename, request):
   8      import shutil, cStringIO
   9 -    from MoinMoin.stats.chart import Chart, ChartData, Color
  10 +    import gdchart
  11  
  12      _ = request.getText
  13  
  14 @@ -219,9 +219,12 @@
  15  
  16      # create image
  17      image = cStringIO.StringIO()
  18 -    c = Chart()
  19 -    c.addData(ChartData(views, color='green'))
  20 -    c.addData(ChartData(edits, color='red'))
  21 +    c = gdchart.Line()
  22 +    c.bg_color= 0xffffff
  23 +    c.line_color = 0x000000
  24 +
  25 +    c.setData((views),(edits))
  26 +    c.ext_color=['green']*len(views) + ['red']*len(edits)
  27      chart_title = ''
  28      if request.cfg.sitename:
  29          chart_title = "%s: " % request.cfg.sitename
  30 @@ -231,26 +234,24 @@
  31              'chart_title': chart_title,
  32              'filterpage': filterpage,
  33          }
  34 -    chart_title = "%s\n%sx%d" % (chart_title, _("green=view\nred=edit"), scalefactor)
  35 -    c.option(
  36 -        title=chart_title.encode('iso-8859-1', 'replace'), # gdchart can't do utf-8
  37 -        xtitle=(_('date') + ' (Server)').encode('iso-8859-1', 'replace'),
  38 -        ytitle=_('# of hits').encode('iso-8859-1', 'replace'),
  39 -        title_font=c.GDC_GIANT,
  40 -        #thumblabel = 'THUMB', thumbnail = 1, thumbval = 10,
  41 -        #ytitle_color = Color('green'),
  42 -        #yaxis2 = 1,
  43 -        #ytitle2 = '# of edits',
  44 -        #ytitle2_color = Color('red'),
  45 -        #ylabel2_color = Color('black'),
  46 -        #interpolations = 0,
  47 -        threed_depth=1.0,
  48 -        requested_yinterval=1.0,
  49 -        stack_type=c.GDC_STACK_BESIDE
  50 -    )
  51 -    c.draw(c.GDC_LINE,
  52 -        (request.cfg.chart_options['width'], request.cfg.chart_options['height']),
  53 -        image, days)
  54 +    chart_title = "%s\n%s x %d" % (chart_title, _("green=view\nred=edit"), scalefactor)
  55 +    c.title=chart_title.encode('iso-8859-1', 'replace') # gdchart can't do utf-8
  56 +    c.xtitle=(_('date') + ' (Server)').encode('iso-8859-1', 'replace')
  57 +    c.ytitle=_('# of hits').encode('iso-8859-1', 'replace')
  58 +    c.title_font_size='GIANT'
  59 +    c.threeD_depth=1.0
  60 +    c.requested_yinterval=1.0
  61 +    c.stack_type='BESIDE'
  62 +    c.width=request.cfg.chart_options['width']
  63 +    c.height=request.cfg.chart_options['height']
  64 +    c.setLabels(days)
  65 +
  66 +    import tempfile
  67 +    f = tempfile.NamedTemporaryFile(suffix=".gif")
  68 +    c.draw(f.file)
  69 +    f.file.seek(0)
  70 +    image.write(f.file.read())
  71 +    f.close()
  72  
  73      headers = [
  74          "Content-Type: image/gif",
  75 diff -x '*.pyc' -u stats.old/pagesize.py stats/pagesize.py
  76 --- stats.old/pagesize.py	2009-05-28 09:45:06.000000000 +0200
  77 +++ stats/pagesize.py	2009-05-28 16:08:31.000000000 +0200
  78 @@ -51,10 +51,10 @@
  79  
  80  def draw(pagename, request):
  81      import bisect, shutil, cStringIO
  82 -    from MoinMoin.stats.chart import Chart, ChartData, Color
  83 +    import gdchart
  84 +    from MoinMoin.util.web import Color
  85  
  86      _ = request.getText
  87 -    style = Chart.GDC_3DBAR
  88  
  89      # get data
  90      pages = request.rootpage.getPageDict()
  91 @@ -72,11 +72,11 @@
  92      if upper_bound >= 65536:
  93          bounds.extend([s*65536 for s in range(2, 9)])
  94  
  95 -    data = [None] * len(bounds)
  96 +    data = [0] * len(bounds)
  97      for size, name in sizes:
  98          idx = bisect.bisect(bounds, size)
  99          ##idx = int((size / upper_bound) * classes)
 100 -        data[idx] = (data[idx] or 0) + 1
 101 +        data[idx] = data[idx] + 1
 102  
 103      labels = ["%d" % b for b in bounds]
 104  
 105 @@ -87,31 +87,35 @@
 106  
 107      # create image
 108      image = cStringIO.StringIO()
 109 -    c = Chart()
 110 -    ##c.addData(ChartData(data, 'magenta'))
 111 -    c.addData(ChartData(_slice(data, 0, 7), 'blue'))
 112 -    if upper_bound >= 1024:
 113 -        c.addData(ChartData(_slice(data, 7, 14), 'green'))
 114 -    if upper_bound >= 8192:
 115 -        c.addData(ChartData(_slice(data, 14, 21), 'red'))
 116 -    if upper_bound >= 65536:
 117 -        c.addData(ChartData(_slice(data, 21, 28), 'magenta'))
 118 +    c = gdchart.Bar3D()
 119 +    c.bg_color= 0xffffff
 120 +    c.line_color = 0x000000
 121 +
 122 +    c.setData(data)
 123 +    c.ext_color= []
 124 +    for x in ['blue', 'green', 'red', 'magenta']:
 125 +        c.ext_color = c.ext_color + [ Color(x) ] * 8
 126      title = ''
 127      if request.cfg.sitename: title = "%s: " % request.cfg.sitename
 128 -    title = title + _('Page Size Distribution')
 129 -    c.option(
 130 -        annotation=(bisect.bisect(bounds, upper_bound), Color('black'), "%d %s" % sizes[-1]),
 131 -        title=title.encode('iso-8859-1', 'replace'), # gdchart can't do utf-8
 132 -        xtitle=_('page size upper bound [bytes]').encode('iso-8859-1', 'replace'),
 133 -        ytitle=_('# of pages of this size').encode('iso-8859-1', 'replace'),
 134 -        title_font=c.GDC_GIANT,
 135 -        threed_depth=2.0,
 136 -        requested_yinterval=1.0,
 137 -        stack_type=c.GDC_STACK_LAYER,
 138 -    )
 139 -    c.draw(style,
 140 -        (request.cfg.chart_options['width'], request.cfg.chart_options['height']),
 141 -        image, labels)
 142 +    c.title = title.encode('iso-8859-1','replace') + _('Page Size Distribution').encode('iso-8859-1', 'replace')
 143 +    c.width=request.cfg.chart_options['width']
 144 +    c.height=request.cfg.chart_options['height']
 145 +    c.xtitle=_('page size upper bound [bytes]').encode('iso-8859-1', 'replace')
 146 +    c.ytitle=_('# of pages of this size').encode('iso-8859-1', 'replace')
 147 +    #c.annotate(point=bisect.bisect(bounds, upper_bound), color='black', note="%d %s" % sizes[-1])
 148 +    c.title_font_size="GIANT"
 149 +    c.stack_type="LAYER"
 150 +    c.threeD_depth=2.0
 151 +    c.requested_yinterval=1.0
 152 +    c.setLabels(labels)
 153 +
 154 +    import tempfile
 155 +    f = tempfile.NamedTemporaryFile(suffix=".gif")
 156 +    c.draw(f.file)
 157 +    f.file.seek(0)
 158 +    image.write(f.file.read())
 159 +    f.close()
 160 +
 161  
 162      headers = [
 163          "Content-Type: image/gif",
 164 diff -x '*.pyc' -u stats.old/useragents.py stats/useragents.py
 165 --- stats.old/useragents.py	2009-05-28 09:45:06.000000000 +0200
 166 +++ stats/useragents.py	2009-05-28 16:11:41.000000000 +0200
 167 @@ -120,12 +120,11 @@
 168  
 169  def draw(pagename, request):
 170      import shutil, cStringIO
 171 -    from MoinMoin.stats.chart import Chart, ChartData, Color
 172 +    import gdchart
 173 +    from MoinMoin.util.web import Color
 174  
 175      _ = request.getText
 176  
 177 -    style = Chart.GDC_3DPIE
 178 -
 179      # get data
 180      colors = ['red', 'mediumblue', 'yellow', 'deeppink', 'aquamarine', 'purple', 'beige',
 181                'blue', 'forestgreen', 'orange', 'cyan', 'fuchsia', 'lime']
 182 @@ -152,26 +151,34 @@
 183  
 184      # create image
 185      image = cStringIO.StringIO()
 186 -    c = Chart()
 187 -    c.addData(data)
 188 +    c = gdchart.Pie3D()
 189 +    c.bg_color= 0xffffff
 190 +    c.line_color = 0x000000
 191 +    c.setData(*data)
 192  
 193      title = ''
 194      if request.cfg.sitename: title = "%s: " % request.cfg.sitename
 195      title = title + _('Distribution of User-Agent Types')
 196 -    c.option(
 197 -        pie_color=colors,
 198 -        label_font=Chart.GDC_SMALL,
 199 -        label_line=1,
 200 -        label_dist=20,
 201 -        threed_depth=20,
 202 -        threed_angle=225,
 203 -        percent_labels=Chart.GDCPIE_PCT_RIGHT,
 204 -        title_font=c.GDC_GIANT,
 205 -        title=title.encode('iso-8859-1', 'replace')) # gdchart can't do utf-8
 206 +    c.color=colors
 207 +    c.label_font_size=0 #'SMALL'
 208 +    c.label_line=1
 209 +    c.label_dist=20
 210 +    c.threeD_depth=20
 211 +    c.threeD_angle=225
 212 +    c.percent_labels='RIGHT'
 213 +    c.title_font_size=2 #"GIANT"
 214 +    c.title=title.encode('iso-8859-1', 'replace') # gdchart can't do utf-8
 215      labels = [label.encode('iso-8859-1', 'replace') for label in labels]
 216 -    c.draw(style,
 217 -        (request.cfg.chart_options['width'], request.cfg.chart_options['height']),
 218 -        image, labels)
 219 +    c.setLabels( labels )
 220 +    c.width = request.cfg.chart_options['width']
 221 +    c.height = request.cfg.chart_options['height']
 222 +
 223 +    import tempfile
 224 +    f = tempfile.NamedTemporaryFile(suffix=".gif")
 225 +    c.draw(f.file)
 226 +    f.file.seek(0)
 227 +    image.write(f.file.read())
 228 +    f.close()
 229  
 230      headers = [
 231          "Content-Type: image/gif",

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-05-28 14:27:56, 7.8 KB) [[attachment:moinmoin_stats.patch]]
  • [get | view] (2009-05-28 19:15:14, 107.4 KB) [[attachment:python-gdchart2-doc.tgz]]
  • [get | view] (2009-05-28 19:17:48, 12.4 KB) [[attachment:stats.tgz]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.