vasturiano / timelines-chart

Timelines Chart
http://vasturiano.github.io/timelines-chart/example/categorical/
MIT License
561 stars 122 forks source link

Proposal to add a toggle to the API inputs to not show timelines if they have no events on the current [startTime, endTime] view #58

Open max-su opened 5 years ago

max-su commented 5 years ago

Happy to write the PR to get the ball rolling - I'd like to not show some timelines and their respective y-axis labels on zoomed in [startTime,endTime] views that don't have events on them.

Manipulating the data array I pass in wouldn't work for this case because these timelines might still have events for the complete [startTime,EndTime] interval - to clarify I just want the timelines to not be displayed on the graph until they have events that are visible based on the current [startTime, endTime] state of the timelines-chart object.

I figure this feature would also be useful to others too who would like a less cluttered timeline?

Implementation wise - I figure the changes need to be made here and I would need to add another filter to the flatData before drawing it?

https://github.com/vasturiano/timelines-chart/blob/master/src/timelines.js#L962-L964

Appreciate any help!

vasturiano commented 5 years ago

@max-su I think this would be a nice feature addition. I'd prefer if it doesn't break backwards compatibility, so the new config flag should default to the current behaviour.

And yes, please send a PR for this change. Your understanding is correct that it should just be a matter of filtering the timelines array before drawing.

We can call the flag .excludeEmptySeries(<bool>).

When zooming in the Y axis (by rectangle brushing) the interaction may lead to unexpected views (like the number of lines decreasing dramatically, or even becoming empty) so it's worth spending a little time testing those type of transitions.