Skip to content

Commit

Permalink
limit number of y-axis labels
Browse files Browse the repository at this point in the history
  • Loading branch information
woheller69 committed Apr 16, 2023
1 parent 3314f62 commit b683856
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,16 @@ public void onLongItemClick(View view, int position) {
if (energyDay>energyMax) energyMax=energyDay;
}

//Calculate step size. Target: 4 <= steps < 10, but step size must integer >= 1
//Calculate step size. Target: 4 <= steps <= 7, but step size must integer >= 1
int stepSize = 1;
int numSteps;

do {
numSteps = (int) (energyMax / stepSize);
if (numSteps > 10) stepSize *=10;
else if (numSteps < 4) stepSize /=2;
} while (numSteps > 10 || numSteps < 4 && stepSize>0);
do {
numSteps = (int) (energyMax / stepSize);
if (numSteps > 10) stepSize *=10;
else if (numSteps > 7) stepSize *=2;
else if (numSteps < 4) stepSize /=2;
} while (numSteps > 7 || numSteps < 4 && stepSize>0);

if (stepSize<1) stepSize=1; //Step size must be integer, min 1

Expand Down

0 comments on commit b683856

Please sign in to comment.