You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From a recent community post, I learned that the January release will probably support a brushing feature, which is great.
I think it would be really useful if you'd expose more events, such as double-click, as this would allow us to better control the desired functionality.
Adding more events is definitely on our roadmap. The only things blocking us at the moment, is the fact that each plotly.js plot type (cartesian, geo, gl, ...) has its own event emitting internals.
Some work should be dedicated to generalizing our internals before exposing more events.
I second @mmek123 comments: we currently want to reload data based on zoom-events but not when relayouting. At the moment, we can't distinguish whether the relayout was caused by an actual zoom-in or simply the user changing the size of the browser window (which will cause a relayout as the plot is responsive).
It is desirable for my container to receive notifications when a user has edited an annotation in an editable graph by moving, rotating or changing length [using a new plotly_editannotation event]
It would be great to expose the original event along with the data in Plotly events.
One practical example would be to know if the user was pressing any special keys when clicking and act accordingly, like add to a selection.
var acummulate = originalEvent.altKey || originalEvent.ctrlKey || originalEvent.shiftKey || originalEvent.metaKey
Also it would be useful to be able to click on the background of the chart and get the coordinates, in order to create more points in an interactive way.
Reacted by Tom von Clef, David Estrada, Arnaud, Cajado, jpskin, Pierre-Bartet, Jessica Peters, Andrea, ngreco and Pablo Vega-Behar
It would be super useful to have the computed tooltip positioning information provided to the hover callback. It would help a lot with rendering our own custom tooltips.
Sounds logical to me to have two distinct events here. I think maybe the names can be confusing, since "doubleclick" sounds general and "deselect" is specific, while they are actually both on the same level (im not sure if i am clear here haha).
But i admit that i have no idea for renaming the event. Maybe unzoom or resetplot but i don't think that this will englobe all the use cases of the event. I guess just mentionning it in the doc should be enough for the users.
I'm working on a SCATTERPLOT and adding some user interactions.
'plotly_click' is only called when a user clicks a point
plotly_selected' is also called when a user clicks either a blank area of the plot OR when a user clicks a point (but returns an empty data obj)
I feel like it makes more sense to call 'plotly_click' no matter where you click on the chart, return data if a point is clicked, but return empty data if no points are clicked.
I'm asking for this feature for some interactions on my scatterplot.
For example:
If a user clicks a point, color the point 'red'
easy, since I can use the data.points[0] to find which marker to color
If a user clicks an empty part of the chart, reset the 'selected' points and color it back to original color.
I can use 'if data == undefined' then color all points back to original color', but problem is data == undefined if I click a point, or click an empty place in chart...'plotly_click' is never called here
To expose more reliable p2c functionality, I wrote:
What I think we should do: is add another plotly_ event (e.g. plotly_mouse) that would get fired on anytime you mouse over a graph with or without triggering plotly_hover.
I gather that there’s currently no way to detect overall mouse down and mouse up events, which are important for being able to pause incremental graphing and a synchronous animation during the time that the mouse button is down. Is that a future possibility?
Please also expose some "before" edit events, especially when editing text (annotations, legends, titles etc). I would like to be able to let users edit placeholder text or select from a list of template strings to be inserted instead of just editing text. In this case I need to change the text being edited before edit mode is activated (and replace it again when edit mode is closed).
Thanks!
I want to plot a server generated histogram in a bar plot that is getting more refined when the user zooms in by updating the data object. Unfortunately I run into an endless loop, because using the update event as a trigger for loading a new refinement (based on new x-min and x-max) does fire everytime the plot is drawn with new data.
I don't see any way right now to avoid the endless loop without a dedicated zoom event. Is there anything happening? Is there something I could provide?
@ccssmnn can you hold onto the range from the previous call, and abort the request for new data if the range hasn't actually changed? Something like this is what's typically done.
I have prepared a Sandbox showing what I've got so far. Here is the Sandbox
In case the link is not working properly I will show the code at the bottom if this comment.
The problem with this solution seems to be that the update event is fired several times after a zoom event with different xmin/xmax values. I would expect one call for the zoom and another one that is triggered because the data changes if we zoom enough. But because there are more calls the user does not nessecarily end up at the expected range after zoom.
importReact,{useState,useEffect,useCallback}from"react";import"./styles.css";importPlotfrom"react-plotly.js";functionbinning(nBins,data,xMin,xMax){constlower=xMin===undefined ? Math.min(...data) : xMin;constupper=xMax===undefined ? Math.max(...data) : xMax;constcount=newArray(nBins).fill(0);data.forEach((value)=>{if(value>=lower&&value<=upper){constbin=Math.floor((Math.abs(value-lower)*nBins)/Math.abs(upper-lower));count[bin]=count[bin]+1;}});constbinMean=newArray(nBins).fill(0);binMean.forEach((_,i)=>{binMean[i]=lower+(i*(upper-lower))/nBins;});constbinWidth=Math.abs(upper-lower)/nBins;return[count,binMean,binWidth];}functionrandomNormal(){const[u,v]=[1-Math.random(),1-Math.random()];returnMath.sqrt(-2.0*Math.log(u))*Math.cos(2.0*Math.PI*v);}exportdefaultfunctionApp(){const[data,setData]=useState([]);const[loading,setLoading]=useState(false);constrequestData=useCallback(async()=>{setLoading(true);constarr=[];for(leti=0;i<200;i++){arr.push(randomNormal());}console.log(arr);setDataArr(arr);setLoading(false);},[]);const[layout,setLayout]=useState({autosize: true});const[dataArr,setDataArr]=useState([]);const[xMin,setXMin]=useState(undefined);const[xMax,setXMax]=useState(undefined);useEffect(()=>{const[count,mean,width]=binning(50,dataArr,xMin,xMax);setData([{x: mean,y: count,width: newArray(count.length).fill(width),type: "bar"}]);setLayout({autosize: true,xaxis: {range: [xMin,xMax]}});},[dataArr,xMin,xMax]);return(<divclassName="App"><h1>Plot Updating on Zoom</h1><buttononClick={requestData}>{loading ? "Loading..." : "Request Data"}</button><Plotdata={data}layout={layout}useResizeHandlerstyle={{width: "100%",height: "100%"}}onDoubleClick={()=>{setXMin(undefined);setXMax(undefined);}}onUpdate={(figure)=>{console.log(`onUpdate: - old Xmin ${xMin} - old Xmax ${xMax} - new Xmin ${figure.layout.xaxis?.range?.[0]} - new Xmax ${figure.layout.xaxis?.range?.[1]} `);constnewXMax=figure.layout.xaxis?.range?.[1];constnewXMin=figure.layout.xaxis?.range?.[0];if(newXMax===undefined||newXMin===undefined)return;if(xMax===undefined||xMin===undefined){setXMax(newXMax);setXMin(newXMin);return;}constoverlap=Math.max(0,Math.abs(Math.min(newXMax,xMax)-Math.max(newXMin,xMin)));constcurrentRange=Math.abs(xMax-xMin);constnewRange=Math.abs(newXMax-newXMin);if(overlap/currentRange<0.7||overlap/newRange<0.7){setXMax(newXMax);setXMin(newXMin);}}}/></div>);}
A community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort.
Sponsorship range: $15k-$20k
What Sponsorship includes:
Completion of this feature to the Sponsor's satisfaction, in a manner coherent with the rest of the Plotly.js library and API
Tests for this feature
Long-term support (continued support of this feature in the latest version of Plotly.js)
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson
Activity
etpinard commentedon Dec 29, 2015
@aderidder thanks again for the suggestion.
Adding more events is definitely on our roadmap. The only things blocking us at the moment, is the fact that each plotly.js plot type (cartesian, geo, gl, ...) has its own event emitting internals.
Some work should be dedicated to generalizing our internals before exposing more events.
etpinard commentedon Feb 16, 2016
@ifll please comment here if you any suggestions about other potential plotly.js events. Thank you.
ifll commentedon Feb 16, 2016
What about having the "plotly_zommin", "plotly_zoomout", "plotly_pan", etc... events?
This would help a lot to control the user interaction with the plot
Thank you!
mmek123 commentedon Feb 25, 2016
when graph is in edit mode would like to get events like
title Edited, X/Y axis edited , annotations edited
also would highly benefit from having a event when you hover over the extrapolated graph points.. currently its only on data points..
thanks..
On Wed, Feb 17, 2016 at 3:25 AM, ifll notifications@github.com wrote:
czellweg commentedon Mar 14, 2016
I second @mmek123 comments: we currently want to reload data based on zoom-events but not when relayouting. At the moment, we can't distinguish whether the
relayoutwas caused by an actual zoom-in or simply the user changing the size of the browser window (which will cause a relayout as the plot is responsive).We'd love to see the following:
plotly_zoomin,plotly_zoomout,plotly_pan,plotly_scale_x,plotly_scale_yIt would be great if all the available data of the current view port to the plot is made available such as start-x, end-x, start-y, end-y etc.
Can you make a statement about a possible roadmap for this?
etpinard commentedon Jul 6, 2016
From @mdfederici in #722 with PoC in #721
Response in #722 (comment)
etpinard commentedon Jul 28, 2016
From @paneyi in #788
paneyi commentedon Jul 28, 2016
Also it would be useful to be able to click on the background of the chart and get the coordinates, in order to create more points in an interactive way.
etpinard commentedon Jul 28, 2016
@paneyi
You might want to check out http://codepen.io/etpinard/pen/EyydEj
paneyi commentedon Jul 28, 2016
Thank you @etpinard, I already saw that but it wasn't enough. Whenever you zoom, it stops working.
etpinard commentedon Sep 13, 2016
Maybe
relayoutevent data should list the current visible point on the graph as described in http://community.plot.ly/t/get-datapoints-in-currently-zoomed-view/259/etpinard commentedon Sep 14, 2016
From @CalvinFernandez in #935
etpinard commentedon Nov 14, 2016
From @smalesys in #1138 :
etpinard commentedon Mar 14, 2017
From @destradafilm in #1471
etpinard commentedon Apr 3, 2017
From @destradafilm's #1548
To expose more reliable
p2cfunctionality, I wrote:BruceSherwood commentedon Feb 5, 2018
I gather that there’s currently no way to detect overall mouse down and mouse up events, which are important for being able to pause incremental graphing and a synchronous animation during the time that the mouse button is down. Is that a future possibility?
jensb commentedon Feb 7, 2018
Please also expose some "before" edit events, especially when editing text (annotations, legends, titles etc). I would like to be able to let users edit placeholder text or select from a list of template strings to be inserted instead of just editing text. In this case I need to change the text being edited before edit mode is activated (and replace it again when edit mode is closed).
Thanks!
etu29414 commentedon Apr 9, 2018
Hello everyone,
i would like add an event when i click on a trace.
for exemple when i click on a trace, i show an alert “you click on trace X”.
for example:

