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

[BUG] all-negative Stacked horizontal Bar Chart size is not correct #222

Closed
liuxuan30 opened this issue Jul 16, 2015 · 6 comments
Closed

Comments

@liuxuan30
Copy link
Member

Hi Daniel,
I have updated the code to today's latest, after you fixed some of the bugs, thanks for it.

If I use all negative values for stacked horizontal bar chart in demo code like:

    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-10, @-10 ] xIndex: 0]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-12, @-13 ] xIndex: 1]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-15, @-15 ] xIndex: 2]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-17, @-17 ] xIndex: 3]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-19, @-20 ] xIndex: 4]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-19, @-19 ] xIndex: 5]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-16, @-16 ] xIndex: 6]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-13, @-14 ] xIndex: 7]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-10, @-11 ] xIndex: 8]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-5, @-6 ] xIndex: 9]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-1, @-2 ] xIndex: 10]];

The size of the stack is out of bound, looks like the range is not calculated correctly; the negative range is still 21M, while it should be @-19 + @-20? check the screenshot:
stacknega

@danielgindi
Copy link
Collaborator

Did you specify a custom range...?

@danielgindi
Copy link
Collaborator

The negative demo sets a custom axis range.

@liuxuan30
Copy link
Member Author

I don't realize you have set

 _chartView.rightAxis.customAxisMax = 25.0;
 _chartView.rightAxis.customAxisMin = -25.0;

Comment it out, it works fine with the all negative values.

However, If I use the default demo code data, e.g. half negative half positive and comment out customAxisMin/Max code, the chart becomes weird... Can you try it on your side?

1 similar comment
@liuxuan30
Copy link
Member Author

I don't realize you have set

 _chartView.rightAxis.customAxisMax = 25.0;
 _chartView.rightAxis.customAxisMin = -25.0;

Comment it out, it works fine with the all negative values.

However, If I use the default demo code data, e.g. half negative half positive and comment out customAxisMin/Max code, the chart becomes weird... Can you try it on your side?

@liuxuan30
Copy link
Member Author

This is the dataSet:

    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-10, @10 ] xIndex: 0]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-12, @13 ] xIndex: 1]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-15, @15 ] xIndex: 2]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-17, @17 ] xIndex: 3]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-19, @20 ] xIndex: 4]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-19, @19 ] xIndex: 5]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-16, @16 ] xIndex: 6]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-13, @14 ] xIndex: 7]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-10, @11 ] xIndex: 8]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-5, @6 ] xIndex: 9]];
    [yValues addObject:[[BarChartDataEntry alloc] initWithValues:@[ @-1, @2 ] xIndex: 10]];

and make sure comment out

 _chartView.rightAxis.customAxisMax = 25.0;
 _chartView.rightAxis.customAxisMin = -25.0;

turn off startAtZeroEnabled:

_chartView.rightAxis.startAtZeroEnabled = NO;

Screenshot, looks like the rightAxis range is not correct, I surpose it is [-20,21], but it looks like [-0.1,1]:
half

@liuxuan30
Copy link
Member Author

@danielgindi, looks like this issue has been fixed on 2.1.2?

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

2 participants