Skip to content

Commit

Permalink
web/em-analysis: Fix visibility of empty power plot
Browse files Browse the repository at this point in the history
The plot would not be visible if the subpage was not visible at
page reload. In this case the visible override would be lost.
  • Loading branch information
photron committed Apr 16, 2024
1 parent da69c4e commit f3cdd74
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions software/web/src/ts/components/uplot_wrapper_2nd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class UplotWrapper extends Component<UplotWrapperProps, {}> {
uplot: uPlot;
data: UplotData;
pending_data: UplotData;
pending_visible: boolean;
series_visibility: {[id: string]: boolean} = {};
visible: boolean = false;
div_ref = createRef();
Expand All @@ -97,7 +98,7 @@ export class UplotWrapper extends Component<UplotWrapperProps, {}> {
this.visible = util.get_active_sub_page() == this.props.sub_page;

if (this.visible && this.pending_data !== undefined) {
this.set_data(this.pending_data);
this.set_data(this.pending_data, this.pending_visible);
}
});

Expand Down Expand Up @@ -315,7 +316,7 @@ export class UplotWrapper extends Component<UplotWrapperProps, {}> {
}

if (this.pending_data !== undefined) {
this.set_data(this.pending_data);
this.set_data(this.pending_data, this.pending_visible);
}
}

Expand Down Expand Up @@ -529,11 +530,13 @@ export class UplotWrapper extends Component<UplotWrapperProps, {}> {
set_data(data: UplotData, visible?: boolean) {
if (!this.uplot || !this.visible) {
this.pending_data = data;
this.pending_visible = visible;
return;
}

this.data = data;
this.pending_data = undefined;
this.pending_visible = undefined;

if (visible === false || (visible === undefined && (!this.data || this.data.keys.length <= 1))) {
this.div_ref.current.style.visibility = 'hidden';
Expand Down
7 changes: 5 additions & 2 deletions software/web/src/ts/components/uplot_wrapper_3rd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class UplotFlagsWrapper extends Component<UplotFlagsWrapperProps, {}> {
uplot: uPlot;
data: UplotData;
pending_data: UplotData;
pending_visible: boolean;
series_visibility: {[id: string]: boolean} = {};
visible: boolean = false;
div_ref = createRef();
Expand All @@ -67,7 +68,7 @@ export class UplotFlagsWrapper extends Component<UplotFlagsWrapperProps, {}> {
this.visible = util.get_active_sub_page() == this.props.sub_page;

if (this.visible && this.pending_data !== undefined) {
this.set_data(this.pending_data);
this.set_data(this.pending_data, this.pending_visible);
}
});

Expand Down Expand Up @@ -225,7 +226,7 @@ export class UplotFlagsWrapper extends Component<UplotFlagsWrapperProps, {}> {
}

if (this.pending_data !== undefined) {
this.set_data(this.pending_data);
this.set_data(this.pending_data, this.pending_visible);
}
}

Expand Down Expand Up @@ -316,11 +317,13 @@ export class UplotFlagsWrapper extends Component<UplotFlagsWrapperProps, {}> {
set_data(data: UplotData, visible?: boolean) {
if (!this.uplot || !this.visible) {
this.pending_data = data;
this.pending_visible = visible;
return;
}

this.data = data;
this.pending_data = undefined;
this.pending_visible = undefined;

if (visible === false || (visible === undefined && (!this.data || this.data.keys.length <= 1))) {
this.div_ref.current.style.visibility = 'hidden';
Expand Down

0 comments on commit f3cdd74

Please sign in to comment.