Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://pyjamas.svn.sourceforge.net/svnroot/pyjamas/trunk@1486 7a2bd370-bda8-463c-979e-2900ccfb811e
- Loading branch information
lkcl
committed
Aug 29, 2009
1 parent
99b4d3d
commit b8dc2ac
Showing
7 changed files
with
105 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import math | ||
|
||
from pyjamas.chart.GChart import GChart | ||
from pyjamas.chart import GChartUtil | ||
|
||
# GWT 1.4's Math class does not include JDK's | ||
# Math.log10--so emulate it. | ||
def log10(x): | ||
return math.log(x)/math.log(10.0) | ||
|
||
"""* | ||
* Defines a traditional "semi-log" chart by using custom | ||
* ticks on the y axis, in conjunction with log-transformed | ||
* y data. | ||
""" | ||
class GChartExample04(GChart): | ||
def __init__(self): | ||
GChart.__init__(self, 300, 450) | ||
self.setChartTitle("<h2>2<sup>x</sup> vs x</h2>") | ||
self.addCurve() | ||
self.getCurve().getSymbol().setHovertextTemplate( | ||
GChartUtil.formatAsHovertext("${y}=2^${x}")) | ||
self.getCurve().setLegendLabel("<b>2<sup>x</sup></b>") | ||
self.getCurve().getSymbol().setBackgroundColor("red") | ||
self.getCurve().getSymbol().setBorderColor("black") | ||
self.getCurve().getSymbol().setWidth(9) | ||
self.getCurve().getSymbol().setHeight(9) | ||
|
||
# add (log10-transformed) powers of 2 from 1/4 to 8 | ||
for i in range(-2, 4): | ||
self.getCurve().addPoint(i,log10(math.pow(2,i))) | ||
|
||
# GChart's "=10^" NumberFormat prefix inverts the log10 | ||
# transform | ||
self.getYAxis().setTickLabelFormat("=10^#.##") | ||
# add conventional log-scaled ticks from .1 to 10 | ||
self.getYAxis().addTick(log10(0.1)) | ||
x = 0.1 | ||
while x < 10: | ||
for y in range(2, 11): | ||
self.getYAxis().addTick(log10(x*y)) | ||
x *= 10 | ||
|
||
self.getXAxis().setAxisLabel("<b>x</b>") | ||
self.getXAxis().setHasGridlines(True) | ||
self.getXAxis().setTickCount(6) | ||
|
||
self.getYAxis().setAxisLabel("<b>2<sup>x</sup></b>") | ||
self.getYAxis().setHasGridlines(True) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
def getDocumentRoot(): | ||
# Safari does not implement $doc.compatMode. | ||
# Use a CSS test to determine rendering mode. | ||
JS(""" | ||
var elem = $doc.createElement('div'); | ||
elem.style.cssText = "width:0px;width:1"; | ||
return parseInt(elem.style.width) != 1 ? $doc.documentElement : | ||
$doc.body; | ||
""") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters