gpt4 book ai didi

ios - 使用图表设置饼图的最大值和宽度

转载 作者:行者123 更新时间:2023-11-30 12:37:11 24 4
gpt4 key购买 nike

您好,我正在使用图表库,并且已经构建了一些图表,但是我想用 PieChart 做一些特殊的事情,但我还不能做到这一点,我不知道哪些属性可以设置我的饼图就像你想要的那样。好的,那么我想将图表的最大值设置为 100,通过设置此值,我想我的图表将仅显示我在本例中尝试显示的数字 es 50,而图表的其他部分应该显示看起来空荡荡的。我希望你能帮助我。

This is what I have now the graph has just one Double value that value is 50

This is the way that the graph should look like

最佳答案

 func createPieGraphRedemptions() {
var chart = PieChartView()
chart = PieChartView(frame: CGRect(x: 229, y: 40, width: 165, height: 165))
let yVals: [Double] = [50]
var entries = [ ChartDataEntry]()
for (i, v) in yVals.enumerated() {
let entry = ChartDataEntry()
entry.x = Double( i)
entry.y = v

entries.append( entry)
}
let set = PieChartDataSet( values: entries, label: "Pie Chart")

set.colors = [UIColor.red]

let data = PieChartData( dataSet: set)
//data.setDrawValues(false)
chart.data = data
chart.noDataText = "No hay datos disponibles"
chart.isUserInteractionEnabled = false
chart.legend.enabled = false
chart.chartDescription?.text = ""
chart.highlighter = nil



self.view.addSubview(chart)
}

关于ios - 使用图表设置饼图的最大值和宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42724826/

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