Skip to content

Commit

Permalink
[frequencies panel] Don't round frequencies below 1%
Browse files Browse the repository at this point in the history
When a frequency value is below 1% we now display "<1%" rather than rounding to the nearest integer which could lead to confusing output of  "frequency: 0%".

Closes #1279
  • Loading branch information
jameshadfield committed Mar 9, 2021
1 parent d713de0 commit 135d999
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/frequencies/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ export const drawStream = (
/* what's the closest pivot? */
const date = scales.x.invert(mousex);
const pivotIdx = pivots.reduce((closestIdx, val, idx, arr) => Math.abs(val - date) < Math.abs(arr[closestIdx] - date) ? idx : closestIdx, 0);
const freqVal = Math.round((d[pivotIdx][1] - d[pivotIdx][0]) * 100) + "%";
const frequency = (d[pivotIdx][1] - d[pivotIdx][0]) * 100;
const freqVal = frequency < 1 ? "<1%" : Math.round(frequency) + "%";
const xValueOfPivot = scales.x(pivots[pivotIdx]);
const y1ValueOfPivot = scales.y(d[pivotIdx][1]);
const y2ValueOfPivot = scales.y(d[pivotIdx][0]);
Expand Down

0 comments on commit 135d999

Please sign in to comment.