refine use ticks[ticks.length - 1].value
This commit is contained in:
@@ -10,7 +10,8 @@ const TOFIXED_DEICMAL = 1;
|
|||||||
export const getStepSizeOfYTicks = (maxTimeInSecond, numOfParts) => {
|
export const getStepSizeOfYTicks = (maxTimeInSecond, numOfParts) => {
|
||||||
const {unitToUse, timeValue} = getTimeUnitAndValueToUse(maxTimeInSecond);
|
const {unitToUse, timeValue} = getTimeUnitAndValueToUse(maxTimeInSecond);
|
||||||
let resultStepSize;
|
let resultStepSize;
|
||||||
resultStepSize = (timeValue * (1.125) / numOfParts);
|
const getLarger = 1 + (1 / (numOfParts - 1));
|
||||||
|
resultStepSize = (timeValue * getLarger / numOfParts);
|
||||||
|
|
||||||
return {resultStepSize, unitToUse};
|
return {resultStepSize, unitToUse};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ export default {
|
|||||||
primeVueSetOption.scales.x.min = minX;
|
primeVueSetOption.scales.x.min = minX;
|
||||||
primeVueSetOption.scales.x.max = maxX;
|
primeVueSetOption.scales.x.max = maxX;
|
||||||
primeVueSetOption.scales.y.ticks.callback = function (value, index, ticks) {
|
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);
|
return getYTicksByIndex(YTickStepSize, index, unitToUse);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -891,7 +891,7 @@ export default {
|
|||||||
padding: 8,
|
padding: 8,
|
||||||
callback: function (value, index, ticks) {
|
callback: function (value, index, ticks) {
|
||||||
// resultStepSize: Y 軸一個刻度的高度的純數值部分,unitToUse則可能是 d,h,m,s 四者之一
|
// 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);
|
return getYTicksByIndex(resultStepSize, index, unitToUse);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ export default {
|
|||||||
primeVueSetOption.scales.y.ticks.callback = function (value, index, ticks) {
|
primeVueSetOption.scales.y.ticks.callback = function (value, index, ticks) {
|
||||||
// resultStepSize: Y 軸一個刻度的高度的純數值部分,unitToUse則可能是 d,h,m,s 四者之一
|
// resultStepSize: Y 軸一個刻度的高度的純數值部分,unitToUse則可能是 d,h,m,s 四者之一
|
||||||
// ticks.length是動態由 PrimeVue 決定的,例如可能是 6 或是 8
|
// 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);
|
return getYTicksByIndex(resultStepSize, index, unitToUse);
|
||||||
};
|
};
|
||||||
primeVueSetOption.scales.y.ticks.stepSize = resultStepSize;
|
primeVueSetOption.scales.y.ticks.stepSize = resultStepSize;
|
||||||
@@ -882,7 +882,7 @@ export default {
|
|||||||
padding: 8,
|
padding: 8,
|
||||||
callback: function (value, index, ticks) {
|
callback: function (value, index, ticks) {
|
||||||
// resultStepSize: Y 軸一個刻度的高度的純數值部分,unitToUse則可能是 d,h,m,s 四者之一
|
// 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);
|
return getYTicksByIndex(resultStepSize, index, unitToUse);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -1026,7 +1026,7 @@ export default {
|
|||||||
padding: 8,
|
padding: 8,
|
||||||
callback: function (value, index, ticks) {
|
callback: function (value, index, ticks) {
|
||||||
// resultStepSize: Y 軸一個刻度的高度的純數值部分,unitToUse則可能是 d,h,m,s 四者之一
|
// 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);
|
return getYTicksByIndex(resultStepSize, index, unitToUse);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user