@@ -13,6 +13,8 @@ class DrillDown extends React.Component {
1313 super ( props ) ;
1414
1515 this . state = {
16+ showOverlaybtn : true ,
17+ overlayZindex : 1 ,
1618 // Absolute position of Overlay Button
1719 positionH : ( this . props . overlayBtn && this . props . overlayBtn . placement && this . props . overlayBtn . placement . includes ( '-' ) ) ? this . props . overlayBtn . placement . split ( '-' ) [ 1 ] : 'right' ,
1820 positionV : ( this . props . overlayBtn && this . props . overlayBtn . placement && this . props . overlayBtn . placement . includes ( '-' ) ) ? this . props . overlayBtn . placement . split ( '-' ) [ 0 ] : 'top' ,
@@ -46,7 +48,7 @@ class DrillDown extends React.Component {
4648 if ( typeof this . state . mappedIds [ 0 ] == 'number' ) {
4749 for ( let i = 0 ; i < this . state . mappedIds . length ; i ++ ) {
4850 let plotPosition = this . state . mappedIds [ i ] ;
49- if ( ! this . state . showDrillDown && index == i && plotPosition && plotPosition < idArrLength ) {
51+ if ( ! this . state . showDrillDown && index == i && plotPosition != null && plotPosition < idArrLength ) {
5052 this . setState ( {
5153 showDrillDown : true ,
5254 selectedChild : plotPosition
@@ -68,6 +70,23 @@ class DrillDown extends React.Component {
6870 }
6971 }
7072
73+ renderComplete ( ) {
74+ if ( this . props && this . props . toggleParentOverlayBtnVisibility ) {
75+ this . props . toggleParentOverlayBtnVisibility ( false ) ;
76+ }
77+ }
78+
79+ toggleParentOverlayBtnVisibility ( visibility ) {
80+ this . setState ( { showOverlaybtn : visibility } ) ;
81+ }
82+
83+ onClickOverlayBtn ( ) {
84+ this . setState ( { showDrillDown : false } ) ;
85+ if ( this . props && this . props . toggleParentOverlayBtnVisibility && this . state . showDrillDown ) {
86+ this . props . toggleParentOverlayBtnVisibility ( true ) ;
87+ }
88+ }
89+
7190 render ( ) {
7291 // In-line style for overlay button
7392 const btnStyle = {
@@ -80,13 +99,11 @@ class DrillDown extends React.Component {
8099 fontWeight : `${ this . state . fontWeight } ` ,
81100 position : 'absolute' ,
82101 [ this . state . positionH ] : `${ this . state . margin } ` ,
83- // left: `${this.props.width - 50}px`,
84102 [ this . state . positionV ] : `${ this . state . margin } ` ,
85103 cursor : 'pointer' ,
104+ // zIndex: this.state.overlayZindex
86105 } ;
87106
88- console . log ( btnStyle ) ;
89-
90107 // In-line style for root element of DrillDown component
91108 const rootStyle = {
92109 position : 'relative' ,
@@ -101,15 +118,23 @@ class DrillDown extends React.Component {
101118 { /* Displaying Correct Drilled Down Chart. */ }
102119 { React . cloneElement (
103120 this . props . children [ this . state . selectedChild ] ,
104- { width : this . props . width , height : this . props . height }
121+ {
122+ width : this . props . width ,
123+ height : this . props . height ,
124+ onRender : this . renderComplete . bind ( this ) ,
125+ // overlayBtn: this.props.overlayBtn,
126+ toggleParentOverlayBtnVisibility : this . toggleParentOverlayBtnVisibility . bind ( this )
127+ }
105128 ) }
106- < span style = { btnStyle }
107- onClick = { ( ) => this . setState ( { showDrillDown : false } ) } >
108- {
109- this . props . overlayBtn && this . props . overlayBtn . message ?
110- this . props . overlayBtn . message : 'Back'
111- }
112- </ span >
129+ { this . state . showOverlaybtn ?
130+ < span style = { btnStyle }
131+ onClick = { this . onClickOverlayBtn . bind ( this ) } >
132+ {
133+ this . props . overlayBtn && this . props . overlayBtn . message ?
134+ this . props . overlayBtn . message : 'Back'
135+ }
136+ </ span > : null
137+ }
113138 </ div >
114139 ) ;
115140 } else {
0 commit comments