Swift Chart месяцев внизу - PullRequest
3 голосов
/ 16 марта 2019

Я интегрирую Chart в свое приложение.

Использование https://github.com/danielgindi/Charts

этого достигли: enter image description here

Ожидаемый результат: enter image description here

Код:

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

Каковы другие свойства для достижения белой вертикальной линии на графике и нижних месяцев внизу.

Заранее спасибо.

1 Ответ

0 голосов
/ 30 марта 2019

use 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
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...