<commit_before>D3.merit_order_price_curve =
  View: class extends D3YearlyChartView
    initialize: ->
      D3YearlyChartView.prototype.initialize.call(this)

    draw: ->
      @average = new ChartSerie(
        color: "#CC0000",
        label: I18n.t("output_element_series.merit_price_average")
      )

      @legendSeries = @model.non_target_series()
      @legendSeries.push(@average)

      @drawChart()
      @dateSelect.setVal(1)

      @drawLegend(@legendSeries, 1)

    averageData: ->
      values  = @prices[0].values.slice()

      color:  @average.attributes.color,
      label:  @average.attributes.label,
      key:    'average',
      values: values.map((price) ->
        x: price.x, y: d3.mean(values.map((price) -> price.y))
      )

    dataForChart: ->
      @prices = @model.non_target_series().map(@convertToDateRange)
      @prices.push(@averageData())
      @prices

    drawData: (xScale, yScale) ->
      line = @line(xScale, yScale)<commit_msg>Fix calculating the mean line of the price curve in a loop<commit_after>D3.merit_order_price_curve =
  View: class extends D3YearlyChartView
    initialize: ->
      D3YearlyChartView.prototype.initialize.call(this)

    draw: ->
      @average = new ChartSerie(
        color: "#CC0000",
        label: I18n.t("output_element_series.merit_price_average")
      )

      @legendSeries = @model.non_target_series()
      @legendSeries.push(@average)

      @drawChart()
      @dateSelect.setVal(1)

      @drawLegend(@legendSeries, 1)

    averageData: ->
      values  = @prices[0].values.slice()
      mean    = d3.mean(values.map((price) -> price.y))

      color:  @average.attributes.color,
      label:  @average.attributes.label,
      key:    'average',
      values: values.map((price) ->
        x: price.x, y: mean
      )

    dataForChart: ->
      @prices = @model.non_target_series().map(@convertToDateRange)
      @prices.push(@averageData())
      @prices

    drawData: (xScale, yScale) ->
      line = @line(xScale, yScale)
{'fraction_non_alphanumeric': 0.13541666666666666, 'fraction_numerical': 0.012896825396825396, 'mean_word_length': 2.6941391941391943, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '4260807', 'n_tokens_mistral': 709, 'n_tokens_neox': 658, 'n_words': 110}