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

Long X-Axis Labels Hidden #301

@kronos317

Description

@kronos317

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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions