Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAgustin Zubiaga <aguz@sugarlabs.org>2012-07-02 00:42:05 (GMT)
committer Agustin Zubiaga <aguz@sugarlabs.org>2012-07-02 00:42:05 (GMT)
commit1a133902641f5e81425fe330877f0c2b2c9fc17a (patch)
tree453bade1c6d60d0544955412a5ecd1102bbaf22c
parent02a15b015a905ec2f3329a2935114502a4c08711 (diff)
Using sugar-pycha
-rw-r--r--sugar-pycha/__init__.py (renamed from pycha/__init__.py)0
-rw-r--r--sugar-pycha/bar.py (renamed from pycha/bar.py)9
-rw-r--r--sugar-pycha/chart.py (renamed from pycha/chart.py)24
-rw-r--r--sugar-pycha/color.py (renamed from pycha/color.py)6
-rw-r--r--sugar-pycha/line.py (renamed from pycha/line.py)1
-rw-r--r--sugar-pycha/pie.py (renamed from pycha/pie.py)22
-rw-r--r--sugar-pycha/polygonal.py (renamed from pycha/polygonal.py)0
-rw-r--r--sugar-pycha/radial.py (renamed from pycha/radial.py)0
-rw-r--r--sugar-pycha/scatter.py (renamed from pycha/scatter.py)0
-rw-r--r--sugar-pycha/stackedbar.py (renamed from pycha/stackedbar.py)4
-rw-r--r--sugar-pycha/utils.py (renamed from pycha/utils.py)1
11 files changed, 33 insertions, 34 deletions
diff --git a/pycha/__init__.py b/sugar-pycha/__init__.py
index 35bba09..35bba09 100644
--- a/pycha/__init__.py
+++ b/sugar-pycha/__init__.py
diff --git a/pycha/bar.py b/sugar-pycha/bar.py
index 8a3168a..ab0eeec 100644
--- a/pycha/bar.py
+++ b/sugar-pycha/bar.py
@@ -43,7 +43,7 @@ class BarChart(Chart):
if len(uniqx) == 1:
self.minxdelta = 1.0
else:
- self.minxdelta = min([abs(uniqx[j] - uniqx[j-1])
+ self.minxdelta = min([abs(uniqx[j] - uniqx[j - 1])
for j in range(1, len(uniqx))])
k = self.minxdelta * self.xscale
@@ -70,7 +70,7 @@ class BarChart(Chart):
h = self.layout.chart.h * bar.h
if (w < 1 or h < 1) and self.options.yvals.skipSmallValues:
- return # don't draw when the bar is too small
+ return # don't draw when the bar is too small
if self.options.stroke.shadow:
cx.set_source_rgba(0, 0, 0, 0.15)
@@ -132,7 +132,6 @@ class VerticalBarChart(BarChart):
xval, yval, yerr = item
else:
xval, yval = item
- yerr = 0.0
x = (((xval - self.minxval) * self.xscale)
+ self.barMargin + (i * self.barWidthForSet))
@@ -154,7 +153,7 @@ class VerticalBarChart(BarChart):
self.xticks = [(tick[0] + offset, tick[1]) for tick in self.xticks]
def _getShadowRectangle(self, x, y, w, h):
- return (x-2, y-2, w+4, h+2)
+ return (x - 2, y - 2, w + 4, h + 2)
def _renderYVal(self, cx, label, labelW, labelH, barX, barY, barW, barH):
x = barX + (barW / 2.0) - (labelW / 2.0)
@@ -238,7 +237,7 @@ class HorizontalBarChart(BarChart):
self._renderLine(cx, tick, False)
def _getShadowRectangle(self, x, y, w, h):
- return (x, y-2, w+2, h+4)
+ return (x, y - 2, w + 2, h + 4)
def _renderXAxisLabel(self, cx, labelText):
labelText = self.options.axis.x.label
diff --git a/pycha/chart.py b/sugar-pycha/chart.py
index 5be11cd..c6a1c34 100644
--- a/pycha/chart.py
+++ b/sugar-pycha/chart.py
@@ -169,7 +169,7 @@ class Chart(object):
if x_range_is_defined:
self.minxval, self.maxxval = self.options.axis.x.range
else:
- xdata = [pair[0] for pair in reduce(lambda a, b: a+b, stores)]
+ xdata = [pair[0] for pair in reduce(lambda a, b: a + b, stores)]
self.minxval = float(min(xdata))
self.maxxval = float(max(xdata))
if self.minxval * self.maxxval > 0 and self.minxval > 0:
@@ -185,7 +185,7 @@ class Chart(object):
if y_range_is_defined:
self.minyval, self.maxyval = self.options.axis.y.range
else:
- ydata = [pair[1] for pair in reduce(lambda a, b: a+b, stores)]
+ ydata = [pair[1] for pair in reduce(lambda a, b: a + b, stores)]
self.minyval = float(min(ydata))
self.maxyval = float(max(ydata))
if self.minyval * self.maxyval > 0 and self.minyval > 0:
@@ -197,7 +197,7 @@ class Chart(object):
else:
self.yscale = 1.0 / self.yrange
- if self.minyval * self.maxyval < 0: # different signs
+ if self.minyval * self.maxyval < 0: # different signs
self.origin = abs(self.minyval) * self.yscale
else:
self.origin = 0.0
@@ -651,14 +651,14 @@ class Layout(object):
self.chart = Area()
self._areas = (
- (self.title, (1, 126/255.0, 0)), # orange
- (self.y_label, (41/255.0, 91/255.0, 41/255.0)), # grey
- (self.x_label, (41/255.0, 91/255.0, 41/255.0)), # grey
- (self.y_tick_labels, (0, 115/255.0, 0)), # green
- (self.x_tick_labels, (0, 115/255.0, 0)), # green
- (self.y_ticks, (229/255.0, 241/255.0, 18/255.0)), # yellow
- (self.x_ticks, (229/255.0, 241/255.0, 18/255.0)), # yellow
- (self.chart, (75/255.0, 75/255.0, 1.0)), # blue
+ (self.title, (1, 126 / 255.0, 0)), # orange
+ (self.y_label, (41 / 255.0, 91 / 255.0, 41 / 255.0)), # grey
+ (self.x_label, (41 / 255.0, 91 / 255.0, 41 / 255.0)), # grey
+ (self.y_tick_labels, (0, 115 / 255.0, 0)), # green
+ (self.x_tick_labels, (0, 115 / 255.0, 0)), # green
+ (self.y_ticks, (229 / 255.0, 241 / 255.0, 18 / 255.0)), # yellow
+ (self.x_ticks, (229 / 255.0, 241 / 255.0, 18 / 255.0)), # yellow
+ (self.chart, (75 / 255.0, 75 / 255.0, 1.0)), # blue
)
def update(self, cx, options, width, height, xticks, yticks):
@@ -758,7 +758,7 @@ class Layout(object):
if not axis.hide:
extents = [cx.text_extents(safe_unicode(
tick[1], options.encoding,
- ))[2:4] # get width and height as a tuple
+ ))[2:4] # get width and height as a tuple
for tick in ticks]
if extents:
widths, heights = zip(*extents)
diff --git a/pycha/color.py b/sugar-pycha/color.py
index b01e0e1..82b436f 100644
--- a/pycha/color.py
+++ b/sugar-pycha/color.py
@@ -36,9 +36,9 @@ def hex2rgb(hexstring, digits=2):
return hexstring
top = float(int(digits * 'f', 16))
- r = int(hexstring[1:digits+1], 16)
- g = int(hexstring[digits+1:digits*2+1], 16)
- b = int(hexstring[digits*2+1:digits*3+1], 16)
+ r = int(hexstring[1:digits + 1], 16)
+ g = int(hexstring[digits + 1:digits * 2 + 1], 16)
+ b = int(hexstring[digits * 2 + 1:digits * 3 + 1], 16)
return r / top, g / top, b / top
diff --git a/pycha/line.py b/sugar-pycha/line.py
index 71116b1..9b12152 100644
--- a/pycha/line.py
+++ b/sugar-pycha/line.py
@@ -83,7 +83,6 @@ class LineChart(Chart):
cx.set_source_rgb(*self.colorScheme[storeName])
cx.stroke()
-
cx.save()
cx.set_line_width(self.options.stroke.width)
if self.options.shouldFill:
diff --git a/pycha/pie.py b/sugar-pycha/pie.py
index 9585c37..d7b3df2 100644
--- a/pycha/pie.py
+++ b/sugar-pycha/pie.py
@@ -55,19 +55,19 @@ class PieChart(Chart):
"""Evaluates pie ticks"""
self.xticks = []
if self.options.axis.x.ticks:
- lookup = dict([(slice.xval, slice) for slice in self.slices])
+ lookup = dict([(_slice.xval, _slice) for _slice in self.slices])
for tick in self.options.axis.x.ticks:
if not isinstance(tick, Option):
tick = Option(tick)
- slice = lookup.get(tick.v, None)
+ _slice = lookup.get(tick.v, None)
label = tick.label or str(tick.v)
- if slice is not None:
- label += ' (%.1f%%)' % (slice.fraction * 100)
+ if _slice is not None:
+ label += ' (%.1f%%)' % (_slice.fraction * 100)
self.xticks.append((tick.v, label))
else:
- for slice in self.slices:
- label = '%s (%.1f%%)' % (slice.name, slice.fraction * 100)
- self.xticks.append((slice.xval, label))
+ for _slice in self.slices:
+ label = '%s (%.1f%%)' % (_slice.name, _slice.fraction * 100)
+ self.xticks.append((_slice.xval, label))
def _renderLines(self, cx):
"""Aux function for _renderBackground"""
@@ -235,12 +235,12 @@ class PieLayout(Layout):
self.radius = min(self.chart.w / 2.0, self.chart.h / 2.0)
for tick in xticks:
- slice = lookup.get(tick[0], None)
+ _slice = lookup.get(tick[0], None)
width, height = get_text_extents(cx, tick[1],
options.axis.tickFont,
options.axis.tickFontSize,
options.encoding)
- angle = slice.getNormalisedAngle()
+ angle = _slice.getNormalisedAngle()
radius = self._get_min_radius(angle, centerx, centery,
width, height)
self.radius = min(self.radius, radius)
@@ -248,8 +248,8 @@ class PieLayout(Layout):
# Now that we now the radius we move the ticks as close as we can
# to the circle
for i, tick in enumerate(xticks):
- slice = lookup.get(tick[0], None)
- angle = slice.getNormalisedAngle()
+ _slice = lookup.get(tick[0], None)
+ angle = _slice.getNormalisedAngle()
self.ticks[i] = self._get_tick_position(self.radius, angle,
self.ticks[i],
centerx, centery)
diff --git a/pycha/polygonal.py b/sugar-pycha/polygonal.py
index b470c87..b470c87 100644
--- a/pycha/polygonal.py
+++ b/sugar-pycha/polygonal.py
diff --git a/pycha/radial.py b/sugar-pycha/radial.py
index 9055e26..9055e26 100644
--- a/pycha/radial.py
+++ b/sugar-pycha/radial.py
diff --git a/pycha/scatter.py b/sugar-pycha/scatter.py
index 27656de..27656de 100644
--- a/pycha/scatter.py
+++ b/sugar-pycha/scatter.py
diff --git a/pycha/stackedbar.py b/sugar-pycha/stackedbar.py
index 92fdc7f..a728e50 100644
--- a/pycha/stackedbar.py
+++ b/sugar-pycha/stackedbar.py
@@ -35,7 +35,7 @@ class StackedBarChart(BarChart):
# Fix the yscale as we accumulate the y values
stores = self._getDatasetsValues()
n_stores = len(stores)
- flat_y = [pair[1] for pair in reduce(lambda a, b: a+b, stores)]
+ flat_y = [pair[1] for pair in reduce(lambda a, b: a + b, stores)]
store_size = len(flat_y) / n_stores
accum = [sum(flat_y[j]for j in xrange(i,
i + store_size * n_stores,
@@ -55,7 +55,7 @@ class StackedBarChart(BarChart):
if len(uniqx) == 1:
self.minxdelta = 1.0
else:
- self.minxdelta = min([abs(uniqx[j] - uniqx[j-1])
+ self.minxdelta = min([abs(uniqx[j] - uniqx[j - 1])
for j in range(1, len(uniqx))])
k = self.minxdelta * self.xscale
diff --git a/pycha/utils.py b/sugar-pycha/utils.py
index aefc5b4..9e1b692 100644
--- a/pycha/utils.py
+++ b/sugar-pycha/utils.py
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with PyCha. If not, see <http://www.gnu.org/licenses/>.
+
def clamp(minValue, maxValue, value):
"""Make sure value is between minValue and maxValue"""
if value < minValue: