[reportlab-users] How to color each bar in a barchart ?
Marcus Vinicius Laranjeira
reportlab-users@reportlab.com
Mon, 08 Jul 2002 14:06:15 -0300
--=====================_268470659==.ALT
Content-Type: text/plain; charset="iso-8859-1"; format=flowed
Content-Transfer-Encoding: quoted-printable
Let's supose I have a data series like:
[[1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 2, 1, 1, 4, 1, 1, 1, 1, 2, 2, 1,=20
1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 1]]
and the lenght of this data serie may change based on some configuration of=
=20
the program...
How do I know how many bars I have, like:
for bar in ???:
bar.fillColor(color.Color(r,g,b)
?!??
Any hints on this !?
At 13:11 08/07/02 +0200, you wrote:
>Marcus Vinicius Laranjeira schrieb am 05.07.02 15:12:30:
> > I am currently learning and discovering the power of reportlab.
> > Actually I am creating two charts, one as a horizontal bar chart and=20
> the other
> > one as a vertical bar chart. In both of them the bars are printed=20
> filled in
> > red.
> >
> > I need these bars to be printed each one with a different colors and=
never
> > repeating the colors (in the same chart).
>
>How about this:
>
>use a stacked bar chart and use only one element in each value
>series, the others set to zero. Then you can change the color
>of each bar.
>
>(example appended)
>
>R=FCdiger
>
>#####
> drawing =3D Drawing(400, 200)
>
> bc =3D HorizontalBarChart()
> bc.x =3D 50
> bc.y =3D 50
> bc.height =3D 125
> bc.width =3D 300
> # Use only one element of each value series.
> # Append a complete value tuple for each additional value you got.
> bc.data =3D [
> (1, 0, 0, 0),
> (0, 2, 0, 0),
> (0, 0, 3, 0),
> (0, 0, 0, 4)
> ]
>
> bc.strokeColor =3D colors.black
>
> bc.valueAxis.valueMin =3D 0
> bc.valueAxis.valueMax =3D 10
> bc.valueAxis.valueStep =3D 1
>
> # must be stacked
> bc.categoryAxis.style =3D 'stacked'
> bc.categoryAxis.labels.boxAnchor =3D 'e'
> bc.categoryAxis.categoryNames =3D ['one', 'two', 'three', 'four']
>
> bc.bars[0].fillColor =3D colors.yellow
> bc.bars[1].fillColor =3D colors.green
> bc.bars[2].fillColor =3D colors.blue
> bc.bars[3].fillColor =3D colors.red
>
> drawing.add(bc)
>
>
>________________________________________________________________
>Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr!
>Beim WEB.DE Lottoservice: http://tippen2.web.de/?x=3D13
>
>
>_______________________________________________
>reportlab-users mailing list
>reportlab-users@reportlab.com
>http://two.pairlist.net/mailman/listinfo/reportlab-users
Marcus Vinicius Laranjeira
MON Center
Datacraft do Brasil - (http://www.datacraft.com.br)
R. Tenente Negr=E3o, 140 - 8o. Andar
Itaim Bibi - S=E3o Paulo - SP - 04530-030
Tel: +55-11-3053-0241
Fax: +55-11-3053-0220
--=====================_268470659==.ALT
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html>
Let's supose I have a data series like:<br><br>
[[1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 2, 1, 1, 4, 1, 1, 1, 1, 2, 2, 1,
1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 3, 1]]<br><br>
and the lenght of this data serie may change based on some configuration
of the program...<br><br>
How do I know how many bars I have, like:<br><br>
for bar in ???:<br>
bar.fillColor(color.Color(r,g,b)<br><br>
?!??<br><br>
Any hints on this !?<br><br>
<br>
At 13:11 08/07/02 +0200, you wrote:<br>
<blockquote type=3Dcite class=3Dcite cite>Marcus Vinicius Laranjeira schrieb
am 05.07.02 15:12:30:<br>
> I am currently learning and discovering the power of=20
reportlab.<br>
> Actually I am creating two charts, one as a horizontal bar chart and
the other<br>
> one as a vertical bar chart. In both of them the bars are printed
filled in <br>
> red.<br>
> <br>
> I need these bars to be printed each one with a different colors and
never<br>
> repeating the colors (in the same chart).<br><br>
How about this:<br><br>
use a stacked bar chart and use only one element in each value <br>
series, the others set to zero. Then you can change the color <br>
of each bar.<br><br>
(example appended)<br><br>
R=FCdiger<br><br>
#####<br>
drawing =3D Drawing(400, 200)<br><br>
bc =3D HorizontalBarChart()<br>
bc.x =3D 50<br>
bc.y =3D 50<br>
bc.height =3D 125<br>
bc.width =3D 300<br>
# Use only one element of each value series.<br>
# Append a complete value tuple for each additional
value you got.<br>
bc.data =3D [<br>
(1, 0, 0, 0), <br>
(0, 2, 0, 0),<br>
(0, 0, 3, 0),<br>
(0, 0, 0, 4)<br>
]<br><br>
bc.strokeColor =3D colors.black<br><br>
bc.valueAxis.valueMin =3D 0<br>
bc.valueAxis.valueMax =3D 10<br>
bc.valueAxis.valueStep =3D 1<br><br>
# must be stacked<br>
bc.categoryAxis.style =3D 'stacked'<br>
bc.categoryAxis.labels.boxAnchor =3D 'e'<br>
bc.categoryAxis.categoryNames =3D ['one', 'two',
'three', 'four']<br>
<br>
bc.bars[0].fillColor =3D colors.yellow<br>
bc.bars[1].fillColor =3D colors.green<br>
bc.bars[2].fillColor =3D colors.blue<br>
bc.bars[3].fillColor =3D colors.red<br>
<br>
drawing.add(bc)<br><br>
<br>
________________________________________________________________<br>
Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr! <br>
Beim WEB.DE Lottoservice:
<a href=3D"http://tippen2.web.de/?x=3D13"=
eudora=3D"autourl">http://tippen2.web.de/?x=3D13</a><br><br>
<br>
_______________________________________________<br>
reportlab-users mailing list<br>
reportlab-users@reportlab.com<br>
<a href=3D"http://two.pairlist.net/mailman/listinfo/reportlab-users"=
eudora=3D"autourl">http://two.pairlist.net/mailman/listinfo/reportlab-users=
</a></blockquote>
<x-sigsep><p></x-sigsep>
<font face=3D"Courier New, Courier"><br><br>
<br>
Marcus Vinicius Laranjeira<br>
MON Center <br><br>
Datacraft do Brasil -
(<a href=3D"http://www.datacraft.com.br/" eudora=3D"autourl">http://www.data=
craft.com.br</a>)
<br>
R. Tenente Negr=E3o, 140 - 8o. Andar <br>
Itaim Bibi - S=E3o Paulo - SP - 04530-030 <br>
Tel: +55-11-3053-0241<br>
Fax: +55-11-3053-0220</font></html>
--=====================_268470659==.ALT--