-
-
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
<Error>: CGAffineTransformInvert: singular matrix #802
Comments
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.
|
Well, we need to check out the matrix values, why it's singular, that's usually the data has some problems and leads to the matrix calculation goes bad. |
I noticed my X axis labels aren't showing up. Maybe that could be the problem? |
can't say for sure right now. Need you to debug to see what's going on. you can try ChartsDemo as well. |
You have a transformer with a singular matrix, probably for the X axis. This means that something is your setup went horribly wrong... |
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. |
@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. |
The OSX demo is not targeted for iOS devices. Check your configuration again. |
@danielgindi I took a look at the statement again, I found @Serk1 is just feeding barChartData with only x values, no data set at all. I looked into the code, it turned out in BarChartView's calcMinMax(): // increase deltax by 1 because the bars have a width of 1
_xAxis.axisRange += 0.5
// extend xDelta to make space for multiple datasets (if ther are one)
_xAxis.axisRange *= Double(data.dataSetCount) <----- BOOM so _xAxis.axisRange is 0 after this, and leads to the scaleX to 0. then the sigularity triggered when translating to pixelToValueMatrix. Any zooming at this moment has unexpected behaviour. It seems we support only feed xVals from the API statement. What do you think is a proper fix? We prevent any zoom/scroll in this case, or make a default one (if dataSetCount is 0, just not multiply), or just print warnings? |
A proper fix might be |
oh yeah, I was just editing - the only problem is in this case, the x value labels are a mess. They are rendered in same position.
|
Dammit. I'll look into it :-) |
having to eat... I was just thinking handle it like normal bars |
@danielgindi I traced down and manage to get it working. The key is to set step to 1, and groupSpace to 0.8 if data set count is 0. Not sure if you have better ones.
is the key part to make sure it is correctly renderered at the right x position, we have to make step = 1 if data set is 0, and groupSpace to 0.8 as well. This kind of code is distributed in several places, like I just don't know where to put this pattern. If you have time, please help on this. I have to work now. |
I got the same error when dynamically adding points to a empty dataset and calling addXValue() after calling addEntry() fixed it. |
Got it when sending data array with an value point, [0]. |
@klanderson 👍 : your lines solve mine. |
the view's - autoScaleMinMaxEnabled = true - seems to cause this problem for me when redrawing charts, setting to false will not give this issue anymore. Does scaling with empty datasets caus the problem? |
I also have this issue, but debugging it with print statements or breakpoints causes the behaviour to return to normal. Some kind of concurrency issue perhaps? |
Should not be concurrency issues.. I think |
No response for a long time and maybe invalid. Closing |
I put some charts in a page view controller and now I get this error on a controller with an empty "No Data" chart simply by linking the view... odd. However the app does not crash and everything seems to be working fine on screen. Still, maybe this issue should be kept open? |
@AndreaPisoni Not really I guess, as you have no data, it should stop rendering, I tested ChartsDemo bar chart with nil data, it prints nothing |
Have you tried having a few charts inside of a page view controller?
…On Fri, 5 May 2017 at 4:33 PM, Xuan ***@***.***> wrote:
@AndreaPisoni <https://github.com/AndreaPisoni> Not really I guess, as
you have no data, it should stop rendering, I tested ChartsDemo bar chart
with nil data, it prints nothing
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#802 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AN_wJi0KSapg6tbMsQTcv1M5ryFVsf3Iks5r2t7MgaJpZM4Hp4wF>
.
|
If you have new issues, open a new thread to track. |
@klanderson Thanks! Your solution worked for me. |
Same problem occured to me too. And the solution doesn't fit. |
I am running into a crash at line 117 in AxisRendererBase in computeAxisValues `(lldb) po _matrixValueToPx
(lldb) po _viewPortHandler.touchMatrix
(lldb) po _matrixOffset
(lldb) po _matrixValueToPx.concatenating(_viewPortHandler.touchMatrix).concatenating(_matrixOffset)
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 |
I am getting this error repeatedly with a LineChartView: I am using it to display speed. But until any movement it will not update or increase my speed any more.That's why my data will not available to display. But after preset timer as my timer ends, it gives this error. I could not able to find the solution. |
Same problem like @dipesh1604 |
After upgrading to Swift 3 I've encountered the same thing. Any luck @xrena , @dipesh1604 ? |
Same problem as @dipesh1604 |
Same Issue... |
Im still seeing this, using Charts wrapped in UIViewRepresentable as per https://medium.com/@zzzzbh/plotting-in-ios-using-charts-framework-with-swiftui-222034a2bea6 |
I am also getting this issue like @gesabo when using Charts wrapped in UIViewRepresentable |
Hey! it's 2022. Yeah I know. I'm currently getting this issue on iOS. I'm using the react-native-charts-wrapper which is a bundle of this library for RN. This was already working properly when I first started, but then I just got this issue recently |
Having the NaN issue in 2023, with SwiftUI UIViewRepresentable. My App involves repeatedly updating (append dataset, setVisibleXRange, moveViewToAniated) and clearing the chart multiple times. The first plot always has no issue. After clearing and starting the second plot, this issue may occur. There is probably some animation matrix operation freaks out when the dataset entries is empty. My solution is to set the |
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:
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.
The text was updated successfully, but these errors were encountered: