gpt4 book ai didi

ios - Swift:图表填充线等

转载 作者:搜寻专家 更新时间:2023-10-31 08:25:48 24 4
gpt4 key购买 nike

我在 swift 上创建了这个名为:Charts 的库 https://github.com/danielgindi/ios-charts

我尽了最大努力添加了一些功能,但对于其他一些功能(在下面列出)我不知道该怎么做。任何帮助将不胜感激。

我正在尝试做的事情:- 填充折线图(完成)- 删除坐标处的圆。 (完毕)- 删除所有轴条 (Y+X) (todo)- 删除 yAxis 图例(待办事项)- 线上,每 x 次显示值 (todo)

我做了什么:

Chart Graph

额外- 在触摸上方显示 yValue- 基于 yValue 的渐变填充- 动画(完成)

这是我的实际代码:

func setChart(dataPoints: [String], values: [Double]) {

//print(dataPoints)
//print(values)
var dataEntries: [ChartDataEntry] = []

for i in 0..<dataPoints.count {
let dataEntry = ChartDataEntry(value: values[i], xIndex: i)
dataEntries.append(dataEntry)
}

//Coloring
let red = Double(arc4random_uniform(256))
let green = Double(arc4random_uniform(256))
let blue = Double(arc4random_uniform(256))
let color = UIColor(red: CGFloat(red/255), green: CGFloat(green/255), blue: CGFloat(blue/255), alpha: 1)


let lineChartDataSet = LineChartDataSet(yVals: dataEntries, label: "Temperatures")
let lineChartData = LineChartData(xVals: dataPoints, dataSet: lineChartDataSet)
//draw as line
lineChartDataSet.drawCubicEnabled = true
//fill graph
lineChartDataSet.drawFilledEnabled = true
//color graph
lineChartDataSet.colors = [color]

lineChartView.data = lineChartData
lineChartView.xAxis.labelPosition = .Bottom
lineChartView.animate(xAxisDuration: 2.0, yAxisDuration: 2.0, easingOption: .EaseInCubic)
//remove coordinate circles
lineChartDataSet.drawCirclesEnabled = false
//remove xAxis line
lineChartView.xAxis.drawGridLinesEnabled = false
lineChartView.xAxis.drawAxisLineEnabled = false

//remove description
lineChartView.descriptionText = ""


}

我想:删除所有轴条 (Y+X)删除 yAxis 图例线上,每x次显示值并在图形触摸时显示值。

感谢您的宝贵时间。

最佳答案

要删除所有轴条和图例,您可以这样做:

这是我的代码片段:

popularityChartView.descriptionText = ""
popularityChartView.noDataText = Constants.messages.NO_POPULARITY_CHART_DATA
popularityChartView.noDataTextDescription = ""
popularityChartView.backgroundColor = UIColor(red:236/255, green:236/255,blue:236/255,alpha:1)

popularityChartView.xAxis.drawAxisLineEnabled = false
popularityChartView.xAxis.drawLimitLinesBehindDataEnabled = false
popularityChartView.xAxis.gridColor = UIColor(red:220/255, green:220/255,blue:220/255,alpha:1)
popularityChartView.xAxis.gridLineWidth = 0.5
popularityChartView.xAxis.drawGridLinesEnabled = true
popularityChartView.xAxis.drawLabelsEnabled = false

popularityChartView.leftAxis.removeAllLimitLines()
popularityChartView.leftAxis.drawZeroLineEnabled = false
popularityChartView.leftAxis.zeroLineWidth = 0
popularityChartView.leftAxis.drawTopYLabelEntryEnabled = false
popularityChartView.leftAxis.drawAxisLineEnabled = false
popularityChartView.leftAxis.drawGridLinesEnabled = false
popularityChartView.leftAxis.drawLabelsEnabled = false
popularityChartView.leftAxis.drawLimitLinesBehindDataEnabled = false

popularityChartView.rightAxis.removeAllLimitLines()
popularityChartView.rightAxis.drawZeroLineEnabled = false
popularityChartView.leftAxis.zeroLineWidth = 0
popularityChartView.rightAxis.drawTopYLabelEntryEnabled = false
popularityChartView.rightAxis.drawAxisLineEnabled = false
popularityChartView.rightAxis.drawGridLinesEnabled = false
popularityChartView.rightAxis.drawLabelsEnabled = false
popularityChartView.rightAxis.drawLimitLinesBehindDataEnabled = false

My Chart

希望对您有所帮助。

关于ios - Swift:图表填充线等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35663721/

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