9
9
10
10
'use strict' ;
11
11
12
- var Plotly = require ( '../../plotly' ) ;
13
12
var d3 = require ( 'd3' ) ;
14
13
var isNumeric = require ( 'fast-isnumeric' ) ;
15
14
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
+
17
23
18
24
var Titles = module . exports = { } ;
19
25
@@ -38,7 +44,7 @@ Titles.draw = function(gd, title) {
38
44
}
39
45
} ) ;
40
46
}
41
- else cont = fullLayout [ Plotly . Axes . id2name ( title . replace ( 'title' , '' ) ) ] || fullLayout ;
47
+ else cont = fullLayout [ axisIds . id2name ( title . replace ( 'title' , '' ) ) ] || fullLayout ;
42
48
43
49
var prop = cont === fullLayout ? 'title' : cont . _name + '.title' ,
44
50
name = colorbar ? 'colorscale' :
@@ -92,9 +98,9 @@ Titles.draw = function(gd, title) {
92
98
xa = cont ;
93
99
ya = ( xa . anchor === 'free' ) ?
94
100
{ _offset :gs . t + ( 1 - ( xa . position || 0 ) ) * gs . h , _length :0 } :
95
- Plotly . Axes . getFromId ( gd , xa . anchor ) ;
96
101
x = xa . _offset + xa . _length / 2 ;
97
102
y = ya . _offset + ( ( xa . side === 'top' ) ?
103
+ axisIds . getFromId ( gd , xa . anchor ) ;
98
104
- 10 - fontSize * ( offsetBase + ( xa . showticklabels ? 1 : 0 ) ) :
99
105
ya . _length + 10 +
100
106
fontSize * ( offsetBase + ( xa . showticklabels ? 1.5 : 0.5 ) ) ) ;
@@ -105,9 +111,9 @@ Titles.draw = function(gd, title) {
105
111
ya = cont ;
106
112
xa = ( ya . anchor === 'free' ) ?
107
113
{ _offset :gs . l + ( ya . position || 0 ) * gs . w , _length :0 } :
108
- Plotly . Axes . getFromId ( gd , ya . anchor ) ;
109
114
y = ya . _offset + ya . _length / 2 ;
110
115
x = xa . _offset + ( ( ya . side === 'right' ) ?
116
+ axisIds . getFromId ( gd , ya . anchor ) ;
111
117
xa . _length + 10 +
112
118
fontSize * ( offsetBase + ( ya . showticklabels ? 1 : 0.5 ) ) :
113
119
- 10 - fontSize * ( offsetBase + ( ya . showticklabels ? 0.5 : 0 ) ) ) ;
@@ -165,7 +171,7 @@ Titles.draw = function(gd, title) {
165
171
. attr ( 'class' , title ) ;
166
172
167
173
function titleLayout ( titleEl ) {
168
- Plotly . Lib . syncOrAsync ( [ drawTitle , scootTitle ] , titleEl ) ;
174
+ Lib . syncOrAsync ( [ drawTitle , scootTitle ] , titleEl ) ;
169
175
}
170
176
171
177
function drawTitle ( titleEl ) {
@@ -176,18 +182,18 @@ Titles.draw = function(gd, title) {
176
182
177
183
titleEl . style ( {
178
184
'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
183
189
} )
184
190
. attr ( options )
185
- . call ( Plotly . util . convertToTspans )
191
+ . call ( svgTextUtils . convertToTspans )
186
192
. attr ( options ) ;
187
193
188
194
titleEl . selectAll ( 'tspan.line' )
189
195
. attr ( options ) ;
190
- return plots . previousPromises ( gd ) ;
196
+ return Plots . previousPromises ( gd ) ;
191
197
}
192
198
193
199
function scootTitle ( titleElIn ) {
@@ -208,7 +214,7 @@ Titles.draw = function(gd, title) {
208
214
shiftSign = ( [ 'left' , 'top' ] . indexOf ( avoid . side ) !== - 1 ) ?
209
215
- 1 : 1 ,
210
216
pad = isNumeric ( avoid . pad ) ? avoid . pad : 2 ,
211
- titlebb = Plotly . Drawing . bBox ( titleGroup . node ( ) ) ,
217
+ titlebb = Drawing . bBox ( titleGroup . node ( ) ) ,
212
218
paperbb = {
213
219
left : 0 ,
214
220
top : 0 ,
@@ -231,9 +237,9 @@ Titles.draw = function(gd, title) {
231
237
// iterate over a set of elements (avoid.selection)
232
238
// to avoid collisions with
233
239
avoid . selection . each ( function ( ) {
234
- var avoidbb = Plotly . Drawing . bBox ( this ) ;
240
+ var avoidbb = Drawing . bBox ( this ) ;
235
241
236
- if ( Plotly . Lib . bBoxIntersect ( titlebb , avoidbb , pad ) ) {
242
+ if ( Lib . bBoxIntersect ( titlebb , avoidbb , pad ) ) {
237
243
shift = Math . max ( shift , shiftSign * (
238
244
avoidbb [ avoid . side ] - titlebb [ backside ] ) + pad ) ;
239
245
}
@@ -278,8 +284,8 @@ Titles.draw = function(gd, title) {
278
284
if ( gd . _context . editable ) {
279
285
if ( ! txt ) setPlaceholder ( ) ;
280
286
281
- el . call ( Plotly . util . makeEditable )
282
- . on ( 'edit' , function ( text ) {
287
+ el . call ( svgTextUtils . makeEditable )
288
+ . on ( 'edit' , function ( text ) {
283
289
if ( colorbar ) {
284
290
var trace = gd . _fullData [ cbnum ] ;
285
291
if ( plots . traceIs ( trace , 'markerColorscale' ) ) {
0 commit comments