vasturiano / timelines-chart

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

Custom Tooltip Function #77

Closed pizzapanther closed 4 years ago

pizzapanther commented 4 years ago

Added an option to be able to supply a segment tooltip function which generates customized tooltip HTML. The function is passed state (chart instance) and d (current data point).

pizzapanther commented 4 years ago

@vasturiano ready for review again

pizzapanther commented 4 years ago

In my usage I was still using the timerange and labelval so having access to everything is useful.

vasturiano commented 4 years ago

Agreed. And as mentioned in the other PR, .data should give you access to the complete segment object, not just the spread filtered attributes.

pizzapanther commented 4 years ago

OK i'm just going to leave it segmentTooltipHtml(d) so you still have access to group, label, labelVal which may be used by the custom tooltip function and are computed. And you'll have access to original data via data

vasturiano commented 4 years ago

Thanks @pizzapanther! This is a nice addition that adds more flexibility to the chart. Did some minor modifications on the docs and renamed the method to segmentTooltipContent since it can also accept plain text for a simple case.

Module is published (2.10.0) with both PRs in. 👍

pizzapanther commented 4 years ago

Sounds great!