@@ -46,9 +46,19 @@ proto.init = function(fullLayout) {
46
46
} ;
47
47
48
48
proto . plot = function ( ternaryCalcData , fullLayout ) {
49
- var _this = this ,
50
- ternaryLayout = fullLayout [ _this . id ] ,
51
- graphSize = fullLayout . _size ;
49
+ var _this = this ;
50
+ var ternaryLayout = fullLayout [ _this . id ] ;
51
+ var graphSize = fullLayout . _size ;
52
+
53
+ _this . _hasClipOnAxisFalse = false ;
54
+ for ( var i = 0 ; i < ternaryCalcData . length ; i ++ ) {
55
+ var trace = ternaryCalcData [ i ] [ 0 ] . trace ;
56
+
57
+ if ( trace . cliponaxis === false ) {
58
+ _this . _hasClipOnAxisFalse = true ;
59
+ break ;
60
+ }
61
+ }
52
62
53
63
_this . adjustLayout ( ternaryLayout , graphSize ) ;
54
64
@@ -66,12 +76,19 @@ proto.makeFramework = function() {
66
76
. classed ( 'clips' , true ) ;
67
77
68
78
// clippath for this ternary subplot
69
- var clipId = 'clip' + _this . layoutId + _this . id ;
79
+ var clipId = _this . clipId = 'clip' + _this . layoutId + _this . id ;
70
80
_this . clipDef = defGroup . selectAll ( '#' + clipId )
71
81
. data ( [ 0 ] ) ;
72
82
_this . clipDef . enter ( ) . append ( 'clipPath' ) . attr ( 'id' , clipId )
73
83
. append ( 'path' ) . attr ( 'd' , 'M0,0Z' ) ;
74
84
85
+ // 'relative' clippath (i.e. no translation) for this ternary subplot
86
+ var clipIdRelative = _this . clipIdRelative = 'clip-relative' + _this . layoutId + _this . id ;
87
+ _this . clipDefRelative = defGroup . selectAll ( '#' + clipIdRelative )
88
+ . data ( [ 0 ] ) ;
89
+ _this . clipDefRelative . enter ( ) . append ( 'clipPath' ) . attr ( 'id' , clipIdRelative )
90
+ . append ( 'path' ) . attr ( 'd' , 'M0,0Z' ) ;
91
+
75
92
// container for everything in this ternary subplot
76
93
_this . plotContainer = _this . container . selectAll ( 'g.' + _this . id )
77
94
. data ( [ 0 ] ) ;
@@ -120,7 +137,7 @@ proto.makeFramework = function() {
120
137
. attr ( 'class' , function ( d ) { return 'grid ' + d ; } )
121
138
. each ( function ( d ) { _this . layers [ d ] = d3 . select ( this ) ; } ) ;
122
139
123
- _this . plotContainer . selectAll ( '.backplot,.frontplot,. grids' )
140
+ _this . plotContainer . selectAll ( '.backplot,.grids' )
124
141
. call ( Drawing . setClipUrl , clipId ) ;
125
142
} ;
126
143
@@ -175,6 +192,16 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {
175
192
} ;
176
193
setConvert ( _this . xaxis , _this . graphDiv . _fullLayout ) ;
177
194
_this . xaxis . setScale ( ) ;
195
+ _this . xaxis . isPtWithinRange = function ( d ) {
196
+ return (
197
+ d . a >= _this . aaxis . range [ 0 ] &&
198
+ d . a <= _this . aaxis . range [ 1 ] &&
199
+ d . b >= _this . baxis . range [ 1 ] &&
200
+ d . b <= _this . baxis . range [ 0 ] &&
201
+ d . c >= _this . caxis . range [ 1 ] &&
202
+ d . c <= _this . caxis . range [ 0 ]
203
+ ) ;
204
+ } ;
178
205
179
206
_this . yaxis = {
180
207
type : 'linear' ,
@@ -187,6 +214,7 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {
187
214
} ;
188
215
setConvert ( _this . yaxis , _this . graphDiv . _fullLayout ) ;
189
216
_this . yaxis . setScale ( ) ;
217
+ _this . yaxis . isPtWithinRange = function ( ) { return true ; } ;
190
218
191
219
// set up the modified axes for tick drawing
192
220
var yDomain0 = _this . yaxis . domain [ 0 ] ;
@@ -257,6 +285,9 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {
257
285
_this . clipDef . select ( 'path' ) . attr ( 'd' , triangleClip ) ;
258
286
_this . layers . plotbg . select ( 'path' ) . attr ( 'd' , triangleClip ) ;
259
287
288
+ var triangleClipRelative = 'M0,' + h + 'h' + w + 'l-' + ( w / 2 ) + ',-' + h + 'Z' ;
289
+ _this . clipDefRelative . select ( 'path' ) . attr ( 'd' , triangleClipRelative ) ;
290
+
260
291
var plotTransform = 'translate(' + x0 + ',' + y0 + ')' ;
261
292
_this . plotContainer . selectAll ( '.scatterlayer,.maplayer' )
262
293
. attr ( 'transform' , plotTransform ) ;
@@ -302,6 +333,9 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {
302
333
if ( ! _this . graphDiv . _context . staticPlot ) {
303
334
_this . initInteractions ( ) ;
304
335
}
336
+
337
+ _this . plotContainer . select ( '.frontplot' )
338
+ . call ( Drawing . setClipUrl , _this . _hasClipOnAxisFalse ? null : _this . clipId ) ;
305
339
} ;
306
340
307
341
proto . drawAxes = function ( doTitles ) {
@@ -589,6 +623,17 @@ proto.initInteractions = function() {
589
623
590
624
_this . drawAxes ( false ) ;
591
625
_this . plotContainer . selectAll ( '.crisp' ) . classed ( 'crisp' , false ) ;
626
+
627
+ if ( _this . _hasClipOnAxisFalse ) {
628
+ var scatterPoints = _this . plotContainer
629
+ . select ( '.scatterlayer' ) . selectAll ( '.points' ) ;
630
+
631
+ scatterPoints . selectAll ( '.point' )
632
+ . call ( Drawing . hideOutsideRangePoints , _this ) ;
633
+
634
+ scatterPoints . selectAll ( '.textpoint' )
635
+ . call ( Drawing . hideOutsideRangePoints , _this ) ;
636
+ }
592
637
}
593
638
594
639
function dragDone ( dragged , numClicks ) {
0 commit comments