<commit_before>//
// Copyright 2015 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//


import UIKit

class TwitterStatsViewController: UIViewController {
  
  @IBOutlet weak var chart: ShinobiChart!
  let chartDatasource = TwitterStatsChartDataSource.defaultData()
  let chartDelegate = TwitterChartDelegate()
  
  override func viewDidLoad() {
    super.viewDidLoad()
    
    // Do any additional setup after loading the view.
    if let chartDatasource = chartDatasource {
      chart.datasource = chartDatasource
    }
    chart.delegate = chartDelegate
    
    prepareChart()
  }
  
  private func prepareChart() {
    chart.backgroundColor = UIColor.clearColor()
    
    let lineColour = UIColor(white: 0.7, alpha: 1.0)
    
    let xAxis = SChartDateTimeAxis()
    xAxis.majorTickFrequency = 60*60*24*7
    xAxis.style.lineWidth = 0.5
    
    xAxis.style.majorGridLineStyle.showMajorGridLines = true
    xAxis.style.majorGridLineStyle.lineWidth = 0.5
    xAxis.style.majorGridLineStyle.lineColor = lineColour
    xAxis.style.majorTickStyle.showTicks = true
    xAxis.style.majorTickStyle.lineWidth = 0.5
    xAxis.style.majorTickStyle.lineLength = 20
    xAxis.style.majorTickStyle.lineColor = lineColour
    xAxis.style.lineColor = lineColour
    
    xAxis.width = 25
    
    // Ticks marks should represent saturday. Have to deal with daylight saving
    let midnightToday = NSCalendar.currentCalendar().dateBySettingHour(0, minute: 0, second: 0, ofDate: NSDate(), options: .allZeros)
    let anchor = NSCalendar.currentCalendar().dateBySettingUnit(.CalendarUnitWeekday, value: 1, ofDate: midnightToday!, options: .allZeros)
    xAxis.anchorPoint = anchor
    
    
    chart.xAxis = xAxis

    
    
    let yAxis = SChartNumberAxis()
    yAxis.axisPosition = SChartAxisPositionReverse
    yAxis.style.lineWidth = 0
    yAxis.majorTickFrequency = 1000
    let formatter = yAxis.labelFormatter.numberFormatter()
    formatter.multiplier = 0.001
    formatter.numberStyle = .DecimalStyle
    formatter.minimumFractionDigits = 1
    formatter.maximumFractionDigits = 1
    formatter.positiveSuffix = "k"
    formatter.negativeSuffix = "k"
    
    yAxis.style.majorGridLineStyle.showMajorGridLines = true
    yAxis.style.majorGridLineStyle.dashedMajorGridLines = true
    yAxis.style.majorGridLineStyle.dashStyle = [1]
    
    yAxis.width = 1
    yAxis.rangePaddingHigh = 100
    
    chart.yAxis = yAxis
  }
  
}

class TwitterChartDelegate: NSObject, SChartDelegate {
  func sChart(chart: ShinobiChart!, alterTickMark tickMark: SChartTickMark!, beforeAddingToAxis axis: SChartAxis!) {
    if let tickLabel = tickMark.tickLabel {
      if axis.isXAxis() {
        tickLabel.frame = tickLabel.frame.rectByOffsetting(dx: tickLabel.bounds.width * 0.5,
          dy: -tickLabel.bounds.height * 1.4)
      } else {
        tickLabel.frame = tickLabel.frame.rectByOffsetting(dx: -tickLabel.bounds.width * 1.5,
          dy: -tickLabel.bounds.height / 2.0)
      }
    }
  }
}<commit_msg>Remove the tick mark and grid line on the y-axis where it crosses the x<commit_after>//
// Copyright 2015 <NAME>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//


import UIKit

class TwitterStatsViewController: UIViewController {
  
  @IBOutlet weak var chart: ShinobiChart!
  let chartDatasource = TwitterStatsChartDataSource.defaultData()
  let chartDelegate = TwitterChartDelegate()
  
