<commit_before>chart = '#material_chart'
overview = '#material_overview'

$(document).ready ->
  userid = $('#userid').val()
  $.getJSON "/rest/v1/#{userid}/materials", (data) ->
    table = translate(data)

    option =
      xaxis: { mode: 'time' }
      yaxes: [{}, { alignTicksWithAxis: 1, position: 'right' }]
      selection: { mode: 'x' }
    plot = $.plot(chart, table, option)
    $(chart).bind 'plotselected', (event, ranges) ->
      newOpt = $.extend true, {}, option,
        xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }
      plot = $.plot(chart, table, newOpt)

    optionO =
      series: { lines: { show: true, lineWidth: 1 }, shadowSize: 0 }
      xaxis: { ticks: [], mode: 'time' }
      yaxes: [{ ticks: [] }, { ticks: [] }]
      selection: { mode: 'x' }
    plotO = $.plot(overview, table, optionO)
    $(overview).bind('plotselected', (event, ranges) -> plot.setSelection(ranges))

translate = (data) ->
  fuel = { data: transElem(data, 'fuel'), label: '燃料', yaxis: 1 }
  ammo = { data: transElem(data, 'ammo'), label: '弾薬' , yaxis: 1 }
  steel = { data: transElem(data, 'steel'), label: '鉄鋼', yaxis: 1 }
  bauxite = { data: transElem(data, 'bauxite'), label: 'ボーキサイト', yaxis: 1 }
  instant = { data: transElem(data, 'instant'), label: '高速建造材', yaxis: 2 }
  bucket = { data: transElem(data, 'bucket'), label: '高速修復材', yaxis: 2 }
  develop = { data: transElem(data, 'develop'), label: '開発資材', yaxis: 2 }
  [fuel, ammo, steel, bauxite, instant, bucket, develop]

transElem = (data, elem) -> data.map (x) -> [x['created']/1000, x[elem]]<commit_msg>Fix Date at Material Graph<commit_after>chart = '#material_chart'
overview = '#material_overview'

$(document).ready ->
  userid = $('#userid').val()
  $.getJSON "/rest/v1/#{userid}/materials", (data) ->
    table = translate(data)

    option =
      xaxis: { mode: 'time' }
      yaxes: [{}, { alignTicksWithAxis: 1, position: 'right' }]
      selection: { mode: 'x' }
    plot = $.plot(chart, table, option)
    $(chart).bind 'plotselected', (event, ranges) ->
      newOpt = $.extend true, {}, option,
        xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }
      plot = $.plot(chart, table, newOpt)

    optionO =
      series: { lines: { show: true, lineWidth: 1 }, shadowSize: 0 }
      xaxis: { ticks: [], mode: 'time' }
      yaxes: [{ ticks: [] }, { ticks: [] }]
      selection: { mode: 'x' }
    plotO = $.plot(overview, table, optionO)
    $(overview).bind('plotselected', (event, ranges) -> plot.setSelection(ranges))

translate = (data) ->
  fuel = { data: transElem(data, 'fuel'), label: '燃料', yaxis: 1 }
  ammo = { data: transElem(data, 'ammo'), label: '弾薬' , yaxis: 1 }
  steel = { data: transElem(data, 'steel'), label: '鉄鋼', yaxis: 1 }
  bauxite = { data: transElem(data, 'bauxite'), label: 'ボーキサイト', yaxis: 1 }
  instant = { data: transElem(data, 'instant'), label: '高速建造材', yaxis: 2 }
  bucket = { data: transElem(data, 'bucket'), label: '高速修復材', yaxis: 2 }
  develop = { data: transElem(data, 'develop'), label: '開発資材', yaxis: 2 }
  [fuel, ammo, steel, bauxite, instant, bucket, develop]

transElem = (data, elem) -> data.map (x) -> [x['created'], x[elem]]
{'fraction_non_alphanumeric': 0.20246367656348704, 'fraction_numerical': 0.0082122552116235, 'mean_word_length': 3.4858356940509916, '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': '3621491', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1177, 'n_words': 291}