<commit_before>// TODO
// How to store all of these different layers of data:
// - asdf

var plots = []; //an array of all plots

// sync this with the one in bridgeChart.js
var margin = {top: 10, right: 10, bottom: 25, left: 40};

var supportsOrientationChange = "onorientationchange" in window,
    orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
window.addEventListener(orientationEvent, function() {
  if (navigator.userAgent.match(/android/i)) {
    setTimeout("redraw()", 500); //Only wait for Android
  } else {
    redraw();
  }
}, false);

var zoom_svg = d3.select("#zoom_svg");
var zoom_rect = d3.select("#zoom_rect");

var redraw = function () {
  plots.forEach(function (plt) {
    plt.container_width(document.getElementById("charts").offsetWidth).update();
  });
  zoom_svg.attr("width", document.getElementById("charts").offsetWidth)
          .attr("height", document.getElementById("charts").offsetHeight);
  zoom_rect.attr("width", document.getElementById("charts").offsetWidth - margin.left - margin.right)
           .attr("height", document.getElementById("charts").offsetHeight)
           .attr("transform", "translate(" + margin.left + ", " + margin.top + ")");

  //update the zoom for the new plot size
  update_zoom();
}

// this will be changed once 'news' is sent from the server
// for now it's just a dummy
var update_zoom = function () { return 0; };

// these are the overall scales which are modified by zooming
var x;
var y;

function zoom_all() {
  plots.forEach(function (plt) {
    plt.xScale(x).xScale(x).update();
  });
}

var zoom = d3.behavior.zoom()
  .on("zoom", zoom_all);


var changeLines = function () {
  plots.forEach(function (plt) {
    plt.setSelectedLines().update();
  });
}

document.getElementById("controls").addEventListener ("change", changeLines, false);


var socket = io.connect('172.16.58.3:8080/');
var first_time = true;

socket.on('connect_failed', function () {
  console.log("connect_failed :(");
});

socket.on('connecting', function () {
  console.log("connecting :!");
});

socket.on('connect', function () {
  console.log("connected !!");
});

socket.on('disconnect', function () {
  console.log("disconnected !!");
});


// Set up the demo in case the server is down:
// TODO: find a way to check if the server is down, so this doesn't always happen

d3.json("Server/ESGgirder1_from_SPBRTData_0A.js", function (error, data) {
  var json = data;

  var plot10 = binnedLineChart();

  var pl10 = d3.select("#charts").append("g").datum(_.map(json, function (d) { return -d.ESGgirder1; })).call(plot10);

  plot10.container_width(document.getElementById("charts").offsetWidth).height(75).margin_top(10).update();

  plots.push(plot10);

  // TODO: trim this all; put it into a separate function, so both this and the from-server code run the same identical code.
  redraw();

  d3.select("#charts").attr("height", 120*plots.length); //TODO: make this dynamic

  zoom_svg.attr("width", document.getElementById("charts").offsetWidth)<commit_msg>Many Comments<commit_after>// TODO
// How to store all of these different layers of data:
// - asdf

var plots = []; //an array of all plots

// sync this with the one in bridgeChart.js
var margin = {top: 10, right: 10, bottom: 25, left: 40};

var supportsOrientationChange = "onorientationchange" in window,
    orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
window.addEventListener(orientationEvent, function() {
  if (navigator.userAgent.match(/android/i)) {
    setTimeout("redraw()", 500); //Only wait for Android
  } else {
    redraw();
  }
}, false);

var zoom_svg = d3.select("#zoom_svg");
var zoom_rect = d3.select("#zoom_rect");

var redraw = function () {
  plots.forEach(function (plt) {
    plt.container_width(document.getElementById("charts").offsetWidth).update();
  });
  zoom_svg.attr("width", document.getElementById("charts").offsetWidth)
          .attr("height", document.getElementById("charts").offsetHeight);
  zoom_rect.attr("width", document.getElementById("charts").offsetWidth - margin.left - margin.right)
           .attr("height", document.getElementById("charts").offsetHeight)
           .attr("transform", "translate(" + margin.left + ", " + margin.top + ")");

  //update the zoom for the new plot size
  update_zoom();
}

// this will be changed once 'news' is sent from the server
// for now it's just a dummy
var update_zoom = function () { return 0; };

// these are the overall scales which are modified by zooming
var x;
var y;

function zoom_all() {
  plots.forEach(function (plt) {
    plt.xScale(x).xScale(x).update();
  });
}

var zoom = d3.behavior.zoom()
  .on("zoom", zoom_all);


var changeLines = function () {
  plots.forEach(function (plt) {
    plt.setSelectedLines().update();
  });
}

document.getElementById("controls").addEventListener ("change", changeLines, false);


var socket = io.connect('172.16.58.3:8080/');
var first_time = true;

socket.on('connect_failed', function () {
  console.log("connect_failed :(");
});

socket.on('connecting', function () {
  console.log("connecting :!");
});

socket.on('connect', function () {
  console.log("connected !!");
});

socket.on('disconnect', function () {
  console.log("disconnected !!");
});


// Set up the demo in case the server is down:
// TODO: find a way to check if the server is down, so this doesn't always happen

d3.json("Server/ESGgirder1_from_SPBRTData_0A.js", function (error, data) {
  if (error) {
    return;
  }

  var json = data;

  var plot10 = binnedLineChart();

  var pl10 = d3.select("#charts").append("g").datum(_.map(json, function (d) { return -d.ESGgirder1; })).call(plot10);

  plot10.container_width(document.getElementById("charts").offsetWidth).height(75).margin_top(10).update();

  plots.push(plot10);

  // TODO: trim this all; put it into a separate function, so both this and the from-server code run the same identical code.
  redraw();

  d3.select("#charts").attr("height", 120*plots.length); //TODO: make this dynamic

  zoom_svg.attr("width", document.getElementById("charts").offsetWidth)
{'fraction_non_alphanumeric': 0.1619281045751634, 'fraction_numerical': 0.016339869281045753, 'mean_word_length': 4.276724137931034, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2705436', 'n_tokens_mistral': 1983, 'n_tokens_neox': 1848, 'n_words': 493}