[reportlab-users] Bug in reportlab horizontal/vertical bar chart modules ????

Marcus Vinicius Laranjeira reportlab-users@reportlab.com
Mon, 15 Jul 2002 15:53:48 -0300


--=====================_3043093==.ALT
Content-Type: text/plain; charset="iso-8859-1"; format=flowed
Content-Transfer-Encoding: quoted-printable

All,

I am sorry to bother you again about this, but I really need some help...=20
Is there any other place where I can look for help ? like a bug reporting=20
or a list where I can talk to the reportlab developers ?

Thanks a lot,

Marcus

At 17:03 12/07/02 -0300, you wrote:
>Robin,
>
>Here is the code of the chart I am having problem:
>
>from reportlab.lib import colors
>from reportlab.graphics.shapes import Drawing
>from reportlab.graphics.charts.barcharts import HorizontalBarChart
>from reportlab.graphics.charts.textlabels import Label
>from reportlab.graphics import renderPM
>
>def chooseColor():
>     choosedColor =3D select(colorSet)
>     if choosedColor is None:
>         for color in colors.getAllNamedColors():
>             colorSet.append(colors.getAllNamedColors()[color])
>         choosedColor =3D select(colorSet)
>     return choosedColor
>
>def select(sequence):
>     if sequence !=3D []:
>         elem =3D sequence[len(sequence)-1]
>         sequence[len(sequence)-1] =3D -1
>         del sequence[len(sequence)-1]
>         return elem
>     else:
>         return None
>
>colorSet =3D []
>
>data =3D [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],        # Data series=
 1
>         [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],        # Data series 2
>         [0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],        # Data series 3
>         [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],        # Data series 4
>         [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],        # Data series 5
>         [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],        # Data series 6
>         [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],        # Data series 7
>         [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],        # Data series 8
>         [0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0],        # Data series 9
>         [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0],        # Data series=
 10
>         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0],        # Data series=
 11
>         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0],        # Data series=
 12
>         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0],        # Data series=
 13
>         [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]        # Data series=
 14
