-
-
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
A field crash issue for highestVisibleXIndex #329
Comments
Is it possible that But the error says But it still does not make sense as the error says it is something with the function signature. Like a call from ObjC when passing wrong argument types, nils etc. |
I have added log before |
Well catch the log: public var highestVisibleXIndex: Int
{
var pt = CGPoint(x: viewPortHandler.contentRight, y: viewPortHandler.contentBottom)
CLSLogv("pt.x %f, xValCount:%d before transform", getVaList([pt.x, _data.xValCount]))
getTransformer(.Left).pixelToValue(&pt)
CLSLogv("pt.x %f, xValCount:%d after transform", getVaList([pt.x, _data.xValCount]))
return (Int(pt.x) >= _data.xValCount) ? _data.xValCount - 1 : Int(pt.x)
} after pixelToValue the pt.x indeed became nan. |
With further debugging, It turned to be the problem that there is only lineData in the combinedChartView. override func calcMinMax() // combined chart
{
super.calcMinMax()
if (self.barData !== nil || self.candleData !== nil || self.bubbleData !== nil)
{
_chartXMin = -0.5
_chartXMax = Double(_data.xVals.count) - 0.5
if (self.bubbleData !== nil)
{
for set in self.bubbleData.dataSets as! [BubbleChartDataSet]
{
let xmin = set.xMin
let xmax = set.xMax
if (xmin < chartXMin)
{
_chartXMin = xmin
}
if (xmax > chartXMax)
{
_chartXMax = xmax
}
}
}
_deltaX = CGFloat(abs(_chartXMax - _chartXMin))
}
} internal override func calcMinMax() // line chart
{
super.calcMinMax()
if (_deltaX == 0.0 && _data.yValCount > 0)
{
_deltaX = 1.0
}
} So when line chart only has one x value, the deltaX would be 0, and then the _matrixValueToPx messed up, the scaleX is inf. public func prepareMatrixValuePx(chartXMin chartXMin: Double, deltaX: CGFloat, deltaY: CGFloat, chartYMin: Double)
{
let scaleX = (_viewPortHandler.contentWidth / deltaX) // deltaX is 0
let scaleY = (_viewPortHandler.contentHeight / deltaY)
// setup all matrices
_matrixValueToPx = CGAffineTransformIdentity
_matrixValueToPx = CGAffineTransformScale(_matrixValueToPx, scaleX, -scaleY)
_matrixValueToPx = CGAffineTransformTranslate(_matrixValueToPx, CGFloat(-chartXMin), CGFloat(-chartYMin))
} @danielgindi, if it is combined chart, I would like to put the single line dot in the middle of xAxis, do you know how to set up this special matrix? I will fix it later. |
I am thinking current logic does supports well for line chart, if only one x value, it will be draw on the left most side. It's better to draw it in the middle. But I cannot come up a matrix that could do so... Tried set _chartXMin, deltaX, _chartXMax, no luck. |
It turned out to be a elegant solution liuxuan30@1bd8c22 exact as how line chart view handles _deltaX. |
…data, not each sub data's index add one more bar data set in demo view controller (+4 squashed commits) Squashed commits: [44ce60e] rename some BarChartDataProvider protocol methods not the same as ChartDataProvider [1bd8c22] Fix issue ChartsOrg#329 check _deltaX when only lineData exists [90a327d] 1. fix bug in getDataSetIndex, it will detect what dataSet it is and determine how to proceed 2. I also override getMarkerPosition for CombinedChartView [80aa1b3] add support for grouped bars in CombinedChartView. add a new demo view controller called GroupedCombinedChartViewController, to illustrate multiple bars + multiple line
…data, not each sub data's index add one more bar data set in demo view controller (+4 squashed commits) Squashed commits: [44ce60e] rename some BarChartDataProvider protocol methods not the same as ChartDataProvider [1bd8c22] Fix issue ChartsOrg#329 check _deltaX when only lineData exists [90a327d] 1. fix bug in getDataSetIndex, it will detect what dataSet it is and determine how to proceed 2. I also override getMarkerPosition for CombinedChartView [80aa1b3] add support for grouped bars in CombinedChartView. add a new demo view controller called GroupedCombinedChartViewController, to illustrate multiple bars + multiple line
I using last version : just download today I have same problem "crash issue for highestVisibleXIndex". pt.x 150.0, xValCount:24 before transform I only have used the LineChartView. I think the problem is about the Y val not about X. Coz my data on Y is same. _yMax Double 0.39000000000000001 0.39000000000000001 _xVals [String?]! 24 values Some |
what's the matrix value? You have to print it out |
Which matrix value ? This one ? |
liuxuan30 commented 37 minutes ago not only x, y is failed too. both nan I think it fail to transform. so both nan |
I know how it happen now. When I used the leftAxis.customAxisMax and leftAxis.customAxisMin, and set with same value. in this case both set 0.39. and it will have the problem. |
so leftAxis.customAxisMax and leftAxis.customAxisMin must be different value. Just tested |
hmm, seems like the matrix.d is nan because of the delta is 0? |
…the whole data, not each sub data's index add one more bar data set in demo view controller (+4 squashed commits) Squashed commits: [44ce60e] rename some BarChartDataProvider protocol methods not the same as ChartDataProvider [1bd8c22] Fix issue ChartsOrg#329 check _deltaX when only lineData exists [90a327d] 1. fix bug in getDataSetIndex, it will detect what dataSet it is and determine how to proceed 2. I also override getMarkerPosition for CombinedChartView [80aa1b3] add support for grouped bars in CombinedChartView. add a new demo view controller called GroupedCombinedChartViewController, to illustrate multiple bars + multiple line
…the whole data, not each sub data's index add one more bar data set in demo view controller (+4 squashed commits) Squashed commits: [44ce60e] rename some BarChartDataProvider protocol methods not the same as ChartDataProvider [1bd8c22] Fix issue ChartsOrg#329 check _deltaX when only lineData exists [90a327d] 1. fix bug in getDataSetIndex, it will detect what dataSet it is and determine how to proceed 2. I also override getMarkerPosition for CombinedChartView [80aa1b3] add support for grouped bars in CombinedChartView. add a new demo view controller called GroupedCombinedChartViewController, to illustrate multiple bars + multiple line
…the whole data, not each sub data's index add one more bar data set in demo view controller (+4 squashed commits) Squashed commits: [44ce60e] rename some BarChartDataProvider protocol methods not the same as ChartDataProvider [1bd8c22] Fix issue ChartsOrg#329 check _deltaX when only lineData exists [90a327d] 1. fix bug in getDataSetIndex, it will detect what dataSet it is and determine how to proceed 2. I also override getMarkerPosition for CombinedChartView [80aa1b3] add support for grouped bars in CombinedChartView. add a new demo view controller called GroupedCombinedChartViewController, to illustrate multiple bars + multiple line
I get below crash captured by Crashlytics twice, not very often, and not sure what would be the cause:
Corresponding code:
I am not familiar with swift exceptions, looks like
Int(pt.x)
is causing the exception? @danielgindi, any ideas?If no one has ideas, maybe I will add a CLS_LOG to see what happened
The text was updated successfully, but these errors were encountered: