我试图把酒吧的价值里面栏上我的HorizontalBarChartView,因为有些值在屏幕的右侧裁剪,但我没有发现在网络上搜索解决方案。另外,我还要把标签贴在图表的左侧,但我不知道如何这一点,我不能在同一个问题问两两件事。
这是我的设置表的代码:
func setupChart() {
self.chartViewHorizontal.fitBars = true
self.chartViewHorizontal.legend.enabled = false
self.chartViewHorizontal.isUserInteractionEnabled = false
self.chartViewHorizontal.animate(yAxisDuration: 1.5)
self.chartViewHorizontal.rightAxis.enabled = false
self.chartViewHorizontal.leftAxis.labelCount = 5
self.chartViewHorizontal.leftAxis.labelFont = UIFont.boldSystemFont(ofSize: 10.0)
self.chartViewHorizontal.leftAxis.valueFormatter = CustomAxisValueFormatter()
self.chartViewHorizontal.xAxis.drawGridLinesEnabled = false
self.chartViewHorizontal.xAxis.enabled = false
}
结果是:
我要这个:
我'使用此lib目录下:https://github.com/danielgindi/Charts
尝试设置以下属性假你chartview
:
self.chartViewHorizontal.drawValueAboveBarEnabled = false
这将帮助你进去BarChart
你的价值标签。
对于你的第二个问题,把你的x轴标签的ChartView
的左侧,你可以使用以下属性来设置它放在左侧。
self.chartViewHorizontal.xAxis.labelPosition = .bottom
尝试上述财产,你会实现你的要求。