>
>labs =3D ['ITA',        # Data series 1
>         'VOT',        # Data series 2
>         'SAN',        # Data series 3
>         'GES2',       # Data series 4
>         'OSA-GES1',   # Data series 5
>         'CID-ANA',    # Data series 6
>         'GHP',        # Data series 7
>         'CCT',        # Data series 8
>         'JAU',        # Data series 9
>         'BEB',        # Data series 10
>         'SJB',        # Data series 11
>         'SJR',        # Data series 12
>         'GES16435',   # Data series 13
>         'CES']        # Data series 14
>
>drawing =3D Drawing(450, 550)
>bc =3D HorizontalBarChart()
>bc.x =3D 120
>bc.y =3D 40
>bc.height =3D 450
>bc.width =3D 320
>bc.data =3D data
>m =3D 0
>for l in data:
>     maux =3D max(l)
>     if maux > m:
>         m =3D maux
>bc.valueAxis.valueMin =3D 0
>bc.valueAxis.valueMax =3D m + 1
>bc.valueAxis.valueStep =3D 1
>bc.valueAxis.rangeRound=3D'both'
>bc.categoryAxis.style =3D 'stacked'
>bc.categoryAxis.configure(labs)
>bc.categoryAxis.categoryNames =3D labs
>bc.categoryAxis.labels.fontName =3D 'Helvetica'
>bc.categoryAxis.labels.textAnchor =3D 'end'
>for a in range(len(data[0])):
>     bc.bars[a].fillColor =3D chooseColor()
>drawing.add(bc)
>renderPM.drawToFile(drawing, "ipa.jpg", 'JPG')
>
>This code actually generates the chart with the black lines I told... I=20
>don't know how to fix it !!!
>
>The data list is a list of lists... this was the only way I found to=20
>change the color of each bar instead of having the bars in only one=20
>color... If I use data with just one list then I receive an error telling=
=20
>me that there was just one data in the data series but was expecting 14...=
=20
>And then, I have to make the labs list as a list containing another list=20
>and this one with the 14 labels regarding to the data series... and this=20
>generates an equal chart, but this chart has just one color, and if I try=
=20
>to change the color for each bar, all bars will have the same color of the=
=20
>last bar I have changed its color...
>
>I am trying to attach the actual jpg of the problem so you can better=20
>understand the problem I am telling.
>
>I would appreciate any help !
>
>Thanks,
>
>Marcus
>




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
--=====================_3043093==.ALT
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
All,<br><br>
I am sorry to bother you again about this, but I really need some help...
Is there any other place where I can look for help ? like a bug reporting
or a list where I can talk to the reportlab developers ?<br><br>
Thanks a lot,<br><br>
Marcus<br><br>
At 17:03 12/07/02 -0300, you wrote:<br>
<blockquote type=3Dcite class=3Dcite cite>Robin,<br><br>
Here is the code of the chart I am having problem:<br><br>
from reportlab.lib import colors<br>
from reportlab.graphics.shapes import Drawing<br>
from reportlab.graphics.charts.barcharts import HorizontalBarChart<br>
from reportlab.graphics.charts.textlabels import Label<br>
from reportlab.graphics import renderPM<br><br>
def chooseColor():<br>
&nbsp;&nbsp;&nbsp; choosedColor =3D select(colorSet)<br>
&nbsp;&nbsp;&nbsp; if choosedColor is None:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for color in
colors.getAllNamedColors():<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
colorSet.append(colors.getAllNamedColors()[color])<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; choosedColor =3D
select(colorSet)<br>
&nbsp;&nbsp;&nbsp; return choosedColor<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab><br>
def select(sequence):<br>
&nbsp;&nbsp;&nbsp; if sequence !=3D []:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elem =3D
sequence[len(sequence)-1]<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sequence[len(sequence)-1] =3D
-1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; del
sequence[len(sequence)-1]<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return elem<br>
&nbsp;&nbsp;&nbsp; else:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return None<br><br>
colorSet =3D []<br><br>
data =3D [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series 1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series
2<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series
3<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series
4<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [0, 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p;&nbsp; # Data series
12<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series
13<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1]]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series
14<br><br>
labs =3D ['ITA',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series
1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'VOT',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series 2<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'SAN',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series 3<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'GES2',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series 4<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'OSA-GES1',&nbsp;&nbsp; # Data
series 5<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'CID-ANA',&nbsp;&nbsp;&nbsp; #
Data series 6<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'GHP',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series 7<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'CCT',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series 8<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'JAU',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series 9<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'BEB',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series 10<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'SJB',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series 11<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'SJR',&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series 12<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'GES16435',&nbsp;&nbsp; # Data
series 13<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
'CES']&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Data series
14<br><br>
drawing =3D Drawing(450, 550)<br>
bc =3D HorizontalBarChart()<br>
bc.x =3D 120<br>
bc.y =3D 40<br>
bc.height =3D 450<br>
bc.width =3D 320<br>
bc.data =3D data<br>
m =3D 0<br>
for l in data:<br>
&nbsp;&nbsp;&nbsp; maux =3D max(l)<br>
&nbsp;&nbsp;&nbsp; if maux &gt; m:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m =3D maux<br>
bc.valueAxis.valueMin =3D 0<br>
bc.valueAxis.valueMax =3D m + 1<br>
bc.valueAxis.valueStep =3D 1<br>
bc.valueAxis.rangeRound=3D'both'<br>
bc.categoryAxis.style =3D 'stacked'<br>
bc.categoryAxis.configure(labs)<br>
bc.categoryAxis.categoryNames =3D labs<br>
bc.categoryAxis.labels.fontName =3D 'Helvetica'<br>
bc.categoryAxis.labels.textAnchor =3D 'end'<br>
for a in range(len(data[0])):<br>
&nbsp;&nbsp;&nbsp; bc.bars[a].fillColor =3D chooseColor()<br>
drawing.add(bc)<br>
renderPM.drawToFile(drawing, &quot;ipa.jpg&quot;, 'JPG')<br><br>
This code actually generates the chart with the black lines I told... I
don't know how to fix it !!!<br><br>
The data list is a list of lists... this was the only way I found to
change the color of each bar instead of having the bars in only one
color... If I use data with just one list then I receive an error telling
me that there was just one data in the data series but was expecting
14... And then, I have to make the labs list as a list containing another
list and this one with the 14 labels regarding to the data series... and
this generates an equal chart, but this chart has just one color, and if
I try to change the color for each bar, all bars will have the same color
of the last bar I have changed its color...<br><br>
I am trying to attach the actual jpg of the problem so you can better
understand the problem I am telling.<br><br>
I would appreciate any help !<br><br>
Thanks,<br><br>
Marcus<br><br>
</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>

--=====================_3043093==.ALT--