我正在将Chart集成到我的应用中。
使用https://github.com/danielgindi/Charts
代码:
let leftAxisFormatter = NumberFormatter()
leftAxisFormatter.minimumFractionDigits = 0
leftAxisFormatter.maximumFractionDigits = 1
leftAxisFormatter.negativePrefix = " $"
leftAxisFormatter.positivePrefix = " $"
chartView.xAxis.gridLineDashPhase = 0
chartView.leftAxis.enabled = false
chartView.xAxis.enabled = false
let rightAxis = chartView.rightAxis
rightAxis.enabled = true
rightAxis.labelFont = .systemFont(ofSize: 10)
rightAxis.labelCount = 4
rightAxis.valueFormatter = DefaultAxisValueFormatter(formatter: leftAxisFormatter)
rightAxis.axisMinimum = 0
rightAxis.drawZeroLineEnabled=true
rightAxis.labelPosition = .insideChart
chartView.leftAxis.drawZeroLineEnabled = true
chartView.legend.enabled = false
chartView.leftAxis.drawAxisLineEnabled = false
chartView.leftAxis.drawGridLinesEnabled = false
chartView.rightAxis.drawAxisLineEnabled = false
chartView.rightAxis.drawGridLinesEnabled = false
chartView.xAxis.drawAxisLineEnabled = false
chartView.xAxis.drawGridLinesEnabled = false
let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
chartView.xAxis.valueFormatter = IndexAxisValueFormatter(values:months)
chartView.xAxis.granularity = 1
在图表上和底部的底部月份中,获得白色垂直线还有哪些其他属性。
谢谢。
答案 0 :(得分:0)
使用lineChart.xAxis.labelPosition = .bottom // LineChart
lineChart.chartDescription?.enabled = false
lineChart.dragEnabled = false
lineChart.setScaleEnabled(false)
lineChart.pinchZoomEnabled = false
lineChart.rightAxis.enabled = false
lineChart.legend.form = .default
lineChart.legend.formSize = 0.0
lineChart.xAxis.axisMinimum = 0.0
lineChart.leftAxis.axisMinimum = 0.0
lineChart.xAxis.axisMaximum = 12.0
lineChart.leftAxis.axisMaximum = 100.0
lineChart.gridBackgroundColor = .clear
lineChart.xAxis.labelPosition = .bottom
lineChart.xAxis.labelFont = UIFont.RobotoRegularFontWithSize(size: 11)
lineChart.xAxis.labelTextColor = UIColor.clear
lineChart.leftAxis.labelTextColor = .clear
lineChart.leftAxis.labelFont = UIFont.RobotoRegularFontWithSize(size: 11)
lineChart.highlightPerTapEnabled = true
lineChart.leftAxis.drawAxisLineEnabled = true
lineChart.leftAxis.drawGridLinesEnabled = false
lineChart.rightAxis.drawAxisLineEnabled = false
lineChart.rightAxis.drawLabelsEnabled = false
lineChart.xAxis.drawGridLinesEnabled = false
lineChart.extraRightOffset = 15*screenWidthFactor
lineChart.drawMarkers = true
lineChart.pinchZoomEnabled = true
lineChart.doubleTapToZoomEnabled = true