core: Implement bar chart

This commit is contained in:
2019-08-18 07:47:02 -05:00
parent 3e2cf48223
commit bfea4b024a
11 changed files with 271 additions and 7 deletions

View File

@@ -42,9 +42,32 @@ class DetailScreenController : UITableViewController {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .edit,
target: self,
action: #selector(self.onEditHabitClicked))
cells.append(buildBarChartCell())
cells.append(buildHistoryChartCell())
}
func buildBarChartCell() -> UITableViewCell {
let today = LocalDate(year: 2019, month: 3, day: 15)
let axis = (0...365).map { today.minus(days: $0) }
let component = BarChart(theme: theme,
dateFormatter: IosLocalDateFormatter())
component.axis = axis
let cell = UITableViewCell()
let view = ComponentView(frame: cell.frame, component: component)
for k in 0...0 {
var series = [KotlinDouble]()
for _ in 1...365 {
series.append(KotlinDouble(value: Double.random(in: 0...5000)))
}
component.series.add(series)
let color = (self.habit.color.index + Int32(k * 3)) % 16
component.colors.add(theme.color(paletteIndex: color))
}
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
cell.contentView.addSubview(view)
return cell
}
func buildHistoryChartCell() -> UITableViewCell {
let component = CalendarChart(today: LocalDate(year: 2019, month: 3, day: 15),
color: color,