<commit_before>(function () {
    var widget = Iris.Widget.create({
        about: {
            name: "Manhattan",
            author: "<NAME>",
            requires: [],
            renderers: {
                default: "scatterplot.js"
            },
        }
    });

    var ctx;
    var ctxi;
    var canvasi;
    var tool = new Object();
    tool.started = false;
    var global_min = 0;
    var globalMax = 0;
    var chrLengths = new Array();
    var totalLen = 0;
    var sc = 2;
    var radius = 2;
    var circles = true;
    var XGUTTER = 10;
    var colorByDensity = true;
    var containerNode;
    var chrRange = new Array();
    var scoreA;
    var scoreB;
    var mincolor = new Array();
    var maxcolor = new Array();

    widget.display = function(args) {
        var div = $("#" + widget.divId);
        div.text('');
        containerNode = div;
        var canvasHeight = Math.max(div.height(), 250);
        var canvasWidth = Math.max(div.width(), 100);
        div.append('<canvas id="' + widget.divId + '_canvas", width=' + canvasWidth + ' height=' + canvasHeight + ' style="position:absolute;left:0;top:0;z-index:0;"></canvas>');
        div.append('<canvas id="' + widget.divId + '_canvasi", width=' + canvasWidth + ' height=' + canvasHeight + ' style="position:absolute;left:0;top:0;z-index:1;"></canvas>');
        div.height(canvasHeight);

        div.parent.height = canvasHeight;
        div.parent.width = canvasWidth;

        var canvas = document.getElementById(widget.divId + "_canvas");
        canvasi = document.getElementById(widget.divId + "_canvasi");
        ctx = canvas.getContext('2d');
        ctxi = canvasi.getContext('2d');

        var study = (args.hasOwnProperty('study')) ? args['study'] : 3396;
        var species = (args.hasOwnProperty('species')) ? args['species'] : 'at';

        // fetch the list of chromosomes and their lengths
        widget.getJSON("/species/" + species + "/chromosomes", function(json) {
            for (var i = 0; i < json.length; i++) {
                chrLengths[i] = json[i][1];
                totalLen += json[i][1];
            }
            // fetch the max score for this study
            widget.getJSON("/gwas/" + study + "/maxscore", function(json) {<commit_msg>reset totalLen to 0 in widget.render()<commit_after>(function () {
    var widget = Iris.Widget.create({
        about: {
            name: "Manhattan",
            author: "<NAME>",
            requires: [],
            renderers: {
                default: "scatterplot.js"
            },
        }
    });

    var ctx;
    var ctxi;
    var canvasi;
    var tool = new Object();
    tool.started = false;
    var global_min = 0;
    var globalMax = 0;
    var chrLengths = new Array();
    var totalLen = 0;
    var sc = 2;
    var radius = 2;
    var circles = true;
    var XGUTTER = 10;
    var colorByDensity = true;
    var containerNode;
    var chrRange = new Array();
    var scoreA;
    var scoreB;
    var mincolor = new Array();
    var maxcolor = new Array();

    widget.display = function(args) {
        var div = $("#" + widget.divId);
        div.text('');
        containerNode = div;
        var canvasHeight = Math.max(div.height(), 250);
        var canvasWidth = Math.max(div.width(), 100);
        div.append('<canvas id="' + widget.divId + '_canvas", width=' + canvasWidth + ' height=' + canvasHeight + ' style="position:absolute;left:0;top:0;z-index:0;"></canvas>');
        div.append('<canvas id="' + widget.divId + '_canvasi", width=' + canvasWidth + ' height=' + canvasHeight + ' style="position:absolute;left:0;top:0;z-index:1;"></canvas>');
        div.height(canvasHeight);

        // div.parent.height = canvasHeight;
        // div.parent.width = canvasWidth;

        var canvas = document.getElementById(widget.divId + "_canvas");
        canvasi = document.getElementById(widget.divId + "_canvasi");
        ctx = canvas.getContext('2d');
        ctxi = canvasi.getContext('2d');

        var study = (args.hasOwnProperty('study')) ? args['study'] : 3396;
        var species = (args.hasOwnProperty('species')) ? args['species'] : 'at';

        // fetch the list of chromosomes and their lengths
		totalLen = 0;
        widget.getJSON("/species/" + species + "/chromosomes", function(json) {
            for (var i = 0; i < json.length; i++) {
                chrLengths[i] = json[i][1];
                totalLen += json[i][1];
            }
            // fetch the max score for this study
            widget.getJSON("/gwas/" + study + "/maxscore", function(json) {
{'fraction_non_alphanumeric': 0.15329105619943145, 'fraction_numerical': 0.012683140170566367, 'mean_word_length': 2.2347949080622347, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, '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': '3074938', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1338, 'n_words': 337}