  override func viewDidLoad() {
    super.viewDidLoad()
    
    // Do any additional setup after loading the view.
    if let chartDatasource = chartDatasource {
      chart.datasource = chartDatasource
    }
    chart.delegate = chartDelegate
    
    prepareChart()
  }
  
  private func prepareChart() {
    chart.backgroundColor = UIColor.clearColor()
    
    let lineColour = UIColor(white: 0.7, alpha: 1.0)
    
    let xAxis = SChartDateTimeAxis()
    xAxis.majorTickFrequency = 60*60*24*7
    xAxis.style.lineWidth = 0.5
    
    xAxis.style.majorGridLineStyle.showMajorGridLines = true
    xAxis.style.majorGridLineStyle.lineWidth = 0.5
    xAxis.style.majorGridLineStyle.lineColor = lineColour
    xAxis.style.majorTickStyle.showTicks = true
    xAxis.style.majorTickStyle.lineWidth = 0.5
    xAxis.style.majorTickStyle.lineLength = 20
    xAxis.style.majorTickStyle.lineColor = lineColour
    xAxis.style.lineColor = lineColour
    
    xAxis.width = 25
    
    // Ticks marks should represent saturday. Have to deal with daylight saving
    let midnightToday = NSCalendar.currentCalendar().dateBySettingHour(0, minute: 0, second: 0, ofDate: NSDate(), options: .allZeros)
    let anchor = NSCalendar.currentCalendar().dateBySettingUnit(.CalendarUnitWeekday, value: 1, ofDate: midnightToday!, options: .allZeros)
    xAxis.anchorPoint = anchor
    
    
    chart.xAxis = xAxis

    
    
    let yAxis = SChartNumberAxis()
    yAxis.axisPosition = SChartAxisPositionReverse
    yAxis.style.lineWidth = 0
    yAxis.majorTickFrequency = 1000
    let formatter = yAxis.labelFormatter.numberFormatter()
    formatter.multiplier = 0.001
    formatter.numberStyle = .DecimalStyle
    formatter.minimumFractionDigits = 1
    formatter.maximumFractionDigits = 1
    formatter.positiveSuffix = "k"
    formatter.negativeSuffix = "k"
    
    yAxis.style.majorGridLineStyle.showMajorGridLines = true
    yAxis.style.majorGridLineStyle.dashedMajorGridLines = true
    yAxis.style.majorGridLineStyle.dashStyle = [1]
    
    yAxis.width = 1
    yAxis.rangePaddingHigh = 100
    
    chart.yAxis = yAxis
  }
  
}

class TwitterChartDelegate: NSObject, SChartDelegate {
  func sChart(chart: ShinobiChart!, alterTickMark tickMark: SChartTickMark!, beforeAddingToAxis axis: SChartAxis!) {
    if let tickLabel = tickMark.tickLabel {
      if axis.isXAxis() {
        tickLabel.frame = tickLabel.frame.rectByOffsetting(dx: tickLabel.bounds.width * 0.5,
          dy: -tickLabel.bounds.height * 1.4)
      } else {
        // y Axis
        if abs(tickMark.value) < 1e-4 {
          // Hide the tick mark and grid line view at origin
          tickMark.tickEnabled = false
          tickMark.gridLineView.hidden = true
        } else {
          // Re-position the tick label
          tickLabel.frame = tickLabel.frame.rectByOffsetting(dx: -tickLabel.bounds.width * 1.45,
            dy: tickLabel.bounds.height / 2.0)
        }
      }
    }
  }
}
{'fraction_non_alphanumeric': 0.08799129606963144, 'fraction_numerical': 0.01591187270501836, 'mean_word_length': 3.1106763555058694, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3111472', 'n_tokens_mistral': 2323, 'n_tokens_neox': 2183, 'n_words': 558}