Last active
August 29, 2015 14:04
-
-
Save jderrett/2f9ac3651edfe977380e to your computer and use it in GitHub Desktop.
librato_chart_example.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<!-- They'll need there own version of jquery or whatever --> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
<script src="https://sdk.librato.com/librato-sdk-v0.5.1-min.js"></script> | |
</head> | |
<body> | |
<div id="thegraph"> | |
</div> | |
<input type="text" name="source" placeholder="dynamic source"></input> | |
<script type="text/javascript"> | |
var hoursBack = 6; | |
var msPerHour = 1000 * 3600; | |
var startEpoch = Math.floor((new Date()).getTime() - hoursBack * msPerHour); | |
var startDate = new Date(startEpoch); | |
var opts = { | |
email: "me@example.com", | |
apiToken: "ABCD1234", | |
divID: "thegraph", | |
instrumentID: 30868334, | |
startDate: startDate, | |
source: 'austin' | |
} | |
var graph = new LibratoMetrics.LineGraph(opts); | |
var update = function(source) { | |
graph.model.setDynamicSource(source); | |
} | |
$('input[name="source"]').on('keyup', function(e) { | |
// Hitting the enter key | |
if (e.keyCode == 13) { | |
update($(this).val()); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment