Skip to content

drop_callback not working for 2nd and more axis since version 2.0.0 (working with 1.10.1) #2499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
GermainHebertABB opened this issue Apr 9, 2025 · 3 comments
Labels
state: pending not addressed yet type: bug bug

Comments

@GermainHebertABB
Copy link

Version of Dear PyGui

Version: 2.0.0
Operating System: Windows 11

My Issue/Question

When using multiple axis on a plot. The drop_callback is not working for 2nd and more axis since version 2.0.0 (working with 1.10.1)

To Reproduce

Simply put two axis with callback, drag an item into it. The 2nd axis isn't going yellow and no callback are call.

Expected behavior

Same script was working well with drop back with 1.10.1

Screenshots/Video

Standalone, minimal, complete and verifiable example

        def new_axis_drop_callback(y: str):
            def _callback(_s, app_data, _u):
                dpg.add_text('new axis', indent=10, parent="Console")
                ds: DataTable = app_data["dragged_data"]
                if dpg.does_item_exist(ds.formatted_key):
                    return

                if ds in {TimeseriesDataTables.FRINGE_EDGES}:
                    add_stem_series(ds, y)
                else:
                    add_line_series(ds, y)

            return _callback

        with dpg.plot(
            drop_callback=plot_drop, payload_type="plotting", width=-1, height=-1, tag="log view",
        ):
            dpg.add_plot_legend(payload_type="plotting")
            dpg.add_plot_axis(dpg.mvXAxis, tag="x_axis", label="t")
            dpg.add_plot_axis(
                dpg.mvYAxis,
                tag="y1_axis",
                label="y1",
                drop_callback=new_axis_drop_callback("y1_axis"),
                payload_type="plotting",
            )
            dpg.add_plot_axis(
                dpg.mvYAxis,
                tag="y2_axis",
                label="y2",
                drop_callback=new_axis_drop_callback("y2_axis"),
                payload_type="plotting",
            )
            dpg.add_plot_axis(
                dpg.mvYAxis,
                tag="y3_axis",
                label="y3",
                drop_callback=new_axis_drop_callback("y3_axis"),
                payload_type="plotting",
            )
@GermainHebertABB GermainHebertABB added state: pending not addressed yet type: bug bug labels Apr 9, 2025
@nvglucifer
Copy link
Contributor

You need to change these 3 to another string:
"y1_axis", "y2_axis", "y3_axis"

because the terminal says: Message: Alias already exists.
If drop_callback still not working, can you provide a short/reproducible example?

@nvglucifer
Copy link
Contributor

My bad about those string, I might forget to rename it - duplicate.

yes, The 2nd axis isn't going yellow and no callback are call.
because of some related issue (#2409, #2459, #2387, #2502).

I see it worked by modifying mvPlotting.cpp line#513 - #2502.

@nvglucifer
Copy link
Contributor

import dearpygui.dearpygui as dpg

dpg.create_context()

with dpg.window(width=500, height=500):

    def new_axis_drop_callback(y:str):
        def _callback(sender, app_data, user_data):
            try:  # parent - y or sender
                dpg.add_line_series([0, 1, 2, 3, 4], [4, 0, 3, 0, 4], parent=y, label=f"line_series: {y}")
            except Exception as e:
                print(f"{y} drop target not accepted")
            finally:
                pass # print(app_data)
        return _callback

    with dpg.plot(width=-1, height=-30, label="test"):
        dpg.add_plot_legend(payload_type="plotting",
                            drop_callback=new_axis_drop_callback("legend"))
        
        dpg.add_plot_axis(dpg.mvXAxis, tag="x_axis", label="t")

        dpg.add_plot_axis(
            dpg.mvYAxis,
            tag="y1_axis",
            label="y1",
            drop_callback=new_axis_drop_callback("y1_axis"),
            payload_type="plotting",
        )

        dpg.add_plot_axis(
            dpg.mvYAxis,
            tag="y2_axis",
            label="y2",
            drop_callback=new_axis_drop_callback("y2_axis"),
            payload_type="plotting",
        )

        dpg.add_plot_axis(
            dpg.mvYAxis,
            tag="y3_axis",
            label="y3",
            drop_callback=new_axis_drop_callback("y3_axis"),
            payload_type="plotting",
        )

    dpg.add_button(label=">> drag me")
    with dpg.drag_payload(parent=dpg.last_item(), payload_type="plotting", drag_data="button ?"):
        dpg.add_text("dragging")

dpg.create_viewport()
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: pending not addressed yet type: bug bug
Projects
None yet
Development

No branches or pull requests

3 participants
@nvglucifer @GermainHebertABB and others