我想在水平滚动视图中插入2个IOS CHARTS,但滚动不起作用。 第一个图表是可见的,但我无法滚动查看第二个项目 我们可以帮帮我吗?
这是我的2个图表之一的代码
func updateGraph18(){
var lineChartEntry = [ChartDataEntry]()
let storageElettricità = DataManager.shared.storageElettricità.filter { ($0.tipo == .elettricita) }
let arreyAnnoCorrente = storageElettricità.filter { $0.data.year == Date().year}
var doubleArray = arreyAnnoCorrente.map{ NSString(string: $0.costo).doubleValue }
doubleArray = doubleArray.reversed()
for i in 0..<doubleArray.count {
let value = ChartDataEntry(x: Double(i), y: doubleArray[i]) // here we set the X and Y status in a data chart entry
lineChartEntry.append(value) // here we add it to the data set
}
let annoCorrente = String (Date().year)
let line1 = LineChartDataSet(values: lineChartEntry, label: annoCorrente + " " + loc("ELECTR_BILL"))
//Here we convert lineChartEntry to a LineChartDataSet
line1.colors = [#colorLiteral(red: 1, green: 0.8323456645, blue: 0.4732058644, alpha: 1)]
let data = LineChartData() //This is the object that will be added to the chart
data.addDataSet(line1) //Adds the line to the dataSet
Grafico18.animate(yAxisDuration: 1.0, easingOption: .easeInBack)
Grafico18.data = data //finally - it adds the chart data to the chart and causes an update
Grafico18.chartDescription?.text = "" // Here we set the description for the graph
Grafico18.rightAxis.enabled = false
Grafico18.leftAxis.enabled = false
Grafico18.maxVisibleCount = 0
Grafico18.drawGridBackgroundEnabled = false
Grafico18.isUserInteractionEnabled = true
Grafico18.clipValuesToContentEnabled = false
Grafico18.backgroundColor = UIColor.white
Grafico18.gridBackgroundColor = UIColor.white
line1.circleRadius = 8
line1.circleHoleRadius = 5
line1.circleColors = [#colorLiteral(red: 1, green: 0.8323456645, blue: 0.4732058644, alpha: 1)]
line1.lineWidth = 5
line1.valueTextColor = UIColor(red: 0.03269767389, green: 0.06364088506, blue: 0.3465765417, alpha: 1)
line1.valueFont = UIFont.boldSystemFont(ofSize: 10)
line1.drawHorizontalHighlightIndicatorEnabled = false
line1.drawVerticalHighlightIndicatorEnabled = false
Grafico18.xAxis.enabled = false
Grafico18.setViewPortOffsets(left: 30, top: 30, right: 30, bottom: 30)
Grafico18.isUserInteractionEnabled = true
let pFormatter = NumberFormatter()
pFormatter.numberStyle = .currency
data.setValueFormatter(DefaultValueFormatter(formatter: pFormatter))
}
我们可以帮助我吗?