<commit_before>/**
 * Created by hen on 2/20/14.
 */
    var bbVis, brush, createVis, dataSet, handle, height, margin, svg, svg2, width;
    var color = d3.scale.category10();


    margin = {
        top: 50,
        right: 50,
        bottom: 50,
        left: 150
    };

    width = 960 - margin.left - margin.right;

    height = 300 - margin.bottom - margin.top;

    bbVis = {
        x: 0 + 100,
        y: 10,
        w: width - 100,
        h: 100
    };

    var dataSet = [];
    var studies =[];


    svg = d3.select("#vis").append("svg").attr({
        width: width + margin.left + margin.right,
        height: height + margin.top + margin.bottom
    }).append("g").attr({
            transform: "translate(" + margin.left + "," + margin.top + ")"
        });


    d3.csv("data.csv", function(data) {

        dataSet = data;
        //console.log(dataSet);
        color.domain(d3.keys(dataSet[0]).filter(function(key) { return key !== "year"; }));
          studies = color.domain().map(function(name) {
            return {
              name: name,
              values: dataSet.map(function(d) {
                return {year: +d.year, estimate: +d[name], interpolated: 0};
              })
            };
          });

        // goes through studies data and creates known year and estimate arrays
        studies.forEach(function(d){
            var knownYears = [];
            var knownEstimates = [];
            d.values.map(function(e,i){
                if (e.estimate){
                    knownYears.push(e.year);
                    knownEstimates.push(e.estimate);
                }

            });
            console.log(knownYears);
            console.log(knownEstimates);

            var min_year = d3.min(knownYears);
            var max_year = d3.max(knownYears);
            //console.log(max_year);

            // interpolates missing data points
             var interpolate = d3.scale.linear().domain(knownYears).range(knownEstimates);
             d.values.forEach(function(e,i){
                if ((e.estimate == 0) && (e.year > min_year && e.year < max_year)) {
                   // console.log("test");
                    e.estimate = interpolate(e.year);
                    e.interpolated = 1;
                    
                } 

                // checks if values are within range
                var a = d.values.length;
                for (j = 0; j < a; j++){
                    if (d.values[j].year < min_year || d.values[j].year > max_year){
                        d.values.splice(j,1);
                        a --; 
                        j --;
                    }
                }

               // console.log(min_year,max_year);

            });

        });
        
        console.log(studies);
        return createVis();
    });


    createVis = function() {
        var xAxis, xScale, yAxis,  yScale, line;
       

        var visFrame = svg.append("g").attr({
              "transform": "translate(" + bbVis.x + "," + (bbVis.y + bbVis.h) + ")",
              //....

          });

          visFrame.append("rect");

        
        <commit_msg>Update linegraph.js<commit_after>/**
 * Created by hen on 2/20/14.
 */
    var bbVis, brush, createVis, dataSet, handle, height, margin, svg, svg2, width;
    var color = d3.scale.category10();


    margin = {
        top: 50,
        right: 50,
        bottom: 50,
        left: 150
    };

    width = 960 - margin.left - margin.right;

    height = 300 - margin.bottom - margin.top;

    bbVis = {
        x: 0 + 100,
        y: 10,
        w: width - 100,
        h: 100
    };

    var dataSet = [];
    var studies =[];


    svg = d3.select("#vis").append("svg").attr({
        width: width + margin.left + margin.right,
        height: height + margin.top + margin.bottom
    }).append("g").attr({
            transform: "translate(" + margin.left + "," + margin.top + ")"
        });


    d3.csv("data.csv", function(data) {

        dataSet = data;
        //console.log(dataSet);
        color.domain(d3.keys(dataSet[0]).filter(function(key) { return key !== "year"; }));
          studies = color.domain().map(function(name) {
            return {
              name: name,
              values: dataSet.map(function(d) {
                return {year: +d.year, estimate: +d[name], interpolated: 0};
              })
            };
          });

        // goes through studies data and creates known year and estimate arrays
        studies.forEach(function(d){
            var knownYears = [];
            var knownEstimates = [];
            d.values.map(function(e,i){
                if (e.estimate){
                    knownYears.push(e.year);
                    knownEstimates.push(e.estimate);
                }

            });
            console.log(knownYears);
            console.log(knownEstimates);

            var min_year = d3.min(knownYears);
            var max_year = d3.max(knownYears);
            //console.log(max_year);

            //interpolates missing data points
             var interpolate = d3.scale.linear().domain(knownYears).range(knownEstimates);
             d.values.forEach(function(e,i){
                if ((e.estimate == 0) && (e.year > min_year && e.year < max_year)) {
                   // console.log("test");
                    e.estimate = interpolate(e.year);
                    e.interpolated = 1;
                    
                } 

                // checks if values are within range
                var a = d.values.length;
                for (j = 0; j < a; j++){
                    if (d.values[j].year < min_year || d.values[j].year > max_year){
                        d.values.splice(j,1);
                        a --; 
                        j --;
                    }
                }

               console.log(min_year,max_year);

            });

        });
        
        console.log(studies);
        return createVis();
    });


    createVis = function() {
        var xAxis, xScale, yAxis,  yScale, line;
       

        var visFrame = svg.append("g").attr({
              "transform": "translate(" + bbVis.x + "," + (bbVis.y + bbVis.h) + ")",
              //....

          });

          visFrame.append("rect");

        
        
{'fraction_non_alphanumeric': 0.14256132526282256, 'fraction_numerical': 0.015291494106403312, 'mean_word_length': 1.2991578176492127, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 7, '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': '5791776', 'n_tokens_mistral': 1954, 'n_tokens_neox': 1774, 'n_words': 369}