Accepted answer

What you're missing is the parsing of the data from text to the right format, using function type (which in turn calls the date parser function). Just insert the following line:


About the line axis, you need to revert to the original code (which doesn't have to change for you):

var line = d3.svg.line()
    .x(function(d) { return x(; })
    .y(function(d) { return y(d.price); }); is your original data, x( translates this into an x-coordinate for the drawing, and the block above tells that the data should use the x and y functions to generate the coordinates. at this point, the data doesn't have to be taken into account.

I general, to use local data instead of an external file, look for the line as this one:

d3.csv("readme.csv", type, function(error, data) {

and you need to apply the same preprocessing to your data (here, the type function), and then call the function. What I usualy do is the following:

process =  function(error, data) {
/* use external file: */
//d3.csv("readme.csv", type, process) 
/* use local data: */
process(false, data)

Related Query