lvwerra HF Staff commited on
Commit
acb55be
·
verified ·
1 Parent(s): 9cfa933

Chart: bump right padding to 80px, drop non-record labels (orange records only)

Browse files
Files changed (1) hide show
  1. static/index.html +6 -40
static/index.html CHANGED
@@ -1801,9 +1801,6 @@ const HF_ORANGE_LABEL_BG = 'rgba(255,157,0,0.12)';
1801
  const HF_ORANGE_LABEL_BORDER = 'rgba(255,157,0,0.35)';
1802
  const HF_ORANGE_LABEL_TEXT = '#d97706';
1803
  const NON_BEST_COLOR = '#9ca3af';
1804
- const NON_BEST_LABEL_BG = 'rgba(107,114,128,0.08)';
1805
- const NON_BEST_LABEL_BORDER = 'rgba(107,114,128,0.2)';
1806
- const NON_BEST_LABEL_TEXT = '#6b7280';
1807
  const GRID_COLOR = 'rgba(0,0,0,0.05)';
1808
 
1809
  // Hash of the entries last passed to renderChart. We rebuild the chart only
@@ -1912,40 +1909,10 @@ function renderChart(entries) {
1912
  ctx2.restore();
1913
  }
1914
  };
1915
- const nonBestLabels = {
1916
- id: 'nonBestLabels',
1917
- afterDatasetsDraw(c) {
1918
- const meta = c.getDatasetMeta(2);
1919
- if (!meta?.data) return;
1920
- const ctx2 = c.ctx;
1921
- ctx2.save();
1922
- meta.data.forEach((pt, i) => {
1923
- const e = nonBestData[i];
1924
- if (!e) return;
1925
- const label = `${e.agent} ${e.y.toLocaleString()} bytes`;
1926
- ctx2.font = '500 10px "JetBrains Mono", monospace';
1927
- const tw = ctx2.measureText(label).width;
1928
- const px = 6, boxW = tw + px * 2, boxH = 20, off = 14;
1929
- let lx = pt.x + 10, ly = pt.y + off;
1930
- const a = c.chartArea;
1931
- if (lx + boxW > a.right) lx = pt.x - boxW - 10;
1932
- if (ly + boxH > a.bottom) ly = pt.y - off - boxH;
1933
- ctx2.fillStyle = NON_BEST_LABEL_BG;
1934
- ctx2.strokeStyle = NON_BEST_LABEL_BORDER;
1935
- ctx2.lineWidth = 1;
1936
- ctx2.beginPath(); ctx2.roundRect(lx, ly, boxW, boxH, 5); ctx2.fill(); ctx2.stroke();
1937
- ctx2.fillStyle = NON_BEST_LABEL_TEXT;
1938
- ctx2.textBaseline = 'middle';
1939
- ctx2.fillText(label, lx + px, ly + boxH / 2);
1940
- });
1941
- ctx2.restore();
1942
- }
1943
- };
1944
 
1945
  // Horizontal dashed line per baseline, spanning the full visible x-range.
1946
- // Added *after* the three core datasets so the bestLabels (idx 1) and
1947
- // nonBestLabels (idx 2) plugins continue to find their dataset metas.
1948
- // Identified by name on hover (tooltip), not by always-on labels.
1949
  const BASELINE_COLOR = 'rgba(107,114,128,0.55)';
1950
  const BASELINE_HOVER_COLOR = 'rgba(55,65,81,0.95)';
