more precision in chart data minmax

This commit is contained in:
tjs 2023-02-13 22:31:01 -05:00
parent bc85db22b5
commit 52a84a7268
2 changed files with 11 additions and 6 deletions

View File

@ -363,12 +363,14 @@ const DetailedAreaChart: FunctionComponent<DetailedAreaChartProps> = ({
domain
? domain
: ([dataMin, dataMax]) => {
const difference =
Math.abs(dataMax) - Math.abs(dataMin)
if (difference < 0.1) {
const difference = dataMax - dataMin
if (difference < 0.01) {
return [dataMin - 0.001, dataMax + 0.001]
} else if (difference < 0.1) {
return [dataMin - 0.01, dataMax + 0.01]
} else if (difference < 1) {
return [dataMin - 0.1, dataMax + 0.1]
return [dataMin - 0.1, dataMax + 0.11]
} else if (difference < 10) {
return [dataMin - 1, dataMax + 1]
} else {

View File

@ -43,8 +43,11 @@ const SimpleAreaChart = ({
<XAxis dataKey={xKey} hide />
<YAxis
domain={([dataMin, dataMax]) => {
const difference = Math.abs(dataMax) - Math.abs(dataMin)
if (difference < 0.1) {
const difference = dataMax - dataMin
if (difference < 0.01) {
return [dataMin - 0.001, dataMax + 0.001]
} else if (difference < 0.1) {
return [dataMin - 0.01, dataMax + 0.01]
} else if (difference < 1) {
return [dataMin - 0.1, dataMax + 0.11]