BEMSimpleLineGraph icon indicating copy to clipboard operation
BEMSimpleLineGraph copied to clipboard

Long X-Axis Labels Hidden

Open kronos317 opened this issue 7 years ago • 2 comments

First of all, thank you for creating such awesome graph library. It's really easy to use and customize.

I have xAxisLabel issue while using this library. They were not showing at all at first integration. I did some debugging, and I found the reason.

In BEMSimpleLineGraphView.m file, you created drawXAsis method. This was creating xAxisLabels and adding to graph view.

Btw, they were just removed right after added, by the following code in this method.

for (UILabel *l in overlapLabels) {
    [l removeFromSuperview];
}

The reason was, fullyContainsLabel was being set NO.

BOOL fullyContainsLabel = CGRectContainsRect(self.bounds, label.frame);

From debugging, what I found is,

self.bounds.size = (280, 210)
label.frame = ({some value}, 194.66000003, size (width = {some value}, height = 15.34000000))

This means, the bottom edge of label goes beyond the height of graph view.

Personally, I think, it makes more sense if we show label as long as it intersects with graph view, because we need to show the label even if it is showing partially.

So, I changed the line to

BOOL intersectsLabel = CGRectIntersectsRect(self.bounds, label.frame);

And it worked very well.

Also, I was having special requirements that, I need to show the y-axis values in formatted string like $20K, and dot-values being $18,237 which were not possible by just using formattedString.

So, I defined some delegate methods and used it. If you don't mind, I may fork your repo and send PR.

Please let me know your thoughts.

kronos317 avatar May 15 '17 12:05 kronos317

... we need to show the label even if it is showing partially....

I do not quite agree with this; as I think a label should be displayed in full or appropriately scaled if there isn't enough room to show it.

If you don't mind, I may fork your repo and send PR.

Absolutely! Looking forward to it!

Sam-Spencer avatar Jul 18 '17 19:07 Sam-Spencer

Upon further review this bug report may be a duplicate of #294.

Sam-Spencer avatar Jul 21 '17 19:07 Sam-Spencer