The purpose of this markdown document is to document exploration of how to best attach the Plotly.Snapshot.toImage
function to the plot/div
itself most fully discussed in issue 83. Another very nice ability would be to offer resize options for the snapshot.
Where do we attach toImage on the graph div?
Is it _toImage?
Do we just require /snapshot and bind to this
?
Will any of the chart types require special snapshot abilities or features?
What is the expected use case of our new ability?
How do we piggyback on the snapshot button in the toolbar?
How do we ask for new size?
Are there reference points from other libraries that we could mimic or learn from?
-
Plotly.Snapshot.clone
could be used to resize by adding this tooptions
when/if we usePlotly.plot
with our cloneddiv
. We could also dynamically show a resulting view in a modal or something similar and adjust withPlotly.relayout
. -
Plotly.Snapshot.clone
by default setsstaticPlot:true
inconfig
. -
A very basic way to attach this assuming there is a modebar would be to do something like this. See codepen.
gd._toImage = function(){
this._fullLayout._modeBar.buttons.filter(
function(btn){return btn[0].name==="toImage"
})[0][0].click(this)
}
-
Plotly.Snapshot.clone
already has thumbnail ability by specifying options tileClass:"thumbnail" for the specific thumbnail use case. -
Quick code to experiment from R
library(plotly)
ggplotly(ggplot(cars,aes(speed,dist))+geom_point())