From 0c9a7f2494dab9c9dc5d3bba1a73996c2b5a745c Mon Sep 17 00:00:00 2001 From: Manuel Luis SanmartĂ­n Rozada Date: Fri, 25 Jul 2014 18:12:13 +0200 Subject: jsrrdgraph: Check when this.gdes[i].legend is null --- js/RrdGraph.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/RrdGraph.js b/js/RrdGraph.js index cba141d..642b9c5 100644 --- a/js/RrdGraph.js +++ b/js/RrdGraph.js @@ -1697,9 +1697,14 @@ RrdGraph.prototype.leg_place = function (calc_width) if (this.gdes[i].gf === RrdGraphDesc.GF_VRULE && (this.gdes[i].xrule < this.start || this.gdes[i].xrule > this.end)) this.gdes[i].legend = null; } - this.gdes[i].legend = this.gdes[i].legend.replace(/\\t/gi, "\t") /* turn \\t into tab */ - leg_cc = this.gdes[i].legend.length; + if (this.gdes[i].legend != null) { + this.gdes[i].legend = this.gdes[i].legend.replace(/\\t/gi, "\t") /* turn \\t into tab */ + leg_cc = this.gdes[i].legend.length; + } else { + leg_cc = 0; + } + /* is there a controle code at the end of the legend string ? */ if (leg_cc >= 2 && this.gdes[i].legend.charAt(leg_cc - 2) === '\\') { prt_fctn = this.gdes[i].legend.charAt(leg_cc - 1); -- cgit v1.1