Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b9db80949 | |||
| 6cfbcd0408 | |||
| 93608ca8ef |
@@ -8,13 +8,15 @@ import { Sizes } from '../../styles'
|
||||
import { CHART_TICK_WIDTH } from '../../config'
|
||||
|
||||
const Tick = ({ yPosition, height, isBold, shouldShowLabel, label }) => {
|
||||
const top = yPosition - height / 2
|
||||
const top = yPosition - height / 2 - 4
|
||||
const containerStyle = [styles.container, { flexBasis: height, height, top }]
|
||||
const textStyle = isBold ? styles.textBold : styles.textNormal
|
||||
|
||||
if (!shouldShowLabel) return null
|
||||
|
||||
return (
|
||||
<View style={containerStyle}>
|
||||
<AppText style={textStyle}>{shouldShowLabel && label}</AppText>
|
||||
<AppText style={textStyle}>{label}</AppText>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
@@ -36,6 +38,7 @@ const styles = StyleSheet.create({
|
||||
position: 'absolute',
|
||||
right: 0,
|
||||
width: CHART_TICK_WIDTH,
|
||||
minHeight: Sizes.base + 2,
|
||||
},
|
||||
textBold: {
|
||||
fontSize: Sizes.base,
|
||||
|
||||
@@ -3,6 +3,7 @@ import { LocalDate } from '@js-joda/core'
|
||||
import { scaleObservable, unitObservable } from '../../local-storage'
|
||||
import { getCycleStatusForDay } from '../../lib/sympto-adapter'
|
||||
import { getCycleDay, getAmountOfCycleDays } from '../../db'
|
||||
import { Sizes } from '../../styles'
|
||||
|
||||
//YAxis helpers
|
||||
|
||||
@@ -50,15 +51,19 @@ export function getTickList(columnHeight) {
|
||||
const label = tick.toFixed(1)
|
||||
let shouldShowLabel
|
||||
|
||||
// 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 units === 0.1 and tick height is big enough, we show temp values with step 0.2
|
||||
// when units === 0.5 and tick height is not big enough, we show temp values with step 1
|
||||
// otherwise we show temp values with step 0.5
|
||||
|
||||
if (unit === 0.1) {
|
||||
// show label with step 0.2
|
||||
shouldShowLabel = !((label * 10) % 2)
|
||||
} else {
|
||||
// show label with step 0.5
|
||||
shouldShowLabel = !((label * 10) % 5)
|
||||
switch (true) {
|
||||
case unit === 0.1 && tickHeight > Sizes.base + 2:
|
||||
shouldShowLabel = !((label * 10) % 2)
|
||||
break
|
||||
case unit === 0.5 && tickHeight <= Sizes.base + 2:
|
||||
shouldShowLabel = !((label * 10) % 10)
|
||||
break
|
||||
default:
|
||||
shouldShowLabel = !((label * 10) % 5)
|
||||
}
|
||||
|
||||
// don't show label, if first or last tick
|
||||
|
||||
+10
-4
@@ -12,10 +12,16 @@ export const unitObservable = Observable()
|
||||
unitObservable.set(TEMP_SCALE_UNITS)
|
||||
scaleObservable((scale) => {
|
||||
const scaleRange = scale.max - scale.min
|
||||
if (scaleRange <= 1.5) {
|
||||
unitObservable.set(0.1)
|
||||
} else {
|
||||
unitObservable.set(0.5)
|
||||
|
||||
switch (true) {
|
||||
case scaleRange <= 1:
|
||||
unitObservable.set(0.1)
|
||||
break
|
||||
case scaleRange > 1 && scaleRange <= 2:
|
||||
unitObservable.set(0.2)
|
||||
break
|
||||
default:
|
||||
unitObservable.set(0.5)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user