in ChartsDemo-iOS/Swift/DemoBaseViewController.swift [127:181]
func handleOption(_ option: Option, forChartView chartView: ChartViewBase) {
switch option {
case .toggleValues:
for set in chartView.data! {
set.drawValuesEnabled = !set.drawValuesEnabled
}
chartView.setNeedsDisplay()
case .toggleIcons:
for set in chartView.data! {
set.drawIconsEnabled = !set.drawIconsEnabled
}
chartView.setNeedsDisplay()
case .toggleHighlight:
chartView.data!.isHighlightEnabled = !chartView.data!.isHighlightEnabled
chartView.setNeedsDisplay()
case .animateX:
chartView.animate(xAxisDuration: 3)
case .animateY:
chartView.animate(yAxisDuration: 3)
case .animateXY:
chartView.animate(xAxisDuration: 3, yAxisDuration: 3)
case .saveToGallery:
UIImageWriteToSavedPhotosAlbum(chartView.getChartImage(transparent: false)!, nil, nil, nil)
case .togglePinchZoom:
let barLineChart = chartView as! BarLineChartViewBase
barLineChart.pinchZoomEnabled = !barLineChart.pinchZoomEnabled
chartView.setNeedsDisplay()
case .toggleAutoScaleMinMax:
let barLineChart = chartView as! BarLineChartViewBase
barLineChart.autoScaleMinMaxEnabled = !barLineChart.isAutoScaleMinMaxEnabled
chartView.notifyDataSetChanged()
case .toggleData:
shouldHideData = !shouldHideData
updateChartData()
case .toggleBarBorders:
for set in chartView.data! {
if let set = set as? BarChartDataSet {
set.barBorderWidth = set.barBorderWidth == 1.0 ? 0.0 : 1.0
}
}
chartView.setNeedsDisplay()
default:
break
}
}