diff --git a/src/visualizers/panels/ExecutionIndex/ExecutionIndexControl.js b/src/visualizers/panels/ExecutionIndex/ExecutionIndexControl.js index 97af1d739..fac2f5920 100644 --- a/src/visualizers/panels/ExecutionIndex/ExecutionIndexControl.js +++ b/src/visualizers/panels/ExecutionIndex/ExecutionIndexControl.js @@ -49,8 +49,9 @@ define([ }; ExecutionIndexControl.prototype._updateGraphWidget = function () { - if (this.displayedExecCount() > 0) { - const plotlyJSON = this._consolidateGraphData(this.displayedExecutions); + const plotlyJSON = this._consolidateGraphData(this.displayedExecutions); + const hasDisplayedMetadata = !!plotlyJSON; + if (hasDisplayedMetadata) { this._widget.updateNode(plotlyJSON); } else { this._widget.removeNode(); @@ -78,7 +79,7 @@ define([ graphDescs.forEach((desc) => { if (!consolidatedDesc) { consolidatedDesc = JSON.parse(JSON.stringify(desc)); - consolidatedDesc.subGraphs.forEach((subGraph) =>{ + consolidatedDesc.subGraphs.forEach((subGraph) => { subGraph.abbr = desc.abbr; subGraph.title = getDisplayTitle(subGraph, true); }); diff --git a/src/visualizers/widgets/PlotlyGraph/PlotlyGraphWidget.js b/src/visualizers/widgets/PlotlyGraph/PlotlyGraphWidget.js index c3fb1a379..ca32801f4 100644 --- a/src/visualizers/widgets/PlotlyGraph/PlotlyGraphWidget.js +++ b/src/visualizers/widgets/PlotlyGraph/PlotlyGraphWidget.js @@ -1,4 +1,4 @@ -/*globals define, _*/ +/*globals define, _, $*/ define(['./lib/plotly.min',], function (Plotly) { 'use strict'; @@ -7,6 +7,13 @@ define(['./lib/plotly.min',], function (Plotly) { function PlotlyGraphWidget(logger, container) { this.logger = logger.fork('widget'); this.$el = container; + this.$defaultTextDiv = $('
', { + class: 'h2 center' + }).text('No Data Available.') + .css({ + 'margin-top': this.$el.height() / 2 + }); + this.$el.append(this.$defaultTextDiv); this.$el.css('overflow', 'auto'); this.$el.addClass(WIDGET_CLASS); this.nodes = {}; @@ -14,6 +21,7 @@ define(['./lib/plotly.min',], function (Plotly) { this.layout = {}; this.created = false; this.logger.debug('ctor finished'); + this.setTextVisibility(true); } PlotlyGraphWidget.prototype.onWidgetContainerResize = function (width, height) { @@ -22,29 +30,35 @@ define(['./lib/plotly.min',], function (Plotly) { width: width, height: height }); + this.$defaultTextDiv.css({ + 'margin-top': height / 2 + }); this.logger.debug('Widget is resizing...'); }; // Adding/Removing/Updating items PlotlyGraphWidget.prototype.addNode = function (desc) { - if (desc) { - this.plotlyJSON = desc; - this.refreshChart(); - } + this.addOrUpdateNode(desc); }; PlotlyGraphWidget.prototype.removeNode = function () { this.plotlyJSON = null; this.refreshChart(); + this.setTextVisibility(true); }; - PlotlyGraphWidget.prototype.updateNode = function (desc) { + PlotlyGraphWidget.prototype.addOrUpdateNode = function (desc) { if (desc) { this.plotlyJSON = desc; + this.setTextVisibility(false); this.refreshChart(); } }; + PlotlyGraphWidget.prototype.updateNode = function (desc) { + this.addOrUpdateNode(desc); + }; + PlotlyGraphWidget.prototype.createOrUpdateChart = function () { if (!this.plotlyJSON) { this.deleteChart(); @@ -52,7 +66,7 @@ define(['./lib/plotly.min',], function (Plotly) { if (!this.created && !_.isEmpty(this.plotlyJSON)) { Plotly.newPlot(this.$el[0], this.plotlyJSON); this.created = true; - } else if(!_.isEmpty(this.plotlyJSON)) { + } else if (!_.isEmpty(this.plotlyJSON)) { Plotly.react(this.$el[0], this.plotlyJSON); } } @@ -68,6 +82,10 @@ define(['./lib/plotly.min',], function (Plotly) { this.created = false; }; + PlotlyGraphWidget.prototype.setTextVisibility = function (display) { + display = display ? 'block' : 'none'; + this.$defaultTextDiv.css('display', display); + }; /* * * * * * * * Visualizer life cycle callbacks * * * * * * * */ PlotlyGraphWidget.prototype.destroy = function () { Plotly.purge(this.$el[0]);