You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried setting up a tests class with a bar graph but on iOS 8.1, it seems that one of the bars is missing/not displayed (image below). This happens in both the Simulator and on the iPhone.
I've also copied all of my code below.
Thanks!
import UIKit
import JBChart
class FirstViewController: UIViewController, JBBarChartViewDelegate, JBBarChartViewDataSource {
var barChartView: JBBarChartView?
var chartLegend = ["11-14", "11-15", "11-16", "11-17", "11-18", "11-19", "11-20"]
var chartData = [70, 80.0, 76, 88, 90, 69, 74]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
barChartView = JBBarChartView()
barChartView!.frame = CGRectMake(20, 20, self.view.bounds.width - 40, self.view.bounds.height * 0.5)
barChartView!.backgroundColor = UIColor.darkGrayColor()
barChartView!.delegate = self
barChartView!.dataSource = self
view.addSubview(barChartView!)
var footerView = FooterView()
footerView.leftLabel.text = chartLegend[0];
footerView.rightLabel.text = chartLegend[chartLegend.count - 1 ];
barChartView!.footerView = footerView
barChartView!.reloadData()
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
view.setNeedsLayout()
barChartView!.reloadData()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: JBBarChartView
func numberOfBarsInBarChartView(barChartView: JBBarChartView!) -> UInt {
return UInt(chartData.count)
}
func barChartView(barChartView: JBBarChartView!, heightForBarViewAtIndex index: UInt) -> CGFloat {
let height = CGFloat(chartData[Int(index)])
println("Index: \(index); Height: \(height)")
return height
}
func barChartView(barChartView: JBBarChartView!, colorForBarViewAtIndex index: UInt) -> UIColor! {
println("Color for index \(index)")
return (index % 2 == 0) ? UIColor.greenColor() : UIColor.blueColor()
}
The text was updated successfully, but these errors were encountered:
Hi DirkLXX,
any chance you can elaborate on adding a 0 value entry at the end? Did you add that to the array that acts as the datasource for the chart? For me this just seems to place the blank bar (corresponding to the smallest value in the array) at the end. Thoughts? Thank you so much in advance.
I tried setting up a tests class with a bar graph but on iOS 8.1, it seems that one of the bars is missing/not displayed (image below). This happens in both the Simulator and on the iPhone.
I've also copied all of my code below.
Thanks!
The text was updated successfully, but these errors were encountered: