~toolpart/openobject-server/toolpart

« back to all changes in this revision

Viewing changes to bin/reportlab/graphics/samples/stacked_bar.py

  • Committer: pinky
  • Date: 2006-12-07 13:41:40 UTC
  • Revision ID: pinky-3f10ee12cea3c4c75cef44ab04ad33ef47432907
New trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#Autogenerated by ReportLab guiedit do not edit
 
2
from reportlab.graphics.charts.legends import Legend
 
3
from reportlab.graphics.charts.barcharts import HorizontalBarChart
 
4
from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin, String
 
5
from reportlab.graphics.charts.textlabels import Label
 
6
from excelcolors import *
 
7
 
 
8
class StackedBar(_DrawingEditorMixin,Drawing):
 
9
    def __init__(self,width=200,height=150,*args,**kw):
 
10
        apply(Drawing.__init__,(self,width,height)+args,kw)
 
11
        self._add(self,HorizontalBarChart(),name='chart',validate=None,desc="The main chart")
 
12
        self.chart.width      = 115
 
13
        self.chart.height     = 80
 
14
        self.chart.x          = 30
 
15
        self.chart.y          = 40
 
16
        self.chart.bars[0].fillColor = color01
 
17
        self.chart.bars[1].fillColor = color02
 
18
        self.chart.bars[2].fillColor = color03
 
19
        self.chart.bars[3].fillColor = color04
 
20
        self.chart.bars[4].fillColor = color05
 
21
        self.chart.bars[5].fillColor = color06
 
22
        self.chart.bars[6].fillColor = color07
 
23
        self.chart.bars[7].fillColor = color08
 
24
        self.chart.bars[8].fillColor = color09
 
25
        self.chart.bars[9].fillColor = color10
 
26
        self.chart.fillColor         = backgroundGrey
 
27
        self.chart.barLabels.fontName              = 'Helvetica'
 
28
        self.chart.valueAxis.labels.fontName       = 'Helvetica'
 
29
        self.chart.valueAxis.labels.fontSize       = 6
 
30
        self.chart.valueAxis.forceZero             = 1
 
31
        self.chart.data             = [(100, 150, 180), (125, 180, 200)]
 
32
        self.chart.groupSpacing     = 15
 
33
        self.chart.valueAxis.avoidBoundFrac           = 1
 
34
        self.chart.valueAxis.gridEnd                  = 80
 
35
        self.chart.valueAxis.tickDown                 = 3
 
36
        self.chart.valueAxis.visibleGrid              = 1
 
37
        self.chart.categoryAxis.categoryNames         = ['North', 'South', 'Central']
 
38
        self.chart.categoryAxis.tickLeft              = 3
 
39
        self.chart.categoryAxis.labels.fontName       = 'Helvetica'
 
40
        self.chart.categoryAxis.labels.fontSize       = 6
 
41
        self.chart.categoryAxis.labels.dx             = -3
 
42
        self._add(self,Label(),name='Title',validate=None,desc="The title at the top of the chart")
 
43
        self.Title.fontName   = 'Helvetica-Bold'
 
44
        self.Title.fontSize   = 7
 
45
        self.Title.x          = 100
 
46
        self.Title.y          = 135
 
47
        self.Title._text      = 'Chart Title'
 
48
        self.Title.maxWidth   = 180
 
49
        self.Title.height     = 20
 
50
        self.Title.textAnchor ='middle'
 
51
        self._add(self,Legend(),name='Legend',validate=None,desc="The legend or key for the chart")
 
52
        self.Legend.colorNamePairs = [(color01, 'Widgets'), (color02, 'Sprockets')]
 
53
        self.Legend.fontName       = 'Helvetica'
 
54
        self.Legend.fontSize       = 7
 
55
        self.Legend.x              = 153
 
56
        self.Legend.y              = 85
 
57
        self.Legend.dxTextSpace    = 5
 
58
        self.Legend.dy             = 5
 
59
        self.Legend.dx             = 5
 
60
        self.Legend.deltay         = 5
 
61
        self.Legend.alignment      ='right'
 
62
        self._add(self,Label(),name='XLabel',validate=None,desc="The label on the horizontal axis")
 
63
        self.XLabel.fontName       = 'Helvetica'
 
64
        self.XLabel.fontSize       = 7
 
65
        self.XLabel.x              = 85
 
66
        self.XLabel.y              = 10
 
67
        self.XLabel.textAnchor     ='middle'
 
68
        self.XLabel.maxWidth       = 100
 
69
        self.XLabel.height         = 20
 
70
        self.XLabel._text           = "X Axis"
 
71
        self._add(self,Label(),name='YLabel',validate=None,desc="The label on the vertical axis")
 
72
        self.YLabel.fontName       = 'Helvetica'
 
73
        self.YLabel.fontSize       = 7
 
74
        self.YLabel.x              = 12
 
75
        self.YLabel.y              = 80
 
76
        self.YLabel.angle          = 90
 
77
        self.YLabel.textAnchor     ='middle'
 
78
        self.YLabel.maxWidth       = 100
 
79
        self.YLabel.height         = 20
 
80
        self.YLabel._text          = "Y Axis"
 
81
        self.chart.categoryAxis.style='stacked'
 
82
        self._add(self,0,name='preview',validate=None,desc=None)
 
83
 
 
84
if __name__=="__main__": #NORUNTESTS
 
85
    StackedBar().save(formats=['pdf'],outDir=None,fnRoot='stacked_bar')
 
 
b'\\ No newline at end of file'