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

the first and last point have a line #1672

Closed
liuhui313364809 opened this issue Oct 18, 2016 · 7 comments
Closed

the first and last point have a line #1672

liuhui313364809 opened this issue Oct 18, 2016 · 7 comments

Comments

@liuhui313364809
Copy link

hi,danielgindi:
excuse me,
I have a problem, please help me.
I use the charts, found the first and last point have a line .
how to solve,thank you

1
2
3

@liuhui313364809
Copy link
Author

the point not have the value

@liuhui313364809
Copy link
Author

func initPMDayCharts(){
pmDayChartContainer.subviews.map {$0.removeFromSuperview()}
pmLineChart = LineChartView()
pmDayChartData = NSMutableArray()
pmLineChart.frame = CGRect(x: 0, y: 0, width: pmDayChartContainer.frame.size.width, height: pmDayChartContainer.frame.size.height)
pmLineChart.noDataText = "数据请求超时"
pmLineChart.descriptionText = ""
pmLineChart.setScaleEnabled(false)
pmLineChart.pinchZoomEnabled = false
pmLineChart.xAxis.labelTextColor = UIColor(red: 46.0/255.0, green: 122.0/255.0, blue: 92.0/255.0, alpha: 1.0)
pmLineChart.drawGridBackgroundEnabled = false
pmLineChart.drawMarkers = false
pmLineChart.rightAxis.enabled = false
pmLineChart.leftAxis.enabled = false
pmLineChart.leftAxis.drawGridLinesEnabled = false
pmLineChart.rightAxis.drawGridLinesEnabled = false
pmLineChart.xAxis.drawAxisLineEnabled = false
pmLineChart.xAxis.gridColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.24)
pmLineChart.xAxis.avoidFirstLastClippingEnabled = true
pmLineChart.drawBordersEnabled = false
pmLineChart.userInteractionEnabled = false
pmLineChart.legend.enabled = false
pmLineChart.legend.textColor = UIColor.whiteColor()
pmLineChart.leftAxis.valueFormatter = NSNumberFormatter()
pmLineChart.leftAxis.valueFormatter!.minimumFractionDigits = 0
pmDayChartContainer.addSubview(pmLineChart)
pmDayChartContainer.contentSize = CGSize(width: pmDayChartContainer.frame.size.width, height: pmDayChartContainer.frame.size.height)

}

@liuhui313364809
Copy link
Author

func setPMDayData(var data:NSArray,var labels:NSArray,var desc:NSString) {

    pmLineChart.frame = CGRect(x: 10, y: 0, width: max(CGFloat(data.count*60), pmDayChartContainer.frame.size.width), height: pmDayChartContainer.frame.size.height)

    pmDayChartContainer.contentSize = CGSize(width: max(CGFloat(data.count*60+10), pmDayChartContainer.frame.size.width), height: pmDayChartContainer.frame.size.height)

    var index:Int = 0
    for entry in data
    {
        var tempEntry:ChartDataEntry = ChartDataEntry(value: (String(entry) as NSString).doubleValue, xIndex: index)
        pmDayChartData.addObject(tempEntry)

        index++
    }

    var pmDayDataSet:LineChartDataSet = LineChartDataSet(yVals: pmDayChartData as! [ChartDataEntry], label: "PM")

    var pmDayLinedata:LineChartData = LineChartData(xVals: labels as! [NSObject],dataSet:pmDayDataSet)
    pmDayDataSet.drawFilledEnabled = true
    pmDayDataSet.fillColor = UIColor(red: 73.0/255.0, green: 174.0/255.0, blue: 134.0/255.0, alpha: 1)
    pmDayDataSet.setCircleColor(UIColor.whiteColor())
    pmDayDataSet.circleHoleColor = UIColor.yellowColor()
    pmDayDataSet.setColor(UIColor.whiteColor())
    pmDayDataSet.valueFormatter = NSNumberFormatter()
    pmDayDataSet.valueFormatter?.minimumFractionDigits = 0
    pmDayDataSet.valueFormatter?.minimumIntegerDigits = 1
    pmDayDataSet.lineWidth = 4
    pmDayDataSet.valueTextColor = UIColor.whiteColor()
    pmDayDataSet.valueFont = UIFont.systemFontOfSize(9)

    pmLineChart.clearValues()
    pmLineChart.clear()
    pmLineChart.data = pmDayLinedata
    pmLineChart.notifyDataSetChanged()
}

@danielgindi
Copy link
Collaborator

Your data is probably not ordered... Please revisit your data and make sure it's ordered.

@liuhui313364809
Copy link
Author

how to ordered?

What type of requirements

@danielgindi
Copy link
Collaborator

Entries with x=5 should come before entries with x=6...

@danielgindi
Copy link
Collaborator

It is this way to allow fast searching through the entries.

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

2 participants