I'm trying to use a bar chart to show my data. I want to show things grouped by date, and for each date I have 7 people and their associated value.
I created a tubular CPTBarPlot for each date with a barWidth of 0.25
I'm confused as to what to set the barOffset to for each plot so things draw properly.
For the storage of data, I used var plotData: [NSDate : [Double]]?. That array of double has exactly 7 values for each NSDate (one for each person, in order)
The numberForPlot method I have is drawing all the values, but the grouping seems to be by person instead of date, and they're drawing over each other. This is what I used:
func numberForPlot(plot: CPTPlot, field fieldEnum: UInt, recordIndex idx: UInt) -> AnyObject? {
guard let type = CPTBarPlotField(rawValue: Int(fieldEnum)) else { return nil }
switch type {
case .BarBase:
fatalError()
case .BarLocation:
return idx
case .BarTip:
guard let date = plot.identifier as? NSDate, values = plotData?[date] else {
fatalError()
}
return values[Int(idx)]
}
}