gpt4 book ai didi

ios - 如何将栏的值放在 Swift iOS 图表的 Horizo​​ntalBarChartView 的栏内?

转载 作者:行者123 更新时间:2023-11-28 11:37:56 25 4
gpt4 key购买 nike

我正在尝试将条形图的值放在我的 Horizo​​ntalBarChartView 的条形图内,因为某些值在屏幕的右侧被剪裁,但我没有在网络搜索中找到解决方案。另外,我想将标签放在图表的左侧,但我不知道该怎么做,而且我不能在同一个问题上问两个问题。

这是我的设置图表代码:

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
}

结果:

enter image description here

我想要这个:

enter image description here

我正在使用这个库:https://github.com/danielgindi/Charts

最佳答案

尝试在您的 chartview 中将以下属性设置为 false:

self.chartViewHorizontal.drawValueAboveBarEnabled = false

这将帮助您在 BarChart 中获取您的值标签。

对于将 xAxis 标签放在 ChartView 左侧的第二个问题,您可以使用以下属性将其设置在左侧。

self.chartViewHorizontal.xAxis.labelPosition = .bottom

试试上面的属性,你会达到你的要求。

关于ios - 如何将栏的值放在 Swift iOS 图表的 Horizo​​ntalBarChartView 的栏内?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54553310/

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