ticks.length solves the Y axis bug.

This commit is contained in:
Cindy Chang
2024-06-17 22:32:57 +08:00
parent 541c0080aa
commit 7750f913a8
3 changed files with 173 additions and 23 deletions

View File

@@ -1,5 +1,4 @@
import moment from 'moment';
const NUM_OF_PARTS_TO_SPLIT = 8;
const TOFIXED_DEICMAL = 1;
/**
@@ -8,11 +7,10 @@ const TOFIXED_DEICMAL = 1;
* @param {number} maxTimeInSecond
* @returns {object} {resultStepSize, unitToUse}
*/
export const getStepSizeOfYTicks = (maxTimeInSecond) => {
const numOfParts = NUM_OF_PARTS_TO_SPLIT;
export const getStepSizeOfYTicks = (maxTimeInSecond, numOfParts) => {
const {unitToUse, timeValue} = getTimeUnitAndValueToUse(maxTimeInSecond);
let resultStepSize;
resultStepSize = (timeValue / numOfParts);
resultStepSize = (timeValue * (1.125) / numOfParts);
return {resultStepSize, unitToUse};
}
@@ -30,17 +28,17 @@ const getTimeUnitAndValueToUse = (secondToDecide) => {
const hh = secondToDecide / hour;
const mm = secondToDecide / minutes;
if (dd > 0) {
if (dd > 0 && dd > 1) {
return {
unitToUse: "d",
timeValue: secondToDecide / day,
};
} else if (hh > 0) {
} else if (hh > 0 && hh > 1) {
return {
unitToUse: "h",
timeValue: secondToDecide / hour,
};
} else if (mm > 0) {
} else if (mm > 0 && mm > 1) {
console.log('mm > 0 && mm > 1', secondToDecide / minutes);
return {
unitToUse: "m",