Skip to content

Commit

Permalink
fix: offset added hinders the timestamps for the traces
Browse files Browse the repository at this point in the history
  • Loading branch information
vikrantgupta25 committed Mar 4, 2024
1 parent b736a1a commit 445d6e0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions frontend/src/lib/uPlotLib/plugins/onClickPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ function onClickPlugin(opts: OnClickPluginOpts): uPlot.Plugin {
init: (u: uPlot) => {
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
handleClick = function (event: MouseEvent) {
const mouseX = event.offsetX;
const mouseY = event.offsetY;
const mouseX = event.offsetX + 40;
const mouseY = event.offsetY + 40;

// Convert pixel positions to data values
const xValue = u.posToVal(mouseX, 'x');
const yValue = u.posToVal(mouseY, 'y');
// do not use mouseX and mouseY here as it offsets the timestamp as well
const xValue = u.posToVal(event.offsetX, 'x');
const yValue = u.posToVal(event.offsetY, 'y');

opts.onClick(xValue, yValue, mouseX, mouseY);
};
Expand Down

0 comments on commit 445d6e0

Please sign in to comment.