dygraphs
Version:
dygraphs is a fast, flexible open source JavaScript charting library.
89 lines (81 loc) • 2.81 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<title>dygraphs unboxed</title>
<link rel="stylesheet" type="text/css" href="../dist/dygraph.css" />
<link rel="stylesheet" type="text/css" href="../common/vextlnk.css" />
<script type="text/javascript" src="../dist/dygraph.js"></script>
<script type="text/javascript" src="data.js"></script>
<style type="text/css">
#div_spark {
display: inline-block;
}
</style>
</head>
<body>
<p>This shows dygraphs without any boxlike elements (i.e. axes or grids):</p>
<div id="div_g" style="width:600px; height:300px; border:1px solid white;"></div>
<script type="text/javascript"><!--//--><![CDATA[//><!--
Dygraph.onDOMready(function onDOMready() {
var show_box = false;
g = new Dygraph(
document.getElementById("div_g"),
data, {
axes : {
x : {
drawGrid: show_box,
drawAxis: show_box,
},
y : {
drawGrid: show_box,
drawAxis: show_box,
}
}
}
);
toggleBox = function toggleBox(btn) {
show_box = !show_box;
document.getElementById("div_g").style.border = show_box ? '1px solid black' : '1px solid white';
if (show_box) {
btn.innerHTML = 'Hide box';
} else {
btn.innerHTML = 'Show box';
}
}
});
//--><!]]></script>
<button onClick='toggleBox(this)'>Show box</button>
<!-- Dygraphs constructs a div inside of whatever div we pass in. So the
container div can't be a span or have display: inline-block. We use a
table to get the sparkline to display on the same line as the text.
-->
<p></p>
<table><tr><td>This style can be used to produce interactive sparklines with dygraphs:</td><td><div id="div_spark" style="width:100px; height:20px;"></div></td></tr></table>
<p>Disable the legend though, otherwise it’s not very interactive…</p>
<script type="text/javascript"><!--//--><![CDATA[//><!--
Dygraph.onDOMready(function onDOMready() {
g2 = new Dygraph(
document.getElementById("div_spark"),
data, {
axes : {
x : {
drawGrid: false,
drawAxis: false,
},
y : {
drawGrid: false,
drawAxis: false,
}
},
strokeWidth: 1.0,
rollPeriod: 7,
labelsDiv: '',
legend: 'never',
highlightCircleSize: 2
}
);
});
//--><!]]></script>
</body>
</html>