File tree 2 files changed +28
-1
lines changed 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ var dfltConfig = require('./plot_config');
31
31
* `layout.template` in another figure.
32
32
*/
33
33
exports . makeTemplate = function ( figure ) {
34
- figure = Lib . extendDeep ( { _context : dfltConfig } , figure ) ;
34
+ figure = Lib . extendDeep ( { _context : dfltConfig } , { data : figure . data , layout : figure . layout } ) ;
35
35
Plots . supplyDefaults ( figure ) ;
36
36
var data = figure . data || [ ] ;
37
37
var layout = figure . layout || { } ;
Original file line number Diff line number Diff line change @@ -141,6 +141,33 @@ describe('makeTemplate', function() {
141
141
142
142
expect ( template ) . toEqual ( expected ) ;
143
143
} ) ;
144
+
145
+ it ( 'works on DOM element' , function ( done ) {
146
+ var mock = Lib . extendDeep ( { } , scatterFillMock ) ;
147
+ var gd = createGraphDiv ( ) ;
148
+
149
+ Plotly . newPlot ( gd , mock )
150
+ . then ( function ( ) {
151
+ var template = Plotly . makeTemplate ( gd ) ;
152
+ delete ( template . layout . xaxis ) ;
153
+ delete ( template . layout . yaxis ) ;
154
+ expect ( template ) . toEqual ( {
155
+ data : { scatter : [
156
+ { fill : 'tonext' , line : { shape : 'spline' } } ,
157
+ { fill : 'tonext' } ,
158
+ { fill : 'toself' }
159
+ ] } ,
160
+ layout : {
161
+ title : 'Fill toself and tonext' ,
162
+ width : 400 ,
163
+ height : 400
164
+ }
165
+ } ) ;
166
+ } )
167
+ . catch ( failTest )
168
+ . then ( destroyGraphDiv )
169
+ . then ( done ) ;
170
+ } ) ;
144
171
} ) ;
145
172
146
173
// statics of template application are all covered by the template mock
You can’t perform that action at this time.
0 commit comments