|
python_it at hotmail.com
python_it at hotmail.com
Fri Oct 14 08:13:22 EDT 2005
Did somebody has experience with CharDirector and Mod_python (Publisher).
(Python 2.4 / ChartDirector for Python / Modpython 3.2.2b)
I cant make chart with this combination? (I dont get errors?)
Publisher is working ok with other scripts.
I use the following script files:
Index.htm => index.py => chart.tmpl
Index.htm
=================
Link to index.py
Index.py
=================
from mod_python import psp,util
def index(req, perc=[10 , 10 , 80], descrip=['10', '10' ,'80'],
title="chart", filename="chart.png"):
req.content_type = text/html
tmpl = psp.PSP(req, filename='templates/chart.tmpl', vars={'req': req,
'psp': psp, 'perc': perc, 'descrip': descrip, 'title': title, 'filename':
filename})
tmpl.run()
chart.tmpl
=================
<HTML>
<%=perc%><br>
<%=descrip%><br>
<%=title%><br>
<%=filename%><br>
<%
from pychartdir import *
def graph(perc, descrip, title, filename):
#The data for the pie chart
data = perc
#The labels for the pie chart
labels = descrip
#Create a PieChart object of size 500 x 230 pixels, with a golden background
and
#a 1 pixel 3D border
c = PieChart(1000, 500)
#Set the center of the pie at (150, 100) and the radius to 80 pixels
c.setPieSize(330, 210, 160)
#Add a title at the bottom of the chart using Arial Bold Italic font
c.addTitle(title, "timesbi.ttf", 14)
#Draw the pie in 3D
c.set3D()
#Use the side label layout method
c.setLabelLayout(SideLayout)
#Set the label box the same color as the sector with a 1 pixel 3D border
c.setLabelStyle("ARIALBD.TTF", 10).setBackground(Transparent, -1)
#Set the border color of the sector the same color as the fill color. Set
the
#line color of the join line to black (0x0)
c.setLineColor(SameAsMainColor)
#Set the start angle to 135 degrees may improve layout when there are many
small
#sectors at the end of the data array (that is, data sorted in descending
#order). It is because this makes the small sectors position near the
horizontal
#axis, where the text label has the least tendency to overlap. For data
sorted
#in ascending order, a start angle of 45 degrees can be used instead.
c.setStartAngle(60)
#Set the pie data and the pie labels
c.setData(data, labels)
#output the chart
c.makeChart(filename)
graph(perc, descrip, title, filename)
%>
</HTML>
RESULTS IE
[10, 10, 80]
['10', '10', '80']
chart
chart.png
Im missing the png file in my template directory?
Why the Chart is not making?
_________________________________________________________________
Stuur een voiceclip met MSN Messenger 7.5
http://www1.imagine-msn.com/Messenger/Video.aspx
|