@@ -26,13 +26,6 @@ var Polar = require('../plots/polar');
2626var Color = require ( '../components/color' ) ;
2727var Drawing = require ( '../components/drawing' ) ;
2828var 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' ) ;
3629var Titles = require ( '../components/titles' ) ;
3730var ModeBar = require ( '../components/modebar' ) ;
3831var xmlnsNamespaces = require ( '../constants/xmlns_namespaces' ) ;
@@ -183,9 +176,9 @@ Plotly.plot = function(gd, data, layout, config) {
183176 var calcdata = gd . calcdata ;
184177 var i , cd , trace ;
185178
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 ) ;
189182
190183 for ( i = 0 ; i < calcdata . length ; i ++ ) {
191184 cd = calcdata [ i ] ;
@@ -234,8 +227,8 @@ Plotly.plot = function(gd, data, layout, config) {
234227
235228 // TODO: autosize extra for text markers
236229 return Lib . syncOrAsync ( [
237- Shapes . calcAutorange ,
238- Annotations . calcAutorange ,
230+ Registry . getComponentMethod ( 'shapes' , ' calcAutorange' ) ,
231+ Registry . getComponentMethod ( 'annotations' , ' calcAutorange' ) ,
239232 doAutoRange
240233 ] , gd ) ;
241234 }
@@ -287,8 +280,8 @@ Plotly.plot = function(gd, data, layout, config) {
287280 Plots . style ( gd ) ;
288281
289282 // show annotations and shapes
290- Shapes . draw ( gd ) ;
291- Annotations . draw ( gd ) ;
283+ Registry . getComponentMethod ( 'shapes' , ' draw' ) ( gd ) ;
284+ Registry . getComponentMethod ( 'annoations' , ' draw' ) ( gd ) ;
292285
293286 // source links
294287 Plots . addLinks ( gd ) ;
@@ -303,13 +296,13 @@ Plotly.plot = function(gd, data, layout, config) {
303296 // correctly sized and the whole plot re-margined. gd._replotting must
304297 // be set to false before these will work properly.
305298 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 ) ;
313306 }
314307
315308 function cleanUp ( ) {
@@ -2007,8 +2000,10 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
20072000 arraysToCalcdata = ( ( ( cdi [ 0 ] || { } ) . trace || { } ) . _module || { } ) . arraysToCalcdata ;
20082001 if ( arraysToCalcdata ) arraysToCalcdata ( cdi ) ;
20092002 }
2003+
20102004 Plots . style ( gd ) ;
2011- Legend . draw ( gd ) ;
2005+ Registry . getComponentMethod ( 'legend' , 'draw' ) ( gd ) ;
2006+
20122007 return Plots . previousPromises ( gd ) ;
20132008 } ) ;
20142009 }
@@ -2285,8 +2280,8 @@ Plotly.relayout = function relayout(gd, astr, val) {
22852280 var objNum = p . parts [ 1 ] ,
22862281 objType = p . parts [ 0 ] ,
22872282 objList = layout [ objType ] || [ ] ,
2288- objModule = Plotly [ Lib . titleCase ( objType ) ] ,
22892283 obji = objList [ objNum ] || { } ;
2284+
22902285 // if p.parts is just an annotation number, and val is either
22912286 // 'add' or an entire annotation to add, the undo is 'remove'
22922287 // if val is 'remove' then undo is the whole annotation object
@@ -2303,21 +2298,25 @@ Plotly.relayout = function relayout(gd, astr, val) {
23032298 }
23042299 else Lib . log ( '???' , aobj ) ;
23052300 }
2301+
23062302 if ( ( refAutorange ( obji , 'x' ) || refAutorange ( obji , 'y' ) ) &&
23072303 ! Lib . containsAny ( ai , [ 'color' , 'opacity' , 'align' , 'dash' ] ) ) {
23082304 docalc = true ;
23092305 }
2306+
23102307 // TODO: combine all edits to a given annotation / shape into one call
23112308 // 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 ] ) ;
23132312 delete aobj [ ai ] ;
23142313 }
23152314 else if ( p . parts [ 0 ] === 'images' ) {
23162315 var update = Lib . objectFromPath ( ai , vi ) ;
23172316 Lib . extendDeepAll ( gd . layout , update ) ;
23182317
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 ) ;
23212320 }
23222321 else if ( p . parts [ 0 ] === 'mapbox' && p . parts [ 1 ] === 'layers' ) {
23232322 Lib . extendDeepAll ( gd . layout , Lib . objectFromPath ( ai , vi ) ) ;
@@ -2429,7 +2428,7 @@ Plotly.relayout = function relayout(gd, astr, val) {
24292428
24302429 if ( dolegend ) {
24312430 seq . push ( function doLegend ( ) {
2432- Legend . draw ( gd ) ;
2431+ Registry . getComponentMethod ( 'legend' , ' draw' ) ( gd ) ;
24332432 return Plots . previousPromises ( gd ) ;
24342433 } ) ;
24352434 }
0 commit comments