Skip to content

Commit c0b93ff

Browse files
committed
fix: correct high index with filtered data
1 parent 240946d commit c0b93ff

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/charting/highlight/ChartHighlighter.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Rounding } from '../data/DataSet';
66
import { IDataSet } from '../interfaces/datasets/IDataSet';
77
import { Entry } from '../data/Entry';
88
import { getEntryXValue } from '../data/BaseEntry';
9+
import { LineDataSet } from '../data/LineDataSet';
910

1011
export class ChartHighlighter<T extends BarLineScatterCandleBubbleDataProvider> implements IHighlighter {
1112
/**
@@ -148,17 +149,22 @@ export class ChartHighlighter<T extends BarLineScatterCandleBubbleDataProvider>
148149
entries = set.getEntriesAndIndexesForXValue(getEntryXValue(closest.entry, xKey, closest.index));
149150
}
150151
}
151-
152152
if (entries.length === 0) return highlights;
153153

154154
for (const r of entries) {
155155
const e = r.entry;
156+
let index = r.index;
156157
const xVal = getEntryXValue(e, xKey, r.index);
157158
const pixels = this.mChart.getTransformer(set.getAxisDependency()).getPixelForValues(xVal, e[yKey]);
159+
if ((set as any).isFiltered && (set as LineDataSet).isFiltered()) {
160+
(set as LineDataSet).setIgnoreFiltered(true);
161+
index = set.getEntryIndexForXValue(xVal, NaN, Rounding.CLOSEST);
162+
(set as LineDataSet).setIgnoreFiltered(false);
163+
}
158164

159165
highlights.push({
160166
entry: e,
161-
entryIndex: r.index,
167+
entryIndex: index,
162168
x: xVal,
163169
y: e[yKey],
164170
xPx: pixels.x,

0 commit comments

Comments
 (0)