3
3
// ---external global dependencies
4
4
/* global Promise:false */
5
5
6
-
7
6
var Plotly = require ( './plotly' ) ,
8
7
d3 = require ( 'd3' ) ,
9
8
m4FromQuat = require ( 'gl-mat4/fromQuat' ) ,
@@ -242,7 +241,7 @@ plots.redrawText = function(gd) {
242
241
243
242
function opaqueSetBackground ( gd , bgColor ) {
244
243
gd . _fullLayout . _paperdiv . style ( 'background' , 'white' ) ;
245
- defaultSetBackground ( gd , bgColor ) ;
244
+ Plotly . defaultConfig . setBackground ( gd , bgColor ) ;
246
245
}
247
246
248
247
function setPlotContext ( gd , config ) {
@@ -283,14 +282,20 @@ function setPlotContext(gd, config) {
283
282
}
284
283
}
285
284
286
- // the 'view in plotly' and source links - note that now plot() calls this
287
- // so it can regenerate whenever it replots
285
+ /**
286
+ * Adds the 'Edit chart' link.
287
+ * Note that now Plotly.plot() calls this so it can regenerate whenever it replots
288
+ *
289
+ * Add source links to your graph inside the 'showSources' config argument.
290
+ */
288
291
plots . addLinks = function ( gd ) {
289
292
var fullLayout = gd . _fullLayout ;
290
- var linkContainer = fullLayout . _paper . selectAll ( 'text.js-plot-link-container' ) . data ( [ 0 ] ) ;
293
+
294
+ var linkContainer = fullLayout . _paper
295
+ . selectAll ( 'text.js-plot-link-container' ) . data ( [ 0 ] ) ;
291
296
292
297
linkContainer . enter ( ) . append ( 'text' )
293
- . classed ( 'js-plot-link-container' , true )
298
+ . classed ( 'js-plot-link-container' , true )
294
299
. style ( {
295
300
'font-family' :'"Open Sans",Arial,sans-serif' ,
296
301
'font-size' :'12px' ,
@@ -299,9 +304,9 @@ plots.addLinks = function(gd) {
299
304
} )
300
305
. each ( function ( ) {
301
306
var links = d3 . select ( this ) ;
302
- links . append ( 'tspan' ) . classed ( 'js-link-to-tool' , true ) ;
303
- links . append ( 'tspan' ) . classed ( 'js-link-spacer' , true ) ;
304
- links . append ( 'tspan' ) . classed ( 'js-sourcelinks' , true ) ;
307
+ links . append ( 'tspan' ) . classed ( 'js-link-to-tool' , true ) ;
308
+ links . append ( 'tspan' ) . classed ( 'js-link-spacer' , true ) ;
309
+ links . append ( 'tspan' ) . classed ( 'js-sourcelinks' , true ) ;
305
310
} ) ;
306
311
307
312
// The text node inside svg
@@ -320,24 +325,23 @@ plots.addLinks = function(gd) {
320
325
// Align the text at the left
321
326
attrs [ 'text-anchor' ] = 'start' ;
322
327
attrs . x = 5 ;
323
- } else {
328
+ }
329
+ else {
324
330
// Align the text at the right
325
331
attrs [ 'text-anchor' ] = 'end' ;
326
332
attrs . x = fullLayout . _paper . attr ( 'width' ) - 7 ;
327
333
}
328
334
329
335
linkContainer . attr ( attrs ) ;
330
336
331
-
332
337
var toolspan = linkContainer . select ( '.js-link-to-tool' ) ,
333
338
spacespan = linkContainer . select ( '.js-link-spacer' ) ,
334
339
sourcespan = linkContainer . select ( '.js-sourcelinks' ) ;
335
340
336
- // data source links
337
- Plotly . Lib . showSources ( gd ) ;
341
+ if ( gd . _context . showSources ) gd . _context . showSources ( ) ;
338
342
339
343
// 'view in plotly' link for embedded plots
340
- if ( gd . _context . showLink ) positionPlayWithData ( gd , toolspan ) ;
344
+ if ( gd . _context . showLink ) positionPlayWithData ( gd , toolspan ) ;
341
345
342
346
// separator if we have both sources and tool link
343
347
spacespan . text ( ( toolspan . text ( ) && sourcespan . text ( ) ) ? ' - ' : '' ) ;
0 commit comments