X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=plugins%2Flegend.js;h=2ff939879e74a2c55aa064faddad4c8b703f49b5;hb=ebf77a9fa6953523975f7ee608a05e1c66c43e47;hp=7406f82a950f3c7cf7e516786591123f9400eee9;hpb=691cb47bb65c604efa9a1f1a6537192f618edb3e;p=dygraphs.git diff --git a/plugins/legend.js b/plugins/legend.js index 7406f82..2ff9398 100644 --- a/plugins/legend.js +++ b/plugins/legend.js @@ -88,7 +88,7 @@ legend.prototype.activate = function(g) { try { div.style[name] = messagestyle[name]; } catch (e) { - this.warn("You are using unsupported css properties for your " + + Dygraph.warn("You are using unsupported css properties for your " + "browser in labelsDivStyles"); } } @@ -120,6 +120,10 @@ var calculateEmWidthInDiv = function(div) { return oneEmWidth; }; +var escapeHTML = function(str) { + return str.replace(/&/g, "&").replace(/"/g, """).replace(//g, ">"); +}; + legend.prototype.select = function(e) { var xValue = e.selectedX; var points = e.selectedPoints; @@ -208,7 +212,7 @@ generateLegendHTML = function(g, x, sel_points, oneEmWidth) { strokePattern = g.getOption("strokePattern", labels[i]); dash = generateLegendDashHTML(strokePattern, series.color, oneEmWidth); html += "" + - dash + " " + labels[i] + ""; + dash + " " + escapeHTML(labels[i]) + ""; } return html; } @@ -245,7 +249,7 @@ generateLegendHTML = function(g, x, sel_points, oneEmWidth) { // TODO(danvk): use a template string here and make it an attribute. html += "" + " " + - pt.name + ": " + yval + ""; + escapeHTML(pt.name) + ": " + yval + ""; } return html; };