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

About bar and line combined #2589

Closed
G-Singularity opened this issue Jul 9, 2017 · 2 comments
Closed

About bar and line combined #2589

G-Singularity opened this issue Jul 9, 2017 · 2 comments

Comments

@G-Singularity
Copy link

Hi, brothers, I got a problem about Charts. I wanna make a chart view with one group bars and one line. I copied the code from ChartsDemo's CombinedChartViewController. CombinedChartViewController had two BarChartDataSet, but I only need one. then I deleted BarChartDataSet2. code become likes this:

  • (BarChartData *)generateBarData
    {
    NSMutableArray<BarChartDataEntry *> *entries1 = [[NSMutableArray alloc] init];

    for (int index = 0; index < ITEM_COUNT; index++)
    {
    [entries1 addObject:[[BarChartDataEntry alloc] initWithX:0.0 y:(arc4random_uniform(25) + 25)]];
    }

    BarChartDataSet *set1 = [[BarChartDataSet alloc] initWithValues:entries1 label:@"Bar 1"];
    [set1 setColor:[UIColor colorWithRed:60/255.f green:220/255.f blue:78/255.f alpha:1.f]];
    set1.valueTextColor = [UIColor colorWithRed:60/255.f green:220/255.f blue:78/255.f alpha:1.f];
    set1.valueFont = [UIFont systemFontOfSize:10.f];
    set1.axisDependency = AxisDependencyLeft;
    set1.highlightEnabled = NO;

    BarChartData *d = [[BarChartData alloc] initWithDataSet:set1];
    float barWidth = 0.9f;
    d.barWidth = barWidth;
    [d setValueFont:[UIFont systemFontOfSize:10.f]];

    return d;
    }

But all bars draw on the same place. they are overlapped. How I solve these overlapped bars?
4431dfd4-faf8-4a21-b108-3e8f2183d74a

@thierryH91200
Copy link
Contributor

try
[entries1 addObject:[[BarChartDataEntry alloc] initWithX:index y:(arc4random_uniform(25) + 25)]];

@G-Singularity
Copy link
Author

@thierryH91200 thanks, brother.I solved it with your help. thierryH means Thierry Henry? The King of gunners ? Are you a Arsenal fans?

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

3 participants