<commit_before>//
//  ChartDataSetManager.swift
//  Precipitate
//
//  Created by <NAME> on 12/7/15.
//  Copyright © 2015 markedwardmurray. All rights reserved.
//

import Foundation
import SwiftyJSON
import Charts

class ChartDataSetManager {
    static let sharedInstance = ChartDataSetManager()
    
    var dataEntryCollator: DataEntryCollator? {
        didSet {
            self.setHourlyDataSets()
            self.setDailyDataSets()
        }
    }
    func collateDataEntrysFromJSON(json: JSON) {
        dataEntryCollator = DataEntryCollator(json: json)
    }
    
    private(set) var hourlyDataSets: [String: LineChartDataSet]?
    private(set) var dailyDataSets: [String: LineChartDataSet]?
    
    private func setHourlyDataSets() {
        if let dataEntryCollator = dataEntryCollator {
             var hourlyDataSetsTemp = [String: LineChartDataSet]()
            
            for (hourlyKey, dataEntrysArray) in dataEntryCollator.hourlyDataEntrys {
                let label = ChartDataSetManager.hourlyLabelsForHourlyKeys[hourlyKey]
                let hourlyDataSet = LineChartDataSet(yVals: dataEntrysArray, label: label)
                
                // settings for individual lines
                hourlyDataSet.drawCirclesEnabled = false
                hourlyDataSet.drawValuesEnabled = false
                hourlyDataSet.setColor(UIColor.redColor())
                hourlyDataSet.lineWidth = 2.0
                ///////////////////////////////
                
                hourlyDataSetsTemp[hourlyKey] = hourlyDataSet
            }
            hourlyDataSets = hourlyDataSetsTemp
        } else {
            print("ChartDataSetManager - DataEntryCollator is nil")
        }
    }
    
    private func setDailyDataSets() {
        if let dataEntryCollator = dataEntryCollator {
            var dailyDataSetsTemp = [String: LineChartDataSet]()
            
            for (dailyKey, dataEntrysArray) in dataEntryCollator.dailyDataEntrys {
                let label = ChartDataSetManager.dailyLabelsForDailyKeys[dailyKey]
                let dailyDataSet = LineChartDataSet(yVals: dataEntrysArray, label: label)
                
                // settings for individual lines
                dailyDataSet.drawCirclesEnabled = false
                dailyDataSet.drawValuesEnabled = false
                dailyDataSet.setColor(UIColor.greenColor())
                dailyDataSet.lineWidth = 2.0
                ///////////////////////////////
                
                dailyDataSetsTemp[dailyKey] = dailyDataSet
            }
            dailyDataSets = dailyDataSetsTemp
        } else {
            print("ChartDataSetManager - DataEntryCollator is nil")
        }
    }

    static let hourlyLabelsForHourlyKeys: [String : String] =
    [
        "temperature" : "Temp",
        "apparentTemperature" : "Apparent Temp",
        
        "precipProbability" : "Precipitation Probability",
        "precipIntensity" : "Precipitation Intensity",<commit_msg>change line colors to blue & red<commit_after>//
//  ChartDataSetManager.swift
//  Precipitate
//
//  Created by <NAME> on 12/7/15.
//  Copyright © 2015 markedwardmurray. All rights reserved.
//

import Foundation
import SwiftyJSON
import Charts

class ChartDataSetManager {
    static let sharedInstance = ChartDataSetManager()
    
    var dataEntryCollator: DataEntryCollator? {
        didSet {
            self.setHourlyDataSets()
            self.setDailyDataSets()
        }
    }
    func collateDataEntrysFromJSON(json: JSON) {
        dataEntryCollator = DataEntryCollator(json: json)
    }
    
    private(set) var hourlyDataSets: [String: LineChartDataSet]?
    private(set) var dailyDataSets: [String: LineChartDataSet]?
    
    private func setHourlyDataSets() {
        if let dataEntryCollator = dataEntryCollator {
             var hourlyDataSetsTemp = [String: LineChartDataSet]()
            
            for (hourlyKey, dataEntrysArray) in dataEntryCollator.hourlyDataEntrys {
                let label = ChartDataSetManager.hourlyLabelsForHourlyKeys[hourlyKey]
                let hourlyDataSet = LineChartDataSet(yVals: dataEntrysArray, label: label)
                
                // settings for individual lines
                hourlyDataSet.drawCirclesEnabled = false
                hourlyDataSet.drawValuesEnabled = false
                hourlyDataSet.setColor(UIColor.blueColor())
                hourlyDataSet.lineWidth = 2.0
                ///////////////////////////////
                
                hourlyDataSetsTemp[hourlyKey] = hourlyDataSet
            }
            hourlyDataSets = hourlyDataSetsTemp
        } else {
            print("ChartDataSetManager - DataEntryCollator is nil")
        }
    }
    
    private func setDailyDataSets() {
        if let dataEntryCollator = dataEntryCollator {
            var dailyDataSetsTemp = [String: LineChartDataSet]()
            
            for (dailyKey, dataEntrysArray) in dataEntryCollator.dailyDataEntrys {
                let label = ChartDataSetManager.dailyLabelsForDailyKeys[dailyKey]
                let dailyDataSet = LineChartDataSet(yVals: dataEntrysArray, label: label)
                
                // settings for individual lines
                dailyDataSet.drawCirclesEnabled = false
                dailyDataSet.drawValuesEnabled = false
                dailyDataSet.setColor(UIColor.redColor())
                dailyDataSet.lineWidth = 2.0
                ///////////////////////////////
                
                dailyDataSetsTemp[dailyKey] = dailyDataSet
            }
            dailyDataSets = dailyDataSetsTemp
        } else {
            print("ChartDataSetManager - DataEntryCollator is nil")
        }
    }

    static let hourlyLabelsForHourlyKeys: [String : String] =
    [
        "temperature" : "Temp",
        "apparentTemperature" : "Apparent Temp",
        
        "precipProbability" : "Precipitation Probability",
        "precipIntensity" : "Precipitation Intensity",
{'fraction_non_alphanumeric': 0.08889996676636756, 'fraction_numerical': 0.004320372216683284, 'mean_word_length': 1.881282910483485, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5984885', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1544, 'n_words': 314}