amcharts5
amcharts5 copied to clipboard
Toggle showTooltipOn based on zoom / scrollbar start end
In amCharts5, is there a way to toggle showTooltipOn based on how many elements are display in a chart at a given zoom level?
I'd like showTooltipOn = 'always' when the distance between scrollbar start and end is 0.2 or less.
I'd like showTooltipOn = 'hover' when the distance between scrollbar start and end is greater than 0.2.
You can use the settings value change callback to monitor the scrollbar's start
and end
updates and adjust showTooltipOn your series/sprite accordingly:
scrollbar.on('start', (start, target) => {
updateShowTooltipOn(start, target.get('end'))
})
scrollbar.on('end', (end, target) => {
updateShowTooltipOn(target.get('start'), end)
})
function updateShowTooltipOn(start, end) {
let showTooltipOn = end - start > .2 ? 'hover' : 'always'
// set showTooltipOn on your series/sprite/etc here
}
Thanks @martynasma , I've tried a similar setup in the past with the difference being an absolute value and checking specifically if end and start are numbers and are not null (otherwise a value of zero will fail the truthy check), but that's the not issue.
The issue is the chart doesn't update again when setting a series column template tooltip after the value of showtooltipon has been updated. :-(
This issue is stale because it has been open 30 days with no activity. It will be closed in 5 days unless a new comment is added.