From 8e7340b171d0e801398511eee499d71d1734e2a6 Mon Sep 17 00:00:00 2001 From: Laura Fuentes Grau Date: Sun, 29 Mar 2020 15:10:02 +0200 Subject: [PATCH] fix for PlotTable: PlotLegend now only created if signals are selected --- src/dashboard/dashboard.js | 7 +------ src/widget/widgets/plot-table.js | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/dashboard/dashboard.js b/src/dashboard/dashboard.js index df42e37..98c3d40 100644 --- a/src/dashboard/dashboard.js +++ b/src/dashboard/dashboard.js @@ -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, diff --git a/src/widget/widgets/plot-table.js b/src/widget/widgets/plot-table.js index 3e8e8f1..e16b7b1 100644 --- a/src/widget/widgets/plot-table.js +++ b/src/widget/widgets/plot-table.js @@ -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
; - } + 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 (
@@ -159,7 +162,9 @@ class WidgetPlotTable extends Component { />
- + {showLegend? ( + ) : (
) + } );