messere1 opened a new pull request, #6137:
URL: https://github.com/apache/rocketmq-dashboard/pull/6137

   ### What problem does this PR solve?
   
   The dashboard throughput sparkline (`MiniBar`) renders invalid samples as 
traffic:
   
   ```ts
   const max = Math.max(...data, 1);
   height: `${value === 0 ? 0 : Math.max(4, (value / max) * height)}px`
   ```
   
   - A negative sample (a monotonic broker counter reset between collection 
windows produces negative deltas) is rendered as a visible 4px traffic bar 
instead of no traffic.
   - A non-finite sample (a failed collection window) poisons `Math.max`, so 
every bar computes `NaNpx` — an invalid CSS height the browser discards, 
collapsing the whole sparkline.
   
   Original report: #1680 (issue closed as not planned by the stale sweep, not 
invalidated as fixed).
   
   ### What is changed and how it works?
   
   Samples are normalized to a finite non-negative value once, before the 
maximum, the rendered heights and the default accessible label are computed:
   
   ```ts
   const normalizedData = data.map((value) => (Number.isFinite(value) ? 
Math.max(0, value) : 0));
   ```
   
   Valid positive samples keep their current relative heights and minimum 
visibility; negative and non-finite samples read as zero, both in the bars and 
in the localized `aria-label`.
   
   ### Verifies
   
   - [x] `npx vitest run src/components/__tests__/MiniBar.test.tsx` — 7/7 pass; 
the new regression test fails on the unpatched tip (bars end up with 
discarded/empty heights for `[-5, NaN, Infinity, 10]`).
   - [x] `npx eslint` on the touched files — clean.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to