div.appendChild(document.createTextNode(p.annotation.shortText));
}
div.style.left = (p.canvasx - width / 2) + "px";
- div.style.top = (p.canvasy - height - tick_height) + "px";
+ if (a.attachAtBottom) {
+ div.style.top = (this.area.h - height - tick_height) + "px";
+ } else {
+ div.style.top = (p.canvasy - height - tick_height) + "px";
+ }
div.style.width = width + "px";
div.style.height = height + "px";
div.title = p.annotation.text;
var ctx = this.element.getContext("2d");
ctx.strokeStyle = this.colors[p.name];
ctx.beginPath();
- ctx.moveTo(p.canvasx, p.canvasy);
- ctx.lineTo(p.canvasx, p.canvasy - 2 - tick_height);
+ if (!a.attachAtBottom) {
+ ctx.moveTo(p.canvasx, p.canvasy);
+ ctx.lineTo(p.canvasx, p.canvasy - 2 - tick_height);
+ } else {
+ ctx.moveTo(p.canvasx, this.area.h);
+ ctx.lineTo(p.canvasx, this.area.h - 2 - tick_height);
+ }
ctx.closePath();
ctx.stroke();
}
</style>
</head>
<body>
+ <h3>Annotations Demo</h3>
+ <p>Click any point to add an annotation to it or click "Add Annotation".</p>
<input type="button" value="Add Annotation" onclick="add()" />
+ <input type="button" value="Shove to bottom" onclick="bottom(this)" />
<div id="events"> </div>
<div style="position:absolute; left:200px; top: 200px;" id="g"></div>
<div style="position:absolute; left:700px; top: 200px;" id="list"></div>
g.setAnnotations(annotations);
}
+ function bottom(el) {
+ var to_bottom = true;
+ if (el.value != 'Shove to bottom') to_bottom = false;
+
+ var anns = g.annotations();
+ for (var i = 0; i < anns.length; i++) {
+ anns[i].attachAtBottom = to_bottom;
+ }
+ g.setAnnotations(anns);
+
+ if (to_bottom) {
+ el.value = 'Lift back up';
+ } else {
+ el.value = 'Shove to bottom';
+ }
+ }
+
var saveBg = '';
var num = 0;
g.updateOptions( {