-
-
Save pauldix/2d3bcb1eb4b70532f6f1 to your computer and use it in GitHub Desktop.
Examples files from Building Custom Analytics with InfluxDB and D3
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
[ | |
{ | |
"name": "events", | |
"columns": ["type", "email"], | |
"points": [ | |
["signup", "paul@influxdb.com"], | |
["paid", "foo@asdf.com"] | |
] | |
} | |
] | |
[ | |
{ | |
"name": "cpu", | |
"columns": ["time", "value", "host"], | |
"points": [ | |
[1395168540, 56.7, "foo.influxdb.com"] | |
] | |
} | |
] |
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
renderDetail = (series, x) => | |
startTime = x | |
endTime = startTime + 3600 | |
q = "select * from events3 where time > " + startTime + | |
"s and time < " + endTime + | |
"s and type = '" + series + "'" | |
parent.influxdb.query(q, (points) => | |
console.log(points) | |
ul = "<ul>" | |
points.forEach (point) => | |
li = "<li>" | |
li += point.email | |
li += "</li>" | |
ul += li | |
ul += "</ul>" | |
$("#events_detail").html(ul) | |
) | |
parent.influxdb.query("SELECT COUNT(type) FROM events3 GROUP BY time(1h), type fill(0);", (points) => | |
typeToSeries = {} | |
points.forEach((point) => | |
series = typeToSeries[point.type] | |
if !series | |
typeToSeries[point.type] = []; | |
series = typeToSeries[point.type]; | |
series.push({x: point.time / 1000, y: point.count}) | |
) | |
lastColorUsed = -1 | |
colors = d3.scale.category10() | |
data = for type, series of typeToSeries | |
lastColorUsed += 1 | |
data: series.reverse(), color: colors(lastColorUsed) | |
#console.log(data) | |
graph = new Rickshaw.Graph( | |
height: 200, | |
element: document.querySelector("#events_graph"), | |
renderer: 'area', | |
stroke: true, | |
series: data | |
) | |
hoverDetail = new Rickshaw.Graph.HoverDetail( | |
graph: graph, | |
formatter: (series, x, y) -> | |
date = '<span class="date">' + new Date(x * 1000).toUTCString() + '</span>' | |
swatch = '<span class="detail_swatch" style="background-color: ' + series.color + '"></span>' | |
content = swatch + series.name + ": " + parseInt(y) + '<br>' + date | |
renderDetail(series.name, x) | |
content | |
) | |
graph.render() | |
) |
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
<html> | |
<head> | |
<title>Paul's Custom Dash</title> | |
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css"> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-12"> | |
<h1>Paul's Custom Dash</h1> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-md-6" id="events_graph"></div> | |
</div> | |
<div class="row"> | |
<h3>Detail</h3> | |
<div class="col-md-6" id="events_detail"></div> | |
</div> | |
</div> | |
</body> | |
</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
# make the dir in the local admin interface dir so it shows up on the drop down | |
mkdir /usr/local/opt/influxdb/share/admin/interfaces/paul_owns | |
# make the dir and file in the influxdb-admin repo | |
mkdir source/interfaces/paul_owns | |
touch source/interfaces/paul_owns/index.html # or slim, etc. |
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
<script src="http://code.jquery.com/jquery-2.0.3.min.js" type="text/javascript"></script> | |
<script src="http://d3js.org/d3.v3.min.js" type="text/javascript"></script> | |
<script src="http://influxdb.org/javascripts/vendor/rickshaw.js" type="text/javascript"></script> | |
<script src="/javascripts/interfaces/paul_owns.js" type="text/javascript"></script> | |
<link href="http://influxdb.org/stylesheets/vendor/rickshaw.css" media="screen" rel="stylesheet" type="text/css"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment