-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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 with multiple data set crashes on tap #1339
Comments
@liuxuan30 I saw the problem: Over the HorizontalBarChartHighlighter class you have this method public override func getXIndex(x: CGFloat) -> Int
{
if let barData = self.chart?.data as? BarChartData
where !barData.isGrouped
{
// create an array of the touch-point
var pt = CGPoint(x: 0.0, y: x)
// take any transformer to determine the x-axis value
self.chart?.getTransformer(ChartYAxis.AxisDependency.Left).pixelToValue(&pt)
return Int(round(pt.y))
}
else
{
return getXIndex(x)
}
} The multiple dataSets charts has the property isGrouped enabled, so this function will be called forever, and this crash the app. I have the same problem and I'd like to ask which is the correct function that we need to call if we have a isGrouped chart to get the xIndex 🙃 Thanks in advance 👾 |
@liuxuan30 @cuddle-sujeet I guess that i figure out what was the problem, I guess that you wanted to call the super getXIndex method when the condition fail. Just like that: public override func getXIndex(x: CGFloat) -> Int
{
if let barData = self.chart?.data as? BarChartData
where !barData.isGrouped
{
// create an array of the touch-point
var pt = CGPoint(x: 0.0, y: x)
// take any transformer to determine the x-axis value
self.chart?.getTransformer(ChartYAxis.AxisDependency.Left).pixelToValue(&pt)
return Int(round(pt.y))
}
else
{
return super.getXIndex(x)
}
} The parent method has the correct code to handle the grouped charts, So this solve the problem, I don't think that this needs a PR, but I guess you need to include for all the people who is working with the version 2.2.5, Idk if the 3.0 version has the same problem. Thanks in advance 👾🙃 i'd like to be a contributor of this great repo! :) |
This does not happen on Charts 3.0, there are no more x-indexes, and the highlighters have been competely re-written |
Sorry for late reply. |
HorizontalBarViewIssue.zip
I am using a HorizontalBarChartView to display a multiple dataset. But the app crashes on tap.
The text was updated successfully, but these errors were encountered: