aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/js/RrdGraph.js
diff options
context:
space:
mode:
authorManuel Luis SanmartĂ­n Rozada2015-04-03 19:02:59 +0200
committerPim van den Berg2015-06-22 11:01:48 +0200
commite8a4d43c2a55d0a2ebd87b8e6c83d82ac5950291 (patch)
treed397e3389986a1690a817fc008583804504c602a /js/RrdGraph.js
parentjsrrdgraph: Rewrite data a graph commands parser. (diff)
downloadapt-panopticon_cgp-e8a4d43c2a55d0a2ebd87b8e6c83d82ac5950291.zip
apt-panopticon_cgp-e8a4d43c2a55d0a2ebd87b8e6c83d82ac5950291.tar.gz
apt-panopticon_cgp-e8a4d43c2a55d0a2ebd87b8e6c83d82ac5950291.tar.bz2
apt-panopticon_cgp-e8a4d43c2a55d0a2ebd87b8e6c83d82ac5950291.tar.xz
jsrrdgraph: Add support for dashes
Diffstat (limited to 'js/RrdGraph.js')
-rw-r--r--js/RrdGraph.js58
1 files changed, 45 insertions, 13 deletions
diff --git a/js/RrdGraph.js b/js/RrdGraph.js
index c2457c9..25823aa 100644
--- a/js/RrdGraph.js
+++ b/js/RrdGraph.js
@@ -36,7 +36,7 @@ RrdGraphDescError.prototype = new Error();
36 * RrdGraphDesc 36 * RrdGraphDesc
37 * @constructor 37 * @constructor
38 */ 38 */
39var RrdGraphDesc = function (graph) 39var RrdGraphDesc = function (graph)
40{ 40{
41 this.gf = null; /* graphing function */ 41 this.gf = null; /* graphing function */
42 this.stack = false; /* boolean */ 42 this.stack = false; /* boolean */
@@ -164,7 +164,7 @@ RrdGraphDesc.TXA_RIGHT = 1;
164RrdGraphDesc.TXA_CENTER = 2; 164RrdGraphDesc.TXA_CENTER = 2;
165RrdGraphDesc.TXA_JUSTIFIED = 3; 165RrdGraphDesc.TXA_JUSTIFIED = 3;
166 166
167RrdGraphDesc.cf_conv = function (str) 167RrdGraphDesc.cf_conv = function (str)
168{ 168{
169 switch (str){ 169 switch (str){
170 case 'AVERAGE': return RrdGraphDesc.CF_AVERAGE; 170 case 'AVERAGE': return RrdGraphDesc.CF_AVERAGE;
@@ -279,7 +279,7 @@ RrdGraphDesc.prototype.fshift = function (graph, vname, offset)
279 this.legend = ''; 279 this.legend = '';
280}; 280};
281 281
282RrdGraphDesc.prototype.line = function (graph, width, value, color, legend, stack) 282RrdGraphDesc.prototype.line = function (graph, width, value, color, legend, stack, dashes, dash_offset)
283{ 283{
284 this.gf = RrdGraphDesc.GF_LINE; 284 this.gf = RrdGraphDesc.GF_LINE;
285 this.vname = value; 285 this.vname = value;
@@ -287,10 +287,20 @@ RrdGraphDesc.prototype.line = function (graph, width, value, color, legend, stac
287 this.linewidth = width; 287 this.linewidth = width;
288 this.col = color; 288 this.col = color;
289 if (legend === undefined) this.legend = ''; 289 if (legend === undefined) this.legend = '';
290 else if (legend.length === 0) this.legend = '';
290 else this.legend = ' '+legend; 291 else this.legend = ' '+legend;
291 if (stack === undefined) this.stack = false; 292 if (stack === undefined) this.stack = false;
292 else this.stack = stack; 293 else this.stack = stack;
293 this.format = this.legend; 294 this.format = this.legend;
295
296 if (dashes != undefined) {
297 this.dash = true;
298 this.p_dashes = dashes;
299 this.ndash = dashes.length;
300 }
301 if (dash_offset !=undefined) {
302 this.offset = dash_offset;
303 }
294}; 304};
295 305
296RrdGraphDesc.prototype.area = function (graph, value, color, legend, stack) 306RrdGraphDesc.prototype.area = function (graph, value, color, legend, stack)
@@ -300,6 +310,7 @@ RrdGraphDesc.prototype.area = function (graph, value, color, legend, stack)
300 this.vidx = graph.find_var(value); 310 this.vidx = graph.find_var(value);
301 this.col = color; 311 this.col = color;
302 if (legend === undefined) this.legend = ''; 312 if (legend === undefined) this.legend = '';
313 else if (legend.length === 0) this.legend = '';
303 else this.legend = ' '+legend; 314 else this.legend = ' '+legend;
304 if (stack === undefined) this.stack = false; 315 if (stack === undefined) this.stack = false;
305 else this.stack = stack; 316 else this.stack = stack;
@@ -315,6 +326,7 @@ RrdGraphDesc.prototype.tick = function (graph, vname, color, fraction, legend)
315 if (fraction !== undefined) 326 if (fraction !== undefined)
316 this.yrule = fraction; 327 this.yrule = fraction;
317 if (legend === undefined) this.legend = ''; 328 if (legend === undefined) this.legend = '';
329 else if (legend.length === 0) this.legend = '';
318 else this.legend = ' '+legend; 330 else this.legend = ' '+legend;
319 this.format = this.legend; 331 this.format = this.legend;
320}; 332};
@@ -372,16 +384,26 @@ RrdGraphDesc.prototype.textalign = function (graph, align)
372 } 384 }
373}; 385};
374 386
375RrdGraphDesc.prototype.vrule = function (graph, time, color, legend) 387RrdGraphDesc.prototype.vrule = function (graph, time, color, legend, dashes, dash_offset)
376{ 388{
377 this.gf = RrdGraphDesc.GF_VRULE; 389 this.gf = RrdGraphDesc.GF_VRULE;
378 this.xrule = time; 390 this.xrule = time;
379 this.col = color; 391 this.col = color;
380 if (legend === undefined) this.legend = ''; 392 if (legend === undefined) this.legend = '';
393 else if (legend.length === 0) this.legend = '';
381 else this.legend = ' '+legend; 394 else this.legend = ' '+legend;
395
396 if (dashes != undefined) {
397 this.dash = true;
398 this.p_dashes = dashes;
399 this.ndash = dashes.length;
400 }
401 if (dash_offset !=undefined) {
402 this.offset = dash_offset;
403 }
382}; 404};
383 405
384RrdGraphDesc.prototype.hrule = function (graph, value, color, legend) 406RrdGraphDesc.prototype.hrule = function (graph, value, color, legend, dashes, dash_offset)
385{ 407{
386 this.gf = RrdGraphDesc.GF_HRULE; 408 this.gf = RrdGraphDesc.GF_HRULE;
387 this.vidx = graph.find_var(value); 409 this.vidx = graph.find_var(value);
@@ -389,7 +411,17 @@ RrdGraphDesc.prototype.hrule = function (graph, value, color, legend)
389 this.yrule = value; 411 this.yrule = value;
390 this.col = color; 412 this.col = color;
391 if (legend === undefined) this.legend = ''; 413 if (legend === undefined) this.legend = '';
414 else if (legend.length === 0) this.legend = '';
392 else this.legend = ' '+legend; 415 else this.legend = ' '+legend;
416
417 if (dashes != undefined) {
418 this.dash = true;
419 this.p_dashes = dashes;
420 this.ndash = dashes.length;
421 }
422 if (dash_offset !=undefined) {
423 this.offset = dash_offset;
424 }
393}; 425};
394 426
395/** 427/**
@@ -823,10 +855,10 @@ var RrdGraph = function (gfx, data)
823 FONT: 'rgba(0, 0, 0, 1.0)', 855 FONT: 'rgba(0, 0, 0, 1.0)',
824 ARROW: 'rgba(127, 31, 31, 1.0)', 856 ARROW: 'rgba(127, 31, 31, 1.0)',
825 AXIS: 'rgba(31, 31, 31, 1.0)', 857 AXIS: 'rgba(31, 31, 31, 1.0)',
826 FRAME: 'rgba(0, 0, 0, 1.0)' 858 FRAME: 'rgba(0, 0, 0, 1.0)'
827 }; 859 };
828 860
829 this.xlab = [ 861 this.xlab = [
830 {minsec: 0, length: 0, gridtm: RrdGraph.TMT_SECOND, gridst: 30, mgridtm: RrdGraph.TMT_MINUTE, mgridst: 5, labtm: RrdGraph.TMT_MINUTE, labst: 5, precis: 0, stst: '%H:%M' } , 862 {minsec: 0, length: 0, gridtm: RrdGraph.TMT_SECOND, gridst: 30, mgridtm: RrdGraph.TMT_MINUTE, mgridst: 5, labtm: RrdGraph.TMT_MINUTE, labst: 5, precis: 0, stst: '%H:%M' } ,
831 {minsec: 2, length: 0, gridtm: RrdGraph.TMT_MINUTE, gridst: 1, mgridtm: RrdGraph.TMT_MINUTE, mgridst: 5, labtm: RrdGraph.TMT_MINUTE, labst: 5, precis: 0, stst: '%H:%M' } , 863 {minsec: 2, length: 0, gridtm: RrdGraph.TMT_MINUTE, gridst: 1, mgridtm: RrdGraph.TMT_MINUTE, mgridst: 5, labtm: RrdGraph.TMT_MINUTE, labst: 5, precis: 0, stst: '%H:%M' } ,
832 {minsec: 5, length: 0, gridtm: RrdGraph.TMT_MINUTE, gridst: 2, mgridtm: RrdGraph.TMT_MINUTE, mgridst: 10, labtm: RrdGraph.TMT_MINUTE, labst: 10, precis: 0, stst: '%H:%M' } , 864 {minsec: 5, length: 0, gridtm: RrdGraph.TMT_MINUTE, gridst: 2, mgridtm: RrdGraph.TMT_MINUTE, mgridst: 10, labtm: RrdGraph.TMT_MINUTE, labst: 10, precis: 0, stst: '%H:%M' } ,
@@ -2963,9 +2995,9 @@ RrdGraph.prototype.gdes_add_shift = function (vname, offset)
2963 this.gdes.push(new RrdGraphDesc(this, RrdGraphDesc.GF_SHIFT, vname, offset)); 2995 this.gdes.push(new RrdGraphDesc(this, RrdGraphDesc.GF_SHIFT, vname, offset));
2964}; 2996};
2965 2997
2966RrdGraph.prototype.gdes_add_line = function (width, value, color, legend, stack) 2998RrdGraph.prototype.gdes_add_line = function (width, value, color, legend, stack, dashes, dash_offset)
2967{ 2999{
2968 this.gdes.push(new RrdGraphDesc(this, RrdGraphDesc.GF_LINE, width, value, color, legend, stack)); 3000 this.gdes.push(new RrdGraphDesc(this, RrdGraphDesc.GF_LINE, width, value, color, legend, stack, dashes, dash_offset));
2969}; 3001};
2970 3002
2971RrdGraph.prototype.gdes_add_area = function (value, color, legend, stack) 3003RrdGraph.prototype.gdes_add_area = function (value, color, legend, stack)
@@ -2993,14 +3025,14 @@ RrdGraph.prototype.gdes_add_textalign = function (align)
2993 this.gdes.push(new RrdGraphDesc(this, RrdGraphDesc.GF_TEXTALIGN, align)); 3025 this.gdes.push(new RrdGraphDesc(this, RrdGraphDesc.GF_TEXTALIGN, align));
2994}; 3026};
2995 3027
2996RrdGraph.prototype.gdes_add_vrule = function (time, color, legend) 3028RrdGraph.prototype.gdes_add_vrule = function (time, color, legend, dashes, dash_offset)
2997{ 3029{
2998 this.gdes.push(new RrdGraphDesc(this, RrdGraphDesc.GF_VRULE, time, color, legend)); 3030 this.gdes.push(new RrdGraphDesc(this, RrdGraphDesc.GF_VRULE, time, color, legend, dashes, dash_offset));
2999}; 3031};
3000 3032
3001RrdGraph.prototype.gdes_add_hrule = function (value, color, legend) 3033RrdGraph.prototype.gdes_add_hrule = function (value, color, legend, dashes, dash_offset)
3002{ 3034{
3003 this.gdes.push(new RrdGraphDesc(this, RrdGraphDesc.GF_HRULE, value, color, legend)); 3035 this.gdes.push(new RrdGraphDesc(this, RrdGraphDesc.GF_HRULE, value, color, legend, dashes, dash_offset));
3004}; 3036};
3005 3037
3006RrdGraph.prototype.tmt_conv = function (str) 3038RrdGraph.prototype.tmt_conv = function (str)