i would like that if i click on red trace there an alert but not on black point
thanks !
Pierre-Bartet commentedon Mar 18, 2020
Any progress on this ? It's a deal breaker.
carlassmann commentedon Sep 3, 2020
I want to plot a server generated histogram in a bar plot that is getting more refined when the user zooms in by updating the data object. Unfortunately I run into an endless loop, because using the update event as a trigger for loading a new refinement (based on new x-min and x-max) does fire everytime the plot is drawn with new data.
I don't see any way right now to avoid the endless loop without a dedicated zoom event. Is there anything happening? Is there something I could provide?
alexcjohnson commentedon Sep 3, 2020
@ccssmnn can you hold onto the range from the previous call, and abort the request for new data if the range hasn't actually changed? Something like this is what's typically done.
jensb commentedon Sep 3, 2020
This should be doable using uirevision:
https://plotly.com/javascript/uirevision/
carlassmann commentedon Sep 7, 2020
Thank you for the fast replies @alexcjohnson & @jensb
I have prepared a Sandbox showing what I've got so far. Here is the Sandbox
In case the link is not working properly I will show the code at the bottom if this comment.
The problem with this solution seems to be that the update event is fired several times after a zoom event with different xmin/xmax values. I would expect one call for the zoom and another one that is triggered because the data changes if we zoom enough. But because there are more calls the user does not nessecarily end up at the expected range after zoom.
jackparmer commentedon Sep 10, 2020
This issue has been tagged with
NEEDS SPON$ORA community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort.
Sponsorship range: $15k-$20k
What Sponsorship includes:
Please include the link to this issue when contacting us to discuss.
gvwilson commentedon Jun 5, 2024
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson