DearPyGui icon indicating copy to clipboard operation
DearPyGui copied to clipboard

Inaccurate time values returned from get_mouse_plot_pos()

Open surelyitsanton opened this issue 1 year ago • 2 comments

Version of Dear PyGui

Version: 1.11.1 Operating System: Windows 10

My Issue/Question

When setting a plot's x-axis to time, the function dpg.get_plot_mouse_pos() returns an x value in increments of 128 seconds instead of returning the exact x-value of the mouse position to the nearest second. For example the seconds returned from this function jump between 1658792320 and 1658792448 instead of returning any of the values in between. The precision of the dpg.get_plot_mouse_pos() return value is brought up here, however that issue is regarding the lack of decimal points in the number of seconds returned.

To Reproduce

Steps to reproduce the behavior:

  1. Run the code below.
  2. Move the mouse pointer horizontally over the graph area between the two plotted points
  3. Watch the coordinates in the command line output (the x-coordinate jumps between 1658792320 and 1658792448 instead of showing any of the values in between)

Expected behavior

We should see the x-coordinate change by 1 as we slowly move the mouse horizontally across the plot

Standalone, minimal, complete and verifiable example

import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport()
dpg.setup_dearpygui()

def mouse_move_callback():
    print(dpg.get_plot_mouse_pos())

with dpg.handler_registry():
    dpg.add_mouse_move_handler(callback=mouse_move_callback)

with dpg.window(tag="Primary"):
    with dpg.plot(height=-1, width=-1):
        dpg.add_plot_axis(dpg.mvXAxis, time=True)
        with dpg.plot_axis(dpg.mvYAxis):
            dpg.add_scatter_series([1658792320, 1658792467], [0, 1])

dpg.show_viewport()
dpg.set_primary_window("Primary", True)
dpg.start_dearpygui()
dpg.destroy_context()

surelyitsanton avatar Jul 15 '24 01:07 surelyitsanton

Probably caused by the same precision loss on 32-bit floats. See this comment for details: https://github.com/hoffstadt/DearPyGui/issues/2157#issuecomment-1679572308

v-ein avatar Jul 15 '24 18:07 v-ein

Hey, any updates on getting this implimented?

khazaddim avatar Jan 03 '25 03:01 khazaddim