diff options
Diffstat (limited to 'docs/examples/assets/js/jsrrdgraph.js')
-rw-r--r-- | docs/examples/assets/js/jsrrdgraph.js | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/docs/examples/assets/js/jsrrdgraph.js b/docs/examples/assets/js/jsrrdgraph.js index 7dfdcad..d296ec6 100644 --- a/docs/examples/assets/js/jsrrdgraph.js +++ b/docs/examples/assets/js/jsrrdgraph.js @@ -4193,14 +4193,14 @@ RRDGraph.prototype = { find_var: function(key) { for (var ii = 0, gdes_c = this.gdes.length; ii < gdes_c; ii++) { - if ((this.gdes[ii].gf === RRDGraphDesc.GF.DEF || - this.gdes[ii].gf === RRDGraphDesc.GF.VDEF || - this.gdes[ii].gf === RRDGraphDesc.GF.CDEF) - && this.gdes[ii].vname === key) { - return ii; + if ((this.gdes[ii].gf === RRDGraphDesc.GF.DEF + || this.gdes[ii].gf === RRDGraphDesc.GF.VDEF + || this.gdes[ii].gf === RRDGraphDesc.GF.CDEF) + && this.gdes[ii].vname === key) { + return ii; + } } - } - return -1; + throw new Error('Key not found ' + key); }, // DEF:<vname>=<rrdfile>:<ds-name>:<CF>[:step=<step>][:start=<time>][:end=<time>][:reduce=<CF>] parse_def: function (line) @@ -4235,7 +4235,7 @@ RRDGraph.prototype = { gdp.gf = RRDGraphDesc.GF.DEF; gdp.vname = vname; - gdp.vidx = this.find_var(vname); +// gdp.vidx = this.find_var(vname); gdp.rrd = rrdfile; gdp.ds_nam = name; gdp.cf = this.cf_conv(cf); @@ -4292,9 +4292,13 @@ RRDGraph.prototype = { var index = rpn.indexOf(','); var name = rpn.substring(0,index); - gdp.vidx = this.find_var(name); // FIXME checks - if (gdp.vidx === -1 - || this.gdes[gdp.vidx].gf != RRDGraphDesc.GF.DEF + var vidx = this.find_var(name); + if (vidx === -1) { + throw 'variable "'+name+'" does not exist in VDEF.'; + } else { + gdp.vidx = vidx; + } + if (this.gdes[gdp.vidx].gf != RRDGraphDesc.GF.DEF && this.gdes[gdp.vidx].gf != RRDGraphDesc.GF.CDEF) { throw 'variable "'+name+'" not DEF nor CDEF in VDEF.'; } |