d3.js - How can I add a duration histogram's time data to its bars? -


i working numerous d3 duration histograms, each different duration. tie in starting time of time range each bar represents div id inside each bar's html. information accessed via jquery.

say example there's bar @ 00:10. add "00:10" bar's div.

what can't figure out how hold of these times. suggestions on how this?

to add attribute use selection.attr() example:

bar.append("rect")     .attr("x", 1)     .attr("width", x(data[0].dx) - 1)     .attr("height", function(d) { return height - y(d.y); })     .attr("data-time", function(d){return formatminutes(d.x)}) 

but, if want access api on click, d3's selection.on():

bar.append("rect")     .attr("x", 1)     .attr("width", x(data[0].dx) - 1)     .attr("height", function(d) { return height - y(d.y); })     .on("click", function(d){          accessapi(formatminutes(d.x))     }) 

eg. http://jsfiddle.net/3saqw/

i recommend learning how d3.js binds data. may jquery isn't required. tutorial series: http://alignedleft.com/tutorials/d3/binding-data/


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -