I also tried to place the
> current.response.files.append(URL('static',
> 'jqplot/jquery.jqplot.min.js'))
> current.response.files.append(URL('static',
> 'jqplot/jquery.jqplot.min.css'))
> current.response.files.append(URL('static',
> 'jqplot/plugins/jqplot.barRenderer.min.js'))
> current.response.files.append(URL('static',
> 'jqplot/plugins/jqplot.categoryAxisRenderer.min.js'))
> current.response.files.append(URL('static',
> 'jqplot/plugins/jqplot.pointLabels.min.js'))
in the xml method, but it didn't make to the response either.
El 13/08/14 a las #4, Pablo Angulo escribió:
> El 13/08/14 a las #4, Anthony escribió:
>> Can you show your module code? Are you doing the appending at the top
>> level in the module, or within a function/method?
> The latter:
>
>> # -*- coding: utf-8 -*-
>> # (C) Copyright (C) 2012-14 Pablo Angulo
>> # This file is part of karakolas <karakolas.org>.
>>
>> # karakolas is free software: you can redistribute it and/or modify
>> # it under the terms of the GNU Affero General Public License as
>> # published by the Free Software Foundation, either version 3 of the
>> # License, or (at your option) any later version.
>>
>> # karakolas is distributed in the hope that it will be useful,
>> # but WITHOUT ANY WARRANTY; without even the implied warranty of
>> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> # GNU General Public License for more details.
>>
>> # You should have received a copy of the GNU Affero General Public
>> # License along with karakolas. If not, see
>> # <http://www.gnu.org/licenses/>.
>>
>> from gluon.html import URL, FORM
>> from gluon import current
>> from collections import defaultdict
>>
>> class JQPlot(FORM):
>>
>> def __init__(self, query,
>> row_field, col_field, data_field,
>> row_ids=None, col_ids=None,
>> row_represent=None, col_represent=None,
>> data_represent=None,
>> _id='',
>> **attributes):
>> '''Muestra una gráfica ligeramente interactiva para visualizar
>> una relacion que representa una funcion (ref1,ref2) -> valor
>> '''
>> FORM.__init__(self, **attributes)
>> current.response.files.append(URL('static',
>> 'jqplot/jquery.jqplot.min.js'))
>> current.response.files.append(URL('static',
>> 'jqplot/jquery.jqplot.min.css'))
>> current.response.files.append(URL('static',
>> 'jqplot/plugins/jqplot.barRenderer.min.js'))
>> current.response.files.append(URL('static',
>> 'jqplot/plugins/jqplot.categoryAxisRenderer.min.js'))
>> current.response.files.append(URL('static',
>> 'jqplot/plugins/jqplot.pointLabels.min.js'))
>>
>> self.query = query
>> self.row_field = row_field
>> self.col_field = col_field
>> self.data_field = data_field
>>
>> self.row_represent = row_represent or row_field.represent or
>> (lambda x:x)
>> self.col_represent = col_represent or col_field.represent or
>> (lambda x:x)
>> try:
>> self.data_represent = data_represent or
>> data_field.represent or (lambda x:x)
>> except AttributeError:
>> #A f.sum() or f.count() doesn't have a represent attribute
>> self.data_represent = (lambda x:x)
>>
>> self.row_ids = row_ids or [r[row_field] for r in
>> current.db(query).select(row_field, groupby=row_field)]
>> self.row_names = [self.row_represent(rid) for rid in self.row_ids]
>> self.col_ids = col_ids or [r[col_field] for r in
>> current.db(query).select(col_field, groupby=col_field)]
>> self.col_names = [self.col_represent(cid) for cid in self.col_ids]
>>
>> def xml(self):
>>
>> d = defaultdict(float)
>> recs = current.db(self.query).select(
>> self.row_field, self.col_field, self.data_field,
>> groupby=self.row_field|self.col_field
>> )
>>
>> for row in recs:
>> d[row[self.row_field],
>> row[self.col_field]]=row[self.data_field]
>>
>> data = [[float(d[r,c]) for c in self.col_ids] for r in
>> self.row_ids]
>> series_labels = ','.join("{label:'%s'}"%self.row_represent(r)
>> for r in self.row_ids)
>> ticks = self.col_names
>>
>> d = dict(data=data,ticks=ticks, series_labels=series_labels)
>> return current.response.render('jqplot.html', d)
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.