Fix getYTicksByIndex truncating integers by using toFixed
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -76,11 +76,7 @@ const getTimeUnitAndValueToUse = (secondToDecide) => {
|
||||
* @returns {string} The formatted tick label (e.g. "2.5h").
|
||||
*/
|
||||
export function getYTicksByIndex(stepSize, index, unitToUse) {
|
||||
const rawStepsizeMultIndex = (stepSize * index).toString();
|
||||
const shortenStepsizeMultIndex = rawStepsizeMultIndex.substring(
|
||||
0,
|
||||
rawStepsizeMultIndex.indexOf(".") + 1 + TOFIXED_DECIMAL,
|
||||
);
|
||||
const shortenStepsizeMultIndex = (stepSize * index).toFixed(TOFIXED_DECIMAL);
|
||||
return `${shortenStepsizeMultIndex}${unitToUse}`;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ describe("getStepSizeOfYTicks", () => {
|
||||
|
||||
describe("getYTicksByIndex", () => {
|
||||
it("formats tick label with unit", () => {
|
||||
expect(getYTicksByIndex(2, 3, "h")).toBe("6h");
|
||||
expect(getYTicksByIndex(2, 3, "h")).toBe("6.0h");
|
||||
});
|
||||
|
||||
it("truncates to 1 decimal place", () => {
|
||||
|
||||
Reference in New Issue
Block a user