Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix disappearing toolbar #758

Merged
merged 4 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 45 additions & 47 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
</table>

<!-- Plots -->
<div [id]="basePlotHTMLTarget" *ngIf="resultType == 'plot'"></div>
<ng-container *ngFor="let comparePlotHTMLTarget of
comparePlotsHTMLTargets">
<div [id]="comparePlotHTMLTarget" *ngIf="resultType == 'plot'"></div>
</ng-container>
<div id="plotHTMLTarget" *ngIf="resultType == 'plot'"></div>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ export class ScenarioComparisonResultsComponent implements OnInit {
yMax: number
};

basePlotHTMLTarget: string;
basePlotJSON: any;
comparePlotsHTMLTargets: string[];
comparePlotsJSON: any[];

constructor(
private location: Location,
Expand Down Expand Up @@ -79,8 +75,6 @@ export class ScenarioComparisonResultsComponent implements OnInit {
// Embed the plots to compare
if (this.formValues !== undefined) {
this.embedBasePlot();
this.comparePlotsHTMLTargets = [];
this.comparePlotsJSON = [];
this.embedComparePlots();
}

Expand Down Expand Up @@ -112,9 +106,7 @@ export class ScenarioComparisonResultsComponent implements OnInit {
this.formValues.subproblem, this.formValues.stage,
this.formValues.project, this.formValues.commitProject, this.formValues.yMax
).subscribe(resultsPlot => {
this.basePlotHTMLTarget = resultsPlot.plotJSON.target_id;
this.basePlotJSON = resultsPlot.plotJSON;
Bokeh.embed_item(this.basePlotJSON);
Bokeh.embed_item(resultsPlot.plotJSON);
});
}

Expand All @@ -128,8 +120,6 @@ export class ScenarioComparisonResultsComponent implements OnInit {
this.formValues.subproblem, this.formValues.stage,
this.formValues.project, this.formValues.commitProject, this.formValues.yMax
).subscribe(resultsPlot => {
this.comparePlotsHTMLTargets.push(resultsPlot.plotJSON.target_id);
this.comparePlotsJSON.push(resultsPlot.plotJSON);
Bokeh.embed_item(resultsPlot.plotJSON);
});
}
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/scenario-results/scenario-results.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ <h6 id="plots-title">Results Plots</h6>

<!-- Row for the results -->
<div class="row">
<!-- Plots -->
<div id="plotHTMLTarget" *ngIf="resultsToShow=='plotDiv'"></div>
<div class="col overflow-x-auto">
<!-- Plots -->
<div [id]="plotHTMLTarget" *ngIf="resultsToShow==plotHTMLTarget"></div>
<!-- Results tables -->
<!-- Results tables -->
<table class="scenario-results-table"
*ngIf="resultsTable !== undefined &&
resultsToShow==resultsTable.table">
Expand Down
36 changes: 11 additions & 25 deletions ui/src/app/scenario-results/scenario-results.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export class ScenarioResultsComponent implements OnInit {

// Which results to show; we use an *ngIf in the table <table> and plot
// <div> definitions to determine whether to show the respective result
// A particular table is shown if the *ngIf is set to the table name
// All plots are shown within the same div if resultsToShow is set to
// 'plotDiv'
resultsToShow: string;

// //// Tables //// //
Expand All @@ -41,13 +44,6 @@ export class ScenarioResultsComponent implements OnInit {
allPlotFormGroups: FormGroup[];
// The possible options for the forms
formOptions: ResultsOptions;
// The value of the submitted plot form
plotFormValue: {};
// The target_id of the plot we'll show; we'll get this from the JSON
// object and set it before embedding the plot
plotHTMLTarget: string;
// The JSON plot object
resultsPlot: any;

// To get the right route for which scenario to use
scenarioID: number;
Expand Down Expand Up @@ -79,9 +75,7 @@ export class ScenarioResultsComponent implements OnInit {
this.makeResultsPlotForms(this.scenarioID);
}

ngOnInit() {

}
ngOnInit() {}

// //// Tables //// //
makeResultsTableButtons(): void {
Expand All @@ -98,8 +92,7 @@ export class ScenarioResultsComponent implements OnInit {
this.resultsTable = inputTableRows;
// Set the values needed to display the table after ngOnInit
this.tableToShow = table;
this.resultsToShow = table;
this.ngOnInit();
this.resultsToShow = this.tableToShow;
});
}

Expand Down Expand Up @@ -163,22 +156,18 @@ export class ScenarioResultsComponent implements OnInit {
});
}

