ios Swift图表发行
我使用Charts iOS library(),我有以下代码:ios Swift图表发行,ios,swift,charts,ios-charts,Ios,Swift,Charts,Ios Charts,我使用Charts iOS library(),我有以下代码: import UIKit import Charts class ChartsViewController: UIViewController , ChartViewDelegate{ var lineChartView: LineChartView? let months = ["Jan" , "Feb", "Mar", "Apr", "May", "June", "July", "A
import UIKit
import Charts
class ChartsViewController: UIViewController , ChartViewDelegate{
var lineChartView: LineChartView?
let months = ["Jan" , "Feb", "Mar", "Apr", "May", "June", "July", "August", "Sept", "Oct", "Nov", "Dec"]
let dollars1 = [1453.0,2352,5431,1442,5451,6486,1173,5678,9234,1345,9411,2212]
override func viewDidLoad() {
super.viewDidLoad()
self.lineChartView = LineChartView(frame: CGRectMake(50, 70, 300, 300))
self.lineChartView!.delegate = self
self.lineChartView!.descriptionText = "Tap node for details"
self.lineChartView!.drawGridBackgroundEnabled = false
self.lineChartView!.descriptionTextColor = UIColor.whiteColor()
self.lineChartView!.noDataText = "No data provided"
setChartData(months)
self.view.addSubview(self.lineChartView!)
}
func setChartData(months : [String]) {
var yVals1 : [ChartDataEntry] = [ChartDataEntry]()
for var i = 0; i < months.count; i++ {
yVals1.append(ChartDataEntry(value: dollars1[i], xIndex: i))
}
let set1: LineChartDataSet = LineChartDataSet(yVals: yVals1, label: "First Set")
set1.lineWidth = 10.0
set1.circleRadius = 0.0 // the radius of the node circle
set1.fillColor = UIColor.redColor()
set1.highlightColor = UIColor.yellowColor()
set1.drawCircleHoleEnabled = false
set1.drawVerticalHighlightIndicatorEnabled = false
var dataSets : [LineChartDataSet] = [LineChartDataSet]()
dataSets.append(set1)
let data: LineChartData = LineChartData(xVals: months, dataSets: dataSets)
data.setValueTextColor(UIColor.whiteColor())
self.lineChartView!.data = data
}
导入UIKit
进口图表
类ChartsViewController:UIViewController、ChartViewDelegate{
var lineChartView:lineChartView?
月份=[“一月”、“二月”、“三月”、“四月”、“五月”、“六月”、“七月”、“八月”、“九月”、“十月”、“十一月”、“十二月”]
让dollars1=[1453.023525431144516486117356789234134594112212]
重写func viewDidLoad(){
super.viewDidLoad()
self.lineChartView=lineChartView(帧:CGRectMake(50,70300300))
self.lineChartView!.delegate=self
self.lineChartView!.descriptionText=“点击节点查看详细信息”
self.lineChartView!.drawGridBackgroundEnabled=false
self.lineChartView!.descriptionTextColor=UIColor.whiteColor()
self.lineChartView!.noDataText=“未提供数据”
setChartData(月)
self.view.addSubview(self.lineChartView!)
}
func setChartData(月份:[字符串]){
变量yVals1:[ChartDataEntry]=[ChartDataEntry]()
对于var i=0;i
我明白了:
我的问题是:
我想删除背景上的网格(垂直线和水平线),但我无法删除,因为我在官方图书馆文档中找不到任何内容
您能帮助我吗?您可以使用此代码禁用网格:
lineChartView.xAxis.drawGridLinesEnabled = false
lineChartView.leftAxis.drawGridLinesEnabled = false
将完成此工作。使用此方法,我只禁用垂直线,但禁用水平线?哦,对不起,我忘记了另一个属性,我更新了我的答案。没有人可以帮助我吗?
self.lineChartView.leftAxis.drawGridLinesEnabled = false
self.lineChartView.xAxis.drawGridLinesEnabled = false