-
-
Save tgrall/00c5d83b85f59d80ad95 to your computer and use it in GitHub Desktop.
Dashboard with Drill and Node
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
var blessed = require('blessed') | |
, contrib = require('blessed-contrib') | |
, request = require('request') | |
, screen = blessed.screen() | |
, bar = contrib.bar( | |
{ label: 'Bar Chart' | |
, barWidth: 12 | |
, barSpacing: 5 | |
, maxHeight: 9 | |
, height: "100%" | |
, width: "100%"}) | |
screen.append(bar); | |
var query = { | |
"queryType" : "SQL", | |
"query" : "select `YEAR`, SUM(`PASSENGER_COUNT`) from dfs.tmp.`airport_data_view` GROUP BY `YEAR`" | |
}; | |
request( | |
{ | |
url: 'http://localhost:8047/query.json', //URL to hit | |
method: 'POST', | |
json: query | |
}, | |
function(error, response, body){ | |
var columns = body.columns; | |
var data = { | |
titles : [], | |
data : [] | |
}; | |
for(var entry of body.rows){ | |
data.titles.push(entry[columns[0]]); | |
data.data.push(entry[columns[1]]); | |
} | |
bar.setData(data); | |
screen.render() | |
}); | |
screen.key(['escape', 'q', 'C-c'], function(ch, key) { | |
return process.exit(0); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment