ChartsOrg / ChartsOrg/Charts

LineChartRenderer add options to drawValues

Open
#3,467 4 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

* [x] I've read, understood, and done my best to follow the [*CONTRIBUTING guidelines](https://github.com/jjatie/Charts/blob/master/CONTRIBUTING.md).

## What did you do?

I implemented LineChart in my project and tried to subclass LineChartRenderer in order to change offset of values that are drawn in `func drawValues(context: CGContext)`. The problem is that the only option is to copy all code of this method from LineChartRenderer into my subclass, but there are warnings, because `_xBounds` property has **internal** protection level.

## What did you expect to happen?

I would like to be able to control value position of DataSet entries on LineChart. For example, in LineChartRenderer in `func drawValues(context: CGContext)` there is an alignment option, which is always set to `.center`, but I need to set it to `left`.

```
if dataSet.isDrawValuesEnabled {
ChartUtils.drawText(
context: context,
text: formatter.stringForValue(
e.y,
entry: e,
dataSetIndex: i,
viewPortHandler: viewPortHandler),
point: CGPoint(
x: pt.x,
y: pt.y - CGFloat(valOffset) - valueFont.lineHeight),
align: .center,
attributes: [NSAttributedStringKey.font: valueFont, NSAttributedStringKey.foregroundColor: dataSet.valueTextColorAt(j)])
}
```

Also it would be great to change **offset** for **X** and **Y** position.

Is there any option to do that without making **fork**?

## Charts Environment

**Charts version/Branch/Commit Number: 3.1.1 Release **
**Xcode version: 9.3.1**
**Swift version: 4.1**
**Platform(s) running Charts: iOS**
**macOS version running Xcode: 10.13.4**

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.