1951
  const baselineDatasets = baselineEntries.map(e => ({
@@ -1974,9 +1941,8 @@ function renderChart(entries) {
1974
  { label: 'Running Best', data: bestLineData, borderColor: HF_ORANGE, backgroundColor: HF_ORANGE_DIM, borderWidth: 2.5, stepped: 'after', fill: true, pointRadius: 0, pointHoverRadius: 0, tension: 0, order: 2 },
1975
  { label: 'Records', data: bestScatter, type: 'scatter', backgroundColor: HF_ORANGE, borderColor: '#fff', borderWidth: 2, pointRadius: 7, pointHoverRadius: 9, pointStyle: 'circle', order: 1 },
1976
  { label: 'Non-Records', data: nonBestData, type: 'scatter', backgroundColor: NON_BEST_COLOR, borderColor: '#fff', borderWidth: 1.5, pointRadius: 5, pointHoverRadius: 7, pointStyle: 'circle', order: 0 },
1977
- // Negatives: same look as Non-Records (full grey dot, same size).
1978
- // The only difference is the nonBestLabels plugin doesn't draw an
1979
- // always-on label for them; tooltip on hover identifies them.
1980
  { label: 'Negatives', data: negativeData, type: 'scatter', backgroundColor: NON_BEST_COLOR, borderColor: '#fff', borderWidth: 1.5, pointRadius: 5, pointHoverRadius: 7, pointStyle: 'circle', order: 0 },
1981
  ...baselineDatasets,
1982
  ],
@@ -1984,7 +1950,7 @@ function renderChart(entries) {
1984
  options: {
1985
  responsive: true,
1986
  maintainAspectRatio: false,
1987
- layout: { padding: { top: 30, right: 30, bottom: 6, left: 6 } },
1988
  plugins: {
1989
  legend: { display: false },
1990
  tooltip: {
@@ -2049,7 +2015,7 @@ function renderChart(entries) {
2049
  // for long stretches so the swooping-in animation gets repetitive.
2050
  animation: false,
2051
  },
2052
- plugins: [bestLabels, nonBestLabels],
2053
  });
2054
  }
2055
 
 
1801
  const HF_ORANGE_LABEL_BORDER = 'rgba(255,157,0,0.35)';
1802
  const HF_ORANGE_LABEL_TEXT = '#d97706';
1803
  const NON_BEST_COLOR = '#9ca3af';
 
 
 
1804
  const GRID_COLOR = 'rgba(0,0,0,0.05)';
1805
 
1806
  // Hash of the entries last passed to renderChart. We rebuild the chart only
 
1909
  ctx2.restore();
1910
  }
1911
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1912
 
1913
  // Horizontal dashed line per baseline, spanning the full visible x-range.
1914
+ // Added *after* the three core datasets so the bestLabels (idx 1) plugin
1915
+ // continues to find its dataset meta. Identified by name on hover.
 
1916
  const BASELINE_COLOR = 'rgba(107,114,128,0.55)';
1917
  const BASELINE_HOVER_COLOR = 'rgba(55,65,81,0.95)';
1918
  const baselineDatasets = baselineEntries.map(e => ({
 
1941
  { label: 'Running Best', data: bestLineData, borderColor: HF_ORANGE, backgroundColor: HF_ORANGE_DIM, borderWidth: 2.5, stepped: 'after', fill: true, pointRadius: 0, pointHoverRadius: 0, tension: 0, order: 2 },
1942
  { label: 'Records', data: bestScatter, type: 'scatter', backgroundColor: HF_ORANGE, borderColor: '#fff', borderWidth: 2, pointRadius: 7, pointHoverRadius: 9, pointStyle: 'circle', order: 1 },
1943
  { label: 'Non-Records', data: nonBestData, type: 'scatter', backgroundColor: NON_BEST_COLOR, borderColor: '#fff', borderWidth: 1.5, pointRadius: 5, pointHoverRadius: 7, pointStyle: 'circle', order: 0 },
1944
+ // Negatives: same styling as Non-Records, also unlabeled. Tooltip
1945
+ // on hover identifies any non-record dot.
 
1946
  { label: 'Negatives', data: negativeData, type: 'scatter', backgroundColor: NON_BEST_COLOR, borderColor: '#fff', borderWidth: 1.5, pointRadius: 5, pointHoverRadius: 7, pointStyle: 'circle', order: 0 },
1947
  ...baselineDatasets,
1948
  ],
 
1950
  options: {
1951
  responsive: true,
1952
  maintainAspectRatio: false,
1953
+ layout: { padding: { top: 30, right: 80, bottom: 6, left: 6 } },
1954
  plugins: {
1955
  legend: { display: false },
1956
  tooltip: {
 
2015
  // for long stretches so the swooping-in animation gets repetitive.
2016
  animation: false,
2017
  },
2018
+ plugins: [bestLabels],
2019
  });
2020
  }
2021