<commit_before>﻿define(['d3'], function () {
    "use strict";

    var renderArrowheadMarker,
        preventOverlap,
        cx, cy, px1, py1, px2, py2, tagY;

    renderArrowheadMarker = function (svg) {
        svg.append('svg:marker')
            .attr('id', 'triangle')
            .attr('refX', 5)
            .attr('refY', 5)
            .attr('markerUnits', 'strokeWidth')
            .attr('markerWidth', 4)
            .attr('markerHeight', 3)
            .attr('orient', 'auto')
            .attr('viewBox', '0 0 10 10')
            .append('svg:path')
                .attr('d', 'M 0 0 L 10 5 L 0 10 z');
    };

    preventOverlap = function preventOverlap(commit, view) {
        var commitData = view.commitData,
            centerBranchLine = view.height / 2,
            shift = view.commitRadius * 4.5,
            overlappedCommit = null;

        for (var i = 0; i < commitData.length; i++) {
            var c = commitData[i];
            if (c.cx === commit.cx && c.cy === commit.cy && c !== commit) {
                overlappedCommit = c;
                break;
            }
        }

        if (overlappedCommit) {
            if (overlappedCommit.cy < centerBranchLine) {
                overlappedCommit.cy -= shift;
            } else {
                overlappedCommit.cy += shift;
            }

            preventOverlap(overlappedCommit, view);
        }
    };

    cx = function (commit, view) {
        var parent = view.getCommit(commit.parent);
        return parent.cx + (view.commitRadius * 4.5);
    };

    cy = function (commit, view) {
        var parent = view.getCommit(commit.parent),
            parentCY = parent.cy,
            centerBranchLine = view.height / 2,
            shift = view.commitRadius * 4.5,
            branches = [], // count the existing branches
            branchIndex = 0;

        for (var i = 0; i < view.commitData.length; i++) {
            var d = view.commitData[i];<commit_msg>Make the prevent overlap logic a little smarter.<commit_after>﻿define(['d3'], function () {
    "use strict";

    var renderArrowheadMarker,
        preventOverlap,
        cx, cy, px1, py1, px2, py2, tagY;

    renderArrowheadMarker = function (svg) {
        svg.append('svg:marker')
            .attr('id', 'triangle')
            .attr('refX', 5)
            .attr('refY', 5)
            .attr('markerUnits', 'strokeWidth')
            .attr('markerWidth', 4)
            .attr('markerHeight', 3)
            .attr('orient', 'auto')
            .attr('viewBox', '0 0 10 10')
            .append('svg:path')
                .attr('d', 'M 0 0 L 10 5 L 0 10 z');
    };

    preventOverlap = function preventOverlap(commit, view) {
        var commitData = view.commitData,
            centerBranchLine = view.height / 2,
            shift = view.commitRadius * 4.5,
            overlapped = null;

        for (var i = 0; i < commitData.length; i++) {
            var c = commitData[i];
            if (c.cx === commit.cx && c.cy === commit.cy && c !== commit) {
                overlapped = c;
                break;
            }
        }

        if (overlapped) {
            var oParent = view.getCommit(overlapped.parent),
                parent = view.getCommit(commit.parent);
        
            if (overlapped.cy < centerBranchLine) {
                overlapped = oParent.cy < parent.cy ? overlapped : commit;
                overlapped.cy -= shift;
            } else {
                overlapped = oParent.cy > parent.cy ? overlapped : commit;
                overlapped.cy += shift;
            }

            preventOverlap(overlapped, view);
        }
    };

    cx = function (commit, view) {
        var parent = view.getCommit(commit.parent);
        return parent.cx + (view.commitRadius * 4.5);
    };

    cy = function (commit, view) {
        var parent = view.getCommit(commit.parent),
            parentCY = parent.cy,
            centerBranchLine = view.height / 2,
            shift = view.commitRadius * 4.5,
            branches = [], // count the existing branches
            branchIndex = 0;

        for (var i = 0; i < view.commitData.length; i++) {
            var d = view.commitData[i];
{'fraction_non_alphanumeric': 0.13058009071377416, 'fraction_numerical': 0.01623299116734304, 'mean_word_length': 1.5721301411909148, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 4, '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': '4767640', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1221, 'n_words': 299}