jiahuang / d3-timeline

Simple JS timeline plugin for d3
1.03k stars 282 forks source link

Added custom timeline item labeling for easy modification #18

Closed charlesfracchia closed 10 years ago

charlesfracchia commented 10 years ago

Each timeline item rectangle (or circle) is now affixed with a unique id attribute (“timelineItem_”+customIdString) for easy manipulation using JQuery. If no custom id is provided, the unique id will use the data index, e.g.: timelineItem_0. Added paragraph to describe it in the Readme. Corrected two typos.

charlesfracchia commented 10 years ago

Ok, sorry about that. Now it's cleaner, all changes merged into a single commit and no omissions :)

jiahuang commented 10 years ago

It seems like this offers a hacky solution for manipulation of the timeline that should really be done in the d3 iterator.

For example, changing the color of the timeline according to an attribute should be done through setting the color cycle of timeline.colors, hover/mouse click/etc should all be done through their individual callbacks.

charlesfracchia commented 10 years ago

This is not just for colors though. The example uses colors but you could add strokes like so: $('#timelineItem_0').css('stroke-dasharray','3'); $('#timelineItem_0').css('stroke','black'); $('#timelineItem_0').css('stroke-width','1');"

or dynamically hide it: $('#timelineItem_0').hide();

or anything else that JQuery allows you to do :) I think it's a pretty useful handle to have :)

jiahuang commented 10 years ago

I've merged this into master. Sorry about the delay.