Skip to content
New issue

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

Fixed: Pie Chart percentage does not display on demo project #5143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ChartsDemo-iOS/Objective-C/Demos/PieChartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,18 @@ - (void)setDataCount:(int)count range:(double)range
dataSet.colors = colors;

PieChartData *data = [[PieChartData alloc] initWithDataSet:dataSet];

[data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:11.f]];
[data setValueTextColor:UIColor.blackColor];

_chartView.data = data;

NSNumberFormatter *pFormatter = [[NSNumberFormatter alloc] init];
pFormatter.numberStyle = NSNumberFormatterPercentStyle;
pFormatter.maximumFractionDigits = 1;
pFormatter.multiplier = @1.f;
pFormatter.percentSymbol = @" %";
[data setValueFormatter:[[ChartDefaultValueFormatter alloc] initWithFormatter:pFormatter]];
[data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:11.f]];
[data setValueTextColor:UIColor.blackColor];

_chartView.data = data;
[_chartView highlightValues:nil];
}

Expand Down
10 changes: 5 additions & 5 deletions ChartsDemo-iOS/Swift/Demos/PieChartViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ class PieChartViewController: DemoBaseViewController {

let data = PieChartData(dataSet: set)

data.setValueFont(.systemFont(ofSize: 11, weight: .light))
data.setValueTextColor(.black)

chartView.data = data

let pFormatter = NumberFormatter()
pFormatter.numberStyle = .percent
pFormatter.maximumFractionDigits = 1
pFormatter.multiplier = 1
pFormatter.percentSymbol = " %"
data.setValueFormatter(DefaultValueFormatter(formatter: pFormatter))

data.setValueFont(.systemFont(ofSize: 11, weight: .light))
data.setValueTextColor(.black)

chartView.data = data
chartView.highlightValues(nil)
}

Expand Down