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

Unable to display empty bars in barcharts #911

Closed
mavencode01 opened this issue Apr 2, 2016 · 7 comments
Closed

Unable to display empty bars in barcharts #911

mavencode01 opened this issue Apr 2, 2016 · 7 comments

Comments

@mavencode01
Copy link

Failed to draw bar at specify xIndex when there is no data in between.

//Initialise all the x-axis so each bar is drawn on each point if exist  <-- doesn't work!
for (int i = 0; i < biodata.count; i++){
    NSInteger val = ...
    [_xVals addObject:@(val)];
}

// draw the bar at a particular xIdx and with gaps e.g |...||.....||||.....|
for (int i = 0; i < biodata.count; i++)
{
    float y = ... 
    NSInteger xIdx = ....
    BarChartDataEntry *entry = [[BarChartDataEntry alloc] initWithValue:val xIndex:xIdx];     
    [_yAxisVals addObject:entry];
}
....
@mavencode01
Copy link
Author

So basically, if you are drawing a bar on the x-Axis, it should calculate the space/gaps based on the x-axis maximum or chart width before drawing the bar at that point.

....................................

...I............II...........I......

it doesn't seems to do this, instead it draws the bar to fill the entire width and recalculate the bar widths when new points is added to the dataset.

@danielgindi
Copy link
Collaborator

I don't understand what the problem is here.

@danielgindi
Copy link
Collaborator

You don't have to add values for each xIndex.

@mavencode01
Copy link
Author

@danielgindi I've a requirement to display bar at a particular x-axis, for example:

I've got an x-axis in the range of 1-100

What I want to do is for each update, draw a bar at a particular point once data is available and putting spaces between those points with no data:

.......||..........|.............
0                              100

@danielgindi
Copy link
Collaborator

So where is the problem?...

@liuxuan30
Copy link
Member

Are you looking for ignoring bars at specific index?

for (int i = 0; i < biodata.count; i++)
{
    float y = ... 
    NSInteger xIdx = ....
    if ([self hasDataAt:xIndx]) {
        BarChartDataEntry *entry = [[BarChartDataEntry alloc] initWithValue:val xIndex:xIdx];     
        [_yAxisVals addObject:entry];
    }
}

should do the job. [self hasDataAt:xIndx] is what you have to implement
there are groupSpace and barSpace to control the space between bars and bar groups.

@liuxuan30
Copy link
Member

I think this can be closed. If it's a bug you think, just reopen

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