fix: flip slope tooltip below dot when near chart top edge
This commit is contained in:
@@ -355,11 +355,15 @@
|
||||
);
|
||||
|
||||
if (isSlope) {
|
||||
const nearTop = (d: any) => {
|
||||
const range = lineDomainMax - lineDomainMin;
|
||||
return range > 0 && (d[yKey] - lineDomainMin) / range > 0.85;
|
||||
};
|
||||
marks.push(
|
||||
Plot.text(lineData, Plot.pointerX({
|
||||
x, y: yKey,
|
||||
text: (d: any) => d.slope != null ? `${d.slope > 0.05 ? '+' : ''}${(+d.slope).toFixed(1)}%` : '',
|
||||
dy: -22,
|
||||
dy: (d: any) => nearTop(d) ? 22 : -22,
|
||||
fill: (d: any) => slopeColor(d.slope ?? 0),
|
||||
stroke: tc.tooltipBg, strokeWidth: 3,
|
||||
fontSize: 11, fontWeight: '700',
|
||||
@@ -367,7 +371,7 @@
|
||||
Plot.text(lineData, Plot.pointerX({
|
||||
x, y: yKey,
|
||||
text: (d: any) => d[yKey] != null ? `${Math.round(d[yKey])}m` : '',
|
||||
dy: -10,
|
||||
dy: (d: any) => nearTop(d) ? 10 : -10,
|
||||
fill: tc.axis, stroke: tc.tooltipBg, strokeWidth: 3,
|
||||
fontSize: 10,
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user