We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In UIView I have buttons( 1,2,3,4) and UIView with Charts
I want if button1 press - remove old data line and show new with new data^ and if press button2 similar reload
func populateData(withCount countA: [Double], countB: [Double]) { for index in 0..<countB.count{ let dataEntry = ChartDataEntry(x: countB[index], y: countA[index]) values.append(dataEntry) } let set = LineChartDataSet(values: values, label: "") set.mode = .cubicBezier set.cubicIntensity = 0.2 set.drawCirclesEnabled = true set.lineWidth = 2.7 set.circleRadius = 2.8 set.setCircleColor(.green) set.setColor(#colorLiteral(red: 0.3176470588, green: 0.9960784314, blue: 0.6549019608, alpha: 1)) set.fillColor = .green set.fillAlpha = 1.0 set.drawHorizontalHighlightIndicatorEnabled = false set.drawVerticalHighlightIndicatorEnabled = false let gradientColors = [UIColor.cyan.cgColor, UIColor.clear.cgColor] as CFArray let colorLocations:[CGFloat] = [1.0, 0.0] let gradient = CGGradient.init(colorsSpace: CGColorSpaceCreateDeviceRGB(), colors: gradientColors, locations: colorLocations set.fill = Fill.fillWithLinearGradient(gradient!, angle: 90.0) set.drawFilledEnabled = true let data = LineChartData(dataSet: set) data.setDrawValues(false) chartView.data = data }
In viewDidLoad I load data from button1:
let a: [Double] = [2.530, 2.014, 2.625, 1.898, 0.556, 2.3767, 2.554, 2.6676, 1.8777, 2.098, 2.567, 3.0, 3.5, 3.7, 3.2] let b: [Double] = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0] let c: [Double] = [1.530, 3.014, 0.625, 3.898, 2.556, 3.3767, 1.554, 1.6676, 3.8777, 1.098, 3.567, 2.0, 2.5, 1.7, 2.2] let d: [Double] = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0] override func viewDidLoad() { super.viewDidLoad() populateData(withCount: a, countB: b) }
In button1:
chartView.clear() populateData(withCount: a, countB: b)
In button2:
chartView.clear() populateData(withCount: c, countB: d)
But it's not work, data does't change, only add and show 2 lines
How can I delete and put new data?
The text was updated successfully, but these errors were encountered:
Create
func populateData(withCount countA: [Double], countB: [Double]) { values = [] for index in 0..<countB.count{ let dataEntry = ChartDataEntry(x: countB[index], y: countA[index]) values.append(dataEntry) }
Sorry, something went wrong.
ask on stack overflow please.
No branches or pull requests
In UIView I have buttons( 1,2,3,4) and UIView with Charts
I want if button1 press - remove old data line and show new with new data^ and if press button2 similar reload
In viewDidLoad I load data from button1:
In button1:
In button2:
But it's not work, data does't change, only add and show 2 lines
How can I delete and put new data?
The text was updated successfully, but these errors were encountered: