2e02e6d00e98c4b404bf4f0b4bfb164d9390f1f6 hiram Tue Nov 10 09:14:09 2020 -0800 now passing fontSize to js and sending number of data values for mouseOver mean detection refs #21980 diff --git src/hg/hgTracks/wigTrack.c src/hg/hgTracks/wigTrack.c index 75ca4e3..f73de33 100644 --- src/hg/hgTracks/wigTrack.c +++ src/hg/hgTracks/wigTrack.c @@ -845,31 +845,31 @@ wgo->yOff = yOff; return wgo; } /* prototype version of mouseOverData using this static array, * will alter this to be a private linked list */ static struct wigMouseOver *mouseOverData = NULL; static int mouseOverIdx = -1; struct wigMouseOver { int x1; /* beginning of a rectangle for this value */ int x2; /* end of the rectangle */ double value; /* data value for this region */ - boolean mean; /* if data value is mean */ + int valueCount; /* number of data values in this rectangle */ }; void graphPreDraw(struct preDrawElement *preDraw, int preDrawZero, int width, struct track *tg, void *image, WigVerticalLineVirtual vLine, int xOff, int yOff, double *yOffsets, int numTrack, double graphUpperLimit, double graphLowerLimit, double graphRange, double epsilon, Color *colorArray, enum trackVisibility vis, struct wigCartOptions *wigCart, struct pixelCountBin *pixelBins) /* graph the preDraw array */ { int x1; int h = tg->lineHeight; /* the height of our drawing window */ double scaleFactor = h/graphRange; Color oldDrawColor = colorArray[0] + 1; /* Just to be different from 1st drawColor. */ Color mediumColor = MG_BLACK; // Will be overriden Color lightColor = MG_BLACK; // Will be overriden @@ -907,49 +907,45 @@ /* ===== mouseOver calculations===== */ if (enableMouseOver) { if (!skipMouseOvers && (p->count > 0)) /* checking mouseOver construction */ { if (p->count > 0) /* allow any number of values to display */ { double thisValue = p->sumData/p->count; /* average if 2 */ if (mouseOverX2 < 0) /* first valid data found */ { ++mouseOverIdx; mouseOverX2 = x1+1; mouseOverData[mouseOverIdx].x1 = x1; mouseOverData[mouseOverIdx].x2 = mouseOverX2; mouseOverData[mouseOverIdx].value = thisValue; - mouseOverData[mouseOverIdx].mean = FALSE; - if (p->count > 1) - mouseOverData[mouseOverIdx].mean = TRUE; + mouseOverData[mouseOverIdx].valueCount = p->count; previousValue = thisValue; } else /* see if we need a new item */ { if (fabs(thisValue - previousValue) > epsilonLimit) { /* finish off the existing run of data */ mouseOverData[mouseOverIdx].x2 = mouseOverX2; mouseOverX2 = x1+1; ++mouseOverIdx; mouseOverData[mouseOverIdx].x1 = x1; mouseOverData[mouseOverIdx].x2 = mouseOverX2; mouseOverData[mouseOverIdx].value = thisValue; - mouseOverData[mouseOverIdx].mean = FALSE; - if (p->count > 1) - mouseOverData[mouseOverIdx].mean = TRUE; + mouseOverData[mouseOverIdx].valueCount = p->count; previousValue = thisValue; } else /* continue run of same data value */ mouseOverX2 = x1+1; } } else skipMouseOvers = TRUE; /* has become too dense to make sense */ } else /* perhaps entered region without values after some data already */ { if (mouseOverX2 > 0) /* yes, been in data, end it here */ { mouseOverData[mouseOverIdx].x2 = mouseOverX2; mouseOverX2 = -1; /* start over with new data when found */ @@ -1471,31 +1467,31 @@ trashDirFile(&jsonData, "hgt", tg->track, ".json"); FILE *trashJson = mustOpen(jsonData.forCgi, "w"); struct jsonWrite *jw = jsonWriteNew(); jsonWriteObjectStart(jw, NULL); jsonWriteListStart(jw, tg->track); int i; /* could put up a 'no data' box when these items are not contiguous * e.g. when gaps interrupt the track data */ for (i = 0; i <= mouseOverIdx; ++i) { jsonWriteObjectStart(jw, NULL); jsonWriteNumber(jw, "x1", (long long)mouseOverData[i].x1); jsonWriteNumber(jw, "x2", (long long)mouseOverData[i].x2); jsonWriteDouble(jw, "v", mouseOverData[i].value); - jsonWriteBoolean(jw, "m", mouseOverData[i].mean); + jsonWriteNumber(jw, "c", mouseOverData[i].valueCount); jsonWriteObjectEnd(jw); } jsonWriteListEnd(jw); jsonWriteObjectEnd(jw); fputs(jw->dy->string,trashJson); carefulClose(&trashJson); mouseOverIdx = -1; freez(&mouseOverData); if (! beenHereDoneThat ) { hPrintf("<div id='mouseOverVerticalLine' class='mouseOverVerticalLine'></div>\n"); hPrintf("<div id='mouseOverText' class='mouseOverText'></div>\n"); // hPrintf("<div id='mouseDbg'><span id='debugMsg'><p>. . . mouseDbg</p></span></div>\n"); beenHereDoneThat = TRUE; }