Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 55 lines (42 sloc) 1.762 kb
b8dc2ac more gchart update
lkcl authored
1 import math
2
3 from pyjamas.chart.GChart import GChart
82a85cf more gchart update
lkcl authored
4 from pyjamas.chart.HovertextChunk import formatAsHovertext
5
b8dc2ac more gchart update
lkcl authored
6
7 # GWT 1.4's Math class does not include JDK's
8 # Math.log10--so emulate it.
9 def log10(x):
10 return math.log(x)/math.log(10.0)
11
12 """*
13 * Defines a traditional "semi-log" chart by using custom
14 * ticks on the y axis, in conjunction with log-transformed
15 * y data.
16 """
17 class GChartExample04(GChart):
18 def __init__(self):
b8801a7 more gchart update
lkcl authored
19 GChart.__init__(self, XChartSize=300, YChartSize=450)
b8dc2ac more gchart update
lkcl authored
20 self.setChartTitle("<h2>2<sup>x</sup> vs x</h2>")
21 self.addCurve()
22 self.getCurve().getSymbol().setHovertextTemplate(
82a85cf more gchart update
lkcl authored
23 formatAsHovertext("${y}=2^${x}"))
b8dc2ac more gchart update
lkcl authored
24 self.getCurve().setLegendLabel("<b>2<sup>x</sup></b>")
25 self.getCurve().getSymbol().setBackgroundColor("red")
26 self.getCurve().getSymbol().setBorderColor("black")
27 self.getCurve().getSymbol().setWidth(9)
28 self.getCurve().getSymbol().setHeight(9)
64eff55 @xtfxme find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
29
b8dc2ac more gchart update
lkcl authored
30 # add (log10-transformed) powers of 2 from 1/4 to 8
31 for i in range(-2, 4):
32 self.getCurve().addPoint(i,log10(math.pow(2,i)))
64eff55 @xtfxme find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
33
b8dc2ac more gchart update
lkcl authored
34 # GChart's "=10^" NumberFormat prefix inverts the log10
35 # transform
36 self.getYAxis().setTickLabelFormat("=10^#.##")
37 # add conventional log-scaled ticks from .1 to 10
38 self.getYAxis().addTick(log10(0.1))
39 x = 0.1
40 while x < 10:
41 for y in range(2, 11):
42 self.getYAxis().addTick(log10(x*y))
43 x *= 10
64eff55 @xtfxme find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
44
b8dc2ac more gchart update
lkcl authored
45 self.getXAxis().setAxisLabel("<b>x</b>")
46 self.getXAxis().setHasGridlines(True)
47 self.getXAxis().setTickCount(6)
64eff55 @xtfxme find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
48
b8dc2ac more gchart update
lkcl authored
49 self.getYAxis().setAxisLabel("<b>2<sup>x</sup></b>")
50 self.getYAxis().setHasGridlines(True)
64eff55 @xtfxme find * -name '*.py' | xargs sed -i -r 's,\s+$,,'
xtfxme authored
51
52
b8dc2ac more gchart update
lkcl authored
53
54
Something went wrong with that request. Please try again.