Created
May 20, 2014 14:47
-
-
Save himynamesdave/cedc35308cd0e356b0d5 to your computer and use it in GitHub Desktop.
Intro to creating pages using the Splunk Web Framework
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
{% extends "splunkdj:base_with_app_bar.html" %} | |
{% load splunkmvc %} | |
{% block content %} | |
<div id="barchart"></div> | |
{% endblock content%} | |
{% block js %} | |
<script> | |
var deps = [ | |
"splunkjs/ready!", | |
"splunkjs/mvc/searchmanager", | |
"splunkjs/mvc/chartview" | |
]; | |
require(deps, function(mvc) { | |
var SearchManager = require("splunkjs/mvc/searchmanager"); | |
var ChartView = require("splunkjs/mvc/chartview"); | |
new SearchManager({ | |
id: "mysearch", | |
search: "index=_internal | head 1000 | stats count by sourcetype" | |
}); | |
var mychart = new ChartView ({ | |
id: "mychart", | |
managerid: "mysearch", | |
type: "bar", | |
el: $("#barchart") | |
}).render(); | |
// Event handler | |
mychart.on("click:chart", function (e) { | |
e.preventDefault(); | |
console.log("Clicked chart: ", e.value); | |
}); | |
}); | |
</script> | |
{% endblock js %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment