<commit_before>Template.chart.helpers
  nonNumberDataColumnSpec: ->
    for spec in @header.slice(1)
      if spec.chartType isnt "number"
        return spec
  reactivityHack: ->
    if not Session.get("chartsLoaded")
      return
    _.defer =>
      data = new google.visualization.DataTable()
      series = []
      for spec in @header
        if @output is "rwstats" and (spec.isPercentage or spec.name is "cumul_%")
          continue
        data.addColumn(spec.chartType, i18n.t("rwcut.fields." + spec.name))
        series.push({})
      for row in @rows
        values = []
        for value, index in row
          spec = @header[index]
          if @output is "rwstats" and (spec.isPercentage or spec.name is "cumul_%")
            continue
          values.push(value)
        data.addRow(values)
      chartWrapper = share.chartWrappers.get(@_id)
      chartWrapper.setDataTable(data)
      chartWrapper.setChartType(@chartType)
      chartWrapper.setView(
        columns: _.range(data.getNumberOfColumns())
      )
      chartWrapper.setOptions(
        height: @chartHeight
        curveType: "function"
        series: series
        vAxis:
          logScale: true
        hAxis:
          logScale: @chartType not in ["LineChart"]
      )
      container = $(".chart[data-id='" + @_id + "'] .chart-container").get(0)
      chartWrapper.container = container
      chartWrapper.draw(container)
    null

Template.chart.rendered = ->

Template.chart.events
#  "click .selector": (event, template) -><commit_msg>Change legend position<commit_after>Template.chart.helpers
  nonNumberDataColumnSpec: ->
    for spec in @header.slice(1)
      if spec.chartType isnt "number"
        return spec
  reactivityHack: ->
    if not Session.get("chartsLoaded")
      return
    _.defer =>
      data = new google.visualization.DataTable()
      series = []
      for spec in @header
        if @output is "rwstats" and (spec.isPercentage or spec.name is "cumul_%")
          continue
        data.addColumn(spec.chartType, i18n.t("rwcut.fields." + spec.name))
        series.push({})
      for row in @rows
        values = []
        for value, index in row
          spec = @header[index]
          if @output is "rwstats" and (spec.isPercentage or spec.name is "cumul_%")
            continue
          values.push(value)
        data.addRow(values)
      chartWrapper = share.chartWrappers.get(@_id)
      chartWrapper.setDataTable(data)
      chartWrapper.setChartType(@chartType)
      chartWrapper.setView(
        columns: _.range(data.getNumberOfColumns())
      )
      chartWrapper.setOptions(
        height: @chartHeight
        curveType: "function"
        series: series
        legend:
          position: "bottom"
        vAxis:
          logScale: true
        hAxis:
          logScale: @chartType not in ["LineChart"]
      )
      container = $(".chart[data-id='" + @_id + "'] .chart-container").get(0)
      chartWrapper.container = container
      chartWrapper.draw(container)
    null

Template.chart.rendered = ->

Template.chart.events
#  "click .selector": (event, template) ->
{'fraction_non_alphanumeric': 0.11368015414258188, 'fraction_numerical': 0.002569043031470777, 'mean_word_length': 2.2720588235294117, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 13, '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': '3622804', 'n_tokens_mistral': 924, 'n_tokens_neox': 915, 'n_words': 211}