58ecdffac6432e41d3a1a8d355e0e2eeda6e6d5d
kent
  Thu Jan 21 13:41:35 2021 -0800
Tweaking bar widths and spacing at different scales.

diff --git src/hg/hgTracks/barChartTrack.c src/hg/hgTracks/barChartTrack.c
index e9bca0b..e1a4dd6 100644
--- src/hg/hgTracks/barChartTrack.c
+++ src/hg/hgTracks/barChartTrack.c
@@ -367,71 +367,75 @@
 extras->winMedGraph = WIN_MED_GRAPH_DEFAULT;
 char *setting = trackDbSetting(tdb, BAR_CHART_SIZE_WINDOWS);
 if (isNotEmpty(setting))
     {
     char *words[2];
     int ct = chopLine(setting, words);
     if (ct == 2)
         {
         extras->winMaxGraph = atoi(words[0]);
         extras->winMedGraph = atoi(words[1]);
         }
     }
 int barCount = getCategoryCount(tg);
 double scale = 1.0;
 if (barCount <= 20)
-    scale = 2.0;
-else if (barCount <= 50)
-    scale = 1.5;
-else if (barCount <= 100)
+    scale = 2.5;
+else if (barCount <= 40)
+    scale = 1.6;
+else if (barCount <= 60)
     scale = 1.0;
-else if (barCount <= 150)
-    scale = 0.75;
+else if (barCount <= 120)
+    scale = 0.9;
 else if (barCount <= 200)
-    scale = 0.5;
+    scale = 0.75;
 else 
-    scale = 0.25;
+    scale = 0.5;
 
 long winSize = virtWinBaseCount;
 if (winSize < extras->winMaxGraph && 
         sameString(extras->maxGraphSize, BAR_CHART_MAX_GRAPH_SIZE_LARGE))
 {
     extras->boxModelHeight = MAX_BAR_CHART_MODEL_HEIGHT;
     extras->barWidth = MAX_BAR_WIDTH * scale;
     extras->padding = MAX_GRAPH_PADDING;
     extras->maxHeight = MAX_GRAPH_HEIGHT;
     }
 else if (winSize < extras->winMedGraph && 
         differentString(extras->maxGraphSize, BAR_CHART_MAX_GRAPH_SIZE_SMALL))
     {
     extras->boxModelHeight = MED_BAR_CHART_MODEL_HEIGHT;
     extras->barWidth = MED_BAR_WIDTH * scale;
     extras->padding = MED_GRAPH_PADDING;
     extras->maxHeight = MED_GRAPH_HEIGHT;
     }
 else
     {
     extras->boxModelHeight = MIN_BAR_CHART_MODEL_HEIGHT;
     extras->barWidth = MIN_BAR_WIDTH * scale;
     extras->padding = MIN_GRAPH_PADDING;
     extras->maxHeight = tl.fontHeight * 4;
     }
-if (extras->barWidth <= 2)
+if (extras->barWidth == 1 && extras->padding == 1)
    {
-    if (extras->padding > 1)
-	extras->padding = 1;
    extras->barWidth = 2;
+   extras->padding = 0;
+   }
+if (extras->barWidth < 1)
+    {
+    extras->barWidth = 1;
+    extras->padding = 0;
     }
 
 extras->modelHeight =  extras->boxModelHeight + 3;
 extras->margin = 1;
 extras->squishHeight = tl.fontHeight - tl.fontHeight/2;
 
 /* Get bed (names and all-sample category median scores) in range */
 loadSimpleBedWithLoader(tg, (bedItemLoader)barChartSimpleBedLoad);
 
 /* Create itemInfo items with BED and geneModels */
 struct barChartItem *itemInfo = NULL, *list = NULL;
 struct bed *bed = (struct bed *)tg->items;
 
 /* Test that configuration matches data file */
 if (bed != NULL)
@@ -682,31 +686,31 @@
 
 int graphX = barChartX(bed);
 if (graphX < 0)
     return;
 
 // x1 is at left of graph
 x1 = insideX + graphX;
 int i = 0;
 for (categ = categs; categ != NULL; categ = categ->next, i++)
     {
     if (!filterCategory(extras, categ->name))
 	continue;
     double expScore = bed->expScores[i];
     int height = valToClippedHeight(expScore, extras->maxMedian, extras->maxViewLimit,
                                         extras->maxHeight, extras->doLogTransform);
-    mapBoxHc(hvg, itemStart, itemEnd, x1, yZero-height, extras->barWidth, height, 
+    mapBoxHc(hvg, itemStart, itemEnd, x1, yZero-height, extras->barWidth + extras->padding, height, 
                         tg->track, mapItemName, chartMapText(tg, categ, expScore));
     x1 = x1 + extras->barWidth + extras->padding;
     }
 
 // map over background of chart
 int graphWidth = chartWidth(tg, itemInfo);
 getItemX(start, end, &x1, &x2);
 mapBoxHc(hvg, itemStart, itemEnd, x1, y, graphWidth, itemHeight-3,
                     tg->track, mapItemName, itemName);
 }
 
 /* This is lifted nearly wholesale from gtexGene track.  Could be shared */
 
 static int getBarChartHeight(void *item)
 {