1

I'm new to d3js, and I'm successfully using example here: https://gist.github.com/d3noob/4414436

That's quite nice, because it works remotely, the CSV being stored on server side. Now, I'd like to go further, and add the ability to select the source CSV from a list and the redraw the chart.

I'm stuck in writing php and java, and java echo'ed by php, so I think that I'm totally on the wrong way.

Would you have an example that illustrates how to perform the chart update reading a new CSV selected from a dropdown list containing the server side's CSV pathes?

Kind regards,

Sylvain

1 Answer 1

2

I'm assuming you don't need help making the drop-down list. The simplest method would be to simply feed in the drop-down list selection into a var, and use that var when you do your d3.csv() call. For example:

//storing the drop-down selection in the ddSelection var
var ddSelection = document.getElementById("secondOption").value,

//feeding that to create the csv filename you want
var csvFile = "/some server path/" + ddSelection + ".csv";

d3.csv(csvFile, function(error, dataset) {
    //a bunch of cool visualizing stuff
})

Then you'll just need to remember to include .exit() when you're joining your data, so that the graph updates with the new dataset - Mike Bostock's Thinking with Joins is the standard reference for that.

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

1 Comment

Wonderful. Now I'm able to choose which CSV to display graphically. Many thanks. I'm closing the thread.

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.