<commit_before>height = null
width = null
svg = null
Session.set("mapRegion", "Derelik")

resizeHandler = ->
  route = Router.current()
  if !route? || route.template isnt "fleetCommander"
    return
  height = $("#fcMiddle").height()
  width = $("#fcMiddle").width()
  console.log height+"x"+width
  rerender()

$(window).resize resizeHandler

redraw = ->
  #console.log "here", d3.event.translate, d3.event.scale
  svg.attr "transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")"

Template.fcMiddle.rendered = ->
  svg = d3.select("#fcMiddle").append("svg").attr("width", width).attr("height", height).attr("pointer-events", "all")
  resizeHandler()
  
rerender = ->
  $("#fcMiddle svg").empty()
  svg.append('svg:g').call(d3.behavior.zoom().on("zoom", redraw)).append('svg:g').append('svg:rect').attr('width', width).attr('height', height).attr('fill', 'white')
  color = d3.scale.category20()
  force = d3.layout.force().size([width, height]).charge(-200).gravity(0.05)#.linkDistance(30)
  d3.json "/data/"+Session.get("mapRegion")+".json", (error, graph) ->
    console.log graph
    svg.append("text").attr("x", (width / 2)).attr("y", '50px').style("font-weight", "bold").attr("text-anchor", "middle").style("font-size", "24px").text(Session.get("mapRegion"))
    force.nodes(graph.systems).links(graph.jumps).start()
    link = svg.selectAll(".link").data(graph.jumps).enter().append("line").attr("class", "link").style("stroke-width", (d) ->
      Math.sqrt d.value
    )
    node = svg.selectAll(".node").data(graph.systems).enter().append("g").attr("class", "node").call(force.drag)
    node.append("text").attr("dx", 12).attr("dy", ".35em").text (d) ->
      d.name
    node.append("circle").attr("r", 5)
  
    force.on "tick", ->
      link.attr("x1", (d) ->
        d.source.x
      ).attr("y1", (d) ->
        d.source.y
      ).attr("x2", (d) ->
        d.target.x
      ).attr "y2", (d) ->
        d.target.y
      node.attr "transform", (d)->
        "translate("+d.x+","+d.y+")"<commit_msg>Added zoom and pan to the map<commit_after>height = null
width = null
nodeContainer = null
svg = null
Session.set("mapRegion", "Derelik")

resizeHandler = ->
  route = Router.current()
  if !route? || route.template isnt "fleetCommander"
    return
  height = $("#fcMiddle").height()
  width = $("#fcMiddle").width()
  console.log height+"x"+width
  rerender()

$(window).resize resizeHandler

redraw = ->
  #console.log "here", d3.event.translate, d3.event.scale
  nodeContainer.attr "transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")"

Template.fcMiddle.rendered = ->
  svg = d3.select("#fcMiddle").append("svg").attr("width", width).attr("height", height).attr("pointer-events", "all")
  resizeHandler()
  
rerender = ->
  $("#fcMiddle svg").empty()
  svg.append('svg:g').call(d3.behavior.zoom().on("zoom", redraw)).append('svg:g').append('svg:rect').attr('width', width).attr('height', height).attr('fill', 'white')
  nodeContainer = svg.append('svg:g').attr('width', width).attr('height', height)
  color = d3.scale.category20()
  force = d3.layout.force().size([width, height]).charge(-200).gravity(0.05).linkDistance(30)
  d3.json "/data/"+Session.get("mapRegion")+".json", (error, graph) ->
    console.log graph
    svg.append("text").attr("x", (width / 2)).attr("y", '50px').style("font-weight", "bold").attr("text-anchor", "middle").style("font-size", "24px").text(Session.get("mapRegion"))
    force.nodes(graph.systems).links(graph.jumps).start()
    link = nodeContainer.selectAll(".link").data(graph.jumps).enter().append("line").attr("class", "link").style("stroke-width", (d) ->
      Math.sqrt d.value
    )
    node = nodeContainer.selectAll(".node").data(graph.systems).enter().append("g").attr("class", "node").call(force.drag)
    node.append("text").attr("dx", 12).attr("dy", ".35em").text (d) ->
      d.name
    node.append("circle").attr("r", 5)
  
    force.on "tick", ->
      link.attr("x1", (d) ->
        d.source.x
      ).attr("y1", (d) ->
        d.source.y
      ).attr("x2", (d) ->
        d.target.x
      ).attr "y2", (d) ->
        d.target.y
      node.attr "transform", (d)->
        "translate("+d.x+","+d.y+")"
{'fraction_non_alphanumeric': 0.24137115839243498, 'fraction_numerical': 0.015602836879432624, 'mean_word_length': 3.7970521541950113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '2876946', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1463, 'n_words': 223}