Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Long X-Axis Labels Hidden #301

Open
kronos317 opened this issue May 15, 2017 · 2 comments
Open

Long X-Axis Labels Hidden #301

kronos317 opened this issue May 15, 2017 · 2 comments

Comments

@kronos317
Copy link

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.

@Sam-Spencer
Copy link
Collaborator

... 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
Copy link
Collaborator

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

@Sam-Spencer Sam-Spencer marked this as a duplicate of #294 Jul 21, 2017
@Sam-Spencer Sam-Spencer self-assigned this Jul 21, 2017
@Sam-Spencer Sam-Spencer changed the title xAxisLabels not showing Long X-Axis Labels Hidden Jul 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants