e37bc753fd4ecbc758ea232a79905a139909e75b
kate
  Tue Sep 17 15:44:38 2019 -0700
Add barChartMaxSize setting to limit size of charts (override semantic zoom).  Values are small/medium/large (defaults to large). refs #24161

diff --git src/hg/hgTracks/barChartTrack.c src/hg/hgTracks/barChartTrack.c
index e44efd1..88e249a 100644
--- src/hg/hgTracks/barChartTrack.c
+++ src/hg/hgTracks/barChartTrack.c
@@ -21,30 +21,33 @@
 /* Track extras */
     {
     boolean noWhiteout;         /* Suppress whiteout of graph background (allow highlight, blue lines) */
     double maxMedian;           /* Maximum median across all categories */
     boolean doLogTransform;     /* Log10(x+1) */
     char *unit;                /* Units for category values (e.g. RPKM) */
     struct barChartCategory *categories; /* Category names, colors, etc. */
     int categCount;             /* Count of categories - derived from above */
     char **categNames;          /* Category names  - derived from above */
     char **categLabels;         /* Category labels  - derived from above */
     struct rgbColor *colors;    /* Colors  for all categories */
     struct hash *categoryFilter; /* NULL out excluded factors */
     int maxViewLimit;
 
     // dimensions for drawing
+    char *maxGraphSize;         /* optionally limit graph size (override semantic zoom)
+                                     small, medium, or large (default) */
+
     int squishHeight;           /* Height of item in squish mode (larger than typical) */
     int boxModelHeight;         /* Height of indicator box drawn under graph to show gene extent */
     int modelHeight;            /* Height of box drawn under graph with padding */
     int barWidth;               /* Width of individual bar in pixels */
     int margin;
     int padding;
     int maxHeight;
     };
 
 struct barChartItem
 /* BED item plus computed values for display */
     {
     struct barChartItem *next;  /* Next in singly linked list */
     struct bed *bed;            /* Item coords, name, exp count and values */
     int height;                 /* Item height in pixels */
@@ -320,83 +323,83 @@
 /* Get track UI info */
 struct barChartTrack *extras;
 if (!tg->extraUiData)
     {
     AllocVar(extras);
     tg->extraUiData = extras;
     }
 extras = (struct barChartTrack *)tg->extraUiData;
 
 extras->colors = getCategoryColors(tg);
 
 struct trackDb *tdb = tg->tdb;
 extras->doLogTransform = cartUsualBooleanClosestToHome(cart, tdb, FALSE, BAR_CHART_LOG_TRANSFORM, 
                                                 BAR_CHART_LOG_TRANSFORM_DEFAULT);
 extras->maxMedian = barChartUiMaxMedianScore(tdb);
-extras->noWhiteout = cartUsualBooleanClosestToHome(cart, tdb, FALSE, BAR_CHART_NO_WHITEOUT,
-                                                        BAR_CHART_NO_WHITEOUT_DEFAULT);
-extras->unit = trackDbSettingClosestToHomeOrDefault(tdb, BAR_CHART_UNIT, "");
-
+extras->noWhiteout = cartUsualBooleanClosestToHome(cart, tdb, FALSE, 
+                                                        BAR_CHART_NO_WHITEOUT, BAR_CHART_NO_WHITEOUT_DEFAULT);
 extras->maxViewLimit = (double)cartUsualIntClosestToHome(cart, tg->tdb, FALSE, 
                                 BAR_CHART_MAX_VIEW_LIMIT, BAR_CHART_MAX_VIEW_LIMIT_DEFAULT);
+extras->maxGraphSize = trackDbSettingClosestToHomeOrDefault(tdb, 
+                                BAR_CHART_MAX_GRAPH_SIZE, BAR_CHART_MAX_GRAPH_SIZE_DEFAULT);
+extras->unit = trackDbSettingClosestToHomeOrDefault(tdb, BAR_CHART_UNIT, "");
 
 /* Set barchart dimensions to draw.  For three window sizes */
 #define WIN_MAX_GRAPH 50000
 #define WIN_MED_GRAPH 500000
 
 #define MAX_BAR_CHART_MODEL_HEIGHT     2
 #define MED_BAR_CHART_MODEL_HEIGHT     2
 #define MIN_BAR_CHART_MODEL_HEIGHT     1
 
 #define WIN_MAX_GRAPH 50000
 #define MAX_GRAPH_HEIGHT 175
 #define MAX_BAR_WIDTH 5
 #define MAX_GRAPH_PADDING 2
 
 #define WIN_MED_GRAPH 500000
 #define MED_GRAPH_HEIGHT 100
 #define MED_BAR_WIDTH 3
 #define MED_GRAPH_PADDING 1
 
 #define MIN_BAR_WIDTH 1
 #define MIN_GRAPH_PADDING 0
 
 int scale = (getCategoryCount(tg) < 15 ? 2 : 1);
 long winSize = virtWinBaseCount;
-if (winSize < WIN_MAX_GRAPH)
+if (winSize < WIN_MAX_GRAPH && 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 < WIN_MED_GRAPH)
+else if (winSize < WIN_MED_GRAPH && 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;
     }
 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)
     {
     int categCount = getCategoryCount(tg);
     int expCount = bed->expCount;