Wednesday, 11 September 2013

d3js plot zoomed in a modal window on 'click'

d3js plot zoomed in a modal window on 'click'

I used d3js to plot data from a csv file:
draw(filename, divID) {
d3.csv(filename, function(data){
...
.on('click', function(d){
//open a modal and plot csv filename again
draw_bigger(filename); //call $("#mymodal").modal(); inside
The idea is that once the user clicks on the plot, a modal window pops out
and re-plot the data with auto-range (more zoomed-in). Because of
javascript closure, "filename" gets passed naturally to the inner
draw_bigger function.
However the same file is requested twice from the server. I wonder if
there is a better way to do this.

No comments:

Post a Comment