dash icon indicating copy to clipboard operation
dash copied to clipboard

allow deletion of data from Heat Figs with Patch()

Open cleaaum opened this issue 1 year ago • 4 comments

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.

cleaaum avatar Mar 18 '24 19:03 cleaaum

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]

alexcjohnson avatar Mar 18 '24 22:03 alexcjohnson

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.

justinzhu17 avatar Apr 08 '24 03:04 justinzhu17

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: [email protected]

Coding-with-Adam avatar Apr 09 '24 17:04 Coding-with-Adam

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

justinzhu17 avatar Apr 17 '24 22:04 justinzhu17