<commit_before>(function() {
  'use strict';
  var relvis = window.relvis = window.relvis || {};
  relvis.fixedViewport = false;
  // {{{1 coordinate transformations
  // transformations to/from canvas coordinates
  var xy = relvis.xy;
  relvis.offset = { // odd start offset for testing
    x: 123,
    y: 456
  };
  relvis.scale = { // odd start offset for testing
    x: 7,
    y: 8
  };
  relvis.toCanvasCoord = function(p) { //{{{1
    return xy.mul(xy.sub(p, relvis.offset), relvis.scale);
  };
  relvis.toGraphCoord = function(p) { //{{{1
    return xy.add(xy.mul(p, xy.inv(relvis.scale)), relvis.offset);
  };
  relvis.nodeAt = function(x, y) { //{{{1
    for (var i = 0; i < relvis.nodes.length; ++i) {
      var node = relvis.nodes[i];
      if (Math.abs(node.vx - x) <= node.xsize &&
        Math.abs(node.vy - y) <= node.ysize) {
        return node;
      }
    }
    return undefined;
  };

  relvis.addEventListener('redraw', function() { //{{{1
    if (!relvis.nodes || !relvis.overlayVisible) {
      return;
    }

    var visibleNodes = relvis.nodes.filter(function(o) {
      return o.visible;
    });

    // get and clear drawing context
    var canvas = relvis.canvas;
    var ctx = canvas.getContext('2d');
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    ctx.fillStyle = 'rgba(0,0,0,0.2)';
    ctx.fillRect(0, 0, canvas.width, canvas.height);

    // Find coordinate transformation
    if (!relvis.fixedViewport && visibleNodes.length && typeof visibleNodes[0].x === 'number') {
      var margin = 3 * relvis.avgSize / (relvis.canvas.height + relvis.canvas.width) || 0;
      var boundaries = relvis.findBoundaries(visibleNodes);

      relvis.offset = xy.sub(boundaries.min,
        xy.scale(boundaries.range, margin));
      relvis.scale = xy.scale(boundaries.range, 1 + 2 * margin);
      relvis.scale = xy.mul({
          x: canvas.width,
          y: canvas.height<commit_msg>better margins<commit_after>(function() {
  'use strict';
  var relvis = window.relvis = window.relvis || {};
  relvis.fixedViewport = false;
  // {{{1 coordinate transformations
  // transformations to/from canvas coordinates
  var xy = relvis.xy;
  relvis.offset = { // odd start offset for testing
    x: 123,
    y: 456
  };
  relvis.scale = { // odd start offset for testing
    x: 7,
    y: 8
  };
  relvis.toCanvasCoord = function(p) { //{{{1
    return xy.mul(xy.sub(p, relvis.offset), relvis.scale);
  };
  relvis.toGraphCoord = function(p) { //{{{1
    return xy.add(xy.mul(p, xy.inv(relvis.scale)), relvis.offset);
  };
  relvis.nodeAt = function(x, y) { //{{{1
    for (var i = 0; i < relvis.nodes.length; ++i) {
      var node = relvis.nodes[i];
      if (Math.abs(node.vx - x) <= node.xsize &&
        Math.abs(node.vy - y) <= node.ysize) {
        return node;
      }
    }
    return undefined;
  };

  relvis.addEventListener('redraw', function() { //{{{1
    if (!relvis.nodes || !relvis.overlayVisible) {
      return;
    }

    var visibleNodes = relvis.nodes.filter(function(o) {
      return o.visible;
    });

    // get and clear drawing context
    var canvas = relvis.canvas;
    var ctx = canvas.getContext('2d');
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    ctx.fillStyle = 'rgba(0,0,0,0.2)';
    ctx.fillRect(0, 0, canvas.width, canvas.height);

    // Find coordinate transformation
    if (!relvis.fixedViewport && visibleNodes.length && typeof visibleNodes[0].x === 'number') {
      var margin = 5 * relvis.avgSize / (relvis.canvas.height + relvis.canvas.width) || 0;
      var boundaries = relvis.findBoundaries(visibleNodes);

      relvis.offset = xy.sub(boundaries.min,
        xy.scale(boundaries.range, margin));
      relvis.scale = xy.scale(boundaries.range, 1 + 2 * margin);
      relvis.scale = xy.mul({
          x: canvas.width,
          y: canvas.height
{'fraction_non_alphanumeric': 0.1592273557817802, 'fraction_numerical': 0.015139650221874185, 'mean_word_length': 2.6495238095238096, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '5801994', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1311, 'n_words': 290}