0

consider this fiddle link FIDDLE. In this example I would like to use a csv file to load data at line no.33-[data.csv] and data at line no.158-[data1.csv]. I want to use two separate csv files. I tried using a csv file for data at line no.33 with this code

 d3.csv("data.csv", function(csvData) {

csvData.forEach(function (d,i) {
    data[i] = {
      first: +d.first, 
      second: +d.second
    } 
});
console.log(data);

I was able to get an output but the charts had moved far away from each other with the following errors : Unexpected value NaN parsing cy attribute. How to load the two datasets in an efficient way using two separate csv files ?

18
  • You would have to use d3.csv twice. Commented Apr 3, 2014 at 12:45
  • Yes Lars, but the chart is moved downwards i.e. the charts on top is distant from bottom chart by certain empty space,with this error:Unexpected value NaN parsing cy attribute. Commented Apr 3, 2014 at 13:59
  • I don't see that in your jsfiddle. Commented Apr 3, 2014 at 14:03
  • Its when I execute in my browser, and how to use a csv file in jsfiddle ? Commented Apr 3, 2014 at 14:09
  • You can use something like plnkr.co which allows you to have several files. Commented Apr 3, 2014 at 14:17

1 Answer 1

1

Here is hopefully the final plunker in this ever-growing project :) (A lot of the csv work here has been guided by the great Lars...as usual, many kudos to him.)

Updated plunker with data on top chart coming from datam.csv.

Sign up to request clarification or add additional context in comments.

5 Comments

FernOfTheAndes the data.csv is loading properly whereas the datam.csv is not loading i.e. the chart on the top is taking the values of data.csv itself. I want the chart on top to take datam.csv values.
@user3438326 Yes, data(datam) was the fix for that. I have updated the response with the revised plunker. See above.
FernOfTheAndes thank you so much. You are Awesome :)
FernOfTheAndes - Consider this plunker plnkr.co/edit/QPpzfkyd7FMdPuA312Aq?p=preview. In this plunker I have added one more file datan.csv, also one more column to data.csv-named third. I want the chart to be plotted according the Enumerated order from data.csv file, in the data.csv file first denotes X-axis, second denotes number of Y units and third denotes the text which should be sorted according to the order of enumerated data. How to do this ?
FernOfTheAndes can you help with this question stackoverflow.com/questions/22861768/… ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.