ChartsOrg / ChartsOrg/Charts

Recalculate space on label formatting.

Open
#561 18 comments 0 reactions 0 assignees View on GitHub
enhancement task
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Hi. I found a little issue which i have been struggling a lot, it seems that if i apply a format on the x-labels the API doesn't recalculate the space in the wit the new format.

I'm adding a formatter to add an elipsis (...) when the label is more than 7 characters length just like you can see in the image.

screen shot 2015-11-20 at 5 46 00 pm

All the gray area is the barChartView, If i don't use the formatter i got this

screen shot 2015-11-20 at 5 45 28 pm

The code that i'm using to add the formatter is the following:

Container class:

``` objective-c
ChartXAxis *xAxis = barView.xAxis;
LargeValueFormatter *formatter = [LargeValueFormatter new];
xAxis.valueFormatter = formatter;

```

Formatter class:

``` swift
public func stringForXValue(index: Int, original: String, viewPortHandler: ChartViewPortHandler) -> String {

if original.characters.count > 7 {
return self.addEllipsis(value: original)
} else {
return original
}
}
```

As you can see, without the formatter the chart use in a better way the space, i guess that the problem is that API don't recalculate the bottomContent once that the labels are formatted. I'd like to help with this if you guys can give a little explanations if my diagnosis of the issue is ok and where i can find the code that i need to call to recalculate with the new labels. I guess this could be a great feature.

Thanks in advance. 🤓

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.