Charts: : CGAffineTransformInvert: singular matrix
I am getting this error repeatedly with a HorizontalBarChartView:
<Error>: CGAffineTransformInvert: singular matrix.
There is nothing special about my code. I am using a HorizontalBarChartView in OSX that is 175x394 points in size. It is not obstructed by any other views. I initialize the chart with:
@IBOutlet weak var horizontalBarChart: HorizontalBarChartView!
let data = BarChartData(xVals: [1.0, 3.0, 5.0, 7.0, 8.0])
horizontalBarChart.data = data
horizontalBarChart.notifyDataSetChanged()
and then get hit with the error multiple times a second. Any idea what is causing this?
Line 206 in ChartTransformer is the only place the CGAffineTransformInvert is called.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 37 (11 by maintainers)
This doesn’t necessarily address the underlying problem, but a check for matrix singularity avoids the error message. I replaced pixelToValueMatrix in ChartTransformer with this to suppress the error.
@serk1 well, that’s not a positive attitude… We’re closing issues that people do not respond to for a long time - and @liuxuan30 here was trying to help you. Like I said - the only case where that message will be spit out - is when your xAxis is invalid, and you shouldn’t even see the xAxis labels. If you are a user of this library, and want to have a better experience you can help this bug get fixed.
Nope, like I said it’s a simple HorizontalBarChartView and I’m sure the error could be reproduced. You still have a bug in your code but I just don’t have time to help you guys fix it and I found a band-aid workaround.
Closing the issue doesn’t fix the bug, but maybe someday someone else will use this Framework and reopen it when they start getting bombarded with error messages.
I am running into a crash at line 117 in AxisRendererBase in computeAxisValues
let intervalMagnitude = pow(10.0,Double(Int(log10(interval)))).roundedToNextSignficant()` Fatal error: Double value cannot be converted to int because it is either infinite or NaN p1 and p2 in XAxisRenderer in computeAxis on line 37,38 are returning NaN which changes the min and max values to NaN`(lldb) po _matrixValueToPx ▿ CGAffineTransform
(lldb) po _viewPortHandler.touchMatrix ▿ CGAffineTransform
(lldb) po _matrixOffset ▿ CGAffineTransform
(lldb) po _matrixValueToPx.concatenating(_viewPortHandler.touchMatrix).concatenating(_matrixOffset) ▿ CGAffineTransform
so min and max are NaN and the call to computeAxisValues crashes
I am able to consistently make this occur if I start with an empty dataset and then quickly add another piece of data before I let the chart finish rendering
Same problem occured to me too. And the solution doesn’t fit. In my case, there is some normal data inside the LineChart, and if I zoom in the chart, it crash. Seems that it happends at
func computeAxis(min: Double, max: Double, inverted: Bool), calculating the p1 and p2. The transformer call produces the error and return NaN, which crash oncomputeAxisValuesafterwards.