Skip to content

Instantly share code, notes, and snippets.

@aviflax
Created February 13, 2011 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aviflax/824394 to your computer and use it in GitHub Desktop.
Save aviflax/824394 to your computer and use it in GitHub Desktop.
Illustrates a problem I'm having with dygraph annotations
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Annotation Test</title>
<meta name="author" content="Avi Flax">
<script src="dygraph-combined.js"></script>
<script>
window.onload = function(){
var data = [
[new Date(Date.parse('2011-02-12T19:00:00Z')), 400, 200],
[new Date(Date.parse('2011-02-12T20:00:00Z')), 408, 204],
[new Date(Date.parse('2011-02-12T21:00:00Z')), 413, 206],
[new Date(Date.parse('2011-02-12T22:00:00Z')), 444, 208],
[new Date(Date.parse('2011-02-12T23:00:00Z')), 456, 212],
[new Date(Date.parse('2011-02-13T00:00:00Z')), 476, 215],
[new Date(Date.parse('2011-02-13T01:00:00Z')), 479, 218],
[new Date(Date.parse('2011-02-13T02:00:00Z')), 521, 224]
];
var graph = new Dygraph(
document.getElementById("graph"),
data,
{
strokeWidth: 4.0,
width: 720,
height: 420,
axisLabelFontSize: 16,
highlightCircleSize: 5,
labels: ["Date", "Subscribers", "Publishers"]
}
);
console.log(data[data.length-1][0].valueOf());
graph.setAnnotations([
{
series: "Subscribers",
x: data[data.length-1][0].valueOf(),
shortText: data[data.length-1][1] + " S",
text: "Subscribers"
}
]);
};
</script>
</head>
<body>
<div id="graph"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment