• R/O
  • SSH
  • HTTPS

shibuya-trac: Commit


Commit MetaInfo

Revision862 (tree)
Time2015-04-24 20:34:19
Authorjun66j5

Log Message

ReportIncludePlugin: fixed not working with Trac 1.0

Change Summary

Incremental Difference

--- plugins/reportincludeplugin/trunk/0.12/reportinclude/macro.py (revision 861)
+++ plugins/reportincludeplugin/trunk/0.12/reportinclude/macro.py (revision 862)
@@ -32,7 +32,7 @@
3232
3333 def get_templates_dirs(self):
3434 return [pkg_resources.resource_filename(__name__, 'templates')]
35-
35+
3636 # IWikiMacroProvider methods
3737 def get_macros(self):
3838 yield 'ReportInclude'
@@ -65,7 +65,7 @@
6565 * legendXOffset: グラフの凡例位置の横方向のオフセットを指定します。未指定の場合は12となります。
6666 * legendYOffset: グラフの凡例位置の縦方向のオフセットを指定します。未指定の場合は12となります。
6767 * dateFormat: X軸の値を日付としてグラフ表示する場合の、日付フォーマットを指定します。コロンに続けて、yyyy/MM/dd のように指定します。未指定の場合は、デフォルト値としてyyyy-MM-ddを使用します。
68- * width: グラフの幅をpx単位で指定します。未指定の場合は536pxとなります。
68+ * width: グラフの幅をpx単位で指定します。未指定の場合は536pxとなります。
6969 * height: グラフの高さをpx単位で指定します。未指定の場合は300pxとなります。
7070 * table: TracReportのテーブルを出力を制御できます。コロンに続けて、以下の記載が可能です。
7171 * hide[[BR]]
@@ -120,13 +120,13 @@
120120 '''
121121
122122 def expand_macro(self, formatter, name, content):
123-
123+
124124 if not content:
125- raise ResourceNotFound(u"[[ReportInclude(1)]]のように引数を指定してください。")
125+ raise ResourceNotFound(u"[[ReportInclude(1)]]のように引数を指定してください。")
126126 req = formatter.req
127-
127+
128128 self._add_script(req)
129-
129+
130130 if self._is_async(content):
131131 return self._render_async(req, content)
132132 else:
@@ -135,7 +135,7 @@
135135 def _add_script(self, req):
136136 if not hasattr(req, '_reportinclude'):
137137 #add_stylesheet(req, 'reportinclude/css/reportinclude.css')
138-
138+
139139 # add script and css for jqplot
140140 add_script(req, 'reportinclude/js/jqplot/excanvas.min.js')
141141 add_script(req, 'reportinclude/js/jqplot/jquery.jqplot.min.js')
@@ -148,11 +148,11 @@
148148 add_script(req, 'reportinclude/js/jqplot/jqplot.highlighter.min.js')
149149 add_script(req, 'reportinclude/js/jqplot/reportgraph.js')
150150 add_stylesheet(req, 'reportinclude/css/jqplot/jquery.jqplot.min.css')
151-
151+
152152 req._reportinclude = 0
153153 else:
154154 req._reportinclude = req._reportinclude + 1
155-
155+
156156 def _is_async(self, content):
157157 match = re.match(r'.*(async\s*:\s*false).*', content.lower())
158158 if match:
@@ -159,42 +159,37 @@
159159 return False
160160 # default Ajax Mode
161161 return True
162-
162+
163163 def _render(self, req, content):
164164 renderer = ReportRenderer(self.env)
165165 return renderer.render(req, content)
166-
166+
167167 def _render_async(self, req, content):
168168 index = req._reportinclude
169-
169+
170170 div = tag.div(id="reportgraphtable_async_%d" %(index))
171- script = """
172-jQuery(function(){
173- jQuery("#reportgraphtable_loading_%d").ajaxStart(function(){
174- jQuery(this).show();
175- });
176- jQuery("#reportgraphtable_loading_%d").ajaxStop(function(){
177- jQuery(this).hide();
178- });
171+ script = """\
172+jQuery(document).ready(function($){
173+ var loading = $("#reportgraphtable_loading_%d");
174+ loading.ajaxStart(function() { jQuery(this).show() });
175+ loading.ajaxStop(function() { $(this).hide() });
179176
180- jQuery.ajax({
177+ $.ajax({
181178 type: "POST",
182179 url: "%s",
183180 data: "__FORM_TOKEN=%s;index=%s;params=%s",
184181 dataType: "html",
185- success: function (data) {
186- jQuery("#reportgraphtable_%d").html(data);
187- }
182+ success: function (data) { $("#reportgraphtable_%d").html(data) }
188183 })
189184 });
190-""" % (index, index, req.href.tracreportinclude(),
185+""" % (index, req.href.tracreportinclude(),
191186 req.form_token, index, content.replace('&', '__AND__'), index)
192-
187+
193188 div.append(tag.script(script, type='text/javascript'))
194189 div.append(tag.div((tag.img(src=req.href.chrome('reportinclude/image/loading.gif')),
195190 tag.div('loading...')),
196191 id='reportgraphtable_loading_%d' %(index),
197192 style='border: solid 1px black; top: 50%; left: 50%; width: 50%; height: 200px; padding-top: 100px; text-align: center; top: 50%;'))
198- div.append(tag.div('', id='reportgraphtable_%d' %(index)))
199-
193+ div.append(tag.div('', id='reportgraphtable_%d' % index))
194+
200195 return div
--- plugins/reportincludeplugin/trunk/0.12/reportinclude/renderer.py (revision 861)
+++ plugins/reportincludeplugin/trunk/0.12/reportinclude/renderer.py (revision 862)
@@ -1,33 +1,35 @@
11 # -*- coding: utf-8 -*-
22
33 from genshi.builder import tag
4-from genshi.filters import Transformer
54
65 from trac.core import TracError
6+from trac.db.api import get_column_names
77 from trac.resource import ResourceNotFound
88 from trac.ticket.report import ReportModule
99 from trac.util.datefmt import format_datetime, format_date, format_time, parse_date
1010 from trac.util.presentation import to_json
11+from trac.util.translation import _
1112
13+
1214 class ReportRenderer(object):
13-
15+
1416 def __init__(self, env):
1517 self.env = env
16-
18+
1719 def render(self, req, params):
1820 u"""TracReportsの結果をHTMLで返す。オプションによってはテーブル、グラフそれぞれを表示する。
1921 """
2022 self.index = req._reportinclude
21-
23+
2224 id, vars, opts = self._parse_params(req, params)
2325 report = self._get_report_info(id)
24-
26+
2527 if len(report) == 1:
2628 title, sql, desc = report[0]
27-
29+
2830 if opts['title'] == '':
2931 opts['title'] = title
30-
32+
3133 table, columns, table_data = self._render_table(req, id, vars, opts, title, sql, desc)
3234 table = self._render_graph(req, opts, table, columns, table_data, title, desc)
3335 return table
@@ -35,20 +37,20 @@
3537 raise ResourceNotFound(
3638 _('Report [%(num)] does not exist.', num=id),
3739 _('Invalid Report Number'))
38-
40+
3941 def _render_table(self, req, id, vars, opts, title, sql, desc):
4042 db = self.env.get_db_cnx()
41-
43+
4244 sql, vars , missing_vars = self._sql_sub_vars(sql, vars, db)
43-
45+
4446 cursor = db.cursor()
4547 cursor.execute(sql, vars)
46-
48+
4749 if opts['table'] == 'hide':
4850 table_display = 'none'
4951 else:
5052 table_display = 'inline'
51-
53+
5254 table = tag.table(class_="listing tickets",
5355 id="reportgraphtable_%d" %(self.index),
5456 style="display:%s" %(table_display))
@@ -55,51 +57,44 @@
5557 caption = tag.caption(tag.a('%s(report:%s)' %(title, id), href='%s' % req.href.report(id)),
5658 align='center')
5759 table.append(caption)
58-
60+
61+ columns = get_column_names(cursor)
62+ table_data = dict((column, []) for column in columns)
63+
5964 tr = tag.tr()
60- columns = []
61- for desc in cursor.description:
62- columns.append(desc[0])
63- if desc[0] == '__color__' or desc[0] == '__group__':
65+ for column in columns:
66+ if column.startswith('_'):
6467 continue
65- if desc[0].startswith('_'):
66- continue
67-
68- tr.append(tag.th('%s' % desc[0]))
69-
68+ tr.append(tag.th(column))
69+
7070 table.append(tag.thead(tr))
71-
7271 tbody = tag.tbody()
7372 table.append(tbody)
74-
75- table_data = {}
76- for col in columns:
77- table_data[col] = []
78-
73+
7974 for idx, row in enumerate(cursor):
80-
75+
8176 odd_or_even = (idx % 2 == 0) and 'odd' or 'even'
8277 tr = tag.tr()
8378 css_class = ''
84-
79+
8580 for col_idx, col in enumerate(row):
8681 column = columns[col_idx]
87-
82+
8883 if column == '__color__' and css_class is '':
8984 css_class = 'color%s-' % col
9085 continue
9186 if column.startswith('_'):
9287 continue
93-
88+
9489 converted_col = self._convert_col(req, column, col)
95-
90+
9691 tr = tr(tag.td(converted_col))
9792 table_data[column].append(col)
98-
93+
9994 css_class = css_class + odd_or_even
10095 tr = tr(class_ = css_class)
10196 tbody.append(tr)
102-
97+
10398 #add_stylesheet(req, 'wikitable/css/wikitable.css')
10499 return table, columns, table_data
105100
@@ -106,11 +101,11 @@
106101 def _render_graph(self, req, opts, table, columns, table_data, title, desc):
107102 u"""TracReportsの結果をグラフで表示する。
108103 """
109- if opts['graph'] not in ('lines', 'bars', 'pie'):
104+ if opts['graph'] not in ('lines', 'bars', 'pie'):
110105 return table
111-
106+
112107 ticks = table_data[columns[0]]
113-
108+
114109 data = '['
115110 for column in columns[1:]:
116111 #print table_data[column]
@@ -117,47 +112,55 @@
117112 values = self._to_js_array(table_data[column])
118113 data = data + values + ','
119114 data = data[:-1] + ']'
120-
115+
121116 xaxisType = self._getXAxisType(req, ticks, opts)
122117 if isinstance(opts['barWidth'], basestring) and opts['barWidth'].isdigit():
123118 opts['barWidth'] = int(opts['barWidth'])
124119
125- script = """
126-jQuery(document).ready(function($) {
127- $('#reportgraph_%d').reportGraph({
128- graph: '%s',
129- seriesLabel: %s,
130- data: %s,
131- ticks: %s,
132- title: '%s',
133- stack: %s,
134- legendLoc: '%s',
135- legendXOffset: %s,
136- legendYOffset: %s,
137- xaxisType: '%s',
138- xaxisMin: %s,
139- xaxisMax: %s,
140- yaxisMin: %s,
141- yaxisMax: %s,
142- xaxisFormatString: '%s',
143- yaxisFormatString: '%s',
144- barWidth: %s
145- });
146-});
147- """ % (self.index, opts['graph'], self._to_js_array(columns[1:]),
148- data, self._to_js_array(ticks),
149- opts['title'], opts['stack'].lower(), opts['legendLoc'],
150- opts['legendXOffset'], opts['legendYOffset'],
151- xaxisType, opts['xaxisMin'], opts['xaxisMax'],
152- opts['yaxisMin'], opts['yaxisMax'],
153- opts['xaxisFormatString'], opts['yaxisFormatString'],
154- to_json(opts['barWidth']))
155-
156- self.env.log.debug(script);
120+ script = """\
121+(function($) {
122+ var options = {
123+ graph: '%(graph)s', seriesLabel: %(seriesLabel)s, data: %(data)s,
124+ ticks: %(ticks)s, title: %(title)s, stack: %(stack)s,
125+ legendLoc: %(legendLoc)s,
126+ legendXOffset: %(legendXOffset)s, legendYOffset: %(legendYOffset)s,
127+ xaxisType: %(xaxisType)s, xaxisMin: %(xaxisMin)s, xaxisMax: %(xaxisMax)s,
128+ yaxisMin: %(yaxisMin)s, yaxisMax: %(yaxisMax)s,
129+ xaxisFormatString: %(xaxisFormatString)s,
130+ yaxisFormatString: %(yaxisFormatString)s, barWidth: %(barWidth)s
131+ };
132+ if ($.fn.reportGraph) {
133+ $('#reportgraph_%(index)d').reportGraph(options);
134+ }
135+ else {
136+ window.reportgraph_data_%(index)d = options;
137+ }
138+})(jQuery);
139+ """ % {
140+ 'index': self.index,
141+ 'graph': opts['graph'],
142+ 'seriesLabel': self._to_js_array(columns[1:]),
143+ 'data': data,
144+ 'ticks': self._to_js_array(ticks),
145+ 'title': to_json(opts['title']),
146+ 'stack': opts['stack'].lower(),
147+ 'legendLoc': to_json(opts['legendLoc']),
148+ 'legendXOffset': opts['legendXOffset'],
149+ 'legendYOffset': opts['legendYOffset'],
150+ 'xaxisType': to_json(xaxisType),
151+ 'xaxisMin': opts['xaxisMin'],
152+ 'xaxisMax': opts['xaxisMax'],
153+ 'yaxisMin': opts['yaxisMin'],
154+ 'yaxisMax': opts['yaxisMax'],
155+ 'xaxisFormatString': to_json(opts['xaxisFormatString']),
156+ 'yaxisFormatString': to_json(opts['yaxisFormatString']),
157+ 'barWidth': to_json(opts['barWidth']),
158+ }
157159
158160 div = tag.div(
159- tag.div(' ',
160- id="reportgraph_%d" % (self.index),
161+ tag.div('',
162+ id="reportgraph_%d" % self.index,
163+ class_='reportgraph_chart',
161164 style="width:%spx;height:%spx;" %
162165 (opts["width"],opts["height"])),
163166 tag.br(),
@@ -164,10 +167,9 @@
164167 table,
165168 tag.script(script, type="text/javascript"),
166169 class_="reportgraph",
167- id="reporinclude_%d" % (self.index)
168- )
170+ id="reporinclude_%d" % self.index)
169171 return div
170-
172+
171173 def _parse_params(self, req, params):
172174 opts = {
173175 'title':'',
@@ -192,7 +194,7 @@
192194 'yaxisFormatString':'',
193195 'barWidth':'50'
194196 }
195-
197+
196198 vars = {}
197199 for (index, param) in enumerate(params.split(',')):
198200 if index == 0:
@@ -199,7 +201,7 @@
199201 id = param
200202 id, vars = self._parse_vars(req, id)
201203 continue
202-
204+
203205 colon_split = param.split(':')
204206 key = colon_split[0].strip()
205207 value = ''
@@ -209,17 +211,17 @@
209211 value = True
210212 opts[key] = value
211213 return id, vars, opts
212-
214+
213215 def _parse_vars(self, req, id):
214216 vars = {}
215-
217+
216218 if id.find('?') == -1:
217219 return id, vars
218-
220+
219221 id_and_params = id.split('?')
220222 params = id_and_params[1]
221223 id = id_and_params[0]
222-
224+
223225 if params.find('&') != -1:
224226 for (index, param) in enumerate(params.split('&')):
225227 if param.find('=') == -1:
@@ -233,23 +235,23 @@
233235 vars[entry[0]] = entry[1]
234236 if vars[entry[0]] == '$USER':
235237 vars[entry[0]] = req.authname
236-
238+
237239 return id, vars
238-
240+
239241 def _get_report_info(self, id):
240242 db = self.env.get_db_cnx()
241243 cursor = db.cursor()
242244 cursor.execute("SELECT title,query,description from report "
243245 "WHERE id=%s", (id,))
244-
246+
245247 report = [(title, sql, desc) for title, sql, desc in cursor]
246248 return report
247-
249+
248250 def _sql_sub_vars(self, sql, vars, db):
249251 rm = ReportModule(self.env)
250252 sql, vars, missing_vars = rm.sql_sub_vars(sql, vars, db)
251253 return sql, vars, missing_vars
252-
254+
253255 def _getXAxisType(self, req, ticks, opts):
254256 if ticks and len(ticks) > 0:
255257 try:
@@ -257,34 +259,18 @@
257259 return 'number'
258260 except ValueError:
259261 pass
260-
262+
261263 try:
262264 parse_date(ticks[0], req.tz)
263265 return 'date'
264266 except TracError:
265267 pass
266-
268+
267269 return 'string'
268-
270+
269271 def _to_js_array(self, array):
270- if array is None:
271- return 'null'
272- if len(array) == 0:
273- return '[]'
274-
275- is_number = True
276- for value in array:
277- try:
278- int(value)
279- except ValueError:
280- is_number = False
281- pass
282-
283- if is_number:
284- return "[" + ",".join(map(str, array)) + "]"
285- else:
286- return "['" + "','".join(map(str, array)) + "']"
287-
272+ return to_json(array)
273+
288274 def _convert_col(self, req, column, col):
289275 if column == 'time' or column.endswith(u'時刻'):
290276 col = col != None and format_time(int(col)) or '--'
@@ -292,7 +278,7 @@
292278 col = col != None and format_date(int(col)) or '--'
293279 if column == 'datetime' or column.endswith(u'日時'):
294280 col = col != None and format_datetime(int(col)) or '--'
295-
281+
296282 if column.lower() in ('ticket', 'id', u'チケット'):
297283 col = tag.a('#' + str(col), title='View Ticket', class_='ticket',
298284 href=req.href.ticket(str(col)))
--- plugins/reportincludeplugin/trunk/0.12/reportinclude/web_ui.py (revision 861)
+++ plugins/reportincludeplugin/trunk/0.12/reportinclude/web_ui.py (revision 862)
@@ -8,9 +8,9 @@
88 from renderer import ReportRenderer
99
1010 class ReportIncludeModule(Component):
11-
11+
1212 implements(IRequestHandler)
13-
13+
1414 # IRequestHandler methods
1515 def match_request(self, req):
1616 match = re.match(r'^/tracreportinclude(?:/(.*))?', req.path_info)
@@ -21,21 +21,20 @@
2121
2222 def process_request(self, req):
2323 req.perm.assert_permission('REPORT_VIEW')
24-
24+
2525 try:
2626 index, content = self._parse_args(req.args)
2727 except KeyError:
2828 return 'reportinclude_response.html', {'response':''}, None
29-
29+
3030 req._reportinclude = index
31-
31+
3232 renderer = ReportRenderer(self.env)
3333 report = renderer.render(req, content)
34-
34+
3535 data = {'response': report.generate()}
36-
36+
3737 return 'reportinclude_response.html', data, None
38-
38+
3939 def _parse_args(self, args):
4040 return (int(args['index']), args['params'].replace('__AND__', '&'))
41-
\ No newline at end of file
--- plugins/reportincludeplugin/trunk/0.12/reportinclude/htdocs/js/jqplot/reportgraph.js (revision 861)
+++ plugins/reportincludeplugin/trunk/0.12/reportinclude/htdocs/js/jqplot/reportgraph.js (revision 862)
@@ -1,5 +1,5 @@
1-(function(jQuery) {
2- jQuery.fn.reportGraph = function(options) {
1+(function($) {
2+ $.fn.reportGraph = function(options) {
33 var defaults = {
44 'graph': 'lines',
55 'stack' : false,
@@ -15,12 +15,12 @@
1515 'yaxisFormatString' : null
1616 };
1717
18- var setting = jQuery.extend(defaults, options);
18+ var setting = $.extend(defaults, options);
1919 var id = this.attr('id');
20-
20+
2121 var graph = _getGraph(setting);
2222 graph.draw(id);
23-
23+
2424 return this;
2525 };
2626
@@ -36,13 +36,13 @@
3636 return new PieGraph(setting);
3737 }
3838 }
39-
39+
4040 /**
4141 * Class: Graph
4242 */
4343 function Graph(setting) {
4444 this.setting = setting;
45-
45+
4646 this.data = this.getData();
4747 this.title = setting.title;
4848 this.stack = setting.stack;
@@ -68,9 +68,9 @@
6868 tickOptions: {formatString: setting.yaxisFormatString}
6969 };
7070 }
71-
71+
7272 Graph.prototype.draw = function(id) {
73- jQuery.jqplot(id, this.data, {
73+ $.jqplot(id, this.data, {
7474 legend: this.legendOption,
7575 title: this.title,
7676 stackSeries: this.stack,
@@ -86,7 +86,7 @@
8686 cursor: {show: true}
8787 });
8888 };
89-
89+
9090 Graph.prototype.getSeriesDefaults = function() {
9191 var seriesDefaults = {};
9292 seriesDefaults = {
@@ -98,11 +98,11 @@
9898 }
9999 return seriesDefaults;
100100 };
101-
101+
102102 Graph.prototype.getRenderer = function() {
103- return jQuery.jqplot.LineRenderer;
103+ return $.jqplot.LineRenderer;
104104 };
105-
105+
106106 Graph.prototype.getData = function() {
107107 if (this.setting.xaxisType == 'date' || this.setting.xaxisType == 'number') {
108108 return _getData(this.setting);
@@ -109,7 +109,7 @@
109109 }
110110 return this.setting.data;
111111 };
112-
112+
113113 Graph.prototype.getTicks = function() {
114114 if (this.setting.xaxisType == 'date' || this.setting.xaxisType == 'number') {
115115 return []
@@ -116,23 +116,23 @@
116116 }
117117 return this.setting.ticks;
118118 };
119-
119+
120120 Graph.prototype.getNumberTicks = function() {
121121 var number = this.setting.ticks.length;
122122 return number;
123123 };
124-
124+
125125 Graph.prototype.getXAxisRenderer = function() {
126126 if (this.setting.xaxisType == 'number') {
127- return jQuery.jqplot.LinerAxisRenderer;
127+ return $.jqplot.LinerAxisRenderer;
128128 }
129129 if (this.setting.xaxisType == 'date') {
130- return jQuery.jqplot.DateAxisRenderer;
130+ return $.jqplot.DateAxisRenderer;
131131 }
132132 // string
133- return jQuery.jqplot.CategoryAxisRenderer;
133+ return $.jqplot.CategoryAxisRenderer;
134134 };
135-
135+
136136 Graph.prototype.getXAxisMin = function() {
137137 if (this.setting.xaxisMin == null) {
138138 return this.setting.ticks[0];
@@ -139,7 +139,7 @@
139139 }
140140 return this.setting.xaxisMin;
141141 };
142-
142+
143143 Graph.prototype.getXAxisMax = function() {
144144 if (this.setting.xaxisMax == null) {
145145 return this.setting.ticks[this.setting.ticks.length-1];
@@ -146,16 +146,16 @@
146146 }
147147 return this.setting.xaxisMax;
148148 };
149-
149+
150150 Graph.prototype.getSeries = function() {
151151 var series = [];
152- jQuery.each(this.setting.seriesLabel, function(index, value){
152+ $.each(this.setting.seriesLabel, function(index, value){
153153 // use default renderer.
154154 series.push({label: value})
155155 });
156156 return series;
157157 };
158-
158+
159159 /**
160160 * Class: BarGraph
161161 */
@@ -162,12 +162,12 @@
162162 function BarGraph(setting) {
163163 Graph.apply(this, arguments);
164164 }
165-
165+
166166 // extend Graph
167- jQuery.extend(BarGraph.prototype, Graph.prototype);
168-
167+ $.extend(BarGraph.prototype, Graph.prototype);
168+
169169 BarGraph.prototype.getRenderer = function() {
170- return jQuery.jqplot.BarRenderer;
170+ return $.jqplot.BarRenderer;
171171 };
172172
173173 BarGraph.prototype.getSeriesDefaults = function() {
@@ -177,7 +177,7 @@
177177 };
178178 return seriesDefaults;
179179 };
180-
180+
181181 /**
182182 * Class: LineGraph
183183 */
@@ -184,14 +184,14 @@
184184 function LineGraph(setting) {
185185 Graph.apply(this, arguments);
186186 }
187-
187+
188188 // extend Graph
189- jQuery.extend(LineGraph.prototype, Graph.prototype);
189+ $.extend(LineGraph.prototype, Graph.prototype);
190190
191191 LineGraph.prototype.getRenderer = function() {
192- return jQuery.jqplot.LineRenderer;
192+ return $.jqplot.LineRenderer;
193193 };
194-
194+
195195 /**
196196 * Class: PieGraph
197197 */
@@ -198,42 +198,42 @@
198198 function PieGraph(setting) {
199199 Graph.apply(this, arguments);
200200 }
201-
201+
202202 // extend Graph
203- jQuery.extend(PieGraph.prototype, Graph.prototype);
203+ $.extend(PieGraph.prototype, Graph.prototype);
204204
205205 PieGraph.prototype.getRenderer = function() {
206- return jQuery.jqplot.PieRenderer;
206+ return $.jqplot.PieRenderer;
207207 };
208-
208+
209209 PieGraph.prototype.getData = function() {
210210 return _getData(this.setting);
211211 };
212-
212+
213213 PieGraph.prototype.getTicks = function() {
214214 return []
215215 };
216-
216+
217217 PieGraph.prototype.getXAxisRenderer = function() {
218- return jQuery.jqplot.LinerAxisRenderer;
218+ return $.jqplot.LinerAxisRenderer;
219219 };
220-
220+
221221 // Utility
222222 function _getData(setting) {
223223 var rtn = [];
224- jQuery.each(setting.data, function(seriesIndex, seriesValue) {
224+ $.each(setting.data, function(seriesIndex, seriesValue) {
225225 var newSeries = [];
226-
226+
227227 // caluculate sum for pie.
228228 var sum = 0;
229229 if (setting.graph == 'pie') {
230- jQuery.each(seriesValue, function(dataIndex, dataValue) {
230+ $.each(seriesValue, function(dataIndex, dataValue) {
231231 sum += dataValue;
232232 });
233233 }
234-
234+
235235 // create series.
236- jQuery.each(seriesValue, function(dataIndex, dataValue) {
236+ $.each(seriesValue, function(dataIndex, dataValue) {
237237 var newTick = setting.ticks[dataIndex];
238238 if (setting.graph == 'pie') {
239239 newTick += ': ' + dataValue + ' (' + Math.round((dataValue/sum)*100*100)/100 + '%)';
@@ -244,6 +244,18 @@
244244 });
245245 return rtn;
246246 }
247-
247+
248+ if ($.documentReady) {
249+ $.documentReady(function() {
250+ $('.reportgraph_chart').each(function() {
251+ var name = 'reportgraph_data_' + this.id.replace(/^reportgraph_/, '');
252+ var data = window[name];
253+ if (data) {
254+ window[name] = undefined;
255+ $(this).reportGraph(data);
256+ }
257+ });
258+ });
259+ }
260+
248261 })(jQuery);
249-
Show on old repository browser