Comments (4)
Interesting request. Thanks for sharing the code, @Voltini
So, if we had this capability, once we set color=np.random.choice(["a", "b"], N)
, and you clicked on point 'b', the result you'd expect would be: 'marker.color': 'b'
?
from dash.
Hi Adam. Exactly, that's what I was thinking!
from dash.
Thank you for this feature request, @Voltini .
Can you please share a MRE with the scatter plots you mention?
from dash.
Sure, take for example the following code:
from dash import Dash, html, dcc, Input, Output
import plotly.express as px
import numpy as np
app = Dash(__name__)
N = 10
app.layout = html.Div(
[
html.Div(
children=[
dcc.Graph(
figure=px.scatter(
x=np.random.random(N),
y=np.random.random(N),
color=np.random.choice(["a", "b"], N),
),
id="plot",
)
],
),
html.Div(id="example", children="Hello World"),
],
)
@app.callback(Output("example", "children"), Input("plot", "clickData"))
def call(clickdata):
return str(clickdata)
if __name__ == "__main__":
app.run(debug=True)
When I click on a point I get:
{'points': [{'curveNumber': 0, 'pointNumber': 3, 'pointIndex': 3, 'x': 0.23940095437991715, 'y': 0.3631388501979541, 'bbox': {'x0': 605.27, 'x1': 611.27, 'y0': 260.14, 'y1': 266.14}}]}
However, if I change the color parameter in my plot to color=np.random.random(N)
I get:
{'points': [{'curveNumber': 0, 'pointNumber': 4, 'pointIndex': 4, 'x': 0.11509044553896275, 'y': 0.41656166816663565, 'marker.color': 0.39641498810036235, 'bbox': {'x0': 329.76, 'x1': 335.76, 'y0': 270.62, 'y1': 276.62}}]}
As you can see now I have a marker.color
attribute that was not present when my data was categorical.
Edit: Also it seems that the frontend already has access to the desired infromation, I don't know if this comment helps.
from dash.
Related Issues (20)
- [Feature Request] Get current active / clicked shape from plotly figure HOT 2
- Validate url to prevent XSS attacks HOT 4
- [MAINTENANCE] Improve react-docgen usage
- [BUG] dcc.Dropdown value does not update when an option is removed (regression from #1868)
- [Feature Request] Python 3.12 support HOT 1
- [Feature Request] Virtual WebGL support HOT 2
- [BUG] `dcc.Graph` inserts phantom rectangular shape on callback update seemingly randomly HOT 2
- [Feature Request] `dash.callback` should utilize `functools.wraps` HOT 4
- Dangerous link detected Error in Dash Debug Window after upgrading from 2.14.2 to 2.15.0 HOT 17
- [BUG] Duplicate callback outputs HOT 4
- [Feature Request] Allow background callbacks to run in the same process as the main app
- [Feature Request] Ability to prevent newer background callbacks from cancelling older ones if desired HOT 3
- [BUG] Dropdown options not rendering on the UI even though it is generated HOT 1
- [Feature Request] More documentaion for new dash-auth 2.2.0 package
- [BUG] dcc.Tooltip children isn't clickable even with targetable=True HOT 3
- [BUG] extending a trace in callback using extendData property doesn't work for a figure with multi-level axis HOT 1
- [BUG] Callback will not render new data until a delay is introduced HOT 6
- Dangerous link detected error after upgrading to Dash 2.15.0 HOT 3
- When moving the cursor, it will sometimes get stuck
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dash.