99
1010'use strict' ;
1111
12- var Plotly = require ( '../../plotly' ) ;
1312var d3 = require ( 'd3' ) ;
1413var isNumeric = require ( 'fast-isnumeric' ) ;
1514
16- var plots = Plotly . Plots ;
15+ var Plotly = require ( '../../plotly' ) ;
16+ var Plots = require ( '../../plots/plots' ) ;
17+ var Lib = require ( '../../lib' ) ;
18+ var Drawing = require ( '../drawing' ) ;
19+ var Color = require ( '../color' ) ;
20+ var svgTextUtils = require ( '../../lib/svg_text_utils' ) ;
21+ var axisIds = require ( '../../plots/cartesian/axis_ids' ) ;
22+
1723
1824var Titles = module . exports = { } ;
1925
@@ -38,7 +44,7 @@ Titles.draw = function(gd, title) {
3844 }
3945 } ) ;
4046 }
41- else cont = fullLayout [ Plotly . Axes . id2name ( title . replace ( 'title' , '' ) ) ] || fullLayout ;
47+ else cont = fullLayout [ axisIds . id2name ( title . replace ( 'title' , '' ) ) ] || fullLayout ;
4248
4349 var prop = cont === fullLayout ? 'title' : cont . _name + '.title' ,
4450 name = colorbar ? 'colorscale' :
@@ -92,9 +98,9 @@ Titles.draw = function(gd, title) {
9298 xa = cont ;
9399 ya = ( xa . anchor === 'free' ) ?
94100 { _offset :gs . t + ( 1 - ( xa . position || 0 ) ) * gs . h , _length :0 } :
95- Plotly . Axes . getFromId ( gd , xa . anchor ) ;
96101 x = xa . _offset + xa . _length / 2 ;
97102 y = ya . _offset + ( ( xa . side === 'top' ) ?
103+ axisIds . getFromId ( gd , xa . anchor ) ;
98104 - 10 - fontSize * ( offsetBase + ( xa . showticklabels ? 1 : 0 ) ) :
99105 ya . _length + 10 +
100106 fontSize * ( offsetBase + ( xa . showticklabels ? 1.5 : 0.5 ) ) ) ;
@@ -105,9 +111,9 @@ Titles.draw = function(gd, title) {
105111 ya = cont ;
106112 xa = ( ya . anchor === 'free' ) ?
107113 { _offset :gs . l + ( ya . position || 0 ) * gs . w , _length :0 } :
108- Plotly . Axes . getFromId ( gd , ya . anchor ) ;
109114 y = ya . _offset + ya . _length / 2 ;
110115 x = xa . _offset + ( ( ya . side === 'right' ) ?
116+ axisIds . getFromId ( gd , ya . anchor ) ;
111117 xa . _length + 10 +
112118 fontSize * ( offsetBase + ( ya . showticklabels ? 1 : 0.5 ) ) :
113119 - 10 - fontSize * ( offsetBase + ( ya . showticklabels ? 0.5 : 0 ) ) ) ;
@@ -165,7 +171,7 @@ Titles.draw = function(gd, title) {
165171 . attr ( 'class' , title ) ;
166172
167173 function titleLayout ( titleEl ) {
168- Plotly . Lib . syncOrAsync ( [ drawTitle , scootTitle ] , titleEl ) ;
174+ Lib . syncOrAsync ( [ drawTitle , scootTitle ] , titleEl ) ;
169175 }
170176
171177 function drawTitle ( titleEl ) {
@@ -176,18 +182,18 @@ Titles.draw = function(gd, title) {
176182
177183 titleEl . style ( {
178184 'font-family' : font ,
179- 'font-size' : d3 . round ( fontSize , 2 ) + 'px' ,
180- fill : Plotly . Color . rgb ( fontColor ) ,
181- opacity : opacity * Plotly . Color . opacity ( fontColor ) ,
182- 'font-weight' : plots . fontWeight
185+ 'font-size' : d3 . round ( fontSize , 2 ) + 'px' ,
186+ fill : Color . rgb ( fontColor ) ,
187+ opacity : opacity * Color . opacity ( fontColor ) ,
188+ 'font-weight' : Plots . fontWeight
183189 } )
184190 . attr ( options )
185- . call ( Plotly . util . convertToTspans )
191+ . call ( svgTextUtils . convertToTspans )
186192 . attr ( options ) ;
187193
188194 titleEl . selectAll ( 'tspan.line' )
189195 . attr ( options ) ;
190- return plots . previousPromises ( gd ) ;
196+ return Plots . previousPromises ( gd ) ;
191197 }
192198
193199 function scootTitle ( titleElIn ) {
@@ -208,7 +214,7 @@ Titles.draw = function(gd, title) {
208214 shiftSign = ( [ 'left' , 'top' ] . indexOf ( avoid . side ) !== - 1 ) ?
209215 - 1 : 1 ,
210216 pad = isNumeric ( avoid . pad ) ? avoid . pad : 2 ,
211- titlebb = Plotly . Drawing . bBox ( titleGroup . node ( ) ) ,
217+ titlebb = Drawing . bBox ( titleGroup . node ( ) ) ,
212218 paperbb = {
213219 left : 0 ,
214220 top : 0 ,
@@ -231,9 +237,9 @@ Titles.draw = function(gd, title) {
231237 // iterate over a set of elements (avoid.selection)
232238 // to avoid collisions with
233239 avoid . selection . each ( function ( ) {
234- var avoidbb = Plotly . Drawing . bBox ( this ) ;
240+ var avoidbb = Drawing . bBox ( this ) ;
235241
236- if ( Plotly . Lib . bBoxIntersect ( titlebb , avoidbb , pad ) ) {
242+ if ( Lib . bBoxIntersect ( titlebb , avoidbb , pad ) ) {
237243 shift = Math . max ( shift , shiftSign * (
238244 avoidbb [ avoid . side ] - titlebb [ backside ] ) + pad ) ;
239245 }
@@ -278,8 +284,8 @@ Titles.draw = function(gd, title) {
278284 if ( gd . _context . editable ) {
279285 if ( ! txt ) setPlaceholder ( ) ;
280286
281- el . call ( Plotly . util . makeEditable )
282- . on ( 'edit' , function ( text ) {
287+ el . call ( svgTextUtils . makeEditable )
288+ . on ( 'edit' , function ( text ) {
283289 if ( colorbar ) {
284290 var trace = gd . _fullData [ cbnum ] ;
285291 if ( plots . traceIs ( trace , 'markerColorscale' ) ) {
0 commit comments