<commit_before>'use strict';
var instrumentChart = dc.pieChart("#instrument-chart");
/*var fluctuationChart = dc.barChart("#fluctuation-chart");
var quarterChart = dc.pieChart("#quarter-chart");
var dayOfWeekChart = dc.rowChart("#day-of-week-chart");
var moveChart = dc.lineChart("#monthly-move-chart");
var volumeChart = dc.barChart("#monthly-volume-chart"); */
var yearlyBubbleChart = dc.bubbleChart("#yearly-bubble-chart");


//Load data
d3.json("data/worldbank.json", function (error, oldData) {
	if(error)
	{
		console.log("!!!ERRROR!!!:"+error)
		return;
	}
	
	//formatting
    var dateFormat = d3.time.format("%m/%d/%Y");
    var numberFormat = d3.format(".2f");
	var data=[];
	
	//data processing and verification
    oldData.forEach(function (d) {
		if(d.ApprovalDate)
		{
			d.dd = dateFormat.parse(d.ApprovalDate);
			d.month = d3.time.month(d.dd); // pre-calculate month for better performance 
			//console.log(d.month)
			data.push(d)
		}
    });
	
	//initializing crossfilter
    var ndx = crossfilter(data);
    var all = ndx.groupAll();

    // dimension by year
    var yearlyDimension = ndx.dimension(function (d) {
        return d3.time.year(d.dd).getFullYear();
    });
	
	
    // maintain running tallies by year as filters are applied or removed
    var yearlyPerformanceGroup = yearlyDimension.group().reduce(
        /* callback for when data is added to the current filter results */
        function (p, v) {
            ++p.count;
            p.lendcost += v.LendProjCost;
            p.duration += v.Duration;
            p.avglend=p.lendcost/p.count;
            p.avgdur=p.duration/p.count;
            return p;
        },
        /* callback for when data is removed from the current filter results */
        function (p, v) {
            --p.count;
            p.lendcost -= v.LendProjCost;
            p.duration -= v.Duration;
            p.avglend=p.lendcost/p.count;
            p.avgdur=p.duration/p.count;
            return p;
        },
        /* initialize p */
        function () {
            return {count: 0, lendcost:0, avglend:0, duration:0, avgdur:0};
        }
    );

     // dimension by full date
    var dateDimension = ndx.dimension(function (d) {
        return d.dd;
    });

    // dimension by month
    var moveMonths = ndx.dimension(function (d) {
        return d.month;
    });
/*    // group by total movement within month
    var monthlyMoveGroup = moveMonths.group().reduceSum(function (d) {
        return Math.abs(d.close - d.open);
    });
    // group by total volume within move, and scale down result
    var volumeByMonthGroup = moveMonths.group().reduceSum(function (d) {
        return d.volume / 500000;
    });
    var indexAvgByMonthGroup = moveMonths.group().reduce(
        function (p, v) {
            ++p.days;
            p.total += (v.open + v.close) / 2;
            p.avg = Math.round(p.total / p.days);
            return p;
        },
        function (p, v) {
            --p.days;
            p.total -= (v.open + v.close) / 2;
            p.avg = p.days ? Math.round(p.total / p.days) : 0;
            return p;
        },
        function () {
            return {days: 0, total: 0, avg: 0};
        }
    );
*/
    // create categorical dimension
    var intrument = ndx.dimension(function (d) {
        return d.LendInstrType;
    });
    // produce counts records in the dimension
    var instrumentGroup = gainOrLoss.group();
/*<commit_msg>touched up pie chart<commit_after>'use strict';
var instrumentChart = dc.pieChart("#instrument-chart");
/*var fluctuationChart = dc.barChart("#fluctuation-chart");
var quarterChart = dc.pieChart("#quarter-chart");
var dayOfWeekChart = dc.rowChart("#day-of-week-chart");
var moveChart = dc.lineChart("#monthly-move-chart");
var volumeChart = dc.barChart("#monthly-volume-chart"); */
var yearlyBubbleChart = dc.bubbleChart("#yearly-bubble-chart");


//Load data
d3.json("data/worldbank.json", function (error, oldData) {
	if(error)
	{
		console.log("!!!ERRROR!!!:"+error)
		return;
	}
	
	//formatting
    var dateFormat = d3.time.format("%m/%d/%Y");
    var numberFormat = d3.format(".2f");
	var data=[];
	
	//data processing and verification
    oldData.forEach(function (d) {
		if(d.ApprovalDate)
		{
			d.dd = dateFormat.parse(d.ApprovalDate);
			d.month = d3.time.month(d.dd); // pre-calculate month for better performance 
			//console.log(d.month)
			data.push(d)
		}
    });
	
	//initializing crossfilter
    var ndx = crossfilter(data);
    var all = ndx.groupAll();

    // dimension by year
    var yearlyDimension = ndx.dimension(function (d) {
        return d3.time.year(d.dd).getFullYear();
    });
	
	
    // maintain running tallies by year as filters are applied or removed
    var yearlyPerformanceGroup = yearlyDimension.group().reduce(
        /* callback for when data is added to the current filter results */
        function (p, v) {
            ++p.count;
            p.lendcost += v.LendProjCost;
            p.duration += v.Duration;
            p.avglend=p.lendcost/p.count;
            p.avgdur=p.duration/p.count;
            return p;
        },
        /* callback for when data is removed from the current filter results */
        function (p, v) {
            --p.count;
            p.lendcost -= v.LendProjCost;
            p.duration -= v.Duration;
            p.avglend=p.lendcost/p.count;
            p.avgdur=p.duration/p.count;
            return p;
        },
        /* initialize p */
        function () {
            return {count: 0, lendcost:0, avglend:0, duration:0, avgdur:0};
        }
    );

     // dimension by full date
    var dateDimension = ndx.dimension(function (d) {
        return d.dd;
    });

    // dimension by month
    var moveMonths = ndx.dimension(function (d) {
        return d.month;
    });
/*    // group by total movement within month
    var monthlyMoveGroup = moveMonths.group().reduceSum(function (d) {
        return Math.abs(d.close - d.open);
    });
    // group by total volume within move, and scale down result
    var volumeByMonthGroup = moveMonths.group().reduceSum(function (d) {
        return d.volume / 500000;
    });
    var indexAvgByMonthGroup = moveMonths.group().reduce(
        function (p, v) {
            ++p.days;
            p.total += (v.open + v.close) / 2;
            p.avg = Math.round(p.total / p.days);
            return p;
        },
        function (p, v) {
            --p.days;
            p.total -= (v.open + v.close) / 2;
            p.avg = p.days ? Math.round(p.total / p.days) : 0;
            return p;
        },
        function () {
            return {days: 0, total: 0, avg: 0};
        }
    );
*/
    // create categorical dimension
    var instrument = ndx.dimension(function (d) {
        return d.LendInstr;
    });
    // produce counts records in the dimension
    var instrumentGroup = instrument.group();
/*
{'fraction_non_alphanumeric': 0.14140534262485482, 'fraction_numerical': 0.006678281068524971, 'mean_word_length': 2.103153153153153, 'pattern_counts': {'":': 0, '<': 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': '3541330', 'n_tokens_mistral': 2263, 'n_tokens_neox': 2162, 'n_words': 507}