iOS 용 Jawbone의 그래프 라이브러리를 사용하여 하나의 차트에 두 세트의 데이터를 표시하려고합니다. 다음 날짜 (x 축), 활동 수준 및 임계 값에 대한 데이터는 다음과 같습니다iOS에서 JBLineChart로 두 줄을 플롯하고 사용자 정의하려면 어떻게합니까?
var activityChartLegend = ["11-14", "11-15", "11-16", "11-17", "11-18", "11-19", "11-20"]
var activityChartData = [88, 81, 69, 77, 70, 89, 90]
var activityThreshold = [80, 80, 80, 80, 80, 80, 80]
내가 성공적으로 activityChartData에 대한 첫 번째 라인을 그려왔다. 그러나 activityThreshold에 대한 두 번째 줄을 그리는 방법에 대해서는 혼란 스럽습니다. 문서가 제한되어 있으므로이 두 번째 줄을 그리는 방법을 잘 모릅니다. 다음 코드에서는 줄 수를 "2"로 반환했지만 다음 함수 내에서 두 줄을 그릴 방법을 이해하지 못합니다.
func numberOfLines(in lineChartView: JBLineChartView!) -> UInt {
return 2
}
func lineChartView(_ lineChartView: JBLineChartView!, numberOfVerticalValuesAtLineIndex lineIndex: UInt) -> UInt {
if (lineIndex == 0) {
return UInt(activityChartData.count)
}
return 0
}
func lineChartView(_ lineChartView: JBLineChartView!, verticalValueForHorizontalIndex horizontalIndex: UInt, atLineIndex lineIndex: UInt) -> CGFloat {
if (lineIndex == 0) {
return CGFloat(activityChartData[Int(horizontalIndex)])
}
return 0
}
또한, 나는 다음과 같은 코드로 첫 선을 포맷, 그러나 성공적 차트 뷰에 추가되면 다른 라인을 포맷하는 방법을 이해하지 않습니다
func lineChartView(_ lineChartView: JBLineChartView!, showsDotsForLineAtLineIndex lineIndex: UInt) -> Bool {
return true // False = do not show the dots
}
func lineChartView(_ lineChartView: JBLineChartView!, dotRadiusForDotAtHorizontalIndex horizontalIndex: UInt, atLineIndex lineIndex: UInt) -> CGFloat {
return CGFloat(6)
}
func lineChartView(_ lineChartView: JBLineChartView!, colorForDotAtHorizontalIndex horizontalIndex: UInt, atLineIndex lineIndex: UInt) -> UIColor! {
return UIColor.lightGray
}
func lineChartView(_ lineChartView: JBLineChartView!, smoothLineAtLineIndex lineIndex: UInt) -> Bool {
return true
}
func lineChartView(_ lineChartView: JBLineChartView!, didSelectLineAt lineIndex: UInt, horizontalIndex: UInt) {
if (lineIndex == 0){
let data = activityChartData[Int(horizontalIndex)]
let key = activityChartLegend[Int(horizontalIndex)]
activityLabel.text = "Number of steps on \(key): \(data)"
}
}
나는 상당히입니다 iOS에서 코딩하는 데 익숙하지 않으며이 주제에 대한 제한된 문서 만 찾았습니다. 제공 할 수있는 도움에 감사드립니다.