Hi Jose,
This program does what you ask:
http://www.web2py.com/sc2009
You can find source and examples:
http://www.web2py.com/examples/static/sc/sc_dna_talk.pdf
http://www.web2py.com/examples/static/sc/web2py.app.dna.w2p
This is part of a tutorial I gave at Supercomputing 2009.
Massimo
On Apr 1, 2010, at 9:05 AM, Jose Roberto Siciliano Iryoda wrote:
First of all: Sorry my english.
---------------------------------------------------------
Dear Massimo,
I'm new in python and web2py. I started watching your vídeo
demonstration, and after that i will trying develop e-Assessment web
application with web2py. In this moment i trying create some reports
with matplolib and i dont find some documentation for that question.
I need to know how the web2py and matplotlib works together. Please
help me!
1 – I work in web2py for Windows, the latest version. My python
version is 2.6 . I have instaled numpy and matplotlib.
2- My module:
import numpy as np
import matplotlib.pyplot as plt
def gera_grafico(aluno_nota,tit_grafico,tity,titx,nom_arq):
pos = np.arange(len(aluno_nota))+.5
nomes=[aluno['nome'] for aluno in aluno_nota]
notas=[aluno['nota'] for aluno in aluno_nota]
plt.subplot(111).set_autoscale_on(False)
plt.axis((0,10,0,len(aluno_nota)))
plt.barh(pos,notas, align='center')
plt.yticks(pos, nomes)
plt.xlabel(titx)
plt.ylabel(tity)
plt.title(tit_grafico)
plt.grid(True, alpha=0.3)
plt.savefig(nom_arq)
My controller:
import random
def rel_aluno_nota():
aluno_nota=[]
from applications.Mestre.modules.graf1 import
gera_grafico
turma_id = request.args[0]
query=(db.aluno.id ==
db
.alocacao
.aluno)&(db.turma.id==db.alocacao.turma)&(db.turma.id==turma_id)
alocacao = db(query).select(db.aluno.matricula)
for aluno in alocacao:
novo_aluno =
{'nome':aluno.matricula,'nota':random.random()*10}
aluno_nota.append(novo_aluno)
gera_grafico(aluno_nota,'Turma 01 -
Notas','Alunos','Notas','applications\Mestre\static\turma01.png')
return dict(imagem = 'turma01.png')
My View:
{{extend 'layout.html'}}
<img src='{{=URL(r=request,c='static',f=imagem)}}'>
The question is: Why my report dont work in web2py? The Server stop
responding and the only way to back is restarting.
Can you post a simple report with graph in web2py?
Thanks !
José Roberto Siciliano Iryoda
Brasil – Rio de Janeiro
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.