// // CollectionViewItemMonth.swift // Graphic Analysis 2 // // Created by Kilian Hofmann on 16.06.17. // Copyright © 2017 Kilian Hofmann. All rights reserved. // import Cocoa class CollectionViewItemMonth: NSCollectionViewItem { @IBOutlet var day: NSTextField! @IBOutlet var loss: NSTextField! @IBOutlet var distributionAM: LossDistributionPie! @IBOutlet var distributionPM: LossDistributionPie! var distribution: [String] = [] override func viewDidLoad() { super.viewDidLoad() view.wantsLayer = true view.layer?.backgroundColor = NSColor.white.cgColor view.layer?.masksToBounds = true view.layer?.borderWidth = 1.0 view.layer?.borderColor = NSColor.clear.cgColor } func redrawDistribution() { var am: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] var pm: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for entry in distribution { let hour: Int = Int(entry.components(separatedBy: ":")[0])! if hour < 12 { am[hour] += 1 } else { pm[hour - 12] += 1 } } distributionAM.distribution = am distributionPM.distribution = pm distributionAM.needsDisplay = true distributionPM.needsDisplay = true } }