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

CGAffineTransformInvert: singular matrix #4290

Closed
schooltech opened this issue Feb 14, 2020 · 5 comments
Closed

CGAffineTransformInvert: singular matrix #4290

schooltech opened this issue Feb 14, 2020 · 5 comments

Comments

@schooltech
Copy link

hi,
error repeatedly with a LineChartView:
[Unknown process name] CGAffineTransformInvert: singular matrix.

and my code is as below:
`struct ZLineChartView: UIViewRepresentable {

var title: String
var dataPoints: [String]
var values: [Double]
var drawValueLabel: Bool

func makeUIView(context: Context) -> LineChartView {
    
    let chartView = LineChartView()
    chartView.noDataText = "no data"

    chartView.chartDescription?.enabled = false
   
    chartView.legend.yOffset = 0
    chartView.autoScaleMinMaxEnabled = false
    
    chartView.xAxis.drawLabelsEnabled = true
    chartView.xAxis.enabled = true
    //lineChartView.xAxis.valueFormatter = IndexAxisValueFormatter(values: dataPoints)
    chartView.xAxis.granularity = 1.0
    chartView.xAxis.labelPosition = .bottom
    chartView.xAxis.drawGridLinesEnabled = true
    chartView.xAxis.labelTextColor = UIColor(named: "checkAxisColor")!
    
    chartView.leftAxis.labelTextColor = UIColor(named: "checkAxisColor")!
    
    chartView.legend.textColor = UIColor(named: "checkAxisColor")!
    
    chartView.rightAxis.drawAxisLineEnabled = false
    chartView.rightAxis.enabled = false
    
    chartView.scaleXEnabled = false
    chartView.scaleYEnabled = false
    
    chartView.animate(xAxisDuration: 1)
    
    return chartView
}

func updateUIView(_ uiView: LineChartView, context: Context) {
    
    var dataEntries: [ChartDataEntry] = []
    
    for i in 0..<dataPoints.count {
        let dataEntry = ChartDataEntry(x: Double(i), y: values[i])
        dataEntries.append(dataEntry)
    }
    
    let lineChartDataSet = LineChartDataSet(entries: dataEntries, label: self.title)

    lineChartDataSet.fillColor = UIColor(named: "chartBar")!
    lineChartDataSet.lineWidth = 1
    lineChartDataSet.drawValuesEnabled = self.drawValueLabel
    
    lineChartDataSet.drawCirclesEnabled = false
    lineChartDataSet.circleHoleColor = UIColor(named: "chartBar")
    lineChartDataSet.drawCircleHoleEnabled = false
    
    lineChartDataSet.colors = [UIColor(named: "chartBar")!]
    
    let lineChartData = LineChartData(dataSet: lineChartDataSet)
    
    uiView.data = lineChartData
    
}

}`

@liuxuan30
Copy link
Member

well.. need log rather than code sample. For such issues, it's usually the data casues the matrix invalid. So you probably want to check your data entry first

@ccworld1000
Copy link

This problem should be opened. I also have this problem. The original problem of illegal data also has the problem of singular matrix

@ccworld1000
Copy link

ccworld1000 commented May 26, 2020

I made a demo to demonstrate the existence of this problem
https://github.com/ccworld1000/CCSingularMatrixProblem.git

@theedov
Copy link

theedov commented Oct 1, 2020

getting the same errors when my dataset is empty.

@xsleonard
Copy link

This occurs if there are 2 or more data entries and all entries have the same y value

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

5 participants