70694f5a2017b74955371ca3ff5e9883cc874083
kent
Mon Dec 6 09:23:30 2021 -0800
Increasing max displayed width of label for a big sloppy data set.
diff --git src/hg/hgc/facetedBar.c src/hg/hgc/facetedBar.c
index 86e2dc6..bb62cc4 100644
--- src/hg/hgc/facetedBar.c
+++ src/hg/hgc/facetedBar.c
@@ -1,137 +1,137 @@
#include "common.h"
#include "hash.h"
#include "hdb.h"
#include "web.h"
#include "hvGfx.h"
#include "trashDir.h"
#include "hCommon.h"
#include "hui.h"
#include "asParse.h"
#include "hgc.h"
#include "trackHub.h"
#include "hgColors.h"
#include "fieldedTable.h"
#include "tablesTables.h"
#include "facetField.h"
#include "barChartBed.h"
#include "hgConfig.h"
#include "facetedTable.h"
#include "facetedBar.h"
struct wrapContext
/* Context used by various wrappers. */
{
int colorIx; /* Index of color in row */
int valIx; /* Where value lives */
double maxVal;/* Maximum of any total value */
};
void wrapVal(struct fieldedTable *table, struct fieldedRow *row,
char *field, char *val, char *shortVal, void *context)
/* Write out wrapper draws a SVG bar*/
{
struct wrapContext *wc = context;
char *color = "#000000";
int colorIx = wc->colorIx;
if (colorIx >= 0)
color = row->row[colorIx];
double x = sqlDouble(val);
int width = 500, height = 13; // These are units of ~2010 pixels or something
double barWidth = (double)width*x/wc->maxVal;
printf("");
printf(" %6.2f", x);
}
struct fieldedTable *addChartVals(struct fieldedTable *table, struct barChartBed *chart)
/* All a new column with chart values */
{
if (chart->expCount != table->rowCount)
errAbort("Mismatch in field counts between %s (%d) and barChartBed (%d)",
table->name, table->rowCount, chart->expCount);
int oldFieldCount = table->fieldCount;
int newFieldCount = oldFieldCount+1;
char *newRow[newFieldCount];
int i;
for (i=0; ifields[i];
newRow[oldFieldCount] = "val";
struct fieldedTable *newTable = fieldedTableNew(table->name, newRow, newFieldCount);
struct fieldedRow *fr;
int rowIx = 0;
for (fr = table->rowList; fr != NULL; fr = fr->next, ++rowIx)
{
for (i=0; irow[i];
char buf[16];
safef(buf, sizeof(buf), "%g", chart->expScores[rowIx]);
newRow[oldFieldCount] = lmCloneString(newTable->lm, buf);
fieldedTableAdd(newTable, newRow, newFieldCount, fr->id);
}
return newTable;
}
void facetedBarChart(char *item, struct barChartBed *chart, struct trackDb *tdb,
double maxVal, char *statsFile, char *facets, char *metric)
{
char *trackName = tdb->track;
struct sqlConnection *conn = sqlConnect(database);
struct hash *wrapperHash = hashNew(0);
/* Write html to make white background */
hInsideStyleToWhite();
/* Set up url that has enough context to get back to us. */
struct dyString *returnUrl = dyStringNew(0);
dyStringPrintf(returnUrl, "../cgi-bin/hgc?g=%s", trackName);
if (item != NULL)
dyStringPrintf(returnUrl, "&i=%s", item);
dyStringPrintf(returnUrl, "&%s", cartSidUrlString(cart));
/* Working within a form we save context. It'd be nice to work outside of form someday. */
printf("\n");
facetedTableFree(&facTab);
sqlDisconnect(&conn);
}