<commit_before>
// Construct a callback for toggling geometries on/off using color groupings.
//
// Args:
//   colorclass: class names assigned to geometries belonging to a paricular
//               color group.
//
// Returns:
//   A callback function.
//
var guide_toggle_color = function(colorclass) {
    var visible = true;
    return (function() {
        if (visible) {
            d3.select(this)
              .transition()
              .duration(250)
              .style("opacity", 0.5);
            d3.selectAll(".geometry." + colorclass)
              .transition()
              .duration(250)
              .style("opacity", 0);
            visible = false;
        } else {
            d3.select(this)
              .transition()
              .duration(250)
              .style("opacity", 1.0);
            d3.selectAll(".geometry." + colorclass)
              .transition()
              .duration(250)
              .style("opacity", 1.0);
            visible = true;
        }
    })
}


// Construct a callback used to toggle highly-visibility grid lines.
//
// Args:
//   color: Faded-in/faded-out color, respectively.
//
// Returns:
//   Callback function.
//
var guide_background_mouseover = function(color) {
    return (function () {
        d3.selectAll(".xgridlines, .ygridlines")
          .transition()
          .duration(250)
          .attr("stroke", color);
    });
}

var guide_background_mouseout = function(color) {
    return (function () {
        d3.selectAll(".xgridlines, .ygridlines")
          .transition()
          .duration(250)
          .attr("stroke", color);
    });
}


// Construct a call back used for mouseover effects in the point geometry.
//
// Args:
//   lw: Stroke width to transition to.
//
// Returns:
//  Callback function.
//
var geom_point_mouseover = function(lw) {
    return (function() {
        d3.select(this)
          .transition()
          .duration(100)
          .attr("stroke-width", lw);
    });
}




var drag_behavior = function(t) {
    return d3.behavior.drag()
      .on("drag", function(d, i) {
        t.x += d3.event.dx;
        t.y += d3.event.dy;

        d3.selectAll(".geometry")
          .attr("transform", function() {
              return "translate(" + [t.x, t.y] + ")";
          });

          d3.selectAll(".xgridlines,.xlabels")
            .attr("transform", function() {
                return "translate(" + [t.x, 0.0] + ")";
            });

          d3.selectAll(".ygridlines,.ylabels")
            .attr("transform", function() {
                return "translate(" + [0.0, t.y] + ")";
            });

        // TODO:
        // Clip tick labels.
        //  How?
        //  This would be nicer if we just added a Clip boolean to the canvas
        //  constructor. Then any canvas could clip its contents. Ok. Let's do
        //  that.
        //
        // Off-screen grid lines.
        // Pan limits.
    });
}
<commit_msg>Set limits on panning.<commit_after>
// Construct a callback for toggling geometries on/off using color groupings.
//
// Args:
//   colorclass: class names assigned to geometries belonging to a paricular
//               color group.
//
// Returns:
//   A callback function.
//
var guide_toggle_color = function(colorclass) {
    var visible = true;
    return (function() {
        if (visible) {
            d3.select(this)
              .transition()
              .duration(250)
              .style("opacity", 0.5);
            d3.selectAll(".geometry." + colorclass)
              .transition()
              .duration(250)
              .style("opacity", 0);
            visible = false;
        } else {
            d3.select(this)
              .transition()
              .duration(250)
              .style("opacity", 1.0);
            d3.selectAll(".geometry." + colorclass)
              .transition()
              .duration(250)
              .style("opacity", 1.0);
            visible = true;
        }
    });
};


// Construct a callback used to toggle highly-visibility grid lines.
//
// Args:
//   color: Faded-in/faded-out color, respectively.
//
// Returns:
//   Callback function.
//
var guide_background_mouseover = function(color) {
    return (function () {
        d3.selectAll(".xgridlines, .ygridlines")
          .transition()
          .duration(250)
          .attr("stroke", color);
    });
};

var guide_background_mouseout = function(color) {
    return (function () {
        d3.selectAll(".xgridlines, .ygridlines")
          .transition()
          .duration(250)
          .attr("stroke", color);
    });
};


// Construct a call back used for mouseover effects in the point geometry.
//
// Args:
//   lw: Stroke width to transition to.
//
// Returns:
//  Callback function.
//
var geom_point_mouseover = function(lw) {
    return (function() {
        d3.select(this)
          .transition()
          .duration(100)
          .attr("stroke-width", lw);
    });
};


// Construct a callback used for dragbehavior.
//
// Args:
//   t: A transform of the form {"x": x, "y": x} to close arround.
//
// Returns:
//   A drag behavior.
//
var drag_behavior = function(t) {
    return d3.behavior.drag()
      .on("drag", function(d, i) {
        var bbox = d3.select(".guide.background").select("path").node().getBBox();
        t.x = Math.max(Math.min(t.x + d3.event.dx, bbox.width), -bbox.width);
        t.y = Math.max(Math.min(t.y + d3.event.dy, bbox.height), -bbox.height);

        d3.selectAll(".geometry")
          .attr("transform", function() {
              return "translate(" + [t.x, t.y] + ")";
          });

        d3.selectAll(".xgridlines,.xlabels")
        .attr("transform", function() {
            return "translate(" + [t.x, 0.0] + ")";
        });

        d3.selectAll(".ygridlines,.ylabels")
          .attr("transform", function() {
              return "translate(" + [0.0, t.y] + ")";
          });
    });
};

{'fraction_non_alphanumeric': 0.15463917525773196, 'fraction_numerical': 0.015379415244211594, 'mean_word_length': 1.6633663366336633, 'pattern_counts': {'":': 2, '<': 3, '<?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': '4574082', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1743, 'n_words': 410}