ad8f916db4351444eadeec304af3391c4b07b4af
tdreszer
  Tue Apr 30 16:18:14 2013 -0700
Fixed rightClick update of wigColorBy tracks. ref #10512  On ajax single track update the whole tracklist is not generated.  Therefore, the colorBy track is not in the trackHash and must be created when needed.
diff --git src/hg/hgTracks/wigTrack.c src/hg/hgTracks/wigTrack.c
index a63eb4a..4d2f56e 100644
--- src/hg/hgTracks/wigTrack.c
+++ src/hg/hgTracks/wigTrack.c
@@ -770,32 +770,38 @@
 	{
 	double dataValue;	/*	the data value in data space	*/
 
 	dataValue = preDraw[preDrawIndex].smooth;
 	/*	negative data is the alternate color	*/
 	if (dataValue < 0.0)
 	    colorArray[x1] = tg->ixAltColor;
 	else
 	    colorArray[x1] = tg->ixColor;
 	}
     }
 
 /* Fill in colors from alternate track if necessary. */
 if (colorTrack != NULL)
     {
-    struct track *cTrack = hashMustFindVal(trackHash, colorTrack);
-
+    struct track *cTrack = hashFindVal(trackHash, colorTrack);
+    if (cTrack == NULL) // rightClick update of wigColorBy track may not have colorTrack in hash
+        {               // so create it on the fly
+        struct trackDb *tdb = hTrackDbForTrack(database,colorTrack);
+        if (tdb != NULL)
+            cTrack = trackFromTrackDb(tdb);
+        }
+    if (cTrack != NULL)
     wigFillInColorArray(tg, hvg, colorArray, width, cTrack);
     }
 
 return colorArray;
 }
 
 void vLineViaHvg(void *image, int x, int y, int height, Color color)
 /* A vertical line drawer that works via hvGfx system. */
 {
 hvGfxBox(image, x, y, 1, height, color);
 }
 
 Color somewhatLighterColor32(Color color)
 /* Get a somewhat lighter shade of a color - 1/3 of the way towards white. 
  * Specialized here to bypass image parameter requirement.*/