removeDataSet(dataSet1) is not working
- Dominant language
- Swift
- Stars
- 28k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
When i tapped button the chartView will be shown the dataset when i clicked(addDataSet), -< is okay but when i tapped twice (removeDataSet)is not working. the chartView still appear the old dataset and adding the new dataSet.
var tapped: Bool = false
let chartDataSet1 = LineChartDataSet()
let chartData = LineChartData()
@IBAction func firstBtn(_ sender: Any) {
var dataEntries1 = [ChartDataEntry]()
for i in 0..<100 {
let y = arc4random()%60
let entry = ChartDataEntry.init(x: Double(i), y: Double(y))
dataEntries1.append(entry)
}
let chartDataSet1 = LineChartDataSet(entries: dataEntries1, label: nil)
chartDataSet1.colors = [.black]
if tapped{
chartView.data?.removeDataSet(chartDataSet1)
chartView.data?.notifyDataChanged()
chartView.notifyDataSetChanged()
tapped = false
}else {
chartView.data?.notifyDataChanged()
chartView.notifyDataSetChanged()
chartView.data?.addDataSet(chartDataSet1)
tapped = true
}
}
viewDidLoad
let chartData = LineChartData(dataSets: [chartDataSet1]
chartView.data = chartData
Contributor guide
Assessment
This issue has not been assessed yet.