more precision in chart data minmax
This commit is contained in:
parent
bc85db22b5
commit
52a84a7268
|
@ -363,12 +363,14 @@ const DetailedAreaChart: FunctionComponent<DetailedAreaChartProps> = ({
|
||||||
domain
|
domain
|
||||||
? domain
|
? domain
|
||||||
: ([dataMin, dataMax]) => {
|
: ([dataMin, dataMax]) => {
|
||||||
const difference =
|
const difference = dataMax - dataMin
|
||||||
Math.abs(dataMax) - Math.abs(dataMin)
|
|
||||||
if (difference < 0.1) {
|
if (difference < 0.01) {
|
||||||
|
return [dataMin - 0.001, dataMax + 0.001]
|
||||||
|
} else if (difference < 0.1) {
|
||||||
return [dataMin - 0.01, dataMax + 0.01]
|
return [dataMin - 0.01, dataMax + 0.01]
|
||||||
} else if (difference < 1) {
|
} else if (difference < 1) {
|
||||||
return [dataMin - 0.1, dataMax + 0.1]
|
return [dataMin - 0.1, dataMax + 0.11]
|
||||||
} else if (difference < 10) {
|
} else if (difference < 10) {
|
||||||
return [dataMin - 1, dataMax + 1]
|
return [dataMin - 1, dataMax + 1]
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -43,8 +43,11 @@ const SimpleAreaChart = ({
|
||||||
<XAxis dataKey={xKey} hide />
|
<XAxis dataKey={xKey} hide />
|
||||||
<YAxis
|
<YAxis
|
||||||
domain={([dataMin, dataMax]) => {
|
domain={([dataMin, dataMax]) => {
|
||||||
const difference = Math.abs(dataMax) - Math.abs(dataMin)
|
const difference = dataMax - dataMin
|
||||||
if (difference < 0.1) {
|
|
||||||
|
if (difference < 0.01) {
|
||||||
|
return [dataMin - 0.001, dataMax + 0.001]
|
||||||
|
} else if (difference < 0.1) {
|
||||||
return [dataMin - 0.01, dataMax + 0.01]
|
return [dataMin - 0.01, dataMax + 0.01]
|
||||||
} else if (difference < 1) {
|
} else if (difference < 1) {
|
||||||
return [dataMin - 0.1, dataMax + 0.11]
|
return [dataMin - 0.1, dataMax + 0.11]
|
||||||
|
|
Loading…
Reference in New Issue