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

Cubic Line Distorted #2459

Closed
sz-ashik440 opened this issue May 20, 2017 · 2 comments
Closed

Cubic Line Distorted #2459

sz-ashik440 opened this issue May 20, 2017 · 2 comments

Comments

@sz-ashik440
Copy link

I was trying to plot a cubic line chart. But it got distorted after some value and after that if I add more value, it gets disappear(couldn't render in iphone). Did I miss something?? Or it's a bug?
distorted-chart

    func drawLineChart() {
        let populationData: [Int: Int] = [ 10: 29, 11: 28, 12: 28, 13: 28, 14: 27, 15: 27, 16: 27, 17: 27, 18: 27, 19: 27, 20: 28, 21: 30, 22: 31 ]
    
        let entries = populationData.map{ x,y in
            return ChartDataEntry(x: Double(x), y: Double(y))
        }
    
        let data = LineChartData()
        //----------------------------- dataset intensified ---------------------------------------
        let dataset = LineChartDataSet(values: entries, label: nil)
        dataset.axisDependency = .left
        dataset.colors = [.yellow]
        dataset.mode = .cubicBezier
        dataset.cubicIntensity = 0.1
    
        // kicked out circlre from line
        dataset.drawCirclesEnabled = false
    
        dataset.lineWidth = 2.0
        dataset.fillAlpha = 100
        dataset.drawFilledEnabled = true
        dataset.fillColor = UIColor.orange
        dataset.highlightColor = UIColor.brown
    
        dataset.drawValuesEnabled = false
    
        data.addDataSet(dataset)
    
        dailyTempView.data = data
    
        //----------------------------- removing background gridline -------------------------------
        dailyTempView.drawGridBackgroundEnabled = false
        dailyTempView.drawBordersEnabled = false
    
        dailyTempView.gridBackgroundColor = UIColor.white
        dailyTempView.xAxis.drawGridLinesEnabled = false
        dailyTempView.leftAxis.drawGridLinesEnabled = false
        dailyTempView.leftAxis.granularityEnabled = true
        dailyTempView.leftAxis.granularity = 1.0
    
        dailyTempView.rightAxis.enabled = false
    
        dailyTempView.chartDescription?.text = ""
        dailyTempView.legend.enabled = false
        dailyTempView.xAxis.labelPosition = .bottom
    }
@thierryH91200
Copy link
Contributor

let populationData: [Int: Int] = [ 10: 29, 11: 28, 12: 28, 13: 28, 14: 27, 15: 27, 16: 27, 17: 27, 18: 27, 19: 27, 20: 28, 21: 30, 22: 31 ]
it's a dictionary

the soluce

let populationData : [[Int]] = [[ 10, 29], [11, 28], [12, 28], [13, 28], [14, 27], [15, 27], [16, 27], [17, 27], [18, 27], [19, 27], [20, 28], [21, 30], [22, 31 ]]

var entries = [ChartDataEntry]()
for i in 0..<populationData.count
{
    entries.append(ChartDataEntry(x: Double(populationData[i][0]), y: Double(populationData[i][1])))
}

@sz-ashik440
Copy link
Author

Thanks it worked. I forgot that swift dictionary is un-ordered

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

3 participants