@@ -26,13 +26,6 @@ var Polar = require('../plots/polar');
26
26
var Color = require ( '../components/color' ) ;
27
27
var Drawing = require ( '../components/drawing' ) ;
28
28
var ErrorBars = require ( '../components/errorbars' ) ;
29
- var Annotations = require ( '../components/annotations' ) ;
30
- var Images = require ( '../components/images' ) ;
31
- var Legend = require ( '../components/legend' ) ;
32
- var RangeSlider = require ( '../components/rangeslider' ) ;
33
- var RangeSelector = require ( '../components/rangeselector' ) ;
34
- var UpdateMenus = require ( '../components/updatemenus' ) ;
35
- var Shapes = require ( '../components/shapes' ) ;
36
29
var Titles = require ( '../components/titles' ) ;
37
30
var ModeBar = require ( '../components/modebar' ) ;
38
31
var xmlnsNamespaces = require ( '../constants/xmlns_namespaces' ) ;
@@ -183,9 +176,9 @@ Plotly.plot = function(gd, data, layout, config) {
183
176
var calcdata = gd . calcdata ;
184
177
var i , cd , trace ;
185
178
186
- Legend . draw ( gd ) ;
187
- RangeSelector . draw ( gd ) ;
188
- UpdateMenus . draw ( gd ) ;
179
+ Registry . getComponentMethod ( 'legend' , ' draw' ) ( gd ) ;
180
+ Registry . getComponentMethod ( 'rangeselector' , ' draw' ) ( gd ) ;
181
+ Registry . getComponentMethod ( 'updatemenus' , ' draw' ) ( gd ) ;
189
182
190
183
for ( i = 0 ; i < calcdata . length ; i ++ ) {
191
184
cd = calcdata [ i ] ;
@@ -234,8 +227,8 @@ Plotly.plot = function(gd, data, layout, config) {
234
227
235
228
// TODO: autosize extra for text markers
236
229
return Lib . syncOrAsync ( [
237
- Shapes . calcAutorange ,
238
- Annotations . calcAutorange ,
230
+ Registry . getComponentMethod ( 'shapes' , ' calcAutorange' ) ,
231
+ Registry . getComponentMethod ( 'annotations' , ' calcAutorange' ) ,
239
232
doAutoRange
240
233
] , gd ) ;
241
234
}
@@ -287,8 +280,8 @@ Plotly.plot = function(gd, data, layout, config) {
287
280
Plots . style ( gd ) ;
288
281
289
282
// show annotations and shapes
290
- Shapes . draw ( gd ) ;
291
- Annotations . draw ( gd ) ;
283
+ Registry . getComponentMethod ( 'shapes' , ' draw' ) ( gd ) ;
284
+ Registry . getComponentMethod ( 'annoations' , ' draw' ) ( gd ) ;
292
285
293
286
// source links
294
287
Plots . addLinks ( gd ) ;
@@ -303,13 +296,13 @@ Plotly.plot = function(gd, data, layout, config) {
303
296
// correctly sized and the whole plot re-margined. gd._replotting must
304
297
// be set to false before these will work properly.
305
298
function finalDraw ( ) {
306
- Shapes . draw ( gd ) ;
307
- Images . draw ( gd ) ;
308
- Annotations . draw ( gd ) ;
309
- Legend . draw ( gd ) ;
310
- RangeSlider . draw ( gd ) ;
311
- RangeSelector . draw ( gd ) ;
312
- UpdateMenus . draw ( gd ) ;
299
+ Registry . getComponentMethod ( 'shapes' , ' draw' ) ( gd ) ;
300
+ Registry . getComponentMethod ( 'images' , ' draw' ) ( gd ) ;
301
+ Registry . getComponentMethod ( 'annotations' , ' draw' ) ( gd ) ;
302
+ Registry . getComponentMethod ( 'legend' , ' draw' ) ( gd ) ;
303
+ Registry . getComponentMethod ( 'rangeslider' , ' draw' ) ( gd ) ;
304
+ Registry . getComponentMethod ( 'rangeselector' , ' draw' ) ( gd ) ;
305
+ Registry . getComponentMethod ( 'updatemenus' , ' draw' ) ( gd ) ;
313
306
}
314
307
315
308
function cleanUp ( ) {
@@ -2007,8 +2000,10 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
2007
2000
arraysToCalcdata = ( ( ( cdi [ 0 ] || { } ) . trace || { } ) . _module || { } ) . arraysToCalcdata ;
2008
2001
if ( arraysToCalcdata ) arraysToCalcdata ( cdi ) ;
2009
2002
}
2003
+
2010
2004
Plots . style ( gd ) ;
2011
- Legend . draw ( gd ) ;
2005
+ Registry . getComponentMethod ( 'legend' , 'draw' ) ( gd ) ;
2006
+
2012
2007
return Plots . previousPromises ( gd ) ;
2013
2008
} ) ;
2014
2009
}
@@ -2285,8 +2280,8 @@ Plotly.relayout = function relayout(gd, astr, val) {
2285
2280
var objNum = p . parts [ 1 ] ,
2286
2281
objType = p . parts [ 0 ] ,
2287
2282
objList = layout [ objType ] || [ ] ,
2288
- objModule = Plotly [ Lib . titleCase ( objType ) ] ,
2289
2283
obji = objList [ objNum ] || { } ;
2284
+
2290
2285
// if p.parts is just an annotation number, and val is either
2291
2286
// 'add' or an entire annotation to add, the undo is 'remove'
2292
2287
// if val is 'remove' then undo is the whole annotation object
@@ -2303,21 +2298,25 @@ Plotly.relayout = function relayout(gd, astr, val) {
2303
2298
}
2304
2299
else Lib . log ( '???' , aobj ) ;
2305
2300
}
2301
+
2306
2302
if ( ( refAutorange ( obji , 'x' ) || refAutorange ( obji , 'y' ) ) &&
2307
2303
! Lib . containsAny ( ai , [ 'color' , 'opacity' , 'align' , 'dash' ] ) ) {
2308
2304
docalc = true ;
2309
2305
}
2306
+
2310
2307
// TODO: combine all edits to a given annotation / shape into one call
2311
2308
// as it is we get separate calls for x and y (or ax and ay) on move
2312
- objModule . drawOne ( gd , objNum , p . parts . slice ( 2 ) . join ( '.' ) , aobj [ ai ] ) ;
2309
+
2310
+ var drawOne = Registry . getComponentMethod ( objType , 'drawOne' ) ;
2311
+ drawOne ( gd , objNum , p . parts . slice ( 2 ) . join ( '.' ) , aobj [ ai ] ) ;
2313
2312
delete aobj [ ai ] ;
2314
2313
}
2315
2314
else if ( p . parts [ 0 ] === 'images' ) {
2316
2315
var update = Lib . objectFromPath ( ai , vi ) ;
2317
2316
Lib . extendDeepAll ( gd . layout , update ) ;
2318
2317
2319
- Images . supplyLayoutDefaults ( gd . layout , gd . _fullLayout ) ;
2320
- Images . draw ( gd ) ;
2318
+ Registry . getComponentMethod ( 'images' , ' supplyLayoutDefaults' ) ( gd . layout , gd . _fullLayout ) ;
2319
+ Registry . getComponentMethod ( 'images' , ' draw' ) ( gd ) ;
2321
2320
}
2322
2321
else if ( p . parts [ 0 ] === 'mapbox' && p . parts [ 1 ] === 'layers' ) {
2323
2322
Lib . extendDeepAll ( gd . layout , Lib . objectFromPath ( ai , vi ) ) ;
@@ -2429,7 +2428,7 @@ Plotly.relayout = function relayout(gd, astr, val) {
2429
2428
2430
2429
if ( dolegend ) {
2431
2430
seq . push ( function doLegend ( ) {
2432
- Legend . draw ( gd ) ;
2431
+ Registry . getComponentMethod ( 'legend' , ' draw' ) ( gd ) ;
2433
2432
return Plots . previousPromises ( gd ) ;
2434
2433
} ) ;
2435
2434
}
0 commit comments