X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fplugins%2Fannotations.js;h=f6dd68edd7c58048acae920a13d84f990877afb6;hb=9154f07d785b038e8af866da745a67f5ba531771;hp=46d08918ef99128420dc59d34ade8cda2af1a406;hpb=6ecc073934b76e5076f917112a24ff7094857730;p=dygraphs.git diff --git a/src/plugins/annotations.js b/src/plugins/annotations.js index 46d0891..f6dd68e 100644 --- a/src/plugins/annotations.js +++ b/src/plugins/annotations.js @@ -56,12 +56,6 @@ annotations.prototype.didDrawChart = function(e) { if (!points || points.length === 0) return; var containerDiv = e.canvas.parentNode; - var annotationStyle = { - "position": "absolute", - "fontSize": g.getOption('axisLabelFontSize') + "px", - "zIndex": 10, - "overflow": "hidden" - }; var bindEvt = function(eventName, classEventName, pt) { return function(annotation_event) { @@ -75,7 +69,7 @@ annotations.prototype.didDrawChart = function(e) { }; // Add the annotations one-by-one. - var area = e.dygraph.plotter_.area; + var area = e.dygraph.getArea(); // x-coord to sum of previous annotation's heights (used for stacking). var xToUsedHeight = {}; @@ -93,18 +87,18 @@ annotations.prototype.didDrawChart = function(e) { tick_height = a.tickHeight; } + // TODO: deprecate axisLabelFontSize in favor of CSS var div = document.createElement("div"); - for (var name in annotationStyle) { - if (annotationStyle.hasOwnProperty(name)) { - div.style[name] = annotationStyle[name]; - } - } + div.style['fontSize'] = g.getOption('axisLabelFontSize') + "px"; + var className = 'dygraph-annotation'; if (!a.hasOwnProperty('icon')) { - div.className = "dygraphDefaultAnnotation"; + // camelCase class names are deprecated. + className += ' dygraphDefaultAnnotation dygraph-default-annotation'; } if (a.hasOwnProperty('cssClass')) { - div.className += " " + a.cssClass; + className += " " + a.cssClass; } + div.className = className; var width = a.hasOwnProperty('width') ? a.width : 16; var height = a.hasOwnProperty('height') ? a.height : 16; @@ -154,7 +148,8 @@ annotations.prototype.didDrawChart = function(e) { var ctx = e.drawingContext; ctx.save(); - ctx.strokeStyle = g.colorsMap_[p.name]; + ctx.strokeStyle = a.hasOwnProperty('tickColor') ? a.tickColor : g.colorsMap_[p.name]; + ctx.lineWidth = a.hasOwnProperty('tickWidth') ? a.tickWidth : g.getOption('strokeWidth'); ctx.beginPath(); if (!a.attachAtBottom) { ctx.moveTo(p.canvasx, p.canvasy);