Skip to content

Commit

Permalink
Small interaction improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
vasturiano committed Oct 23, 2023
1 parent fe1dbbe commit 30ba6a3
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions src/hilbert.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,21 +300,18 @@ export default Kapsule({
state.hoverD = hoverD;

state.rangeTooltip.style('display', 'none');
if (hoverD) {
if (state.showRangeTooltip) {
state.rangeTooltip.style('display', 'inline');

const d = hoverD;
if (state.rangeTooltipContent) {
state.rangeTooltip.html(accessorFn(state.rangeTooltipContent)(d));
} else {
// default tooltip
const rangeLabel = accessorFn(state.rangeLabel);
const rangeFormatter = d => state.valFormatter(d.start) + (d.length > 1 ? ' - ' + state.valFormatter(d.start + d.length - 1) : '');
state.rangeTooltip.html(`<b>${rangeLabel(d)}</b>: ${rangeFormatter(d)}`);
}
}
if (hoverD && state.showRangeTooltip) {
const d = hoverD;
const tooltipContent = state.rangeTooltipContent
? accessorFn(state.rangeTooltipContent)(d)
// default tooltip
: `<b>${accessorFn(state.rangeLabel)(d)}</b>: ${state.valFormatter(d.start) + (d.length > 1 ? ' - ' + state.valFormatter(d.start + d.length - 1) : '')}`

state.rangeTooltip.html(tooltipContent || '');
tooltipContent && state.rangeTooltip.style('display', 'inline');
}

hilbertCanvas.style('cursor', hoverD && state.onRangeClick ? 'pointer' : null);
state.onRangeHover && state.onRangeHover(hoverD || null);
}
}
Expand Down Expand Up @@ -439,16 +436,13 @@ export default Kapsule({
state.rangeTooltip.style('display', 'none');

if (state.showRangeTooltip) {
state.rangeTooltip.style('display', 'inline');

if (state.rangeTooltipContent) {
state.rangeTooltip.html(accessorFn(state.rangeTooltipContent)(d));
} else {
const tooltipContent = state.rangeTooltipContent
? accessorFn(state.rangeTooltipContent)(d)
// default tooltip
const rangeLabel = accessorFn(state.rangeLabel);
const rangeFormatter = d => state.valFormatter(d.start) + (d.length > 1 ? ' - ' + state.valFormatter(d.start + d.length - 1) : '');
state.rangeTooltip.html(`<b>${rangeLabel(d)}</b>: ${rangeFormatter(d)}`);
}
: `<b>${accessorFn(state.rangeLabel)(d)}</b>: ${state.valFormatter(d.start) + (d.length > 1 ? ' - ' + state.valFormatter(d.start + d.length - 1) : '')}`

state.rangeTooltip.html(tooltipContent || '');
tooltipContent && state.rangeTooltip.style('display', 'inline');
}

state.onRangeHover && state.onRangeHover(d);
Expand Down

0 comments on commit 30ba6a3

Please sign in to comment.