ReetuBok / MIMChart-Library

iPhone/iPad chart library
http://mimchartlibrary.blogspot.com/
173 stars 32 forks source link

Strange behavior of bar chart when values are alike #4

Closed dmi3j closed 9 years ago

dmi3j commented 12 years ago

In case when values for the chart distinguish, we get something like http://d.pr/i/cXYU (In this case the first value is around 7'000, all others around 30'000) But if all the values are alike — http://d.pr/i/yHGI (In this case all the values are around 30'000).

dmi3j commented 12 years ago

As a quick solution may offer following:

In the MIMBarGraph.m on line 753 replace

float pixelPerTile=(maxOfY-minOfY)/(HorLines-1);

with the

float pixelPerTile;

if (maxOfY > 0 && minOfY > 0) {
   pixelPerTile=(maxOfY)/(HorLines-1);
} else if (maxOfY < 0 && minOfY < 0) {
    pixelPerTile=(-minOfY)/(HorLines-1);
} else {
   pixelPerTile=(maxOfY-minOfY)/(HorLines-1);
}