Skip to content

Commit fb52fe7

Browse files
add some starter code to a _toImage attached to the div leveraging the snapshot button
1 parent 89e05ce commit fb52fe7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

snapshot.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Where do we attach toImage on the graph div?
1010
Is it _toImage?
1111
Do we just require /snapshot and bind to `this`?
1212

13+
Will any of the chart types require special snapshot abilities or features?
14+
1315
What is the expected use case of our new ability?
1416

1517
How do we piggyback on the snapshot button in the toolbar?
@@ -25,4 +27,16 @@ Are there reference points from other libraries that we could mimic or learn fro
2527

2628
`Plotly.Snapshot.clone` could be used to resize by adding this to `options` when/if we use `Plotly.plot` with our cloned `div`. We could also dynamically show a resulting view in a modal or something similar and adjust with `Plotly.relayout`.
2729

28-
`Plotly.Snapshot.clone` by default sets `staticPlot:true` in `config`.
30+
`Plotly.Snapshot.clone` by default sets `staticPlot:true` in `config`.
31+
32+
A very basic way to attach this assuming there is a modebar would be to do something like this.
33+
34+
```
35+
gd._toImage = function(){this._fullLayout._modeBar.buttons.filter(function(btn){return btn[0].name==="toImage"})[0][0].click(this)}
36+
```
37+
38+
```
39+
library(plotly)
40+
41+
ggplotly(ggplot(cars,aes(speed,dist))+geom_point())
42+
```

0 commit comments

Comments
 (0)