我正在使用Two Tables库在swift中绘制图形。我想在LineChartView上显示以下值。 我的价值如下。
1)x:0.0 y:0.62020133693747
2)x:0.0 y:0.62020133693747
3)x:0.0 y:0.62020133693747
4)x:8500.0 y:0.62020133693747
5)x:8500.0 y:0.925703706122449
6)x:9000.0 y:0.925703706122449
7)x:9000.0 y:1.43307403327373
8)x:9500.0 y:1.43307403327373
9)x:9500.0 y:0.37799568
10)x:9500.0 y:0.37799568
11)x:9500.0 y:0.37799568
12)x:9000.0 y:0.37799568
13)x:9000.0 y:0.269996914285714
14)x:8500.0 y:0.269996914285714
15)x:8500.0 y:0.239997257142857
16)x:6000.0 y:0.239997257142857
17)x:6000.0 y:0.219552079597251
18)x:0.0 y:0.219552079597251
19)x:0.0 y:0.453594816
20)x:0.0 y:0.453594816
根据这些值,预期图表为:
似乎图书馆无法绘制最后的值。
我尝试了各种设置,但它没有解决我的问题。
我的代码:
`func updateChartValues(arrLineCDE: Array<ChartDataEntry>) -> (LineChartDataSet) {
let Xvalues: [Double] = [/*All My X values are here*/]
let Yvalues: [Double] = [/*All My Y values are here*/]
var entries: [ChartDataEntry] = Array()
for (i, x) in Xvalues.enumerated() {
entries.append(ChartDataEntry(x: Xvalues[i], y: Yvalues[i], data: UIImage(named: "icon", in: Bundle(for: self.classForCoder), compatibleWith: nil)))
}
self.dataSet = LineChartDataSet(values: entries, label: "Depth vs. FV")
self.dataSet.mode = LineChartDataSet.Mode.cubicBezier
return dataSet
}`
折线图定位
`func setLineChartProperty(lineChartView lcv: LineChartView) {
//Line Chart Setting:
// lcv.delegate = self
lcv.setViewPortOffsets(left: 44.0, top: 30.0, right: 44.0, bottom: 44.0)
lcv.backgroundColor = darkBlueColor
lcv.chartDescription?.enabled = false
lcv.dragEnabled = false
lcv.setScaleEnabled(false)
lcv.pinchZoomEnabled = false
lcv.drawGridBackgroundEnabled = false
lcv.xAxis.labelFont = UIFont(name: "HelveticaNeue-Light", size: CGFloat(12.0))!
lcv.xAxis.setLabelCount(6, force: false)
lcv.xAxis.labelTextColor = UIColor.white
lcv.xAxis.labelPosition = .bottom
lcv.xAxis.axisLineColor = UIColor.white
lcv.xAxis.gridColor = UIColor.white
lcv.xAxis.drawGridLinesEnabled = true
lcv.xAxis.axisMaximum = 10000
lcv.xAxis.axisMinimum = 0
lcv.leftAxis.labelFont = UIFont(name: "HelveticaNeue-Light", size: CGFloat(12.0))!
lcv.leftAxis.setLabelCount(6, force: false)
lcv.leftAxis.labelTextColor = UIColor.white
lcv.leftAxis.labelPosition = .outsideChart
lcv.leftAxis.axisLineColor = UIColor.white
lcv.leftAxis.gridColor = UIColor.white
lcv.leftAxis.drawGridLinesEnabled = true
lcv.legend.horizontalAlignment = .right
lcv.legend.verticalAlignment = .bottom
lcv.legend.orientation = .horizontal
lcv.legend.drawInside = true
lcv.legend.form = .square
lcv.legend.formSize = 8.0
lcv.legend.formToTextSpace = 4.0
lcv.legend.xEntrySpace = 6.0
lcv.xAxis.enabled = true
lcv.rightAxis.enabled = false
lcv.leftAxis.enabled = true
lcv.legend.enabled = true
lcv.legend.textColor = UIColor.white
lcv.animate(xAxisDuration: 1.0, yAxisDuration: 1.0)
}`