63abfc194497bf296afda0797dd8d6c47b6d69f2
chmalee
  Fri Mar 11 10:22:32 2022 -0800
Changes from code review. Advance the x coordinate of the next bar in a barChart by the barWidth of the previous bar, which may be from our dynamic calculation or a user defined min width, refs #29060

diff --git src/hg/hgTracks/barChartTrack.c src/hg/hgTracks/barChartTrack.c
index 0a9dce2..83efba9 100644
--- src/hg/hgTracks/barChartTrack.c
+++ src/hg/hgTracks/barChartTrack.c
@@ -782,31 +782,32 @@
 for (i=0, categ=extras->categories; i<expCount && categ != NULL; i++, categ=categ->next)
     {
     if (!filterCategory(extras, categ->name))
         continue;
     struct rgbColor fillColor = extras->colors[i];
     int fillColorIx = hvGfxFindColorIx(hvg, fillColor.r, fillColor.g, fillColor.b);
     double expScore = bed->expScores[i];
     int height = valToClippedHeight(expScore, extras->maxMedian, extras->maxViewLimit, 
                                         extras->maxHeight, extras->doLogTransform);
     boolean isClipped = (!extras->doLogTransform && expScore > extras->maxViewLimit);
     int barTop = yZero - height + 1;
     if (extras->padding == 0 || sameString(colorScheme, BAR_CHART_COLORS_USER))
         {
         int cStart = barsDrawn * graphWidth * invCount;
         int cEnd = (barsDrawn+1) * graphWidth * invCount;
-        x1 = cStart + x0;
+        if (i >= 1)
+            x1 += barWidth + extras->padding;
         barWidth = max(userMinBarWidth, cEnd - cStart - extras->padding);
         if (x1 + barWidth > x0 + graphWidth)
             break;
         hvGfxBox(hvg, x1, barTop, barWidth, height, fillColorIx);
         if (isClipped)
             hvGfxBox(hvg, x1, barTop, barWidth, 2, clipColor);
         barsDrawn += 1;
         }
     else
         {
         hvGfxOutlinedBox(hvg, x1, barTop, barWidth, height, fillColorIx, lineColorIx);
         // mark clipped bar with magenta tip
         if (isClipped)
             hvGfxBox(hvg, x1, barTop, barWidth, 2, clipColor);
         x1 = x1 + barWidth + extras->padding;