aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/js/RrdJson.js
diff options
context:
space:
mode:
authorPim van den Berg2013-05-10 21:36:54 +0200
committerPim van den Berg2013-05-10 21:36:54 +0200
commit0163faefef02207ad0ea3330af688103633293ff (patch)
treec407fca93a3418af59c4c7133327f5bc1630fba5 /js/RrdJson.js
parentMerge pull request #5 from mce35/nut (diff)
downloadapt-panopticon_cgp-0163faefef02207ad0ea3330af688103633293ff.zip
apt-panopticon_cgp-0163faefef02207ad0ea3330af688103633293ff.tar.gz
apt-panopticon_cgp-0163faefef02207ad0ea3330af688103633293ff.tar.bz2
apt-panopticon_cgp-0163faefef02207ad0ea3330af688103633293ff.tar.xz
import js directory from jsrrdgraph for client side graph rendering
Source: https://github.com/manuelluis/jsrrdgraph@276b880
Diffstat (limited to 'js/RrdJson.js')
-rw-r--r--js/RrdJson.js588
1 files changed, 588 insertions, 0 deletions
diff --git a/js/RrdJson.js b/js/RrdJson.js
new file mode 100644
index 0000000..85b7f11
--- /dev/null
+++ b/js/RrdJson.js
@@ -0,0 +1,588 @@
1/**
2 *
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the Free
5 * Software Foundation; either version 2 of the License, or (at your option)
6 * any later version.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
16
17 *
18 * Manuel Sanmartin <manuel.luis at gmail.com>
19 **/
20
21"use strict";
22
23/**
24 * RrdJson
25 * @constructor
26 */
27var RrdJson = function() {
28 if (arguments.length == 1) {
29 this.init1.apply(this, arguments);
30 } else if (arguments.length == 2) {
31 this.init2.apply(this, arguments);
32 } else if (arguments.length == 3) {
33 this.init3.apply(this, arguments);
34 }
35};
36
37RrdJson.prototype = {
38 graph: null,
39 json: null,
40
41 init1: function (rrdgraph)
42 {
43 this.graph = rrdgraph
44 },
45 init2: function (rrdgraph, jsonstr)
46 {
47 this.json = JSON.parse(jsonstr);
48 this.graph = rrdgraph
49 },
50 init3: function (gfx, fetch, jsonstr)
51 {
52 this.json = JSON.parse(jsonstr);
53 this.graph = new RrdGraph(gfx, fetch);
54 },
55 parse: function()
56 {
57 for (var option in this.json) {
58 switch(option) {
59 case 'alt_autoscale':
60 this.graph.alt_autoscale = this.json.alt_autoscale;
61 break;
62 case 'base':
63 this.graph.base = parseInt(this.json.base, 10);
64 if (this.graph.base !== 1000 && this.graph.base !== 1024)
65 throw 'the only sensible value for base apart from 1000 is 1024';
66 break;
67 case 'color':
68 for (var color in this.json.color) {
69 if (color in this.graph.GRC) {
70 this.graph.GRC[color] = this.json.color[color];
71 } else {
72 throw "invalid color name '"+name+"'";
73 }
74 }
75 break;
76 case 'full_size_mode':
77 this.graph.full_size_mode = this.json.full_size_mode;
78 break;
79 case 'slope_mode':
80 this.graph.slopemode = this.json.slope_mode;
81 break;
82 case 'end':
83 this.graph.end_t = new RrdTime(this.json.end);
84 break;
85 case 'force_rules_legend':
86 this.graph.force_rules_legend = this.json.force_rules_legend;
87 break;
88 case 'no_legend':
89 this.graph.no_legend = this.json.no_legend;
90 break;
91 case 'height':
92 this.graph.ysize = this.json.height;
93 break;
94 case 'no_minor':
95 this.graph.no_minor = this.json.no_minor;
96 break;
97 case 'alt_autoscale_min':
98 this.graph.alt_autoscale_min = this.json.alt_autoscale_min;
99 break;
100 case 'only_graph':
101 this.graph.only_graph = this.json.only_graph;
102 break;
103 case 'units_length':
104 this.graph.unitslength = this.json.units_length; // FIXME
105 this.graph.forceleftspace = true;
106 break;
107 case 'lower_limit':
108 if (this.json.lower_limit === null) this.graph.setminval = Number.NaN;
109 else this.graph.setminval = this.json.lower_limit;
110 break;
111 case 'alt_autoscale_max':
112 this.graph.alt_autoscale_max = this.json.alt_autoscale_max;
113 break;
114 case 'zoom':
115 this.graph.zoom = this.json.zoom;
116 if (this.graph.zoom <= 0.0)
117 throw "zoom factor must be > 0";
118 break;
119 case 'no_gridfit':
120 this.graph.gridfit = this.json.no_gridfit;
121 break;
122 case 'font':
123 for (var font in this.json.font) {
124 if (font in this.graph.TEXT) {
125 if (this.json.font[font].size !== undefined)
126 this.graph.TEXT[font].size = this.json.font[font].size;
127 if (this.json.font[font].font !== undefined)
128 this.graph.TEXT[font].font = this.json.font[font].font;
129 } else {
130 throw "invalid text property name";
131 }
132 }
133 break;
134 case 'logarithmic':
135 this.graph.logarithmic = this.json.logarithmic;
136 break;
137 case 'rigid':
138 this.graph.rigid = this.json.rigid;
139 break;
140 case 'step':
141 this.graph.step = this.json.step;
142 break;
143 case 'start':
144 this.graph.start_t = new RrdTime(this.json.start);
145 break;
146 case 'tabwidth':
147 this.graph.tabwidth = this.json.tabwidth;
148 break;
149 case 'title':
150 this.graph.title = this.json.title;
151 break;
152 case 'upper_limit':
153 if (this.json.upper_limit === null) this.graph.setmaxval = Number.NaN;
154 else this.graph.setmaxval = this.json.upper_limit;
155 break;
156 case 'vertical_label':
157 this.graph.ylegend = this.json.vertical_label;
158 break;
159 case 'watermark':
160 this.graph.watermark = this.json.watermark;
161 break;
162 case 'width':
163 this.graph.xsize = this.json.width;
164 if (this.graph.xsize < 10)
165 throw "width below 10 pixels";
166 break;
167 case 'units_exponent':
168 this.graph.unitsexponent = this.json.units_exponent;
169 break;
170 case 'x_grid':
171 break;
172 case 'alt_ygrid':
173 this.graph.alt_ygrid = this.json.alt_ygrid;
174 break;
175 case 'y_grid':
176 break;
177 case 'lazy':
178 this.graph.lazy = this.json.lazy;
179 break;
180 case 'units':
181 break;
182 case 'disable_rrdtool_tag':
183 this.graph.no_rrdtool_tag = this.json.disable_rrdtool_tag;
184 break;
185 case 'right_axis':
186 break;
187 case 'right_axis_label':
188 this.graph.second_axis_legend = this.json.right_axis_label;
189 break;
190 case 'right_axis_format':
191 this.graph.second_axis_format = this.json.right_axis_format;
192 break;
193 case 'legend_position':
194 if (this.json.legend_position === "north") {
195 this.graph.legendposition = this.graph.LEGEND_POS.NORTH;
196 } else if (this.json.legend_position === "west") {
197 this.graph.legendposition = this.graph.LEGEND_POS.WEST;
198 } else if (this.json.legend_position === "south") {
199 this.graph.legendposition = this.graph.LEGEND_POS.SOUTH;
200 } else if (this.json.legend_position === "east") {
201 this.graph.legendposition = this.graph.LEGEND_POS.EAST;
202 } else {
203 throw "unknown legend-position '"+value+"'";
204 }
205 break;
206 case 'legend_direction':
207 if (this.json.legend_direction === "topdown") {
208 this.graph.legenddirection = this.graph.LEGEND_DIR.TOP_DOWN;
209 } else if (this.json.legend_direction === "bottomup") {
210 this.graph.legenddirection = this.graph.LEGEND_DIR.BOTTOM_UP;
211 } else {
212 throw "unknown legend-position '"+value+"'";
213 }
214 break;
215 case 'border':
216 this.graph.draw_3d_border = this.json.border;
217 break;
218 case 'grid_dash':
219 if (this.json.grid_dash.length !== 2)
220 throw "expected grid-dash format float:float";
221 this.graph.grid_dash_on = this.json.grid_dash[0];
222 this.graph.grid_dash_off = this.json.grid_dash[1];
223 break;
224 case 'dynamic_labels':
225 this.graph.dynamic_labels = this.json.dynamic_labels;
226 break;
227 case 'gdes':
228 this.parse_gdes(this.json.gdes);
229 break;
230 default:
231 throw 'Unknow option "'+option+'"';
232 }
233 }
234 var start_end = RrdTime.proc_start_end(this.graph.start_t, this.graph.end_t); // FIXME here?
235 this.graph.start = start_end[0];
236 this.graph.end = start_end[1];
237 },
238 parse_gdes: function (gdes)
239 {
240 for (var i = 0, gdes_c = gdes.length; i < gdes_c; i++) {
241 switch (gdes[i].type) {
242// GPRINT:vname:format
243 case 'GPRINT':
244 this.graph.gdes_add_gprint(gdes[i].vname, gdes[i].cf, gdes[i].format, gdes[i].strftm);
245 break;
246// LINE[width]:value[#color][:[legend][:STACK]][:dashes[=on_s[,off_s[,on_s,off_s]...]][:dash-offset=offset]]
247 case 'LINE':
248 this.graph.gdes_add_line(gdes[i].width, gdes[i].value, gdes[i].color, gdes[i].legend, gdes[i].stack);
249 break;
250// AREA:value[#color][:[legend][:STACK]]
251 case 'AREA':
252 this.graph.gdes_add_area(gdes[i].value, gdes[i].color, gdes[i].legend, gdes[i].stack);
253 break;
254// TICK:vname#rrggbb[aa][:fraction[:legend]]
255 case 'TICK':
256 this.graph.gdes_add_tick(gdes[i].vname, gdes[i].color, gdes[i].fraction, gdes[i].legend);
257 break;
258// HRULE:value#color[:legend][:dashes[=on_s[,off_s[,on_s,off_s]...]][:dash-offset=offset]]
259 case 'HRULE':
260 this.graph.gdes_add_hrule(gdes[i].value, gdes[i].color, gdes[i].legend);
261 break;
262// VRULE:time#color[:legend][:dashes[=on_s[,off_s[,on_s,off_s]...]][:dash-offset=offset]]
263 case 'VRULE':
264 this.graph.gdes_add_vrule(gdes[i].time, gdes[i].color, gdes[i].legend);
265 break;
266// COMMENT:text
267 case 'COMMENT':
268 this.graph.gdes_add_comment(gdes[i].legend);
269 break;
270// TEXTALIGN:{left|right|justified|center}
271 case 'TEXTALIGN':
272 switch (gdes[i].align) {
273 case 'left':
274 this.graph.gdes_add_textaling(RrdGraphDesc.TXA_LEFT);
275 break
276 case 'right':
277 this.graph.gdes_add_textaling(RrdGraphDesc.TXA_RIGHT);
278 break
279 case 'justified':
280 this.graph.gdes_add_textaling(RrdGraphDesc.TXA_JUSTIFIED);
281 break
282 case 'center':
283 this.graph.gdes_add_textaling(RrdGraphDesc.TXA_CENTER);
284 break
285 }
286 break;
287// DEF:<vname>=<rrdfile>:<ds-name>:<CF>[:step=<step>][:start=<time>][:end=<time>][:reduce=<CF>]
288 case 'DEF':
289 this.graph.gdes_add_def(gdes[i].vname, gdes[i].rrdfile, gdes[i].name, gdes[i].cf, gdes[i].step, gdes[i].start, gdes[i].end, gdes[i].reduce)
290 break;
291// CDEF:vname=RPN expression
292 case 'CDEF':
293 this.graph.gdes_add_cdef(gdes[i].vname, gdes[i].rpn);
294 break;
295// VDEF:vname=RPN expression
296 case 'VDEF':
297 this.graph.gdes_add_vdef(gdes[i].vname, gdes[i].rpn);
298 break;
299// SHIFT:vname:offset
300 case 'SHIFT':
301 this.graph.gdes_add_shift(gdes[i].vname, gdes[i].offset);
302 break;
303 }
304 }
305 },
306 dump: function(full)
307 {
308 this.json = {};
309
310 if (full === undefined) full = false;
311
312 if (this.graph.alt_autoscale != false || full)
313 this.json.alt_autoscale = this.graph.alt_autoscale;
314
315 if (this.graph.base != 1000 || full)
316 this.json.base = this.graph.base;
317
318 this.json.color = {};
319
320 if (this.graph.GRC.CANVAS != 'rgba(255, 255, 255, 1.0)' || full)
321 this.json.color.CANVAS = this.graph.GRC.CANVAS;
322 if (this.graph.GRC.BACK != 'rgba(242,242, 242, 1.0)' || full)
323 this.json.color.BACK = this.graph.GRC.BACK;
324 if (this.graph.GRC.SHADEA != 'rgba(207, 207, 207, 1.0)' || full)
325 this.json.color.SHADEA = this.graph.GRC.SHADEA;
326 if (this.graph.GRC.SHADEB != 'rgba(158, 158, 158, 1.0)' || full)
327 this.json.color.SHADEB = this.graph.GRC.SHADEB;
328 if (this.graph.GRC.GRID != 'rgba(143, 143, 143, 0.75)' || full)
329 this.json.color.GRID = this.graph.GRC.GRID;
330 if (this.graph.GRC.MGRID != 'rgba(222, 79, 79, 0.60)' || full)
331 this.json.color.MGRID = this.graph.GRC.MGRID;
332 if (this.graph.GRC.FONT != 'rgba(0, 0, 0, 1.0)' || full)
333 this.json.color.FONT = this.graph.GRC.FONT;
334 if (this.graph.GRC.ARROW != 'rgba(127, 31, 31, 1.0)' || full)
335 this.json.color.ARROW = this.graph.GRC.ARROW;
336 if (this.graph.GRC.AXIS != 'rgba(31, 31, 31, 1.0)' || full)
337 this.json.color.AXIS = this.graph.GRC.AXIS;
338 if (this.graph.GRC.FRAME != 'rgba(0, 0, 0, 1.0)' || full)
339 this.json.color.FRAME = this.graph.GRC.FRAME;
340
341 if (Object.keys(this.json.color) == 0) delete this.json.color;
342
343 if (this.graph.full_size_mode != false || full)
344 this.json.full_size_mode = this.graph.full_size_mode;
345
346 if (this.graph.slopemode != false || full)
347 this.json.slope_mode = this.graph.slopemode;
348
349 this.json.end = this.graph.end_t.tspec;
350 this.json.start = this.graph.start_t.tspec;
351
352 if (this.graph.force_rules_legend != false || full)
353 this.json.force_rules_legend = this.graph.force_rules_legend;
354
355 if (this.graph.no_legend != false || full)
356 this.json.no_legend = this.graph.no_legend;
357
358 this.json.width = this.graph.xsize;
359 this.json.height = this.graph.ysize;
360
361 if (this.graph.no_minor != false || full)
362 this.json.no_minor = this.graph.no_minor;
363
364 if (this.graph.alt_autoscale_min != false || full)
365 this.json.alt_autoscale_min = this.graph.alt_autoscale_min;
366
367 if (this.graph.only_graph != false || full)
368 this.json.only_graph = this.graph.only_graph;
369
370 if (this.graph.unitslength != 6 || full)
371 this.json.units_length = this.graph.unitslength;
372
373 if (!isNaN(this.graph.setminval) || full)
374 this.json.lower_limit = this.graph.setminval;
375
376 if (this.graph.alt_autoscale_max != false || full)
377 this.json.alt_autoscale_max = this.graph.alt_autoscale_max;
378
379 if (this.graph.zoom != 1 || full)
380 this.json.zoom = this.graph.zoom;
381
382 if (this.graph.gridfit != true || full)
383 this.json.no_gridfit = this.graph.gridfit;
384
385 this.json.font = {};
386 if (this.graph.TEXT.DEFAULT.size != 11 || this.graph.TEXT.LEGEND.font != this.graph.DEFAULT_FONT || full)
387 this.json.font.DEFAULT = { size: this.graph.TEXT.DEFAULT.size, font: this.graph.TEXT.DEFAULT.font};
388 if (this.graph.TEXT.TITLE.size != 12 || this.graph.TEXT.TITLE.font != this.graph.DEFAULT_FONT || full)
389 this.json.font.TITLE = { size: this.graph.TEXT.TITLE.size, font: this.graph.TEXT.TITLE.font};
390 if (this.graph.TEXT.AXIS.size != 10 || this.graph.TEXT.AXIS.font != this.graph.DEFAULT_FONT || full)
391 this.json.font.AXIS = { size: this.graph.TEXT.AXIS.size, font: this.graph.TEXT.AXIS.font};
392 if (this.graph.TEXT.UNIT.size != 11 || this.graph.TEXT.UNIT.font != this.graph.DEFAULT_FONT || full)
393 this.json.font.UNIT = { size: this.graph.TEXT.UNIT.size, font: this.graph.TEXT.UNIT.font};
394 if (this.graph.TEXT.LEGEND.size != 11 || this.graph.TEXT.LEGEND.font != this.graph.DEFAULT_FONT || full)
395 this.json.font.LEGEND = { size: this.graph.TEXT.LEGEND.size, font: this.graph.TEXT.LEGEND.font};
396 if (this.graph.TEXT.WATERMARK.size != 8 || this.graph.TEXT.WATERMARK.font != this.graph.DEFAULT_FONT || full)
397 this.json.font.WATERMARK = { size: this.graph.TEXT.WATERMARK.size, font: this.graph.TEXT.WATERMARK.font};
398
399 if (Object.keys(this.json.font) == 0) delete this.json.font;
400
401 if (this.graph.logarithmic != false || full)
402 this.json.logarithmic = this.graph.logarithmic;
403
404 if (this.graph.rigid != false || full)
405 this.json.rigid = this.graph.rigid;
406
407// this.json.step = this.graph.step; // FIXME
408
409 if (this.graph.tabwidth != 40 || full)
410 this.json.tabwidth = this.graph.tabwidth;
411
412 if (this.graph.title != '' || full)
413 this.json.title = this.graph.title;
414
415 if (!isNaN(this.graph.setmaxval) || full)
416 this.json.upper_limit = this.graph.setmaxval;
417
418 if (this.graph.ylegend != null || full)
419 this.json.vertical_label = this.graph.ylegend;
420
421 if (this.graph.watermark != null || full)
422 this.json.watermark = this.graph.watermark;
423
424 if (this.graph.unitsexponent != 9999 || full)
425 this.json.units_exponent = this.graph.unitsexponent;
426
427// this.json.x-grid = // FIXME
428
429 if (this.graph.alt_ygrid != false || full)
430 this.json.alt_ygrid = this.graph.alt_ygrid;
431
432// this.json.y_grid = // FIXME
433
434// this.json.lazy = this.graph.lazy;
435
436 if (this.graph.force_units_si != false || full)
437 this.json.units = 'si'; // FIXME
438
439 if (this.graph.no_rrdtool_tag != false || full)
440 this.json.disable_rrdtool_tag = this.graph.no_rrdtool_tag;
441
442// this.json.right_axis = FIXME
443
444 if (this.graph.second_axis_legend != null || full)
445 this.json.right_axis_label = this.graph.second_axis_legend;
446 if (this.graph.second_axis_format != null || full)
447 this.json.right_axis_format = this.graph.second_axis_format;
448
449// this.json.legendposition = this.graph.legendposition; // FIXME
450// this.json.legend-direction = this.graph.legenddirection; // FIXME
451
452 if (this.graph.draw_3d_border != 2 || full)
453 this.json.border = this.graph.draw_3d_border;
454
455 if (this.graph.grid_dash_on != 1 || this.graph.grid_dash_off != 1 || full)
456 this.json.grid_dash = [this.graph.grid_dash_on, this.graph.grid_dash_off]
457
458 if (this.graph.dynamic_labels != false || full)
459 this.json.dynamic_labels = this.graph.dynamic_labels;
460
461 this.json.gdes = [];
462 for (var i = 0, gdes_c = this.graph.gdes.length; i < gdes_c; i++) {
463 switch (this.graph.gdes[i].gf) {
464// GPRINT:vname:format
465 case RrdGraphDesc.GF_GPRINT:
466 this.json.gdes.push({
467 type: 'GPRINT',
468 vname: this.graph.gdes[i].vname,
469 cf: RrdGraphDesc.cf2str(this.graph.gdes[i].cf),
470 format: this.graph.gdes[i].format,
471 strftm: (this.graph.gdes[i].strftm === false ? undefined : this.graph.gdes[i].strftm) });
472 break;
473// LINE[width]:value[#color][:[legend][:STACK]][:dashes[=on_s[,off_s[,on_s,off_s]...]][:dash-offset=offset]]
474 case RrdGraphDesc.GF_LINE:
475 this.json.gdes.push({
476 type: 'LINE',
477 width: this.graph.gdes[i].linewidth,
478 value: this.graph.gdes[i].vname,
479 color: this.graph.gdes[i].col,
480 legend: (this.graph.gdes[i].legend === '' ? undefined : this.graph.gdes[i].legend.substr(2)),
481 stack: (this.graph.gdes[i].stack === false ? undefined : this.graph.gdes[i].stack) });
482 break;
483// AREA:value[#color][:[legend][:STACK]]
484 case RrdGraphDesc.GF_AREA:
485 this.json.gdes.push({
486 type: 'AREA',
487 value: this.graph.gdes[i].vname,
488 color: this.graph.gdes[i].col,
489 legend: (this.graph.gdes[i].legend === '' ? undefined : this.graph.gdes[i].legend.substr(2)),
490 stack: (this.graph.gdes[i].stack === false ? undefined : this.graph.gdes[i].stack) });
491 break;
492// TICK:vname#rrggbb[aa][:fraction[:legend]]
493 case RrdGraphDesc.GF_TICK:
494 this.json.gdes.push({
495 type: 'TICK',
496 vname: this.graph.gdes[i].vname,
497 color: this.graph.gdes[i].col,
498 fraction: this.graph.gdes[i].yrule,
499 legend: (this.graph.gdes[i].legend === '' ? undefined : this.graph.gdes[i].legend.substr(2)) });
500 break;
501// HRULE:value#color[:legend][:dashes[=on_s[,off_s[,on_s,off_s]...]][:dash-offset=offset]]
502 case RrdGraphDesc.GF_HRULE:
503 this.json.gdes.push({
504 type: 'HRULE',
505 value: this.graph.gdes[i].yrule,
506 color: this.graph.gdes[i].col,
507 legend: (this.graph.gdes[i].legend === '' ? undefined : this.graph.gdes[i].legend.substr(2)) });
508 break;
509// VRULE:time#color[:legend][:dashes[=on_s[,off_s[,on_s,off_s]...]][:dash-offset=offset]]
510 case RrdGraphDesc.GF_VRULE:
511 this.json.gdes.push({
512 type: 'VRULE',
513 time: this.graph.gdes[i].xrule,
514 color: this.graph.gdes[i].col,
515 legend: (this.graph.gdes[i].legend === '' ? undefined : this.graph.gdes[i].legend.substr(2)) });
516 break;
517// COMMENT:text
518 case RrdGraphDesc.GF_COMMENT:
519 this.json.gdes.push({
520 type: 'COMMENT',
521 legend: this.graph.gdes[i].legend});
522 break;
523// TEXTALIGN:{left|right|justified|center}
524 case RrdGraphDesc.GF_TEXTALIGN:
525 var align = '';
526 switch (this.graph.gdes[i].txtalign) {
527 case RrdGraphDesc.TXA_LEFT:
528 align = 'left';
529 break
530 case RrdGraphDesc.TXA_RIGHT:
531 align = 'right';
532 break
533 case RrdGraphDesc.TXA_JUSTIFIED:
534 align = 'justified';
535 break
536 case RrdGraphDesc.TXA_CENTER:
537 align = 'center';
538 break
539 }
540
541 this.json.gdes.push({
542 type: 'TEXTALIGN',
543 align: align });
544 break;
545// DEF:<vname>=<rrdfile>:<ds-name>:<CF>[:step=<step>][:start=<time>][:end=<time>][:reduce=<CF>]
546 case RrdGraphDesc.GF_DEF:
547 this.json.gdes.push({
548 type: 'DEF',
549 vname: this.graph.gdes[i].vname,
550 rrdfile: this.graph.gdes[i].rrd,
551 name: this.graph.gdes[i].ds_nam,
552 cf: RrdGraphDesc.cf2str(this.graph.gdes[i].cf),
553// step: this.graph.gdes[i].step,
554 step: undefined,
555 start: undefined,
556 // start: this.graph.gdes[i].start, // FIXME
557 end: undefined,
558 // end: this.graph.gdes[i].end, // FIXME
559 // reduce: RrdGraphDesc.cf2str(this.graph.gdes[i].cf_reduce)
560 reduce: undefined
561 });
562
563 break;
564// CDEF:vname=RPN expression
565 case RrdGraphDesc.GF_CDEF:
566 this.json.gdes.push({
567 type: 'CDEF',
568 vname: this.graph.gdes[i].vname,
569 rpn: this.graph.gdes[i].rpnp.rpnexpr});
570 break;
571// VDEF:vname=RPN expression
572 case RrdGraphDesc.GF_VDEF:
573 this.json.gdes.push({
574 type: 'VDEF',
575 vname: this.graph.gdes[i].vname,
576 rpn: this.graph.gdes[this.graph.gdes[i].vidx].vname+','+this.graph.gdes[i].vf.expr});
577 break;
578// SHIFT:vname:offset
579 case RrdGraphDesc.GF_SHIFT:
580 this.json.gdes.push({
581 type: 'VDEF',
582 vname: this.graph.gdes[i].vname,
583 offset: this.shidx });
584 break;
585 }
586 }
587 }
588};