// This function is called when a user requests a plot; this will change
// some values, namely the plotHTMLTarget and then call ngOnInit, which
// in turn calls getResultPlot
// This function is called when a user requests a plot
showPlotOrDownloadData(formGroup): void {

// Figure out which button was pressed
const buttonName = document.activeElement.getAttribute('Name');
console.log(buttonName);

// We need to set the plotFormValue and plotHTMLTarget before
// calling ngOnInit to be able to embed the plot
this.plotFormValue = formGroup;

const formValues = getFormGroupValues(formGroup);

if (buttonName === 'showPlot') {
this.resultsToShow = 'plotDiv';

this.scenarioResultsService.getResultsPlot(
this.scenarioID, formValues.plotType, formValues.loadZone,
formValues.rpsZone, formValues.carbonCapZone,
Expand All @@ -187,11 +176,8 @@ export class ScenarioResultsComponent implements OnInit {
formValues.subproblem, formValues.stage,
formValues.project, formValues.commitProject, formValues.yMax
).subscribe(resultsPlot => {
this.plotHTMLTarget = resultsPlot.plotJSON.target_id;
this.resultsToShow = resultsPlot.plotJSON.target_id;
this.resultsPlot = resultsPlot.plotJSON;
Bokeh.embed_item(this.resultsPlot);
this.ngOnInit();
// Embed the plot; all plots have 'plotHTMLTarget' as their target_id
Bokeh.embed_item(resultsPlot.plotJSON);
});
}

Expand Down Expand Up @@ -233,7 +219,7 @@ export class ScenarioResultsComponent implements OnInit {

clearResults(): void {
this.resultsToShow = null;
this.ngOnInit();

}

getScenarioName(scenarioID): void {
Expand Down
2 changes: 1 addition & 1 deletion viz/capacity_factor_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def main(args=None):

# Return plot in json format if requested
if parsed_args.return_json:
return json_item(plot, plot_name)
return json_item(plot, "plotHTMLTarget")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion viz/capacity_new_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def main(args=None):

# Return plot in json format if requested
if parsed_args.return_json:
return json_item(plot, plot_name)
return json_item(plot, "plotHTMLTarget")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion viz/capacity_retired_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def main(args=None):

# Return plot in json format if requested
if parsed_args.return_json:
return json_item(plot, plot_name)
return json_item(plot, "plotHTMLTarget")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion viz/capacity_total_loadzone_comparison_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def main(args=None):

# Return plot in json format if requested
if parsed_args.return_json:
return json_item(plot, plot_name)
return json_item(plot, "plotHTMLTarget")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion viz/capacity_total_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def main(args=None):

# Return plot in json format if requested
if parsed_args.return_json:
return json_item(plot, plot_name)
return json_item(plot, "plotHTMLTarget")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion viz/capacity_total_scenario_comparison_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def main(args=None):

# Return plot in json format if requested
if parsed_args.return_json:
return json_item(plot, plot_name)
return json_item(plot, "plotHTMLTarget")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion viz/carbon_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def main(args=None):

# Return plot in json format if requested
if parsed_args.return_json:
return json_item(plot, plot_name)
return json_item(plot, "plotHTMLTarget")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion viz/cost_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def main(args=None):

# Return plot in json format if requested
if parsed_args.return_json:
return json_item(plot, plot_name)
return json_item(plot, "plotHTMLTarget")


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion viz/curtailment_hydro_heatmap_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def main(args=None):

# Return plot in json format if requested
if parsed_args.return_json:
return json_item(plot, plot_name)
return json_item(plot, "plotHTMLTarget")


if __name__ == "__main__":
Expand Down
Loading