We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to build a bar chart like this? Sum of values are placed above the bar
Thanks
The text was updated successfully, but these errors were encountered:
I would like to know if you already fixed this issue, would you mind sharing it? Thanks.
Sorry, something went wrong.
@mackyfamous here it is!
var yVals = [BarChartDataEntry]() for item in chartDataItems { let sum = item.yValues.reduce(0, +) let data = String(format: "%.0f", sum) as AnyObject let entry = BarChartDataEntry(x: item.x, yValues: item.yValues, data: data) yVals.append(entry) } let set = BarChartDataSet(values: yVals, label: nil) set.valueFormatter = IndexValueFormatter()
class IndexValueFormatter: IValueFormatter { func stringForValue(_ value: Double, entry: ChartDataEntry, dataSetIndex: Int, viewPortHandler: ViewPortHandler?) -> String { let barEntry = entry as! BarChartDataEntry let nonEmpty = barEntry.yValues?.filter({ $0 > 0 })// removes zero-item guard nonEmpty?.last == value else { return "" } return entry.data as! String } }
No branches or pull requests
Is it possible to build a bar chart like this? Sum of values are placed above the bar
Thanks
The text was updated successfully, but these errors were encountered: