Created
July 14, 2014 17:05
-
-
Save frabcus/d7fb0cd82147f809e14b to your computer and use it in GitHub Desktop.
Graph stock data
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
scraperwiki.sql("select * from stocks", function(data, textStatus, jqXHR) { | |
console.log('Great! Here are your stocks:', data) | |
var fields = [ 'Adj_Close', 'Close', 'High', 'Low', 'Open', 'Volume', 'Date' ] | |
for (var i = 0; i < data.length; i++) { | |
data[i]['Date'] = data[i]['Date'].substr(0,10) | |
} | |
var chart = c3.generate({ | |
bindto: "#mychart", | |
data: { | |
x: 'Date', | |
json: data, | |
keys: { value: ['Date', 'Low', 'High', 'Volume'] }, | |
axes: { Low: 'y', High: 'y', Volume: 'y2' } | |
}, | |
point: { | |
show: false | |
}, | |
axis: { | |
x: { type: 'timeseries', tick: { format: '%Y-%m-%d', count : 8 } }, | |
y2: { show : true }, | |
}, | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment