gpt4 book ai didi

ios - 底部的 Swift Chart 月份

转载 作者:搜寻专家 更新时间:2023-10-31 23:06:07 26 4
gpt4 key购买 nike

我正在将 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

还有哪些其他属性可以实现图表上的白色垂直线和底部的底部月份。

提前致谢。

最佳答案

使用 lineChart.xAxis.labelPosition = .bottom//折线图

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

关于ios - 底部的 Swift Chart 月份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55193695/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com