b33425c626414803bbddc702caecc256c5022277 max Fri Mar 20 09:10:59 2026 -0700 defining detailsHistogram tdb statements and an example histogram drawing code for it, used in the trexplorer track, refs #37273 diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c index fafdfa1af60..ba853ae81d5 100644 --- src/hg/hgc/hgc.c +++ src/hg/hgc/hgc.c @@ -1745,51 +1745,69 @@ if (strchr(tmp->name, '|')) { title = strchr(fieldName, '|'); *title++ = 0; } struct embeddedTbl *new; AllocVar(new); new->field = fieldName; new->title = title != NULL ? cloneString(title) : fieldName; slAddHead(retList, new); slNameAddHead(retFieldNames, fieldName); hashAdd(embeddedTblHash, fieldName, new); } } -void printFieldLabel(char *entry) +static void printFieldLabelInner(char *entry, char *fieldName) /* print the field label, the first column in the table, as a <td>. Allow a * longer description after a |-char, as some fields are not easy to - * understand. */ + * understand. If fieldName is not NULL, add id="bfld_<fieldName>" to <tr>. */ { char *afterPipe = strchr(entry, '|'); if (afterPipe) *afterPipe = 0; +if (fieldName) + printf("<tr id=\"bfld_%s\"><td>%s", fieldName, entry); +else printf("<tr><td>%s", entry); if (afterPipe) { // Could also have a "?" icon and show the description on mouse over afterPipe++; // skip past | character printf("<br><span class='bedExtraTblNote'>%s</small>", afterPipe); } puts("</td>"); } +void printFieldLabel(char *entry) +/* print the field label, the first column in the table, as a <td>. Allow a + * longer description after a |-char, as some fields are not easy to + * understand. */ +{ +printFieldLabelInner(entry, NULL); +} + +void printFieldLabelWithId(char *entry, char *fieldName) +/* Like printFieldLabel but adds id="bfld_<fieldName>" to the <tr> element, + * so JavaScript can find the row by field name. */ +{ +printFieldLabelInner(entry, fieldName); +} + #define TDB_STATICTABLE_SETTING "extraDetailsTable" #define TDB_STATICTABLE_SETTING_2 "detailsStaticTable" int extraFieldsPrintAs(struct trackDb *tdb,struct sqlResult *sr,char **fields,int fieldCount, struct asObject *as) // Any extra bed or bigBed fields (defined in as and occurring after N in bed N + types. // sr may be null for bigBeds. // Returns number of extra fields actually printed. { // We are trying to print extra fields so we need to figure out how many fields to skip int start = extraFieldsStart(tdb, fieldCount, as); struct asColumn *col = as->columnList; char *urlsStr = trackDbSettingClosestToHomeOrDefault(tdb, "urls", NULL); struct hash* fieldToUrl = hashFromString(urlsStr); boolean skipEmptyFields = trackDbSettingOn(tdb, "skipEmptyFields"); @@ -1914,31 +1932,31 @@ printf("<br><table class='bedExtraTbl'>"); // split this table to separate current row from the previous one, if the trackDb option is set if (sepFields && slNameInList(sepFields, fieldName)) printf("</tr></table>\n<p>\n<table class='bedExtraTbl'>"); // field description char *entry; if (sameString(fieldName, "cdsStartStat") && sameString("enum('none','unk','incmpl','cmpl')", col->comment)) entry = "Status of CDS start annotation (none, unknown, incomplete, or complete)"; else if (sameString(fieldName, "cdsEndStat") && sameString("enum('none','unk','incmpl','cmpl')", col->comment)) entry = "Status of CDS end annotation (none, unknown, incomplete, or complete)"; else entry = col->comment; - printFieldLabel(entry); + printFieldLabelWithId(entry, fieldName); if (col->isList || col->isArray || col->lowType->stringy || asTypesIsInt(col->lowType->type)) printIdOrLinks(col, fieldToUrl, tdb, fields[ix]); else if (asTypesIsFloating(col->lowType->type)) { double valDouble = strtod(fields[ix],NULL); if (errno == 0 && valDouble != 0) printf("<td>%g</td></tr>\n", valDouble); else printf("<td>%s</td></tr>\n", fields[ix]); // decided not to print error } else printf("<td class='bedExtraTblVal'>%s</td></tr>\n", fields[ix]); printCount++; }