diff --git a/src/module/timeLabel.js b/src/module/timeLabel.js index 84a58af..5e14612 100644 --- a/src/module/timeLabel.js +++ b/src/module/timeLabel.js @@ -10,7 +10,8 @@ const TOFIXED_DEICMAL = 1; export const getStepSizeOfYTicks = (maxTimeInSecond, numOfParts) => { const {unitToUse, timeValue} = getTimeUnitAndValueToUse(maxTimeInSecond); let resultStepSize; - resultStepSize = (timeValue * (1.125) / numOfParts); + const getLarger = 1 + (1 / (numOfParts - 1)); + resultStepSize = (timeValue * getLarger / numOfParts); return {resultStepSize, unitToUse}; } diff --git a/src/views/Compare/Dashboard/index.vue b/src/views/Compare/Dashboard/index.vue index e72643a..203bea7 100644 --- a/src/views/Compare/Dashboard/index.vue +++ b/src/views/Compare/Dashboard/index.vue @@ -407,7 +407,7 @@ export default { primeVueSetOption.scales.x.min = minX; primeVueSetOption.scales.x.max = maxX; primeVueSetOption.scales.y.ticks.callback = function (value, index, ticks) { - const {resultStepSize: YTickStepSize, unitToUse} = getStepSizeOfYTicks(maxY, ticks.length); // Stepsize only needs to be calculated once + const {resultStepSize: YTickStepSize, unitToUse} = getStepSizeOfYTicks(ticks[ticks.length - 1].value, ticks.length); // Stepsize only needs to be calculated once return getYTicksByIndex(YTickStepSize, index, unitToUse); } break; @@ -891,7 +891,7 @@ export default { padding: 8, callback: function (value, index, ticks) { // resultStepSize: Y 軸一個刻度的高度的純數值部分,unitToUse則可能是 d,h,m,s 四者之一 - const {resultStepSize, unitToUse} = getStepSizeOfYTicks(maxY, ticks.length); + const {resultStepSize, unitToUse} = getStepSizeOfYTicks(ticks[ticks.length - 1].value, ticks.length); return getYTicksByIndex(resultStepSize, index, unitToUse); }, } diff --git a/src/views/Discover/Performance/index.vue b/src/views/Discover/Performance/index.vue index 5fc1963..0af9db8 100644 --- a/src/views/Discover/Performance/index.vue +++ b/src/views/Discover/Performance/index.vue @@ -411,7 +411,7 @@ export default { primeVueSetOption.scales.y.ticks.callback = function (value, index, ticks) { // resultStepSize: Y 軸一個刻度的高度的純數值部分,unitToUse則可能是 d,h,m,s 四者之一 // ticks.length是動態由 PrimeVue 決定的,例如可能是 6 或是 8 - const {resultStepSize, unitToUse} = getStepSizeOfYTicks(maxY, ticks.length); + const {resultStepSize, unitToUse} = getStepSizeOfYTicks(ticks[ticks.length - 1].value, ticks.length); return getYTicksByIndex(resultStepSize, index, unitToUse); }; primeVueSetOption.scales.y.ticks.stepSize = resultStepSize; @@ -882,7 +882,7 @@ export default { padding: 8, callback: function (value, index, ticks) { // resultStepSize: Y 軸一個刻度的高度的純數值部分,unitToUse則可能是 d,h,m,s 四者之一 - const {resultStepSize, unitToUse} = getStepSizeOfYTicks(maxY, ticks.length); + const {resultStepSize, unitToUse} = getStepSizeOfYTicks(ticks[ticks.length - 1].value, ticks.length); return getYTicksByIndex(resultStepSize, index, unitToUse); }, } @@ -1026,7 +1026,7 @@ export default { padding: 8, callback: function (value, index, ticks) { // resultStepSize: Y 軸一個刻度的高度的純數值部分,unitToUse則可能是 d,h,m,s 四者之一 - const {resultStepSize, unitToUse} = getStepSizeOfYTicks(maxY, ticks.length); + const {resultStepSize, unitToUse} = getStepSizeOfYTicks(ticks[ticks.length - 1].value, ticks.length); return getYTicksByIndex(resultStepSize, index, unitToUse); }, }