mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-16 00:00:03 +01:00
fix for PlotTable: PlotLegend now only created if signals are selected
This commit is contained in:
parent
5c95cbf05f
commit
8e7340b171
2 changed files with 14 additions and 14 deletions
|
@ -264,12 +264,7 @@ class Dashboard extends Component {
|
|||
|
||||
|
||||
deleteWidget(widget, index) {
|
||||
/*const widgets = this.state.dashboard.get('widgets');
|
||||
delete widgets[index];
|
||||
|
||||
const dashboard = this.state.dashboard.set('widgets');
|
||||
|
||||
this.setState({ dashboard });*/
|
||||
|
||||
AppDispatcher.dispatch({
|
||||
type: 'widgets/start-remove',
|
||||
data: widget,
|
||||
|
|
|
@ -92,14 +92,12 @@ class WidgetPlotTable extends Component {
|
|||
|
||||
render() {
|
||||
let checkBoxes = [];
|
||||
|
||||
let icData = [];
|
||||
let legendSignals = [];
|
||||
// Data passed to plot
|
||||
if (this.props.config == null) {
|
||||
return <div />;
|
||||
}
|
||||
if (this.props.config) {
|
||||
|
||||
const ic = this.props.config.icID;
|
||||
let icData = [];
|
||||
|
||||
if (this.props.data[ic] != null && this.props.data[ic].output != null && this.props.data[ic].output.values != null) {
|
||||
icData = this.props.data[ic].output.values.filter((values, index) => (
|
||||
|
@ -121,7 +119,7 @@ class WidgetPlotTable extends Component {
|
|||
}
|
||||
|
||||
// Prepare an array with the signals to show in the legend
|
||||
var legendSignals = this.state.preselectedSignals.reduce( (accum, signal, i) => {
|
||||
legendSignals = this.state.preselectedSignals.reduce( (accum, signal, i) => {
|
||||
if (this.state.signals.includes(signal.index)) {
|
||||
accum.push({
|
||||
index: signal.index,
|
||||
|
@ -130,7 +128,12 @@ class WidgetPlotTable extends Component {
|
|||
});
|
||||
}
|
||||
return accum;
|
||||
}, []);
|
||||
}, []);}
|
||||
|
||||
let showLegend = false;
|
||||
if(legendSignals !== []){
|
||||
showLegend = true;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="plot-table-widget" ref="wrapper">
|
||||
|
@ -159,7 +162,9 @@ class WidgetPlotTable extends Component {
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<PlotLegend signals={legendSignals} />
|
||||
{showLegend? (
|
||||
<PlotLegend signals={legendSignals} /> ) : (<div></div>)
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue