ios Swift 图表问题

标签 ios swift charts ios-charts

我使用 Charts iOS 库( https://github.com/danielgindi/Charts )并且我有以下代码:

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            
        }

我明白了:

https://postimg.org/image/6z6nk5nkn/

我的问题是这样的:

我想删除背景上的网格(垂直和水平线),但我无法删除,因为我在官方库文档中找不到任何内容。

你能帮我吗?

最佳答案

self.lineChartView.leftAxis.drawGridLinesEnabled = false
self.lineChartView.xAxis.drawGridLinesEnabled = false

会完成这项工作。

关于ios Swift 图表问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37874878/

相关文章:

ios - ViewController 加载后不会更新

swift - 在 SpriteKit Swift 中移动相机

javascript - 直到可视化结束,气泡才能够承受 - Google Motion Bubble Chart

java - 添加/累积 "line chart components"

jquery - 如何创建像Google Finance那样的动态折线图?

android - multer, react 原生图像选择器图像上传在 iOS 上不起作用

ios - ReactiveCocoa - SignalProducer,发出数组中最新的 N 个值

iphone - 如何让两个 subview 相互交互?

swift - 如何完全删除所有 Xcode 程序和缓存文件?

swift - Swift 中来自 URL 的部分组件