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

iOS-charts Get Currently visible bars for MultipleBarChartViewController demo #782

Closed
iAmdH opened this issue Feb 29, 2016 · 4 comments
Closed

Comments

@iAmdH
Copy link

iAmdH commented Feb 29, 2016

I asked this question on SO. A user mentioned to ask it here. Its my first question at GIT not sure if I'm doing everything right here.
In my application i show month wise data in bar charts. We have data from 2010 to 2016. So there are a lot of months but only show 12 months at a time and user has to swipe left/right to view other month’s data. Below line does it:
chartView.setVisibleXRangeMaximum(12)

Above the charts we are showing the data range currently viewable by the user. e.g. if the left most visible bar is Mar 2015 and right most visible bar is Feb 2016, the range shows “Mar 2015 - Feb 2016”. Im using following method to grab the visible data on screen. This method is called whenever a user swipes the screen left/right to view previous/next data.

var arrVisibleIndexes:[Int] = [Int]()            
var count: Int? = chartData.dataSets.first?.yVals.count
    for i in 0...count! - 1 {

        var point:CGPoint = CGPointMake(CGFloat(i), 0.0)
        chartView.getTransformer(.Left).pointValueToPixel(&point)

        if (chartView.viewPortHandler.isInBoundsX(point.x)) {
            arrVisibleIndexes.append(i)
        }
    }

At the end arrVisibleIndexes has all the bars currently visible on screen. I pick the first and last items from this array to show the range. Its working absolutely fine for Simple Bar Charts. However the problem is with Multiple Bar Charts. In the example code its the “MultipleBarChartViewController” demo. Its acting weird. Its returning those indexes of data that are not visible on screen and also the other way around i.e. not returning data indexes that are visible on screen right now. e.g initially when the screen loads only 4 pairs of bar charts are visible on screen but I get indexes from 0 - 11 as visible on screen. Any pointers please?

@danielgindi
Copy link
Collaborator

This is a case of grouped bars, I think.
I'll look into it

@danielgindi
Copy link
Collaborator

In Charts 3.0 you will not have this issue now :-)

@islamshazly
Copy link

@danielgindi could u plz tell me how can i clone Charts V3 because the release now is 2.2.5

@liuxuan30
Copy link
Member

2.2.5 is not released yet, you could check out master branch for now.

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

4 participants