ChartsOrg / ChartsOrg/Charts

DataSet valueFormatter does not work.

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

Description

DataSet valueFormatter does not work.
When I create a DataSet and specify my value formatter it gets ignored and seems like a new DefaultValueFormatter is used.

```
let dataSet = BarChartDataSet(entries: entries, label: "Amount")
dataSet.colors = [.categoryChart]
dataSet.valueFont = .systemFont(ofSize: 11)
dataSet.valueTextColor = .text

// This never renders the correctly formatted values
dataSet.valueFormatter = DefaultValueFormatter(formatter: Formatters.numberWithSeparatorsRounded)

// if I use this blocked based formatter, it's never invoked
dataSet.valueFormatter = DefaultValueFormatter(block: { (value, entry, index, viewPortHandler) -> String in
// this is never called
return "xxx"
})
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the BarChartDataSet snippet and trace how DataSet.valueFormatter is consumed during value rendering. Confirm that both the DefaultValueFormatter instance and its block are invoked, and that their returned text is displayed; no specific file or test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.