author | Rémi Cardona <remi.cardona@logilab.fr> |
Wed, 16 Sep 2015 17:22:41 +0200 | |
changeset 10696 | 4ba4be5553cf |
parent 10688 | fa29f3628a1b |
permissions | -rw-r--r-- |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7919
diff
changeset
|
1 |
# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5389
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
6582
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5940
diff
changeset
|
18 |
"""basic plot views""" |
1886
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
19 |
|
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
20 |
__docformat__ = "restructuredtext en" |
10666
7f6b5f023884
[py3k] replace '_ = unicode' in global scope (closes #7589459)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10609
diff
changeset
|
21 |
from cubicweb import _ |
1886
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
22 |
|
10688
fa29f3628a1b
[py3k] use six.add_metaclass
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10669
diff
changeset
|
23 |
from six import add_metaclass |
10609
e2d8e81bfe68
[py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8190
diff
changeset
|
24 |
from six.moves import range |
e2d8e81bfe68
[py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8190
diff
changeset
|
25 |
|
4466
8b0ca7904820
moved generic datetime manipulation function to lgc
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4459
diff
changeset
|
26 |
from logilab.common.date import datetime2ticks |
7919
ae3307cac44e
[view, plot] deprecate flot and encourage usage of the jqplot cube (closes #1625218)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7879
diff
changeset
|
27 |
from logilab.common.deprecation import class_deprecated |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7919
diff
changeset
|
28 |
from logilab.common.registry import objectify_predicate |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2161
diff
changeset
|
29 |
from logilab.mtconverter import xml_escape |
0 | 30 |
|
5940
0e3ae19b181a
[uilib] refactor json_dumps code organization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
31 |
from cubicweb.utils import UStringIO, json_dumps |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7919
diff
changeset
|
32 |
from cubicweb.predicates import multi_columns_rset |
0 | 33 |
from cubicweb.web.views import baseviews |
34 |
||
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7919
diff
changeset
|
35 |
@objectify_predicate |
2161
200481e7b156
prepare time where it won't be mandatory to give rset to select()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2009
diff
changeset
|
36 |
def all_columns_are_numbers(cls, req, rset=None, *args, **kwargs): |
0 | 37 |
"""accept result set with at least one line and two columns of result |
38 |
all columns after second must be of numerical types""" |
|
39 |
for etype in rset.description[0]: |
|
7460
2455cdbeadca
[schema] support for BigInt type. Closes #1720995
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7393
diff
changeset
|
40 |
if etype not in ('Int', 'BigInt', 'Float'): |
0 | 41 |
return 0 |
42 |
return 1 |
|
43 |
||
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7919
diff
changeset
|
44 |
@objectify_predicate |
2161
200481e7b156
prepare time where it won't be mandatory to give rset to select()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2009
diff
changeset
|
45 |
def second_column_is_number(cls, req, rset=None, *args, **kwargs): |
1886
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
46 |
etype = rset.description[0][1] |
7460
2455cdbeadca
[schema] support for BigInt type. Closes #1720995
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7393
diff
changeset
|
47 |
if etype not in ('Int', 'BigInt', 'Float'): |
1886
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
48 |
return 0 |
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
49 |
return 1 |
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
50 |
|
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7919
diff
changeset
|
51 |
@objectify_predicate |
2161
200481e7b156
prepare time where it won't be mandatory to give rset to select()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2009
diff
changeset
|
52 |
def columns_are_date_then_numbers(cls, req, rset=None, *args, **kwargs): |
1888
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
53 |
etypes = rset.description[0] |
7166
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6582
diff
changeset
|
54 |
if etypes[0] not in ('Date', 'Datetime', 'TZDatetime'): |
1888
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
55 |
return 0 |
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
56 |
for etype in etypes[1:]: |
7460
2455cdbeadca
[schema] support for BigInt type. Closes #1720995
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7393
diff
changeset
|
57 |
if etype not in ('Int', 'BigInt', 'Float'): |
1888
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
58 |
return 0 |
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
59 |
return 1 |
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
60 |
|
0 | 61 |
|
1888
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
62 |
def filterout_nulls(abscissa, plot): |
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
63 |
filtered = [] |
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
64 |
for x, y in zip(abscissa, plot): |
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
65 |
if x is None or y is None: |
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
66 |
continue |
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
67 |
filtered.append( (x, y) ) |
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
68 |
return sorted(filtered) |
0 | 69 |
|
1892
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
70 |
class PlotWidget(object): |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
71 |
# XXX refactor with cubicweb.web.views.htmlwidgets.HtmlWidget |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
72 |
def _initialize_stream(self, w=None): |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
73 |
if w: |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
74 |
self.w = w |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
75 |
else: |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
76 |
self._stream = UStringIO() |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
77 |
self.w = self._stream.write |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
78 |
|
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
79 |
def render(self, *args, **kwargs): |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
80 |
w = kwargs.pop('w', None) |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
81 |
self._initialize_stream(w) |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
82 |
self._render(*args, **kwargs) |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
83 |
if w is None: |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
84 |
return self._stream.getvalue() |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
85 |
|
7879
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7569
diff
changeset
|
86 |
def _render(self, *args, **kwargs): |
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7569
diff
changeset
|
87 |
raise NotImplementedError |
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7569
diff
changeset
|
88 |
|
10688
fa29f3628a1b
[py3k] use six.add_metaclass
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10669
diff
changeset
|
89 |
|
fa29f3628a1b
[py3k] use six.add_metaclass
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10669
diff
changeset
|
90 |
@add_metaclass(class_deprecated) |
1892
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
91 |
class FlotPlotWidget(PlotWidget): |
1891
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
92 |
"""PlotRenderer widget using Flot""" |
7919
ae3307cac44e
[view, plot] deprecate flot and encourage usage of the jqplot cube (closes #1625218)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7879
diff
changeset
|
93 |
__deprecation_warning__ = '[3.14] cubicweb.web.views.plots module is deprecated, use the jqplot cube instead' |
4209
8712d699beb2
do not recompute the plot on subsequent onload events #615338
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3785
diff
changeset
|
94 |
onload = u""" |
7567
d6366de1d0dc
Display proper date in plot/flot (closes #1725589)
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
7393
diff
changeset
|
95 |
var fig = jQuery('#%(figid)s'); |
4209
8712d699beb2
do not recompute the plot on subsequent onload events #615338
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3785
diff
changeset
|
96 |
if (fig.attr('cubicweb:type') != 'prepared-plot') { |
8712d699beb2
do not recompute the plot on subsequent onload events #615338
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3785
diff
changeset
|
97 |
%(plotdefs)s |
7567
d6366de1d0dc
Display proper date in plot/flot (closes #1725589)
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
7393
diff
changeset
|
98 |
jQuery.plot(jQuery('#%(figid)s'), [%(plotdata)s], |
4209
8712d699beb2
do not recompute the plot on subsequent onload events #615338
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3785
diff
changeset
|
99 |
{points: {show: true}, |
8712d699beb2
do not recompute the plot on subsequent onload events #615338
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3785
diff
changeset
|
100 |
lines: {show: true}, |
8712d699beb2
do not recompute the plot on subsequent onload events #615338
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3785
diff
changeset
|
101 |
grid: {hoverable: true}, |
7567
d6366de1d0dc
Display proper date in plot/flot (closes #1725589)
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
7393
diff
changeset
|
102 |
/*yaxis : {tickFormatter : suffixFormatter},*/ |
4209
8712d699beb2
do not recompute the plot on subsequent onload events #615338
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3785
diff
changeset
|
103 |
xaxis: {mode: %(mode)s}}); |
7567
d6366de1d0dc
Display proper date in plot/flot (closes #1725589)
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
7393
diff
changeset
|
104 |
jQuery('#%(figid)s').data({mode: %(mode)s, dateformat: %(dateformat)s}); |
d6366de1d0dc
Display proper date in plot/flot (closes #1725589)
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
7393
diff
changeset
|
105 |
jQuery('#%(figid)s').bind('plothover', onPlotHover); |
4209
8712d699beb2
do not recompute the plot on subsequent onload events #615338
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3785
diff
changeset
|
106 |
fig.attr('cubicweb:type','prepared-plot'); |
8712d699beb2
do not recompute the plot on subsequent onload events #615338
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3785
diff
changeset
|
107 |
} |
8712d699beb2
do not recompute the plot on subsequent onload events #615338
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3785
diff
changeset
|
108 |
""" |
1892
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
109 |
|
1891
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
110 |
def __init__(self, labels, plots, timemode=False): |
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
111 |
self.labels = labels |
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
112 |
self.plots = plots # list of list of couples |
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
113 |
self.timemode = timemode |
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
114 |
|
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
115 |
def dump_plot(self, plot): |
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
116 |
if self.timemode: |
7567
d6366de1d0dc
Display proper date in plot/flot (closes #1725589)
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
7393
diff
changeset
|
117 |
plot = [(datetime2ticks(x), y) for x, y in plot] |
5940
0e3ae19b181a
[uilib] refactor json_dumps code organization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
118 |
return json_dumps(plot) |
1892
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
119 |
|
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
120 |
def _render(self, req, width=500, height=400): |
4209
8712d699beb2
do not recompute the plot on subsequent onload events #615338
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3785
diff
changeset
|
121 |
if req.ie_browser(): |
8712d699beb2
do not recompute the plot on subsequent onload events #615338
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3785
diff
changeset
|
122 |
req.add_js('excanvas.js') |
8712d699beb2
do not recompute the plot on subsequent onload events #615338
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3785
diff
changeset
|
123 |
req.add_js(('jquery.flot.js', 'cubicweb.flot.js')) |
10669
155c29e0ed1c
[py3k] use next builtin instead of next method
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10666
diff
changeset
|
124 |
figid = u'figure%s' % next(req.varmaker) |
1891
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
125 |
plotdefs = [] |
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
126 |
plotdata = [] |
1892
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
127 |
self.w(u'<div id="%s" style="width: %spx; height: %spx;"></div>' % |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
128 |
(figid, width, height)) |
1891
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
129 |
for idx, (label, plot) in enumerate(zip(self.labels, self.plots)): |
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
130 |
plotid = '%s_%s' % (figid, idx) |
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
131 |
plotdefs.append('var %s = %s;' % (plotid, self.dump_plot(plot))) |
3714
3cb7dcd9ae77
ugly workaround to javascript serialisation problem #481437 (not considered fixed by this changeset)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
3689
diff
changeset
|
132 |
# XXX ugly but required in order to not crash my demo |
3cb7dcd9ae77
ugly workaround to javascript serialisation problem #481437 (not considered fixed by this changeset)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
3689
diff
changeset
|
133 |
plotdata.append("{label: '%s', data: %s}" % (label.replace(u'&', u''), plotid)) |
7567
d6366de1d0dc
Display proper date in plot/flot (closes #1725589)
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
7393
diff
changeset
|
134 |
fmt = req.property_value('ui.date-format') # XXX datetime-format |
d6366de1d0dc
Display proper date in plot/flot (closes #1725589)
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
7393
diff
changeset
|
135 |
# XXX TODO make plot options customizable |
1891
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
136 |
req.html_headers.add_onload(self.onload % |
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
137 |
{'plotdefs': '\n'.join(plotdefs), |
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
138 |
'figid': figid, |
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
139 |
'plotdata': ','.join(plotdata), |
7567
d6366de1d0dc
Display proper date in plot/flot (closes #1725589)
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
7393
diff
changeset
|
140 |
'mode': self.timemode and "'time'" or 'null', |
d6366de1d0dc
Display proper date in plot/flot (closes #1725589)
Arthur Lutz <arthur.lutz@logilab.fr>
parents:
7393
diff
changeset
|
141 |
'dateformat': '"%s"' % fmt}) |
1892
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
142 |
|
1891
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
143 |
|
10688
fa29f3628a1b
[py3k] use six.add_metaclass
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10669
diff
changeset
|
144 |
@add_metaclass(class_deprecated) |
1888
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
145 |
class PlotView(baseviews.AnyRsetView): |
7919
ae3307cac44e
[view, plot] deprecate flot and encourage usage of the jqplot cube (closes #1625218)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7879
diff
changeset
|
146 |
__deprecation_warning__ = '[3.14] cubicweb.web.views.plots module is deprecated, use the jqplot cube instead' |
3408
c92170fca813
[api] use __regid__ instead of deprecated id
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3338
diff
changeset
|
147 |
__regid__ = 'plot' |
1888
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
148 |
title = _('generic plot') |
4320
4efd4c306746
closes #345410: two_lines_rset, two_cols_rset, two_etypes_rset are badly named
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
149 |
__select__ = multi_columns_rset() & all_columns_are_numbers() |
1891
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
150 |
timemode = False |
7390
be2fffc9ec17
[plot views] don't paginate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7166
diff
changeset
|
151 |
paginable = False |
0 | 152 |
|
1888
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
153 |
def call(self, width=500, height=400): |
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
154 |
# prepare data |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
155 |
rqlst = self.cw_rset.syntax_tree() |
1888
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
156 |
# XXX try to make it work with unions |
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
157 |
varnames = [var.name for var in rqlst.children[0].get_selected_variables()][1:] |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
158 |
abscissa = [row[0] for row in self.cw_rset] |
1891
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
159 |
plots = [] |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
160 |
nbcols = len(self.cw_rset.rows[0]) |
10609
e2d8e81bfe68
[py3k] import range using six.moves
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8190
diff
changeset
|
161 |
for col in range(1, nbcols): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
162 |
data = [row[col] for row in self.cw_rset] |
1991
8a9d8f1ee100
bugfix for plots
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
163 |
plots.append(filterout_nulls(abscissa, data)) |
1891
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
164 |
plotwidget = FlotPlotWidget(varnames, plots, timemode=self.timemode) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
165 |
plotwidget.render(self._cw, width, height, w=self.w) |
0 | 166 |
|
1888
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
167 |
|
f36d43f00f32
[views] plot with flot and get rid of matplotlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1886
diff
changeset
|
168 |
class TimeSeriePlotView(PlotView): |
4320
4efd4c306746
closes #345410: two_lines_rset, two_cols_rset, two_etypes_rset are badly named
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
169 |
__select__ = multi_columns_rset() & columns_are_date_then_numbers() |
1891
dd7c1d7715e7
[views][plots] extract the plotting mechanism in an HTMLWidget to make mit more re-usable
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1888
diff
changeset
|
170 |
timemode = True |
1886
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
171 |
|
1892
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
172 |
|
1886
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
173 |
try: |
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
174 |
from GChartWrapper import Pie, Pie3D |
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
175 |
except ImportError: |
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
176 |
pass |
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
177 |
else: |
1892
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
178 |
|
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
179 |
class PieChartWidget(PlotWidget): |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
180 |
def __init__(self, labels, values, pieclass=Pie, title=None): |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
181 |
self.labels = labels |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
182 |
self.values = values |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
183 |
self.pieclass = pieclass |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
184 |
self.title = title |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
185 |
|
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
186 |
def _render(self, width=None, height=None): |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
187 |
piechart = self.pieclass(self.values) |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
188 |
piechart.label(*self.labels) |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
189 |
if width is not None: |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
190 |
height = height or width |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
191 |
piechart.size(width, height) |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
192 |
if self.title: |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
193 |
piechart.title(self.title) |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2161
diff
changeset
|
194 |
self.w(u'<img src="%s" />' % xml_escape(piechart.url)) |
1892
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
195 |
|
1886
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
196 |
class PieChartView(baseviews.AnyRsetView): |
3408
c92170fca813
[api] use __regid__ instead of deprecated id
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3338
diff
changeset
|
197 |
__regid__ = 'piechart' |
1886
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
198 |
pieclass = Pie |
7390
be2fffc9ec17
[plot views] don't paginate
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7166
diff
changeset
|
199 |
paginable = False |
1892
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
200 |
|
4320
4efd4c306746
closes #345410: two_lines_rset, two_cols_rset, two_etypes_rset are badly named
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
201 |
__select__ = multi_columns_rset() & second_column_is_number() |
1886
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
202 |
|
1956
9865daa96cd7
[views][plot] piechart view now accepts either final or non final entities in the first column
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1911
diff
changeset
|
203 |
def _guess_vid(self, row): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
204 |
etype = self.cw_rset.description[row][0] |
4045
f4a52abb6f4f
cw 3.6 api update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
205 |
if self._cw.vreg.schema.eschema(etype).final: |
1956
9865daa96cd7
[views][plot] piechart view now accepts either final or non final entities in the first column
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1911
diff
changeset
|
206 |
return 'final' |
9865daa96cd7
[views][plot] piechart view now accepts either final or non final entities in the first column
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1911
diff
changeset
|
207 |
return 'textincontext' |
9865daa96cd7
[views][plot] piechart view now accepts either final or non final entities in the first column
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1911
diff
changeset
|
208 |
|
1886
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
209 |
def call(self, title=None, width=None, height=None): |
1956
9865daa96cd7
[views][plot] piechart view now accepts either final or non final entities in the first column
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1911
diff
changeset
|
210 |
labels = [] |
9865daa96cd7
[views][plot] piechart view now accepts either final or non final entities in the first column
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1911
diff
changeset
|
211 |
values = [] |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
212 |
for rowidx, (_, value) in enumerate(self.cw_rset): |
1956
9865daa96cd7
[views][plot] piechart view now accepts either final or non final entities in the first column
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1911
diff
changeset
|
213 |
if value is not None: |
9865daa96cd7
[views][plot] piechart view now accepts either final or non final entities in the first column
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1911
diff
changeset
|
214 |
vid = self._guess_vid(rowidx) |
7393
7824d61f41a2
fix some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7390
diff
changeset
|
215 |
label = '%s: %s' % (self._cw.view(vid, self.cw_rset, row=rowidx, col=0), |
1956
9865daa96cd7
[views][plot] piechart view now accepts either final or non final entities in the first column
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1911
diff
changeset
|
216 |
value) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
217 |
labels.append(label.encode(self._cw.encoding)) |
1956
9865daa96cd7
[views][plot] piechart view now accepts either final or non final entities in the first column
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1911
diff
changeset
|
218 |
values.append(value) |
1892
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
219 |
pie = PieChartWidget(labels, values, pieclass=self.pieclass, |
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
220 |
title=title) |
1886
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
221 |
if width is not None: |
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
222 |
height = height or width |
1892
fb80d9c434e5
[views] extract a PieWidget from pie views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1891
diff
changeset
|
223 |
pie.render(width, height, w=self.w) |
1886
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
224 |
|
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
225 |
|
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
226 |
class PieChart3DView(PieChartView): |
3408
c92170fca813
[api] use __regid__ instead of deprecated id
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3338
diff
changeset
|
227 |
__regid__ = 'piechart3D' |
1886
f0e28ddba7c5
[views] add pie chart views with google chart / GChartWrapper
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1133
diff
changeset
|
228 |
pieclass = Pie3D |