22ee4e58588dbf633ee93b9c661e08349ff8e908
kent
  Mon Jan 18 20:28:29 2021 -0800
Fixing it so underbar and space should be equivalent in the bar chart labels in the stats file.

diff --git src/hg/hgc/barChartClick.c src/hg/hgc/barChartClick.c
index 230f54e..aa85492 100644
--- src/hg/hgc/barChartClick.c
+++ src/hg/hgc/barChartClick.c
@@ -378,53 +378,63 @@
 static double longestLabelSize(struct barChartCategory *categList)
 /* Get estimate of longest label in pixels */
 {
 MgFont *font = mgHelvetica14Font();
 int longest = 0;
 struct barChartCategory *categ;
 for (categ = categList; categ != NULL; categ = categ->next)
     {
     int size = mgFontStringWidth(font, categ->label);
     if (size > longest)
         longest = size;
     }
 return longest * 1.09;
 }
 
+void deunderbarColumn(struct fieldedTable *ft, char *field)
+/* Ununderbar all of a column inside table because space/underbar gets
+ * so confusing */
+{
+int fieldIx = fieldedTableFindFieldIx(ft, field);
+struct fieldedRow *row;
+for (row = ft->rowList; row != NULL; row = row->next)
+    replaceChar(row->row[fieldIx], '_', ' ');
+}
 
 static void printBarChart(struct barChartBed *chart, struct trackDb *tdb, double maxVal, char *metric)
 /* Plot bar chart without quartiles or anything fancy just using SVG */
 {
 /* Load up input labels, color, and data */
 struct barChartCategory *categs = barChartUiGetCategories(database, tdb);
 int categCount = slCount(categs);
 if (categCount != chart->expCount)
     {
     warn("Problem in %s barchart track. There are %d categories in trackDb and %d in data",
 	tdb->track, categCount, chart->expCount);
     return;
     }
 
 char *statsFile = trackDbSetting(tdb, "barChartStatsUrl");
 struct hash *statsHash = NULL;
 int countStatIx = 0;
 double statsSize = 0.0;
 if (statsFile != NULL)
     {
     char *required[] = {"cluster", "count", "total"};
     struct fieldedTable *ft = fieldedTableFromTabFile(
 	statsFile, statsFile, required, ArraySize(required));
+    deunderbarColumn(ft, "cluster");
     statsHash = fieldedTableIndex(ft, "cluster");
     countStatIx = fieldedTableFindFieldIx(ft, "count");
     statsSize = 8*(fieldedTableMaxColChars(ft, countStatIx)+1);
     }
 
 /* Some constants that control layout */
 double heightPer=18.0;
 double totalWidth=1250.0;
 double borderSize = 1.0;
 
 double headerHeight = heightPer + 2*borderSize;
 double innerHeight=heightPer-borderSize;
 double labelWidth = longestLabelSize(categs) + 9;  // Add some because size is just estimate
 if (labelWidth > totalWidth/2) labelWidth = totalWidth/2;  // Don't let labels take up more than half
 double patchWidth = heightPer;
@@ -461,43 +471,41 @@
     if (maxVal > 0.0)
 	barWidth = barMaxWidth * score/maxVal;
     char *deunder = cloneString(categ->label);
     replaceChar(deunder, '_', ' ');
     printf("<rect x=\"0\" y=\"%g\" width=\"15\" height=\"%g\" style=\"fill:#%06X\"/>\n",
 	yPos, innerHeight, categ->color);
     printf("<rect x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" style=\"fill:#%06X\"/>\n",
 	barOffset, yPos, barWidth, innerHeight, categ->color);
     if (i&1)  // every other time
 	printf("<rect x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" style=\"fill:#%06X\"/>\n",
 	    labelOffset, yPos, labelWidth+statsSize, innerHeight, 0xFFFFFF);
     printf("<text x=\"%g\" y=\"%g\" font-size=\"%g\" clip-path=\"url(#labelClip)\"\">%s</text>\n", 
  	labelOffset, yPos+innerHeight-1, innerHeight-1, deunder);
     if (statsSize > 0.0)
 	{
-	struct fieldedRow *fr = hashFindVal(statsHash, categ->label);
-	if (fr == NULL)
-	    fr = hashFindVal(statsHash, deunder);
+	struct fieldedRow *fr = hashFindVal(statsHash, deunder);
 	if (fr != NULL)
 	    {
 	    printf("<text x=\"%g\" y=\"%g\" font-size=\"%g\" text-anchor=\"end\">%s</text>\n", 
 		statsRightOffset, yPos+innerHeight-1, innerHeight-1, fr->row[countStatIx]);
 	    }
 	}
     printf("<text x=\"%g\" y=\"%g\" font-size=\"%g\">%5.3f</text>\n", 
 	barOffset+barWidth+2, yPos+innerHeight-1, innerHeight-1, score);
     }
-printf("<svg>");
+printf("</svg>");
 }
 
 
 struct asColumn *asFindColByIx(struct asObject *as, int ix)
 /* Find AS column by index */
 {
 struct asColumn *asCol;
 int i;
 for (i=0, asCol = as->columnList; asCol != NULL && i<ix; asCol = asCol->next, i++);
     return asCol;
 }
 
 void doBarChartDetails(struct trackDb *tdb, char *item)
 /* Details of barChart item */
 {