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

Feature Request #2802 #2837

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

justinzhu17
Copy link

@justinzhu17 justinzhu17 commented Apr 22, 2024

Attempt to implement feature request #2802

Start with a description of this PR. Then edit the list below to the items that make sense for your PR scope, and check off the boxes as you go!

Contributor Checklist

  • I have broken down my PR scope into the following TODO tasks
    • Implement a way to delete data from heatmaps within Patch()
    • Create local tests to check for bugs
  • I have run the tests locally and they passed. (refer to testing section in contributing)
  • I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR

optionals

  • I have added entry in the CHANGELOG.md
  • If this PR needs a follow-up in dash docs, community thread, I have mentioned the relevant URLS as follows
    • this GitHub #PR number updates the dash docs
    • here is the show and tell thread in Plotly Dash community

Attempt to implement feature request plotly#2802
@T4rk1n
Copy link
Contributor

T4rk1n commented May 28, 2024

For #2802 we need something that will handle not knowing the length of the array to be patched.
The implementation would be on the frontend I think in this function you would have to get all the paths if you encounter a marked case.

function getLocationPath(location: LocationIndex[], obj: any) {
const current = [];
for (let i = 0; i < location.length; i++) {
const value = getLocationIndex(location[i], path(current, obj));
current.push(value);
}
return current;
}

Then on the Python side there would be an object representing FOREACH operations of an array

class _ForEach:
    def to_plotly_json():
        return {"_dash_patch_index": "FOREACH"}

# singleton then imported in dash for easy access.
FOREACH = _ForEach()

Then you would use in callback like this:

from dash import Dash, Input, html, Patch, FOREACH

def callback(_):
    fig = Patch()
    del fig['data'][0]['z'][FOREACH][0]
    return p

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 this pull request may close these issues.

Delete Data from Heat Figs with Patch() [Feature Request]
2 participants