Skip to content
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

Delete Data from Heat Figs with Patch() [Feature Request] #2802

Open
cleaaum opened this issue Mar 18, 2024 · 4 comments · May be fixed by #2837
Open

Delete Data from Heat Figs with Patch() [Feature Request] #2802

cleaaum opened this issue Mar 18, 2024 · 4 comments · May be fixed by #2837

Comments

@cleaaum
Copy link

cleaaum commented Mar 18, 2024

I am trying to delete some data from a heat fig, and it doesn't seem to be possible with patch. With patch, you would return something like

fig = Patch()
del fig['data'][0][x][0]

to delete the first item in the heatfig. The issue is that the heatfig has the following structure:

{ "data": [
    {
      "x": ["2021-12-21T19:58:00.542000", "2021-12-21T19:58:01.542000", "2021-12-21T19:58:02.542000" ],
      "y": [13500.0, 13503.33591, 13506.67183 ],
      "z": [[599.8054, 581.1404, 570.4771 ],
              [678.9323, 644.2858, 610.9979 ],
              [576.6772, 568.9164, 565.6251 ],
    }]}

and so you would need to loop through each list in the z field to remove the first item as well (as the heatfig is a 3D array). We can't know ahead of time how many items are in the z field making it impossible to delete data.

Basically, if you want to remove the first timestamp in the fig, you would need the data to look like:

{ "data": [
    {
      "x": ["2021-12-21T19:58:01.542000", "2021-12-21T19:58:02.542000" ],
      "y": [13500.0, 13503.33591, 13506.67183 ],
      "z": [[581.1404, 570.4771 ],
              [644.2858, 610.9979 ],
              [568.9164, 565.6251 ],
    }]}

I don't want to load in the whole fig as state because it is quite large (and defeats the purpose of using a Patch()).
I haven't found a work around for this yet.

@alexcjohnson
Copy link
Contributor

Short-term I'd suggest trying to do this with a client-side callback.

I recall us discussing this situation when we were designing the feature in the first place, and not coming up with a good syntax, since what you're suggesting doesn't have a simple Python analog - if you were modifying the real object rather than a Patch proxy, you'd do something like:

for row in fig['data'][0]['z']:
    del row[0]

but we can't iterate over something we don't have, so the only route I could think of would be some new syntax like:

del fig['data'][0]['z'][dash.FOREACH][0]

@justinzhu17
Copy link

Hey, I'm looking to make my first contribution to an open source project and am looking to make this feature my first contribution.

I want to ensure that I'm following the correct procedures as I go through this process. Is there a general protocol to how one contributes to this project?

Thank you.

@Coding-with-Adam
Copy link

hi @justinzhu17
Thank you for your interest in making your first contribution to Dash. Can you please email me. I need a little more info before I can guide you through the process.

my email: adam@plot.ly

@justinzhu17
Copy link

hey @Coding-with-Adam
I've just sent you an email. Thank you so much for reaching out!

justinzhu17 added a commit to justinzhu17/dash that referenced this issue Apr 22, 2024
Attempt to implement feature request plotly#2802
justinzhu17 added a commit to justinzhu17/dash that referenced this issue Apr 22, 2024
@justinzhu17 justinzhu17 linked a pull request Apr 22, 2024 that will close this issue
9 tasks
@ndrezn ndrezn linked a pull request Apr 22, 2024 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants