<commit_before>class App.Views.ChartView extends Backbone.View

  initialize: ->

    width = @model.get('width')
    height = @model.get('height')
    data = @model.get('data')
    yAxisAreaWidth = 100
    dataWidth = width - yAxisAreaWidth

    @lineX = (d,i) => i * (dataWidth / data.length)
    @lineY = (d) => height - @scales.y(d)

    @render()

  initialRender: ->

    yAxisAreaWidth = 100
    width = @model.get('width')
    height = @model.get('height')
    data = @model.get('data')

    @svg = d3.select(@el)
      .attr("width", width)
      .attr("height", height)
     
    @svg.append("g")
      .attr("class", "axis")
      .attr("transform", "translate(#{width - yAxisAreaWidth}, 0)")
      .attr("height", height)
      .call(@yAxis)

    @

  setScales: ->

    height = @model.get('height')
    data = @model.get('data')

    @scales =

      y: d3.scale.linear()
        .domain([0, @model.get('maxY')])
        .range([0, @model.get('height')])

      yAxis: d3.scale.linear()
        .domain([0, @model.get('maxY')])
        .range([height, 0])

    @yAxis = d3.svg.axis()
      .scale(@scales.yAxis)
      .orient("right")
      .ticks(3)

    @

  render: ->

    @setScales()

    @initialRender() unless @svg

    @line = d3.svg.line()
      .x(@lineX)
      .y(@lineY)

    @svg.append("path")
        .attr("class", "line")
        .attr("d", @line(@model.get('data')))

    @model.on "change", => @transition()

  transition: ->

    @setScales()<commit_msg>refactors chart view a small amount<commit_after>class App.Views.ChartView extends Backbone.View

  initialize: ->

    width = @model.get('width')
    height = @model.get('height')
    data = @model.get('data')
    yAxisAreaWidth = 100
    dataWidth = width - yAxisAreaWidth

    @lineX = (d,i) => i * (dataWidth / data.length)
    @lineY = (d) => height - @scales.y(d)

    @render()

    @model.on "change", => @transition()


  setScales: ->

    height = @model.get('height')
    maxY = @model.get('maxY')

    @scales =

      y: d3.scale.linear()
        .domain([0, maxY])
        .range([0, height])

      yAxis: d3.scale.linear()
        .domain([0, maxY])
        .range([height, 0])

    @yAxis = d3.svg.axis()
      .scale(@scales.yAxis)
      .orient("right")
      .ticks(3)

    @

  render: ->

    @setScales()

    yAxisAreaWidth = 100
    width = @model.get('width')
    height = @model.get('height')
    data = @model.get('data')

    @svg = d3.select(@el)
      .attr("width", width)
      .attr("height", height)
     
    @svg.append("g")
      .attr("class", "axis")
      .attr("transform", "translate(#{width - yAxisAreaWidth}, 0)")
      .attr("height", height)
      .call(@yAxis)

    @line = d3.svg.line()
      .x(@lineX)
      .y(@lineY)

    @svg.append("path")
        .attr("class", "line")
        .attr("d", @line(@model.get('data')))

    @

  transition: ->

    @setScales()
{'fraction_non_alphanumeric': 0.19924294562973158, 'fraction_numerical': 0.01169993117687543, 'mean_word_length': 2.2736486486486487, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '400485', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1027, 'n_words': 186}