Skip to content

Instantly share code, notes, and snippets.

@himynamesdave
Created May 20, 2014 14:47
Show Gist options
  • Save himynamesdave/cedc35308cd0e356b0d5 to your computer and use it in GitHub Desktop.
Save himynamesdave/cedc35308cd0e356b0d5 to your computer and use it in GitHub Desktop.
Intro to creating pages using the Splunk Web Framework
{% 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