Skip to content

Commit

Permalink
Change format to 2 decimal places
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoldowsky committed Mar 28, 2024
1 parent 2eebd66 commit d2a767f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/plugins/graph/utilities/graph-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,11 @@ export function lineToAxisIntercepts(iSlope: number, iIntercept: number,
}

export function equationString(slope: number, intercept: number, attrNames: {x: string, y: string}) {
const float = format('.4~r');
const f = Intl.NumberFormat(undefined, { maximumFractionDigits: 2, useGrouping: false});
if (isFinite(slope) && slope !== 0) {
return `<em>${attrNames.y}</em> = ${float(slope)} <em>${attrNames.x}</em> + ${float(intercept)}`;
return `<em>${attrNames.y}</em> = ${f.format(slope)} <em>${attrNames.x}</em> + ${f.format(intercept)}`;
} else {
return `<em>${slope === 0 ? attrNames.y : attrNames.x}</em> = ${float(intercept)}`;
return `<em>${slope === 0 ? attrNames.y : attrNames.x}</em> = ${f.format(intercept)}`;
}
}

Expand Down

0 comments on commit d2a767f

Please sign in to comment.