<commit_before>money = require('common/swag').money

PriceChartView = Ember.View.extend
  content: []
  valuePadding: 10

  chartData: (->
    data = []
    @get("content").forEach (item) ->
      date = item.date
      if date
        date = new Date(date)
      else
        return unless date

      value = item.value
      return unless value

      data.push value: value, date: date
    data.sort (a, b) -> a.date - b.date
  ).property("content")

  xDomain: (->
    d3.extent @get("chartData"), (item) -> item.date
  ).property("chartData")

  yDomain: (->
    padding = @get("valuePadding")
    # d3.extent(@get("chartData"), (item) -> item.value)
    # .map (value, index) ->
    #   if index is 0
    #     Math.max (value - padding), 0
    #   else
    #     value + padding
    [0, d3.max(@get("chartData"), (item) -> item.value) + padding]
  ).property("chartData")

  updateChart: (->
    @render()<commit_msg>Fix Bug In Price Chart When There is Not Data<commit_after>money = require('common/swag').money

PriceChartView = Ember.View.extend
  content: []
  valuePadding: 10

  chartData: (->
    data = []
    @get("content")?.forEach (item) ->
      date = item.date
      if date
        date = new Date(date)
      else
        return unless date

      value = item.value
      return unless value

      data.push value: value, date: date
    data.sort (a, b) -> a.date - b.date
  ).property("content")

  xDomain: (->
    d3.extent @get("chartData"), (item) -> item.date
  ).property("chartData")

  yDomain: (->
    padding = @get("valuePadding")
    # d3.extent(@get("chartData"), (item) -> item.value)
    # .map (value, index) ->
    #   if index is 0
    #     Math.max (value - padding), 0
    #   else
    #     value + padding
    [0, d3.max(@get("chartData"), (item) -> item.value) + padding]
  ).property("chartData")

  updateChart: (->
    @render()
{'fraction_non_alphanumeric': 0.1651619755708975, 'fraction_numerical': 0.008497079129049389, 'mean_word_length': 2.3642857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '2629756', 'n_tokens_mistral': 647, 'n_tokens_neox': 622, 'n_words': 152}