Skip to content

Commit

Permalink
Fix time-chart not displaying after hiding tool tabs, and then re-sho…
Browse files Browse the repository at this point in the history
…wing them,

I *think* the time div holding the time chart was being removed from the DOM and then added back in, removing some references or something.  So now refresh the JS when this happens.
  • Loading branch information
wcjohns committed Sep 4, 2024
1 parent f9c842f commit e396fcc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
11 changes: 11 additions & 0 deletions InterSpec/D3TimeChart.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ class D3TimeChart : public Wt::WContainerWidget
*/
virtual void doJavaScript( const std::string &js );

#if( OPTIMIZE_D3TimeChart_HIDDEN_LOAD )
/** Causes `defineJavaScript()` to be called next time the `render(flags)` function is called.
This is fixes an issuer where if, while time-chart is showing, we hide tool tabs, and then show
them again, then the time chart wont show. I *think* it has something to do with the timechart
div getting taken out of the DOM, and then reinserted, causing whatever references to be lost.
Maybe, not really sure.
*/
void refreshJs();
#endif
protected:

void defineJavaScript();
Expand Down Expand Up @@ -233,6 +243,7 @@ class D3TimeChart : public Wt::WContainerWidget

//ResetXDomain = 0x10

RefreshJs = 0x04
//ToDo: maybe add a few other things to this mechanism.
};//enum D3RenderActions

Expand Down
16 changes: 14 additions & 2 deletions src/D3TimeChart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,16 @@ D3TimeChart::~D3TimeChart()
}

#if( OPTIMIZE_D3TimeChart_HIDDEN_LOAD )
void D3TimeChart::refreshJs()
{
m_renderFlags |= TimeRenderActions::RefreshJs;
m_renderFlags |= TimeRenderActions::UpdateData;
m_renderFlags |= TimeRenderActions::UpdateHighlightRegions;

scheduleRender();
}
#endif

void D3TimeChart::setHidden( bool hidden, const Wt::WAnimation &animation )
{
cout << "D3TimeChart::setHidden( " << hidden << " );" << endl;
Expand All @@ -1077,13 +1087,12 @@ void D3TimeChart::setHidden( bool hidden, const Wt::WAnimation &animation )

WContainerWidget::setHidden( hidden, animation );
}//void D3TimeChart::setHidden(...)
#endif //OPTIMIZE_D3TimeChart_HIDDEN_LOAD


void D3TimeChart::defineJavaScript()
{
#if( OPTIMIZE_D3TimeChart_HIDDEN_LOAD )
assert( !m_inited );
assert( !m_inited || m_renderFlags.testFlag(TimeRenderActions::RefreshJs) );
#endif
//WWebWidget::doJavaScript( "$(" + m_chart->jsRef() + ").append('<svg width=\"400\" height=\"75\" style=\"box-sizing: border-box; \"><rect width=\"300\" height=\"75\" style=\"fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)\" /></svg>' ); console.log( 'Added rect' );" );

Expand Down Expand Up @@ -2529,6 +2538,9 @@ void D3TimeChart::render( Wt::WFlags<Wt::RenderFlag> flags )
#if( OPTIMIZE_D3TimeChart_HIDDEN_LOAD )
if( isVisible() )
{
if( m_renderFlags.testFlag(TimeRenderActions::RefreshJs) )
defineJavaScript();

if( m_renderFlags.testFlag(TimeRenderActions::UpdateData) )
setDataToClient();

Expand Down
7 changes: 7 additions & 0 deletions src/InterSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6618,6 +6618,13 @@ void InterSpec::setToolTabsVisible( bool showToolTabs )
if( m_menuDiv && !m_menuDiv->isHidden() ) //get rid of a small amount of space between the menu bar and the chart
m_charts->setMargin( -layoutVertSpacing, Wt::Top );

#if( OPTIMIZE_D3TimeChart_HIDDEN_LOAD )
// With out this next line the time chart wont show if we hide tool tabs, and then show
// them again. I think it has something to do with the timechart div getting taken out
// of the DOM, and references lost. Maybe.
m_timeSeries->refreshJs();
#endif

//Without using the wrapper below, the tabs widget will change height, even
// if it is explicitly set, when different tabs are clicked (unless a
// manual resize is performed by the user first)
Expand Down

0 comments on commit e396fcc

Please sign in to comment.