author | rgbecker |
Fri, 14 Jul 2006 09:25:10 +0000 | |
changeset 2660 | c147aff8edae |
parent 2511 | 83406bfe8569 |
child 2676 | 2142d5f874d8 |
permissions | -rw-r--r-- |
2332 | 1 |
#Copyright ReportLab Europe Ltd. 2000-2004 |
817 | 2 |
#see license.txt for license details |
2332 | 3 |
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/graphics/charts/barcharts.py |
1080 | 4 |
"""This module defines a variety of Bar Chart components. |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
5 |
|
834 | 6 |
The basic flavors are Side-by-side, available in horizontal and |
7 |
vertical versions. |
|
8 |
||
9 |
Stacked and percentile bar charts to follow... |
|
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
10 |
""" |
2332 | 11 |
__version__=''' $Id$ ''' |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
12 |
|
1028
9258a4d99201
Added sampleSymbol1() using shaded bars (experimental).
dinu_gherman
parents:
1019
diff
changeset
|
13 |
import string, copy |
835 | 14 |
from types import FunctionType, StringType |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
15 |
|
909
a5ee7d2bdb17
Extracted validator functions into lib.validators.
dinu_gherman
parents:
907
diff
changeset
|
16 |
from reportlab.lib import colors |
2426 | 17 |
from reportlab.lib.validators import isNumber, isColor, isColorOrNone, isString,\ |
2431
84617376d454
charts: minor adjustments to legends/swatches for pies/barcharts
rgbecker
parents:
2427
diff
changeset
|
18 |
isListOfStrings, SequenceOf, isBoolean, isNoneOrShape, isStringOrNone,\ |
2660 | 19 |
NoneOr, isListOfNumbersOrNone |
2431
84617376d454
charts: minor adjustments to legends/swatches for pies/barcharts
rgbecker
parents:
2427
diff
changeset
|
20 |
from reportlab.graphics.widgets.markers import uSymbol2Symbol, isSymbol |
1453 | 21 |
from reportlab.lib.formatters import Formatter |
1692 | 22 |
from reportlab.lib.attrmap import AttrMap, AttrMapValue |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
23 |
from reportlab.pdfbase.pdfmetrics import stringWidth |
918 | 24 |
from reportlab.graphics.widgetbase import Widget, TypedPropertyCollection, PropHolder |
1255
5af1802a7939
Added various minor tweaks to make useAbsolute easier
rgbecker
parents:
1251
diff
changeset
|
25 |
from reportlab.graphics.shapes import Line, Rect, Group, Drawing, NotImplementedError |
2431
84617376d454
charts: minor adjustments to legends/swatches for pies/barcharts
rgbecker
parents:
2427
diff
changeset
|
26 |
from reportlab.graphics.charts.axes import XCategoryAxis, YValueAxis, YCategoryAxis, XValueAxis |
1284 | 27 |
from reportlab.graphics.charts.textlabels import BarChartLabel, NA_Label, NoneOrInstanceOfNA_Label |
1692 | 28 |
from reportlab.graphics.charts.areas import PlotArea |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
29 |
|
918 | 30 |
class BarChartProperties(PropHolder): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
31 |
_attrMap = AttrMap( |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
32 |
strokeColor = AttrMapValue(isColorOrNone, desc='Color of the bar border.'), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
33 |
fillColor = AttrMapValue(isColorOrNone, desc='Color of the bar interior area.'), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
34 |
strokeWidth = AttrMapValue(isNumber, desc='Width of the bar border.'), |
2660 | 35 |
strokeDashArray = AttrMapValue(isListOfNumbersOrNone, desc='Dash array of a line.'), |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
36 |
symbol = AttrMapValue(None, desc='A widget to be used instead of a normal bar.'), |
2426 | 37 |
name = AttrMapValue(isString, desc='Text to be associated with a bar (eg seriesname)'), |
2432 | 38 |
swatchMarker = AttrMapValue(NoneOr(isSymbol), desc="None or makeMarker('Diamond') ..."), |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
39 |
) |
1081 | 40 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
41 |
def __init__(self): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
42 |
self.strokeColor = None |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
43 |
self.fillColor = colors.blue |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
44 |
self.strokeWidth = 0.5 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
45 |
self.symbol = None |
918 | 46 |
|
907 | 47 |
# Bar chart classes. |
1692 | 48 |
class BarChart(PlotArea): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
49 |
"Abstract base class, unusable by itself." |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
50 |
|
1692 | 51 |
_attrMap = AttrMap(BASE=PlotArea, |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
52 |
useAbsolute = AttrMapValue(isNumber, desc='Flag to use absolute spacing values.'), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
53 |
barWidth = AttrMapValue(isNumber, desc='The width of an individual bar.'), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
54 |
groupSpacing = AttrMapValue(isNumber, desc='Width between groups of bars.'), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
55 |
barSpacing = AttrMapValue(isNumber, desc='Width between individual bars.'), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
56 |
bars = AttrMapValue(None, desc='Handle of the individual bars.'), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
57 |
valueAxis = AttrMapValue(None, desc='Handle of the value axis.'), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
58 |
categoryAxis = AttrMapValue(None, desc='Handle of the category axis.'), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
59 |
data = AttrMapValue(None, desc='Data to be plotted, list of (lists of) numbers.'), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
60 |
barLabels = AttrMapValue(None, desc='Handle to the list of bar labels.'), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
61 |
barLabelFormat = AttrMapValue(None, desc='Formatting string or function used for bar labels.'), |
1790 | 62 |
barLabelCallOut = AttrMapValue(None, desc='Callout function(label)\nlabel._callOutInfo = (self,g,rowNo,colNo,x,y,width,height,x00,y00,x0,y0)'), |
1936 | 63 |
barLabelArray = AttrMapValue(None, desc='explicit array of bar label values, must match size of data if present.'), |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
64 |
reversePlotOrder = AttrMapValue(isBoolean, desc='If true, reverse common category plot order.'), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
65 |
naLabel = AttrMapValue(NoneOrInstanceOfNA_Label, desc='Label to use for N/A values.'), |
2147 | 66 |
annotations = AttrMapValue(None, desc='list of callables, will be called with self, xscale, yscale.'), |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
67 |
) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
68 |
|
2427
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
69 |
def makeSwatchSample(self, rowNo, x, y, width, height): |
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
70 |
baseStyle = self.bars |
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
71 |
styleIdx = rowNo % len(baseStyle) |
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
72 |
style = baseStyle[styleIdx] |
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
73 |
strokeColor = getattr(style, 'strokeColor', getattr(baseStyle,'strokeColor',None)) |
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
74 |
fillColor = getattr(style, 'fillColor', getattr(baseStyle,'fillColor',None)) |
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
75 |
strokeDashArray = getattr(style, 'strokeDashArray', getattr(baseStyle,'strokeDashArray',None)) |
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
76 |
strokeWidth = getattr(style, 'strokeWidth', getattr(style, 'strokeWidth',None)) |
2434 | 77 |
swatchMarker = getattr(style, 'swatchMarker', getattr(baseStyle, 'swatchMarker',None)) |
2431
84617376d454
charts: minor adjustments to legends/swatches for pies/barcharts
rgbecker
parents:
2427
diff
changeset
|
78 |
if swatchMarker: |
84617376d454
charts: minor adjustments to legends/swatches for pies/barcharts
rgbecker
parents:
2427
diff
changeset
|
79 |
return uSymbol2Symbol(swatchMarker,x+width/2.,y+height/2.,fillColor) |
2427
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
80 |
return Rect(x,y,width,height,strokeWidth=strokeWidth,strokeColor=strokeColor, |
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
81 |
strokeDashArray=strokeDashArray,fillColor=fillColor) |
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
82 |
|
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
83 |
def getSeriesName(self,i,default=None): |
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
84 |
'''return series name i or default''' |
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
85 |
return getattr(self.bars[i],'name',default) |
1de04210b407
charts: autolegending in place, legend now has boxAnchor
rgbecker
parents:
2426
diff
changeset
|
86 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
87 |
def __init__(self): |
2092 | 88 |
assert self.__class__.__name__ not in ('BarChart','BarChart3D'), 'Abstract Class %s Instantiated' % self.__class__.__name__ |
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
89 |
|
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
90 |
if self._flipXY: |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
91 |
self.categoryAxis = YCategoryAxis() |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
92 |
self.valueAxis = XValueAxis() |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
93 |
else: |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
94 |
self.categoryAxis = XCategoryAxis() |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
95 |
self.valueAxis = YValueAxis() |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
96 |
|
1692 | 97 |
PlotArea.__init__(self) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
98 |
self.barSpacing = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
99 |
self.reversePlotOrder = 0 |
1201 | 100 |
|
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
101 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
102 |
# this defines two series of 3 points. Just an example. |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
103 |
self.data = [(100,110,120,130), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
104 |
(70, 80, 85, 90)] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
105 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
106 |
# control bar spacing. is useAbsolute = 1 then |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
107 |
# the next parameters are in points; otherwise |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
108 |
# they are 'proportions' and are normalized to |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
109 |
# fit the available space. Half a barSpacing |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
110 |
# is allocated at the beginning and end of the |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
111 |
# chart. |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
112 |
self.useAbsolute = 0 #- not done yet |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
113 |
self.barWidth = 10 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
114 |
self.groupSpacing = 5 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
115 |
self.barSpacing = 0 |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
116 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
117 |
self.barLabels = TypedPropertyCollection(BarChartLabel) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
118 |
self.barLabels.boxAnchor = 'c' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
119 |
self.barLabels.textAnchor = 'middle' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
120 |
self.barLabelFormat = None |
1936 | 121 |
self.barLabelArray = None |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
122 |
# this says whether the origin is inside or outside |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
123 |
# the bar - +10 means put the origin ten points |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
124 |
# above the tip of the bar if value > 0, or ten |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
125 |
# points inside if bar value < 0. This is different |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
126 |
# to label dx/dy which are not dependent on the |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
127 |
# sign of the data. |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
128 |
self.barLabels.nudge = 0 |
1203 | 129 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
130 |
# if you have multiple series, by default they butt |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
131 |
# together. |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
132 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
133 |
# we really need some well-designed default lists of |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
134 |
# colors e.g. from Tufte. These will be used in a |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
135 |
# cycle to set the fill color of each series. |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
136 |
self.bars = TypedPropertyCollection(BarChartProperties) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
137 |
self.bars.strokeWidth = 1 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
138 |
self.bars.strokeColor = colors.black |
2660 | 139 |
self.bars.strokeDashArray = None |
1043 | 140 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
141 |
self.bars[0].fillColor = colors.red |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
142 |
self.bars[1].fillColor = colors.green |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
143 |
self.bars[2].fillColor = colors.blue |
2660 | 144 |
self.naLabel = None #NA_Label() |
856 | 145 |
|
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
146 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
147 |
def demo(self): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
148 |
"""Shows basic use of a bar chart""" |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
149 |
if self.__class__.__name__=='BarChart': |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
150 |
raise NotImplementedError, 'Abstract Class BarChart has no demo' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
151 |
drawing = Drawing(200, 100) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
152 |
bc = self.__class__() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
153 |
drawing.add(bc) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
154 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
155 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
156 |
def _getConfigureData(self): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
157 |
cA = self.categoryAxis |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
158 |
data = self.data |
2036 | 159 |
if cA.style not in ('parallel','parallel_3d'): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
160 |
_data = data |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
161 |
data = max(map(len,_data))*[0] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
162 |
for d in _data: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
163 |
for i in xrange(len(d)): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
164 |
data[i] = data[i] + (d[i] or 0) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
165 |
data = list(_data) + [data] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
166 |
self._configureData = data |
1270 | 167 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
168 |
def _getMinMax(self): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
169 |
'''Attempt to return the data range''' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
170 |
self._getConfigureData() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
171 |
self.valueAxis._setRange(self._configureData) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
172 |
return self.valueAxis._valueMin, self.valueAxis._valueMax |
907 | 173 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
174 |
def _drawBegin(self,org,length): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
175 |
'''Position and configure value axis, return crossing value''' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
176 |
vA = self.valueAxis |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
177 |
vA.setPosition(self.x, self.y, length) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
178 |
self._getConfigureData() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
179 |
vA.configure(self._configureData) |
907 | 180 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
181 |
# if zero is in chart, put the other axis there, otherwise use low |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
182 |
crossesAt = vA.scale(0) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
183 |
if crossesAt > org+length or crossesAt<org: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
184 |
crossesAt = org |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
185 |
return crossesAt |
856 | 186 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
187 |
def _drawFinish(self): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
188 |
'''finalize the drawing of a barchart''' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
189 |
cA = self.categoryAxis |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
190 |
vA = self.valueAxis |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
191 |
cA.configure(self._configureData) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
192 |
self.calcBarPositions() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
193 |
g = Group() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
194 |
g.add(self.makeBackground()) |
1936 | 195 |
|
196 |
# ensure any axes have correct spacing set |
|
197 |
# for grids. It sucks that we have to do |
|
198 |
# this here. |
|
199 |
if self._flipXY == 0: |
|
1974 | 200 |
vA.gridStart = cA._x |
201 |
vA.gridEnd = cA._x+cA._length |
|
202 |
cA.gridStart = vA._y |
|
203 |
cA.gridEnd = vA._y+vA._length |
|
1936 | 204 |
else: |
1974 | 205 |
cA.gridStart = vA._x |
206 |
cA.gridEnd = vA._x+vA._length |
|
207 |
vA.gridStart = cA._y |
|
208 |
vA.gridEnd = cA._y+cA._length |
|
2200
be0cfccc662a
Fixed up tabs and whitespace in all source files
andy_robinson
parents:
2147
diff
changeset
|
209 |
|
2054 | 210 |
cA.makeGrid(g,parent=self) |
211 |
vA.makeGrid(g,parent=self) |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
212 |
g.add(self.makeBars()) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
213 |
g.add(cA) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
214 |
g.add(vA) |
2147 | 215 |
for a in getattr(self,'annotations',()): g.add(a(self,cA.scale,vA.scale)) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
216 |
del self._configureData |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
217 |
return g |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
218 |
|
907 | 219 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
220 |
def calcBarPositions(self): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
221 |
"""Works out where they go. default vertical. |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
222 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
223 |
Sets an attribute _barPositions which is a list of |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
224 |
lists of (x, y, width, height) matching the data. |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
225 |
""" |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
226 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
227 |
flipXY = self._flipXY |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
228 |
if flipXY: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
229 |
org = self.y |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
230 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
231 |
org = self.x |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
232 |
cA = self.categoryAxis |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
233 |
cScale = cA.scale |
1182 | 234 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
235 |
data = self.data |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
236 |
seriesCount = self._seriesCount = len(data) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
237 |
self._rowLength = rowLength = max(map(len,data)) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
238 |
groupSpacing, barSpacing, barWidth = self.groupSpacing, self.barSpacing, self.barWidth |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
239 |
style = self.categoryAxis.style |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
240 |
if style=='parallel': |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
241 |
groupWidth = groupSpacing+(seriesCount*barWidth)+(seriesCount-1)*barSpacing |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
242 |
bGap = barWidth+barSpacing |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
243 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
244 |
accum = rowLength*[0] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
245 |
groupWidth = groupSpacing+barWidth |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
246 |
bGap = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
247 |
self._groupWidth = groupWidth |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
248 |
useAbsolute = self.useAbsolute |
856 | 249 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
250 |
if useAbsolute: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
251 |
# bar dimensions are absolute |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
252 |
normFactor = 1.0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
253 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
254 |
# bar dimensions are normalized to fit. How wide |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
255 |
# notionally is one group of bars? |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
256 |
availWidth = cScale(0)[1] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
257 |
normFactor = availWidth/float(groupWidth) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
258 |
if self.debug: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
259 |
print '%d series, %d points per series' % (seriesCount, self._rowLength) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
260 |
print 'width = %d group + (%d bars * %d barWidth) + (%d gaps * %d interBar) = %d total' % ( |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
261 |
groupSpacing, seriesCount, barWidth, |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
262 |
seriesCount-1, barSpacing, groupWidth) |
856 | 263 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
264 |
# 'Baseline' correction... |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
265 |
vA = self.valueAxis |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
266 |
vScale = vA.scale |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
267 |
vm, vM = vA._valueMin, vA._valueMax |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
268 |
if vm <= 0 <= vM: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
269 |
baseLine = vScale(0) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
270 |
elif 0 < vm: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
271 |
baseLine = vScale(vm) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
272 |
elif vM < 0: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
273 |
baseLine = vScale(vM) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
274 |
self._baseLine = baseLine |
1177 | 275 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
276 |
COLUMNS = range(max(map(len,data))) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
277 |
if useAbsolute: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
278 |
_cScale = cA._scale |
1234
069de083d1c2
Added reverseDirection, reversePlotOrder and style attributes
rgbecker
parents:
1215
diff
changeset
|
279 |
|
2036 | 280 |
self._normFactor = normFactor |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
281 |
width = self.barWidth*normFactor |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
282 |
self._barPositions = [] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
283 |
reversePlotOrder = self.reversePlotOrder |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
284 |
for rowNo in range(seriesCount): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
285 |
barRow = [] |
2081 | 286 |
if reversePlotOrder: |
287 |
xVal = seriesCount-1 - rowNo |
|
288 |
else: |
|
289 |
xVal = rowNo |
|
290 |
xVal = 0.5*groupSpacing+xVal*bGap |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
291 |
for colNo in COLUMNS: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
292 |
datum = data[rowNo][colNo] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
293 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
294 |
# Ufff... |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
295 |
if useAbsolute: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
296 |
x = groupWidth*_cScale(colNo) + xVal + org |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
297 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
298 |
(g, gW) = cScale(colNo) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
299 |
x = g + normFactor*xVal |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
300 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
301 |
if datum is None: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
302 |
height = None |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
303 |
y = baseLine |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
304 |
else: |
2036 | 305 |
if style not in ('parallel','parallel_3d'): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
306 |
y = vScale(accum[colNo]) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
307 |
if y<baseLine: y = baseLine |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
308 |
accum[colNo] = accum[colNo] + datum |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
309 |
datum = accum[colNo] |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
310 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
311 |
y = baseLine |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
312 |
height = vScale(datum) - y |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
313 |
if -1e-8<height<=1e-8: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
314 |
height = 1e-8 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
315 |
if datum<-1e-8: height = -1e-8 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
316 |
barRow.append(flipXY and (y,x,height,width) or (x, y, width, height)) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
317 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
318 |
self._barPositions.append(barRow) |
833
300f61d6774f
Split draw() methods into makeBars() and makeBackground().
dinu_gherman
parents:
817
diff
changeset
|
319 |
|
907 | 320 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
321 |
def _getLabelText(self, rowNo, colNo): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
322 |
'''return formatted label text''' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
323 |
labelFmt = self.barLabelFormat |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
324 |
if labelFmt is None: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
325 |
labelText = None |
1936 | 326 |
elif labelFmt == 'values': |
327 |
labelText = self.barLabelArray[rowNo][colNo] |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
328 |
elif type(labelFmt) is StringType: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
329 |
labelText = labelFmt % self.data[rowNo][colNo] |
1686 | 330 |
elif callable(labelFmt): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
331 |
labelText = labelFmt(self.data[rowNo][colNo]) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
332 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
333 |
msg = "Unknown formatter type %s, expected string or function" % labelFmt |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
334 |
raise Exception, msg |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
335 |
return labelText |
856 | 336 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
337 |
def _labelXY(self,label,x,y,width,height): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
338 |
'Compute x, y for a label' |
2511
83406bfe8569
merge 2643:2644 from stable textlabels.py, barcharts.py: added boxTarget support
rgbecker
parents:
2434
diff
changeset
|
339 |
nudge = label.nudge |
83406bfe8569
merge 2643:2644 from stable textlabels.py, barcharts.py: added boxTarget support
rgbecker
parents:
2434
diff
changeset
|
340 |
anti = getattr(label,'boxTarget','normal')=='anti' |
83406bfe8569
merge 2643:2644 from stable textlabels.py, barcharts.py: added boxTarget support
rgbecker
parents:
2434
diff
changeset
|
341 |
if anti: nudge = -nudge |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
342 |
if self._flipXY: |
2511
83406bfe8569
merge 2643:2644 from stable textlabels.py, barcharts.py: added boxTarget support
rgbecker
parents:
2434
diff
changeset
|
343 |
value = width |
83406bfe8569
merge 2643:2644 from stable textlabels.py, barcharts.py: added boxTarget support
rgbecker
parents:
2434
diff
changeset
|
344 |
if anti: value = 0 |
83406bfe8569
merge 2643:2644 from stable textlabels.py, barcharts.py: added boxTarget support
rgbecker
parents:
2434
diff
changeset
|
345 |
return x + value + (width>=0 and 1 or -1)*nudge, y + 0.5*height |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
346 |
else: |
2511
83406bfe8569
merge 2643:2644 from stable textlabels.py, barcharts.py: added boxTarget support
rgbecker
parents:
2434
diff
changeset
|
347 |
value = height |
83406bfe8569
merge 2643:2644 from stable textlabels.py, barcharts.py: added boxTarget support
rgbecker
parents:
2434
diff
changeset
|
348 |
if anti: value = 0 |
83406bfe8569
merge 2643:2644 from stable textlabels.py, barcharts.py: added boxTarget support
rgbecker
parents:
2434
diff
changeset
|
349 |
return x + 0.5*width, y + value + (height>=0 and 1 or -1)*nudge |
1203 | 350 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
351 |
def _addBarLabel(self, g, rowNo, colNo, x, y, width, height): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
352 |
text = self._getLabelText(rowNo,colNo) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
353 |
if text: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
354 |
self._addLabel(text, self.barLabels[(rowNo, colNo)], g, rowNo, colNo, x, y, width, height) |
1284 | 355 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
356 |
def _addNABarLabel(self, g, rowNo, colNo, x, y, width, height): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
357 |
na = self.naLabel |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
358 |
if na and na.text: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
359 |
na = copy.copy(na) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
360 |
v = self.valueAxis._valueMax<=0 and -1e-8 or 1e-8 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
361 |
if width is None: width = v |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
362 |
if height is None: height = v |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
363 |
self._addLabel(na.text, na, g, rowNo, colNo, x, y, width, height) |
1284 | 364 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
365 |
def _addLabel(self, text, label, g, rowNo, colNo, x, y, width, height): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
366 |
if label.visible: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
367 |
labelWidth = stringWidth(text, label.fontName, label.fontSize) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
368 |
x0, y0 = self._labelXY(label,x,y,width,height) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
369 |
flipXY = self._flipXY |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
370 |
if flipXY: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
371 |
pm = width |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
372 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
373 |
pm = height |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
374 |
label._pmv = pm #the plus minus val |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
375 |
fixedEnd = getattr(label,'fixedEnd', None) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
376 |
if fixedEnd is not None: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
377 |
v = fixedEnd._getValue(self,pm) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
378 |
x00, y00 = x0, y0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
379 |
if flipXY: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
380 |
x0 = v |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
381 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
382 |
y0 = v |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
383 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
384 |
if flipXY: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
385 |
x00 = x0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
386 |
y00 = y+height/2.0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
387 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
388 |
x00 = x+width/2.0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
389 |
y00 = y0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
390 |
fixedStart = getattr(label,'fixedStart', None) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
391 |
if fixedStart is not None: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
392 |
v = fixedStart._getValue(self,pm) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
393 |
if flipXY: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
394 |
x00 = v |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
395 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
396 |
y00 = v |
1203 | 397 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
398 |
if pm<0: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
399 |
if flipXY: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
400 |
dx = -2*label.dx |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
401 |
dy = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
402 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
403 |
dy = -2*label.dy |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
404 |
dx = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
405 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
406 |
dy = dx = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
407 |
label.setOrigin(x0+dx, y0+dy) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
408 |
label.setText(text) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
409 |
sC, sW = label.lineStrokeColor, label.lineStrokeWidth |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
410 |
if sC and sW: g.insert(0,Line(x00,y00,x0,y0, strokeColor=sC, strokeWidth=sW)) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
411 |
g.add(label) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
412 |
alx = getattr(self,'barLabelCallOut',None) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
413 |
if alx: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
414 |
label._callOutInfo = (self,g,rowNo,colNo,x,y,width,height,x00,y00,x0,y0) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
415 |
alx(label) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
416 |
del label._callOutInfo |
1028
9258a4d99201
Added sampleSymbol1() using shaded bars (experimental).
dinu_gherman
parents:
1019
diff
changeset
|
417 |
|
2036 | 418 |
def _makeBar(self,g,x,y,width,height,rowNo,style): |
419 |
r = Rect(x, y, width, height) |
|
420 |
r.strokeWidth = style.strokeWidth |
|
421 |
r.fillColor = style.fillColor |
|
422 |
r.strokeColor = style.strokeColor |
|
2660 | 423 |
if style.strokeDashArray: |
424 |
r.strokeDashArray = style.strokeDashArray |
|
2036 | 425 |
g.add(r) |
1028
9258a4d99201
Added sampleSymbol1() using shaded bars (experimental).
dinu_gherman
parents:
1019
diff
changeset
|
426 |
|
2036 | 427 |
def _makeBars(self,g,lg): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
428 |
lenData = len(self.data) |
1687 | 429 |
bars = self.bars |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
430 |
for rowNo in range(lenData): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
431 |
row = self._barPositions[rowNo] |
1687 | 432 |
styleCount = len(bars) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
433 |
styleIdx = rowNo % styleCount |
1687 | 434 |
rowStyle = bars[styleIdx] |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
435 |
for colNo in range(len(row)): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
436 |
barPos = row[colNo] |
1687 | 437 |
style = bars.has_key((styleIdx,colNo)) and bars[(styleIdx,colNo)] or rowStyle |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
438 |
(x, y, width, height) = barPos |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
439 |
if None in (width,height): |
2035 | 440 |
self._addNABarLabel(lg,rowNo,colNo,x,y,width,height) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
441 |
continue |
1201 | 442 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
443 |
# Draw a rectangular symbol for each data item, |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
444 |
# or a normal colored rectangle. |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
445 |
symbol = None |
1687 | 446 |
if hasattr(style, 'symbol'): |
447 |
symbol = copy.deepcopy(style.symbol) |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
448 |
elif hasattr(self.bars, 'symbol'): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
449 |
symbol = self.bars.symbol |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
450 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
451 |
if symbol: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
452 |
symbol.x = x |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
453 |
symbol.y = y |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
454 |
symbol.width = width |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
455 |
symbol.height = height |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
456 |
g.add(symbol) |
1687 | 457 |
elif abs(width)>1e-7 and abs(height)>=1e-7 and (style.fillColor is not None or style.strokeColor is not None): |
2036 | 458 |
self._makeBar(g,x,y,width,height,rowNo,style) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
459 |
|
2035 | 460 |
self._addBarLabel(lg,rowNo,colNo,x,y,width,height) |
2036 | 461 |
|
462 |
def makeBars(self): |
|
463 |
g = Group() |
|
464 |
lg = Group() |
|
465 |
self._makeBars(g,lg) |
|
2035 | 466 |
g.add(lg) |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
467 |
return g |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
468 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
469 |
def _desiredCategoryAxisLength(self): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
470 |
'''for dynamically computing the desired category axis length''' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
471 |
style = self.categoryAxis.style |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
472 |
data = self.data |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
473 |
n = len(data) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
474 |
m = max(map(len,data)) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
475 |
if style=='parallel': |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
476 |
groupWidth = (n-1)*self.barSpacing+n*self.barWidth |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
477 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
478 |
groupWidth = self.barWidth |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
479 |
return m*(self.groupSpacing+groupWidth) |
1255
5af1802a7939
Added various minor tweaks to make useAbsolute easier
rgbecker
parents:
1251
diff
changeset
|
480 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
481 |
def draw(self): |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
482 |
cA, vA = self.categoryAxis, self.valueAxis |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
483 |
if vA: ovAjA, vA.joinAxis = vA.joinAxis, cA |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
484 |
if cA: ocAjA, cA.joinAxis = cA.joinAxis, vA |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
485 |
if self._flipXY: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
486 |
cA.setPosition(self._drawBegin(self.x,self.width), self.y, self.height) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
487 |
else: |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
488 |
cA.setPosition(self.x, self._drawBegin(self.y,self.height), self.width) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
489 |
return self._drawFinish() |
907 | 490 |
|
856 | 491 |
class VerticalBarChart(BarChart): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
492 |
"Vertical bar chart with multiple side-by-side bars." |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
493 |
_flipXY = 0 |
907 | 494 |
|
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
495 |
class HorizontalBarChart(BarChart): |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
496 |
"Horizontal bar chart with multiple side-by-side bars." |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
497 |
_flipXY = 1 |
2036 | 498 |
|
499 |
class _FakeGroup: |
|
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
500 |
def __init__(self, cmp=None): |
2036 | 501 |
self._data = [] |
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
502 |
self._cmp = cmp |
2036 | 503 |
|
504 |
def add(self,what): |
|
505 |
self._data.append(what) |
|
506 |
||
507 |
def value(self): |
|
508 |
return self._data |
|
509 |
||
510 |
def sort(self): |
|
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
511 |
self._data.sort(self._cmp) |
2036 | 512 |
|
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
513 |
class BarChart3D(BarChart): |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
514 |
_attrMap = AttrMap(BASE=BarChart, |
2049
32aa6aeebdbd
Fix up to allow for a spce vefore and aft in 3d vertical bar charts
rgbecker
parents:
2036
diff
changeset
|
515 |
theta_x = AttrMapValue(isNumber, desc='dx/dz'), |
32aa6aeebdbd
Fix up to allow for a spce vefore and aft in 3d vertical bar charts
rgbecker
parents:
2036
diff
changeset
|
516 |
theta_y = AttrMapValue(isNumber, desc='dy/dz'), |
2078 | 517 |
zDepth = AttrMapValue(isNumber, desc='depth of an individual series'), |
518 |
zSpace = AttrMapValue(isNumber, desc='z gap around series'), |
|
2049
32aa6aeebdbd
Fix up to allow for a spce vefore and aft in 3d vertical bar charts
rgbecker
parents:
2036
diff
changeset
|
519 |
) |
32aa6aeebdbd
Fix up to allow for a spce vefore and aft in 3d vertical bar charts
rgbecker
parents:
2036
diff
changeset
|
520 |
theta_x = .5 |
32aa6aeebdbd
Fix up to allow for a spce vefore and aft in 3d vertical bar charts
rgbecker
parents:
2036
diff
changeset
|
521 |
theta_y = .5 |
2078 | 522 |
zDepth = None |
523 |
zSpace = None |
|
2049
32aa6aeebdbd
Fix up to allow for a spce vefore and aft in 3d vertical bar charts
rgbecker
parents:
2036
diff
changeset
|
524 |
|
2036 | 525 |
def calcBarPositions(self): |
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
526 |
BarChart.calcBarPositions(self) |
2036 | 527 |
seriesCount = self._seriesCount |
2078 | 528 |
zDepth = self.zDepth |
529 |
if zDepth is None: zDepth = self.barWidth |
|
530 |
zSpace = self.zSpace |
|
531 |
if zSpace is None: zSpace = self.barSpacing |
|
2036 | 532 |
if self.categoryAxis.style=='parallel_3d': |
2078 | 533 |
_3d_depth = seriesCount*zDepth+(seriesCount+1)*zSpace |
2036 | 534 |
else: |
2078 | 535 |
_3d_depth = zDepth + 2*zSpace |
2036 | 536 |
_3d_depth *= self._normFactor |
2078 | 537 |
self._3d_dx = self.theta_x*_3d_depth |
2049
32aa6aeebdbd
Fix up to allow for a spce vefore and aft in 3d vertical bar charts
rgbecker
parents:
2036
diff
changeset
|
538 |
self._3d_dy = self.theta_y*_3d_depth |
2036 | 539 |
|
540 |
def _calc_z0(self,rowNo): |
|
2078 | 541 |
zDepth = self.zDepth |
542 |
if zDepth is None: zDepth = self.barWidth |
|
543 |
zSpace = self.zSpace |
|
544 |
if zSpace is None: zSpace = self.barSpacing |
|
2036 | 545 |
if self.categoryAxis.style=='parallel_3d': |
2078 | 546 |
z0 = self._normFactor*(rowNo*(zDepth+zSpace)+zSpace) |
2036 | 547 |
else: |
2078 | 548 |
z0 = self._normFactor*zSpace |
2036 | 549 |
return z0 |
550 |
||
551 |
def _makeBar(self,g,x,y,width,height,rowNo,style): |
|
2078 | 552 |
zDepth = self.zDepth |
553 |
if zDepth is None: zDepth = self.barWidth |
|
554 |
zSpace = self.zSpace |
|
555 |
if zSpace is None: zSpace = self.barSpacing |
|
2036 | 556 |
z0 = self._calc_z0(rowNo) |
2078 | 557 |
z1 = z0 + zDepth*self._normFactor |
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
558 |
if width<0: |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
559 |
x += width |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
560 |
width = -width |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
561 |
x += z0*self.theta_x |
2049
32aa6aeebdbd
Fix up to allow for a spce vefore and aft in 3d vertical bar charts
rgbecker
parents:
2036
diff
changeset
|
562 |
y += z0*self.theta_y |
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
563 |
if self._flipXY: |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
564 |
y += zSpace |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
565 |
else: |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
566 |
x += zSpace |
2036 | 567 |
g.add((0,z0,z1,x,y,width,height,rowNo,style)) |
568 |
||
569 |
def _addBarLabel(self, g, rowNo, colNo, x, y, width, height): |
|
570 |
z0 = self._calc_z0(rowNo) |
|
2078 | 571 |
zSpace = self.zSpace |
572 |
if zSpace is None: zSpace = self.barSpacing |
|
2036 | 573 |
z1 = z0 |
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
574 |
x += z0*self.theta_x |
2049
32aa6aeebdbd
Fix up to allow for a spce vefore and aft in 3d vertical bar charts
rgbecker
parents:
2036
diff
changeset
|
575 |
y += z0*self.theta_y |
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
576 |
if self._flipXY: |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
577 |
y += zSpace |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
578 |
else: |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
579 |
x += zSpace |
2036 | 580 |
g.add((1,z0,z1,x,y,width,height,rowNo,colNo)) |
581 |
||
582 |
def makeBars(self): |
|
583 |
from utils3d import _draw_3d_bar |
|
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
584 |
fg = _FakeGroup(cmp=self._cmpZ) |
2036 | 585 |
self._makeBars(fg,fg) |
586 |
fg.sort() |
|
587 |
g = Group() |
|
2049
32aa6aeebdbd
Fix up to allow for a spce vefore and aft in 3d vertical bar charts
rgbecker
parents:
2036
diff
changeset
|
588 |
theta_x = self.theta_x |
32aa6aeebdbd
Fix up to allow for a spce vefore and aft in 3d vertical bar charts
rgbecker
parents:
2036
diff
changeset
|
589 |
theta_y = self.theta_y |
2036 | 590 |
for t in fg.value(): |
591 |
if t[0]==1: |
|
592 |
z0,z1,x,y,width,height,rowNo,colNo = t[1:] |
|
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
593 |
BarChart._addBarLabel(self,g,rowNo,colNo,x,y,width,height) |
2036 | 594 |
elif t[0]==0: |
595 |
z0,z1,x,y,width,height,rowNo,style = t[1:] |
|
596 |
dz = z1 - z0 |
|
597 |
_draw_3d_bar(g, x, x+width, y, y+height, dz*theta_x, dz*theta_y, |
|
598 |
fillColor=style.fillColor, fillColorShaded=None, |
|
599 |
strokeColor=style.strokeColor, strokeWidth=style.strokeWidth, |
|
2076
c802426af201
Changed to make 3D barcharts look more 'Excel-like' - there is now a
johnprecedo
parents:
2054
diff
changeset
|
600 |
shading=0.45) |
2036 | 601 |
return g |
602 |
||
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
603 |
class VerticalBarChart3D(BarChart3D,VerticalBarChart): |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
604 |
_cmpZ=lambda self,a,b:cmp((-a[1],a[3],a[0],-a[4]),(-b[1],b[3],b[0],-b[4])) |
907 | 605 |
|
2089
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
606 |
class HorizontalBarChart3D(BarChart3D,HorizontalBarChart): |
06b5fb490c2d
Inheritance/Factorization improved, HorizontalBarChart3D added
rgbecker
parents:
2081
diff
changeset
|
607 |
_cmpZ = lambda self,a,b: cmp((-a[1],a[4],a[0],-a[3]),(-b[1],b[4],b[0],-b[3])) #t, z0, z1, x, y = a[:5] |
833
300f61d6774f
Split draw() methods into makeBars() and makeBackground().
dinu_gherman
parents:
817
diff
changeset
|
608 |
|
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
609 |
# Vertical samples. |
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
610 |
def sampleV0a(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
611 |
"A slightly pathologic bar chart with only TWO data items." |
856 | 612 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
613 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
614 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
615 |
data = [(13, 20)] |
856 | 616 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
617 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
618 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
619 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
620 |
bc.height = 125 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
621 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
622 |
bc.data = data |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
623 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
624 |
bc.strokeColor = colors.black |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
625 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
626 |
bc.valueAxis.valueMin = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
627 |
bc.valueAxis.valueMax = 60 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
628 |
bc.valueAxis.valueStep = 15 |
856 | 629 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
630 |
bc.categoryAxis.labels.boxAnchor = 'ne' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
631 |
bc.categoryAxis.labels.dx = 8 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
632 |
bc.categoryAxis.labels.dy = -2 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
633 |
bc.categoryAxis.labels.angle = 30 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
634 |
bc.categoryAxis.categoryNames = ['Ying', 'Yang'] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
635 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
636 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
637 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
638 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
639 |
|
907 | 640 |
|
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
641 |
def sampleV0b(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
642 |
"A pathologic bar chart with only ONE data item." |
856 | 643 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
644 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
645 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
646 |
data = [(42,)] |
856 | 647 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
648 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
649 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
650 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
651 |
bc.height = 125 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
652 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
653 |
bc.data = data |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
654 |
bc.strokeColor = colors.black |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
655 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
656 |
bc.valueAxis.valueMin = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
657 |
bc.valueAxis.valueMax = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
658 |
bc.valueAxis.valueStep = 15 |
856 | 659 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
660 |
bc.categoryAxis.labels.boxAnchor = 'ne' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
661 |
bc.categoryAxis.labels.dx = 8 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
662 |
bc.categoryAxis.labels.dy = -2 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
663 |
bc.categoryAxis.labels.angle = 30 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
664 |
bc.categoryAxis.categoryNames = ['Jan-99'] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
665 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
666 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
667 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
668 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
669 |
|
856 | 670 |
|
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
671 |
def sampleV0c(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
672 |
"A really pathologic bar chart with NO data items at all!" |
856 | 673 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
674 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
675 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
676 |
data = [()] |
856 | 677 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
678 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
679 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
680 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
681 |
bc.height = 125 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
682 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
683 |
bc.data = data |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
684 |
bc.strokeColor = colors.black |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
685 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
686 |
bc.valueAxis.valueMin = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
687 |
bc.valueAxis.valueMax = 60 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
688 |
bc.valueAxis.valueStep = 15 |
856 | 689 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
690 |
bc.categoryAxis.labels.boxAnchor = 'ne' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
691 |
bc.categoryAxis.labels.dx = 8 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
692 |
bc.categoryAxis.labels.dy = -2 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
693 |
bc.categoryAxis.categoryNames = [] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
694 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
695 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
696 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
697 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
698 |
|
856 | 699 |
|
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
700 |
def sampleV1(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
701 |
"Sample of multi-series bar chart." |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
702 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
703 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
704 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
705 |
data = [ |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
706 |
(13, 5, 20, 22, 37, 45, 19, 4), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
707 |
(14, 6, 21, 23, 38, 46, 20, 5) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
708 |
] |
856 | 709 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
710 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
711 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
712 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
713 |
bc.height = 125 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
714 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
715 |
bc.data = data |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
716 |
bc.strokeColor = colors.black |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
717 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
718 |
bc.valueAxis.valueMin = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
719 |
bc.valueAxis.valueMax = 60 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
720 |
bc.valueAxis.valueStep = 15 |
856 | 721 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
722 |
bc.categoryAxis.labels.boxAnchor = 'ne' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
723 |
bc.categoryAxis.labels.dx = 8 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
724 |
bc.categoryAxis.labels.dy = -2 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
725 |
bc.categoryAxis.labels.angle = 30 |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
726 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
727 |
catNames = string.split('Jan Feb Mar Apr May Jun Jul Aug', ' ') |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
728 |
catNames = map(lambda n:n+'-99', catNames) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
729 |
bc.categoryAxis.categoryNames = catNames |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
730 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
731 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
732 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
733 |
|
856 | 734 |
|
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
735 |
def sampleV2a(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
736 |
"Sample of multi-series bar chart." |
856 | 737 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
738 |
data = [(2.4, -5.7, 2, 5, 9.2), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
739 |
(0.6, -4.9, -3, 4, 6.8) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
740 |
] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
741 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
742 |
labels = ("Q3 2000", "Year to Date", "12 months", |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
743 |
"Annualised\n3 years", "Since 07.10.99") |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
744 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
745 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
746 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
747 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
748 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
749 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
750 |
bc.height = 120 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
751 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
752 |
bc.data = data |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
753 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
754 |
bc.barSpacing = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
755 |
bc.groupSpacing = 10 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
756 |
bc.barWidth = 10 |
856 | 757 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
758 |
bc.valueAxis.valueMin = -15 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
759 |
bc.valueAxis.valueMax = +15 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
760 |
bc.valueAxis.valueStep = 5 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
761 |
bc.valueAxis.labels.fontName = 'Helvetica' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
762 |
bc.valueAxis.labels.fontSize = 8 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
763 |
bc.valueAxis.labels.boxAnchor = 'n' # irrelevant (becomes 'c') |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
764 |
bc.valueAxis.labels.textAnchor = 'middle' |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
765 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
766 |
bc.categoryAxis.categoryNames = labels |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
767 |
bc.categoryAxis.labels.fontName = 'Helvetica' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
768 |
bc.categoryAxis.labels.fontSize = 8 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
769 |
bc.categoryAxis.labels.dy = -60 |
856 | 770 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
771 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
772 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
773 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
774 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
775 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
776 |
def sampleV2b(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
777 |
"Sample of multi-series bar chart." |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
778 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
779 |
data = [(2.4, -5.7, 2, 5, 9.2), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
780 |
(0.6, -4.9, -3, 4, 6.8) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
781 |
] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
782 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
783 |
labels = ("Q3 2000", "Year to Date", "12 months", |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
784 |
"Annualised\n3 years", "Since 07.10.99") |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
785 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
786 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
787 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
788 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
789 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
790 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
791 |
bc.height = 120 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
792 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
793 |
bc.data = data |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
794 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
795 |
bc.barSpacing = 5 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
796 |
bc.groupSpacing = 10 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
797 |
bc.barWidth = 10 |
856 | 798 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
799 |
bc.valueAxis.valueMin = -15 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
800 |
bc.valueAxis.valueMax = +15 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
801 |
bc.valueAxis.valueStep = 5 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
802 |
bc.valueAxis.labels.fontName = 'Helvetica' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
803 |
bc.valueAxis.labels.fontSize = 8 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
804 |
bc.valueAxis.labels.boxAnchor = 'n' # irrelevant (becomes 'c') |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
805 |
bc.valueAxis.labels.textAnchor = 'middle' |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
806 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
807 |
bc.categoryAxis.categoryNames = labels |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
808 |
bc.categoryAxis.labels.fontName = 'Helvetica' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
809 |
bc.categoryAxis.labels.fontSize = 8 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
810 |
bc.categoryAxis.labels.dy = -60 |
856 | 811 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
812 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
813 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
814 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
815 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
816 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
817 |
def sampleV2c(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
818 |
"Sample of multi-series bar chart." |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
819 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
820 |
data = [(2.4, -5.7, 2, 5, 9.99), |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
821 |
(0.6, -4.9, -3, 4, 9.99) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
822 |
] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
823 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
824 |
labels = ("Q3 2000", "Year to Date", "12 months", |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
825 |
"Annualised\n3 years", "Since 07.10.99") |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
826 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
827 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
828 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
829 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
830 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
831 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
832 |
bc.height = 120 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
833 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
834 |
bc.data = data |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
835 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
836 |
bc.barSpacing = 2 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
837 |
bc.groupSpacing = 10 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
838 |
bc.barWidth = 10 |
856 | 839 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
840 |
bc.valueAxis.valueMin = -15 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
841 |
bc.valueAxis.valueMax = +15 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
842 |
bc.valueAxis.valueStep = 5 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
843 |
bc.valueAxis.labels.fontName = 'Helvetica' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
844 |
bc.valueAxis.labels.fontSize = 8 |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
845 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
846 |
bc.categoryAxis.categoryNames = labels |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
847 |
bc.categoryAxis.labels.fontName = 'Helvetica' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
848 |
bc.categoryAxis.labels.fontSize = 8 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
849 |
bc.valueAxis.labels.boxAnchor = 'n' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
850 |
bc.valueAxis.labels.textAnchor = 'middle' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
851 |
bc.categoryAxis.labels.dy = -60 |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
852 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
853 |
bc.barLabels.nudge = 10 |
856 | 854 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
855 |
bc.barLabelFormat = '%0.2f' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
856 |
bc.barLabels.dx = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
857 |
bc.barLabels.dy = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
858 |
bc.barLabels.boxAnchor = 'n' # irrelevant (becomes 'c') |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
859 |
bc.barLabels.fontName = 'Helvetica' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
860 |
bc.barLabels.fontSize = 6 |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
861 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
862 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
863 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
864 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
865 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
866 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
867 |
def sampleV3(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
868 |
"Faked horizontal bar chart using a vertical real one (deprecated)." |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
869 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
870 |
names = ("UK Equities", "US Equities", "European Equities", "Japanese Equities", |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
871 |
"Pacific (ex Japan) Equities", "Emerging Markets Equities", |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
872 |
"UK Bonds", "Overseas Bonds", "UK Index-Linked", "Cash") |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
873 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
874 |
series1 = (-1.5, 0.3, 0.5, 1.0, 0.8, 0.7, 0.4, 0.1, 1.0, 0.3) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
875 |
series2 = (0.0, 0.33, 0.55, 1.1, 0.88, 0.77, 0.44, 0.11, 1.10, 0.33) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
876 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
877 |
assert len(names) == len(series1), "bad data" |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
878 |
assert len(names) == len(series2), "bad data" |
856 | 879 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
880 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
881 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
882 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
883 |
bc.x = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
884 |
bc.y = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
885 |
bc.height = 100 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
886 |
bc.width = 150 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
887 |
bc.data = (series1,) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
888 |
bc.bars.fillColor = colors.green |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
889 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
890 |
bc.barLabelFormat = '%0.2f' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
891 |
bc.barLabels.dx = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
892 |
bc.barLabels.dy = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
893 |
bc.barLabels.boxAnchor = 'w' # irrelevant (becomes 'c') |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
894 |
bc.barLabels.angle = 90 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
895 |
bc.barLabels.fontName = 'Helvetica' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
896 |
bc.barLabels.fontSize = 6 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
897 |
bc.barLabels.nudge = 10 |
856 | 898 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
899 |
bc.valueAxis.visible = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
900 |
bc.valueAxis.valueMin = -2 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
901 |
bc.valueAxis.valueMax = +2 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
902 |
bc.valueAxis.valueStep = 1 |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
903 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
904 |
bc.categoryAxis.tickUp = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
905 |
bc.categoryAxis.tickDown = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
906 |
bc.categoryAxis.categoryNames = names |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
907 |
bc.categoryAxis.labels.angle = 90 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
908 |
bc.categoryAxis.labels.boxAnchor = 'w' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
909 |
bc.categoryAxis.labels.dx = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
910 |
bc.categoryAxis.labels.dy = -125 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
911 |
bc.categoryAxis.labels.fontName = 'Helvetica' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
912 |
bc.categoryAxis.labels.fontSize = 6 |
856 | 913 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
914 |
g = Group(bc) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
915 |
g.translate(100, 175) |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
916 |
g.rotate(-90) |
856 | 917 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
918 |
drawing.add(g) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
919 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
920 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
921 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
922 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
923 |
def sampleV4a(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
924 |
"A bar chart showing value axis region starting at *exactly* zero." |
856 | 925 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
926 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
927 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
928 |
data = [(13, 20)] |
856 | 929 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
930 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
931 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
932 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
933 |
bc.height = 125 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
934 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
935 |
bc.data = data |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
936 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
937 |
bc.strokeColor = colors.black |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
938 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
939 |
bc.valueAxis.valueMin = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
940 |
bc.valueAxis.valueMax = 60 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
941 |
bc.valueAxis.valueStep = 15 |
856 | 942 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
943 |
bc.categoryAxis.labels.boxAnchor = 'n' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
944 |
bc.categoryAxis.labels.dy = -5 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
945 |
bc.categoryAxis.categoryNames = ['Ying', 'Yang'] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
946 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
947 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
948 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
949 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
950 |
|
856 | 951 |
|
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
952 |
def sampleV4b(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
953 |
"A bar chart showing value axis region starting *below* zero." |
856 | 954 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
955 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
956 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
957 |
data = [(13, 20)] |
856 | 958 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
959 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
960 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
961 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
962 |
bc.height = 125 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
963 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
964 |
bc.data = data |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
965 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
966 |
bc.strokeColor = colors.black |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
967 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
968 |
bc.valueAxis.valueMin = -10 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
969 |
bc.valueAxis.valueMax = 60 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
970 |
bc.valueAxis.valueStep = 15 |
856 | 971 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
972 |
bc.categoryAxis.labels.boxAnchor = 'n' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
973 |
bc.categoryAxis.labels.dy = -5 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
974 |
bc.categoryAxis.categoryNames = ['Ying', 'Yang'] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
975 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
976 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
977 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
978 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
979 |
|
856 | 980 |
|
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
981 |
def sampleV4c(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
982 |
"A bar chart showing value axis region staring *above* zero." |
856 | 983 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
984 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
985 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
986 |
data = [(13, 20)] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
987 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
988 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
989 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
990 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
991 |
bc.height = 125 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
992 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
993 |
bc.data = data |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
994 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
995 |
bc.strokeColor = colors.black |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
996 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
997 |
bc.valueAxis.valueMin = 10 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
998 |
bc.valueAxis.valueMax = 60 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
999 |
bc.valueAxis.valueStep = 15 |
856 | 1000 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1001 |
bc.categoryAxis.labels.boxAnchor = 'n' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1002 |
bc.categoryAxis.labels.dy = -5 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1003 |
bc.categoryAxis.categoryNames = ['Ying', 'Yang'] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1004 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1005 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1006 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1007 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1008 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1009 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1010 |
def sampleV4d(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1011 |
"A bar chart showing value axis region entirely *below* zero." |
856 | 1012 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1013 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1014 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1015 |
data = [(-13, -20)] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1016 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1017 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1018 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1019 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1020 |
bc.height = 125 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1021 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1022 |
bc.data = data |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1023 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1024 |
bc.strokeColor = colors.black |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1025 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1026 |
bc.valueAxis.valueMin = -30 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1027 |
bc.valueAxis.valueMax = -10 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1028 |
bc.valueAxis.valueStep = 15 |
856 | 1029 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1030 |
bc.categoryAxis.labels.boxAnchor = 'n' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1031 |
bc.categoryAxis.labels.dy = -5 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1032 |
bc.categoryAxis.categoryNames = ['Ying', 'Yang'] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1033 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1034 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1035 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1036 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1037 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1038 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1039 |
### |
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1040 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1041 |
##dataSample5 = [(10, 20), (20, 30), (30, 40), (40, 50), (50, 60)] |
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1042 |
##dataSample5 = [(10, 60), (20, 50), (30, 40), (40, 30), (50, 20)] |
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1043 |
dataSample5 = [(10, 60), (20, 50), (30, 40), (40, 30)] |
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1044 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1045 |
def sampleV5a(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1046 |
"A simple bar chart with no expressed spacing attributes." |
856 | 1047 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1048 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1049 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1050 |
data = dataSample5 |
856 | 1051 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1052 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1053 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1054 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1055 |
bc.height = 125 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1056 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1057 |
bc.data = data |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1058 |
bc.strokeColor = colors.black |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1059 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1060 |
bc.valueAxis.valueMin = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1061 |
bc.valueAxis.valueMax = 60 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1062 |
bc.valueAxis.valueStep = 15 |
856 | 1063 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1064 |
bc.categoryAxis.labels.boxAnchor = 'n' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1065 |
bc.categoryAxis.labels.dy = -5 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1066 |
bc.categoryAxis.categoryNames = ['Ying', 'Yang'] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1067 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1068 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1069 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1070 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1071 |
|
856 | 1072 |
|
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1073 |
def sampleV5b(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1074 |
"A simple bar chart with proportional spacing." |
856 | 1075 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1076 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1077 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1078 |
data = dataSample5 |
856 | 1079 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1080 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1081 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1082 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1083 |
bc.height = 125 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1084 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1085 |
bc.data = data |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1086 |
bc.strokeColor = colors.black |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1087 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1088 |
bc.useAbsolute = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1089 |
bc.barWidth = 40 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1090 |
bc.groupSpacing = 20 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1091 |
bc.barSpacing = 10 |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1092 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1093 |
bc.valueAxis.valueMin = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1094 |
bc.valueAxis.valueMax = 60 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1095 |
bc.valueAxis.valueStep = 15 |
856 | 1096 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1097 |
bc.categoryAxis.labels.boxAnchor = 'n' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1098 |
bc.categoryAxis.labels.dy = -5 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1099 |
bc.categoryAxis.categoryNames = ['Ying', 'Yang'] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1100 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1101 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1102 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1103 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1104 |
|
856 | 1105 |
|
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1106 |
def sampleV5c1(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1107 |
"Make sampe simple bar chart but with absolute spacing." |
856 | 1108 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1109 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1110 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1111 |
data = dataSample5 |
856 | 1112 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1113 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1114 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1115 |
bc.y = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1116 |
bc.height = 125 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1117 |
bc.width = 300 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1118 |
bc.data = data |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1119 |
bc.strokeColor = colors.black |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1120 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1121 |
bc.useAbsolute = 1 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1122 |
bc.barWidth = 40 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1123 |
bc.groupSpacing = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1124 |
bc.barSpacing = 0 |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1125 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1126 |
bc.valueAxis.valueMin = 0 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1127 |
bc.valueAxis.valueMax = 60 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1128 |
bc.valueAxis.valueStep = 15 |
856 | 1129 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1130 |
bc.categoryAxis.labels.boxAnchor = 'n' |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1131 |
bc.categoryAxis.labels.dy = -5 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1132 |
bc.categoryAxis.categoryNames = ['Ying', 'Yang'] |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1133 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1134 |
drawing.add(bc) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1135 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1136 |
return drawing |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1137 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1138 |
|
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1139 |
def sampleV5c2(): |
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1140 |
"Make sampe simple bar chart but with absolute spacing." |
856 | 1141 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1142 |
drawing = Drawing(400, 200) |
737
8f0e58918da9
Initial checkin, replacing previous trailing digit filenames.
dinu_gherman
parents:
diff
changeset
|
1143 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1144 |
data = dataSample5 |
856 | 1145 |
|
1677
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1146 |
bc = VerticalBarChart() |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1147 |
bc.x = 50 |
1450177dd19e
Exterminated all tab characters and added a test to make sure
andy_robinson
parents:
1673
diff
changeset
|
1148 |
bc.y = 50 |