Skip to content

Commit ce341a7

Browse files
committed
fix: ensure we return the closest value if only one
1 parent 4d0d83f commit ce341a7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/charting/highlight/ChartHighlighter.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ export class ChartHighlighter<T extends BarLineScatterCandleBubbleDataProvider>
5555
*/
5656
protected getHighlightForX(xVal, x, y) {
5757
const closestValues = this.getHighlightsAtXValue(xVal, x, y);
58-
if (closestValues.length === 0) {
59-
return null;
58+
if (closestValues.length <= 1) {
59+
return closestValues[0];
6060
}
6161

6262
const leftAxisMinDist = this.getMinimumDistance(closestValues, y, AxisDependency.LEFT);
6363
const rightAxisMinDist = this.getMinimumDistance(closestValues, y, AxisDependency.RIGHT);
6464

6565
const axis = leftAxisMinDist < rightAxisMinDist ? AxisDependency.LEFT : AxisDependency.RIGHT;
66-
6766
const detail = this.getClosestHighlightByPixel(closestValues, x, y, axis, this.mChart.getMaxHighlightDistance());
6867

6968
return detail;

0 commit comments

Comments
 (0)