@@ -46,9 +46,19 @@ proto.init = function(fullLayout) {
4646} ;
4747
4848proto . 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+ }
5262
5363 _this . adjustLayout ( ternaryLayout , graphSize ) ;
5464
@@ -66,12 +76,19 @@ proto.makeFramework = function() {
6676 . classed ( 'clips' , true ) ;
6777
6878 // clippath for this ternary subplot
69- var clipId = 'clip' + _this . layoutId + _this . id ;
79+ var clipId = _this . clipId = 'clip' + _this . layoutId + _this . id ;
7080 _this . clipDef = defGroup . selectAll ( '#' + clipId )
7181 . data ( [ 0 ] ) ;
7282 _this . clipDef . enter ( ) . append ( 'clipPath' ) . attr ( 'id' , clipId )
7383 . append ( 'path' ) . attr ( 'd' , 'M0,0Z' ) ;
7484
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+
7592 // container for everything in this ternary subplot
7693 _this . plotContainer = _this . container . selectAll ( 'g.' + _this . id )
7794 . data ( [ 0 ] ) ;
@@ -120,7 +137,7 @@ proto.makeFramework = function() {
120137 . attr ( 'class' , function ( d ) { return 'grid ' + d ; } )
121138 . each ( function ( d ) { _this . layers [ d ] = d3 . select ( this ) ; } ) ;
122139
123- _this . plotContainer . selectAll ( '.backplot,.frontplot,. grids' )
140+ _this . plotContainer . selectAll ( '.backplot,.grids' )
124141 . call ( Drawing . setClipUrl , clipId ) ;
125142} ;
126143
@@ -175,6 +192,16 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {
175192 } ;
176193 setConvert ( _this . xaxis , _this . graphDiv . _fullLayout ) ;
177194 _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+ } ;
178205
179206 _this . yaxis = {
180207 type : 'linear' ,
@@ -187,6 +214,7 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {
187214 } ;
188215 setConvert ( _this . yaxis , _this . graphDiv . _fullLayout ) ;
189216 _this . yaxis . setScale ( ) ;
217+ _this . yaxis . isPtWithinRange = function ( ) { return true ; } ;
190218
191219 // set up the modified axes for tick drawing
192220 var yDomain0 = _this . yaxis . domain [ 0 ] ;
@@ -257,6 +285,9 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {
257285 _this . clipDef . select ( 'path' ) . attr ( 'd' , triangleClip ) ;
258286 _this . layers . plotbg . select ( 'path' ) . attr ( 'd' , triangleClip ) ;
259287
288+ var triangleClipRelative = 'M0,' + h + 'h' + w + 'l-' + ( w / 2 ) + ',-' + h + 'Z' ;
289+ _this . clipDefRelative . select ( 'path' ) . attr ( 'd' , triangleClipRelative ) ;
290+
260291 var plotTransform = 'translate(' + x0 + ',' + y0 + ')' ;
261292 _this . plotContainer . selectAll ( '.scatterlayer,.maplayer' )
262293 . attr ( 'transform' , plotTransform ) ;
@@ -302,6 +333,9 @@ proto.adjustLayout = function(ternaryLayout, graphSize) {
302333 if ( ! _this . graphDiv . _context . staticPlot ) {
303334 _this . initInteractions ( ) ;
304335 }
336+
337+ _this . plotContainer . select ( '.frontplot' )
338+ . call ( Drawing . setClipUrl , _this . _hasClipOnAxisFalse ? null : _this . clipId ) ;
305339} ;
306340
307341proto . drawAxes = function ( doTitles ) {
@@ -589,6 +623,17 @@ proto.initInteractions = function() {
589623
590624 _this . drawAxes ( false ) ;
591625 _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+ }
592637 }
593638
594639 function dragDone ( dragged , numClicks ) {
0 commit comments