|
76 | 76 | const seriesColors = ["#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9", "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1"];
|
77 | 77 | const interpolatedColor = "#fcb0f1";
|
78 | 78 |
|
79 |
| - function tooltipPlugin({onclick, commits, isInterpolated, shiftX = 10, shiftY = 10}) { |
| 79 | + function tooltipPlugin({onclick, commits, isInterpolated, absoluteMode, shiftX = 10, shiftY = 10}) { |
80 | 80 | let tooltipLeftOffset = 0;
|
81 | 81 | let tooltipTopOffset = 0;
|
82 | 82 |
|
|
96 | 96 | tooltip.style.left = (tooltipLeftOffset + lft + shiftY) + "px";
|
97 | 97 |
|
98 | 98 | tooltip.style.borderColor = isInterpolated(dataIdx) ? interpolatedColor : seriesColors[seriesIdx - 1];
|
99 |
| - let pctSinceStart = (((u.data[seriesIdx][dataIdx] - u.data[seriesIdx][0]) / u.data[seriesIdx][0]) * 100).toFixed(2); |
| 99 | + let trailer = ""; |
| 100 | + if (absoluteMode) { |
| 101 | + let pctSinceStart = (((u.data[seriesIdx][dataIdx] - u.data[seriesIdx][0]) / u.data[seriesIdx][0]) * 100).toFixed(2); |
| 102 | + trailer = uPlot.fmtNum(u.data[seriesIdx][dataIdx]) + "(" + |
| 103 | + pctSinceStart + "% since start)"; |
| 104 | + } else { |
| 105 | + trailer = uPlot.fmtNum(u.data[seriesIdx][dataIdx]) + "% since start"; |
| 106 | + } |
100 | 107 | tooltip.textContent = (
|
101 |
| - fmtDate(new Date(u.data[0][dataIdx] * 1e3)) + " - " + commits[dataIdx][1].slice(0,10) + "\n" + |
102 |
| - uPlot.fmtNum(u.data[seriesIdx][dataIdx]) + "(" + pctSinceStart + "% since start)" |
| 108 | + fmtDate(new Date(u.data[0][dataIdx] * 1e3)) + " - " + |
| 109 | + commits[dataIdx][1].slice(0,10) + "\n" + trailer |
103 | 110 | );
|
104 | 111 | }
|
105 | 112 |
|
|
160 | 167 | };
|
161 | 168 | }
|
162 | 169 |
|
163 |
| - function genPlotOpts({title, width, height, yAxisLabel, series, commits, stat, isInterpolated, alpha = 0.3, prox = 5}) { |
| 170 | + function genPlotOpts({title, width, height, yAxisLabel, series, commits, |
| 171 | + stat, isInterpolated, alpha = 0.3, prox = 5, absoluteMode}) { |
164 | 172 | return {
|
165 | 173 | title,
|
166 | 174 | width,
|
|
183 | 191 | },
|
184 | 192 | scales: {
|
185 | 193 | y: {
|
186 |
| - range: (self, dataMin, dataMax) => uPlot.rangeNum(0, dataMax, 0.2, true) |
| 194 | + range: (self, dataMin, dataMax) => uPlot.rangeNum(absoluteMode ? 0 : dataMin, dataMax, 0.2, true) |
187 | 195 | }
|
188 | 196 | },
|
189 | 197 | axes: [
|
|
245 | 253 | },
|
246 | 254 | commits,
|
247 | 255 | isInterpolated,
|
| 256 | + absoluteMode, |
248 | 257 | }),
|
249 | 258 | ],
|
250 | 259 | };
|
|
273 | 282 | } else if (state.stat == "faults") {
|
274 | 283 | yAxis = "Faults";
|
275 | 284 | }
|
| 285 | + if (!state.absolute) { |
| 286 | + yAxis = "% change from baseline"; |
| 287 | + } |
276 | 288 |
|
277 | 289 | let yAxisLabel = i == 0 ? yAxis : null;
|
278 | 290 |
|
|
309 | 321 | isInterpolated(dataIdx) {
|
310 | 322 | return cacheStates.full.is_interpolated.has(dataIdx);
|
311 | 323 | },
|
| 324 | + absoluteMode: state.absolute, |
312 | 325 | });
|
313 | 326 |
|
314 | 327 | let u = new uPlot(plotOpts, plotData,
|
|
0 commit comments