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

HorizontalBarChartView:when i set Xvalue = 0,1,2,3..... HorizontalBarChartView some X dont show #2559

Closed
qq912276337 opened this issue Jun 26, 2017 · 1 comment

Comments

@qq912276337
Copy link

No description provided.

@qq912276337 qq912276337 changed the title HorizontalBarChartView:when i set Xvalue = 0,1,2,3..... HorizontalBarChartView X HorizontalBarChartView:when i set Xvalue = 0,1,2,3..... HorizontalBarChartView X some Jun 26, 2017
@qq912276337
Copy link
Author

NSMutableArray *yVals = [[NSMutableArray alloc] init];
for (int i = 0; i < item.values.count; i++)
{
[yVals addObject:[[BarChartDataEntry alloc] initWithX:i * 10 y:[item.values[i] floatValue]]];
}

BarChartDataSet *set1 = nil;
if (_chartView.data.dataSetCount > 0)
{
    set1 = (BarChartDataSet *)_chartView.data.dataSets[0];
    set1.values = yVals;
    [_chartView.data notifyDataChanged];
    [_chartView notifyDataSetChanged];
}
else
{
    set1 = [[BarChartDataSet alloc] initWithValues:yVals label:item.title];
    set1.drawValuesEnabled = YES;// 是否数值显示在柱形图
    
    NSMutableArray *dataSets = [[NSMutableArray alloc] init];
    [dataSets addObject:set1];
    
    BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets];
    [data setValueFont:[UIFont systemFontOfSize:11]];
    data.barWidth = 0.9f;
    _chartView.data = data;
}

@qq912276337 qq912276337 changed the title HorizontalBarChartView:when i set Xvalue = 0,1,2,3..... HorizontalBarChartView X some HorizontalBarChartView:when i set Xvalue = 0,1,2,3..... HorizontalBarChartView some X dont show Jun 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant