Mercurial > hg > rlgallery-misc
comparison py/stats2.py @ 39:a97a20571526
stats2.py: adjust x-axis scale for arogue5 score chart.
The range of scores is higher.
author | John "Elwin" Edwards |
---|---|
date | Fri, 10 Jan 2014 09:03:16 -0500 |
parents | d2c3c29ca4f9 |
children | 1ddd2d950e31 |
comparison
equal
deleted
inserted
replaced
38:d2c3c29ca4f9 | 39:a97a20571526 |
---|---|
79 scrq = "SELECT count(*) FROM {0} WHERE score >= %s AND score < %s;".format(game.uname) | 79 scrq = "SELECT count(*) FROM {0} WHERE score >= %s AND score < %s;".format(game.uname) |
80 xls = range(1, 16) | 80 xls = range(1, 16) |
81 scoreblocks = range(10) | 81 scoreblocks = range(10) |
82 xlcounts = [] | 82 xlcounts = [] |
83 scorecounts = [] | 83 scorecounts = [] |
84 if isinstance(game, rlgall.ARogueGame): | |
85 scorewidth = 1500 | |
86 else: | |
87 scorewidth = 1000 | |
84 for xl in xls: | 88 for xl in xls: |
85 cur.execute(xlq, [xl]) | 89 cur.execute(xlq, [xl]) |
86 xlcounts.append(cur.fetchone()[0]) | 90 xlcounts.append(cur.fetchone()[0]) |
87 for sn in scoreblocks: | 91 for sn in scoreblocks: |
88 lscore = sn * 1000 | 92 lscore = sn * scorewidth |
89 if sn == 9: | 93 if sn == 9: |
90 hscore = 32000 | 94 hscore = scorewidth * 32 |
91 else: | 95 else: |
92 hscore = (sn + 1) * 1000 | 96 hscore = (sn + 1) * scorewidth |
93 cur.execute(scrq, (lscore, hscore)) | 97 cur.execute(scrq, (lscore, hscore)) |
94 scorecounts.append(cur.fetchone()[0]) | 98 scorecounts.append(cur.fetchone()[0]) |
95 xlgraph = open("{0}/xl-{1}.svg".format(svgpath, game.uname), "w") | 99 xlgraph = open("{0}/xl-{1}.svg".format(svgpath, game.uname), "w") |
96 scoregraph = open("{0}/score-{1}.svg".format(svgpath, game.uname), "w") | 100 scoregraph = open("{0}/score-{1}.svg".format(svgpath, game.uname), "w") |
97 xlgraph.write(dochead) | 101 xlgraph.write(dochead) |
119 for block, count in zip(scoreblocks, scorecounts): | 123 for block, count in zip(scoreblocks, scorecounts): |
120 barx = block * 75 + 100 | 124 barx = block * 75 + 100 |
121 barh = round(scale * count) | 125 barh = round(scale * count) |
122 bary = 550 - barh | 126 bary = 550 - barh |
123 scoregraph.write(barstr.format(75, barh, barx, bary)) | 127 scoregraph.write(barstr.format(75, barh, barx, bary)) |
124 scoregraph.write(xllabel.format(barx, block * 1000)) | 128 scoregraph.write(xllabel.format(barx, block * scorewidth)) |
125 for yl in range(scoredivs + 1): | 129 for yl in range(scoredivs + 1): |
126 labeln = int(scoremax * yl / scoredivs) | 130 labeln = int(scoremax * yl / scoredivs) |
127 labelh = 550 + 8 - 500 * yl / scoredivs | 131 labelh = 550 + 8 - 500 * yl / scoredivs |
128 scoregraph.write(ylabel.format(labelh, labeln)) | 132 scoregraph.write(ylabel.format(labelh, labeln)) |
129 | 133 |