52432fd218c9b33509078dd1514acd021d30439b
braney
  Wed May 11 11:50:25 2016 -0700
fix #17281 bug with stacked bars and only one dataset

diff --git src/hg/hgTracks/multiWig.c src/hg/hgTracks/multiWig.c
index 534a6a4..9ea7ef5 100644
--- src/hg/hgTracks/multiWig.c
+++ src/hg/hgTracks/multiWig.c
@@ -183,31 +183,32 @@
 	continue;
 
     struct preDrawElement *p = pre->preDraw + pre->preDrawZero;
     int width = pre->width;
     int i;
     int offset = numTrack * pre->width;
     int prevOffset = (numTrack - 1) * pre->width;
     for (i=0; i<width; ++i, offset++,prevOffset++)
 	{
 	double val = p->smooth;
 
 	if (p->count)
 	    {
 	    if (yOffsets)
 		yOffsets[offset] = val;
-	    else
+
+            if ((numTrack==0) || (yOffsets == NULL))
 		{
 		if (min > val) min = val;
 		if (max < val) max = val;
 		}
 	    }
 	else if (yOffsets)
 	    {
 	    yOffsets[offset] = 0;
 	    }
 	if (yOffsets && (numTrack > 0))
 	    {
 	    yOffsets[offset] += yOffsets[prevOffset];
 	    if (min > yOffsets[offset]) min = yOffsets[offset];
 	    if (max < yOffsets[offset]) max = yOffsets[offset];
 	    }