Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/components/timeline/TrackPowerGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,32 @@ class TrackPowerGraphImpl extends React.PureComponent<Props, State> {
// Right point is closer
hoveredCounter = bisectionCounter;
}

// If there are samples before or after hoveredCounter that fall
// horizontally on the same pixel, move hoveredCounter to the sample
// with the highest power value.
const mouseAtTime = (t) =>
Math.round(((t - rangeStart) / rangeLength) * width + left);
for (
let currentIndex = hoveredCounter - 1;
mouseAtTime(samples.time[currentIndex]) === mouseX &&
currentIndex > 0;
--currentIndex
) {
if (samples.count[currentIndex] > samples.count[hoveredCounter]) {
hoveredCounter = currentIndex;
}
}
for (
let currentIndex = hoveredCounter + 1;
mouseAtTime(samples.time[currentIndex]) === mouseX &&
currentIndex < samples.time.length;
++currentIndex
) {
if (samples.count[currentIndex] > samples.count[hoveredCounter]) {
hoveredCounter = currentIndex;
}
}
} else {
hoveredCounter = bisectionCounter;
}
Expand Down