Fixes bug when .8 and .3 labels are not shown in chart
This commit is contained in:
@@ -44,25 +44,19 @@ export function getTickList(columnHeight) {
|
|||||||
return getTickPositions(columnHeight).map((tickPosition, i) => {
|
return getTickPositions(columnHeight).map((tickPosition, i) => {
|
||||||
|
|
||||||
const tick = scaleMax - i * unit
|
const tick = scaleMax - i * unit
|
||||||
let isBold, label, shouldShowLabel
|
const isBold = Number.isInteger(tick) ? true : false
|
||||||
|
const label = tick.toFixed(1)
|
||||||
if (Number.isInteger(tick)) {
|
let shouldShowLabel
|
||||||
isBold = true
|
|
||||||
label = tick.toString() + '.0'
|
|
||||||
} else {
|
|
||||||
isBold = false
|
|
||||||
label = tick.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
// when temp range <= 2, units === 0.1 we show temp values with step 0.2
|
// when temp range <= 2, units === 0.1 we show temp values with step 0.2
|
||||||
// when temp range > 2, units === 0.5 we show temp values with step 0.5
|
// when temp range > 2, units === 0.5 we show temp values with step 0.5
|
||||||
|
|
||||||
if (unit === 0.1) {
|
if (unit === 0.1) {
|
||||||
// show label with step 0.2
|
// show label with step 0.2
|
||||||
shouldShowLabel = !(tick * 10 % 2)
|
shouldShowLabel = !(label * 10 % 2)
|
||||||
} else {
|
} else {
|
||||||
// show label with step 0.5
|
// show label with step 0.5
|
||||||
shouldShowLabel = !(tick * 10 % 5)
|
shouldShowLabel = !(label * 10 % 5)
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't show label, if first or last tick
|
// don't show label, if first or last tick
|
||||||
|
|||||||
Reference in New Issue
Block a user