diff --git a/platform/features/plot/src/SubPlot.js b/platform/features/plot/src/SubPlot.js index 06b7f7bb0f..dfcaadf352 100644 --- a/platform/features/plot/src/SubPlot.js +++ b/platform/features/plot/src/SubPlot.js @@ -64,6 +64,16 @@ define( this.updateTicks(); } + /** + * Tests whether this subplot has domain data to show for the current pan/zoom level. Absence of domain data + * implies that there is no range data displayed either + * @returns {boolean} true if domain data exists for the current pan/zoom level + */ + SubPlot.prototype.hasDomainData = function() { + return this.panZoomStack + && this.panZoomStack.getDimensions()[0] > 0; + }; + // Utility function for filtering out empty strings. function isNonEmpty(v) { return typeof v === 'string' && v !== ""; @@ -253,7 +263,10 @@ define( this.hovering = true; this.subPlotBounds = $event.target.getBoundingClientRect(); this.mousePosition = this.toMousePosition($event); - this.updateHoverCoordinates(); + //If there is a domain to display, show hover coordinates, otherwise hover coordinates are meaningless + if (this.hasDomainData()) { + this.updateHoverCoordinates(); + } if (this.marqueeStart) { this.updateMarqueeBox(); } diff --git a/platform/features/plot/src/elements/PlotTickGenerator.js b/platform/features/plot/src/elements/PlotTickGenerator.js index af18050955..f759b6bcd6 100644 --- a/platform/features/plot/src/elements/PlotTickGenerator.js +++ b/platform/features/plot/src/elements/PlotTickGenerator.js @@ -53,7 +53,8 @@ define( for (i = 0; i < count; i += 1) { result.push({ - label: format(i * step + start) + //If data to show, display label for each tick line, otherwise show lines but suppress labels. + label: span > 0 ? format(i * step + start) : '' }); } diff --git a/platform/features/plot/test/SubPlotSpec.js b/platform/features/plot/test/SubPlotSpec.js index 58cd19faab..f7a7b667e9 100644 --- a/platform/features/plot/test/SubPlotSpec.js +++ b/platform/features/plot/test/SubPlotSpec.js @@ -157,6 +157,15 @@ define( ); }); + it ("indicates when there is domain data shown", function () { + expect(subplot.hasDomainData()).toEqual(true); + }); + + it ("indicates when there is no domain data shown", function () { + mockPanZoomStack.getDimensions.andReturn([0,0]); + expect(subplot.hasDomainData()).toEqual(false); + }); + it("disallows marquee zoom when start and end Marquee is at the same position", function () { expect(mockPanZoomStack.pushPanZoom).not.toHaveBeenCalled();