ChartsOrg / ChartsOrg/Charts

How to set different values for data and legend entries

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

Description

I'm trying to set different values for dataset entry and legend entry, but it does not work.

Need:
PieChartDataEntry: number
ChartLegendEntry: text

Extra:
Also, I can not find how to swap position of percentages and value labels?
How to hide the number and percent value in a small slice?

Thank you in advance!

![2017-06-29 16 49 21](https://user-images.githubusercontent.com/13317173/27691014-81c8b7f4-5ceb-11e7-9b70-746b46012967.png)
![2017-06-29 16 49 09](https://user-images.githubusercontent.com/13317173/27691016-81eecd40-5ceb-11e7-89ec-3acffa2c9022.png)

for (int i = 0; i < parties.count; i++) {

float value = (arc4random_uniform(mult) + mult / 5);
[values addObject:[[PieChartDataEntry alloc] initWithValue:value
label:[NSString stringWithFormat:@"%.0f", value]]];

ChartLegendEntry *entry = [[ChartLegendEntry alloc] init];
entry.label = parties[i];
[legendEntries addObject:entry];
}

_pieChartView.legend.entries = legendEntries;


PieChartDataSet *dataSet = [[PieChartDataSet alloc] initWithValues:values label:@""];

dataSet.colors = colors;

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

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.