Trouble customizing label points via stringForValue(value:, entry:, dataSetIndex:, viewPortHandler:)
- 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 have a line chart that uses a temps array to draw the points (the temps are the values). I have a second array of times that match the temps at index. I would like to show the temps and times at the same index for the label point. I have extended IValueFormatter and attempted to use the dataSetIndex to find the index of the value on the linechart, but that only gives me [0] for all of the values.
```
final class ChartsFormatterToDegrees: IValueFormatter {
var times = [String]()
var temps = [Double]()
init(values: [Double], time: [String]) {
times = time
temps = value
}
func stringForValue(_ value: Double, entry: ChartDataEntry, dataSetIndex: Int, viewPortHandler: ViewPortHandler?) -> String {
let str = String()
str = """
\(times[dataSetIndex])
\(Int(value))°
"""
return str
}
```
I also tried counting each time stringForValue(value:, entry:, dataSetIndex:, viewPortHandler:) runs, thinking it would only run as many times as there are label points, but this runs many X times and also does not work:
```
final class ChartsFormatterToDegrees: IValueFormatter {
var times = [String]()
var temps = [Double]()
var count = Int()
init(values: [Double], time: [String]) {
times = time
temps = value
count = 0
}
func stringForValue(_ value: Double, entry: ChartDataEntry, dataSetIndex: Int, viewPortHandler: ViewPortHandler?) -> String {
for i in 0..
Contributor guide
Assessment
This issue has not been assessed yet.