denisemauldin / d3-timeline

D3 timeline
BSD 3-Clause "New" or "Revised" License
168 stars 72 forks source link

Is there a way to update the timeline? #15

Open kohesion opened 6 years ago

kohesion commented 6 years ago

Maybe this would be obvious if I knew anything about d3...

If there is a way to update the timeline, could you add it in the documentation?

Thanks!

hodbauer commented 5 years ago

Hi, the only way that I was success to update the timeline was in the next way:

function update(data) {
  // re-init timeline
  if (timelineElement) {
    timelineElement.remove();
  }
  timelineElement = d3.select('#my-id').append('svg');

  // add data
  timelineElement.datum(data).call(timeline); // <- catch here
}

The re-init section is the only way that I found that will "update" the timeline without leave the old version of timeline behind new version. But, as commented in this snippet, there is a catch. I've got error in line 599: node(...).attr is not a function

after a few tests I was modified the code in the mention line to: gParentItem.attr("height", height); and the error was disappears.

So @kohesion, there is unofficial weird way to update. @denisemauldin any better solution?

aftab-git commented 5 years ago

need d3 timeline for angular 2 project help....

denisemauldin commented 5 years ago

@hodbauer This is typically the way you would redraw the chart, yes. :)