<commit_before>/*
 * StackedAreaChart - Object constructor function
 * @param _parentElement 	-- the HTML element in which to draw the visualization
 * @param _districtViolenceData    -- violence data by district
 * @param _totalViolenceData    -- violence for entire country not divided by district
 * @param _dimensions       -- dimensions object
 * @param _colorScale       -- color scale desired from colorbrewer.js
 */

StackedAreaChart = function (_parentElement, _dimensions, _districtViolenceData, _totalViolenceData,
                             _troopNumbersData, _usCasualtiesMonthData, _colorScale) {

    this.parentElement = _parentElement;
    this.districtViolenceData = _districtViolenceData;
    this.totalViolenceData = _totalViolenceData;
    this.troopsBySource = _troopNumbersData;
    this.usCasualtiesByMonth = _usCasualtiesMonthData;
    this.displayData = []; // see data wrangling

    // set dimensions; size based on width of div to allow for easier styling with bootstrap
    this.width = $("#" + this.parentElement).width();
    this.heightRatio = _dimensions.heightRatio;
    this.margin = _dimensions.margin;
    this.selectedColors = _colorScale;

};


/*
 * Initialize visualization (static content, e.g. SVG area or axes)
 */

StackedAreaChart.prototype.initVis = function () {

    var vis = this;

    var otherDivsHeight = $("#controls").height() + $("#information").height();
    vis.height = (vis.width - otherDivsHeight) * vis.heightRatio - vis.margin.top - vis.margin.bottom;
    vis.width = vis.width - vis.margin.left - vis.margin.right;

    // SVG drawing area
    vis.svg = d3.select("#" + vis.parentElement).append("svg")
        .attr("width", vis.width + vis.margin.left + vis.margin.right)
        .attr("height", vis.height + vis.margin.top + vis.margin.bottom)
        .append("g")
        .attr("transform", "translate(" + vis.margin.left + "," + vis.margin.top + ")");

    // Scales and axes
    vis.x = d3.time.scale()
        .range([0, vis.width]);

    vis.y = d3.scale.linear()
        .range([vis.height, 0]);

    // color brewer scale, update range and domain depending on data
    vis.colorScale = d3.scale.ordinal();

    vis.xAxis = d3.svg.axis()
        .scale(vis.x)
        .orient("bottom");

    vis.yAxis = d3.svg.axis()
        .scale(vis.y)
        .orient("left");

    vis.xAxisGroup = vis.svg.append("g")
        .attr("class", "x-axis axis")<commit_msg>stopped overlapping tick marks on x-axis of stacked area chart<commit_after>/*
 * StackedAreaChart - Object constructor function
 * @param _parentElement 	-- the HTML element in which to draw the visualization
 * @param _districtViolenceData    -- violence data by district
 * @param _totalViolenceData    -- violence for entire country not divided by district
 * @param _dimensions       -- dimensions object
 * @param _colorScale       -- color scale desired from colorbrewer.js
 */

StackedAreaChart = function (_parentElement, _dimensions, _districtViolenceData, _totalViolenceData,
                             _troopNumbersData, _usCasualtiesMonthData, _colorScale) {

    this.parentElement = _parentElement;
    this.districtViolenceData = _districtViolenceData;
    this.totalViolenceData = _totalViolenceData;
    this.troopsBySource = _troopNumbersData;
    this.usCasualtiesByMonth = _usCasualtiesMonthData;
    this.displayData = []; // see data wrangling

    // set dimensions; size based on width of div to allow for easier styling with bootstrap
    this.width = $("#" + this.parentElement).width();
    this.heightRatio = _dimensions.heightRatio;
    this.margin = _dimensions.margin;
    this.selectedColors = _colorScale;

};


/*
 * Initialize visualization (static content, e.g. SVG area or axes)
 */

StackedAreaChart.prototype.initVis = function () {

    var vis = this;

    var otherDivsHeight = $("#controls").height() + $("#information").height();
    vis.height = (vis.width - otherDivsHeight) * vis.heightRatio - vis.margin.top - vis.margin.bottom;
    vis.width = vis.width - vis.margin.left - vis.margin.right;

    // SVG drawing area
    vis.svg = d3.select("#" + vis.parentElement).append("svg")
        .attr("width", vis.width + vis.margin.left + vis.margin.right)
        .attr("height", vis.height + vis.margin.top + vis.margin.bottom)
        .append("g")
        .attr("transform", "translate(" + vis.margin.left + "," + vis.margin.top + ")");

    // Scales and axes
    vis.x = d3.time.scale()
        .range([0, vis.width]);

    vis.y = d3.scale.linear()
        .range([vis.height, 0]);

    // color brewer scale, update range and domain depending on data
    vis.colorScale = d3.scale.ordinal();

    vis.xAxis = d3.svg.axis()
        .scale(vis.x)
        .orient("bottom")
        .ticks(5);

    vis.yAxis = d3.svg.axis()
        .scale(vis.y)
        .orient("left");

    vis.xAxisGroup = vis.svg.append("g")
        .attr("class", "x-axis axis")
{'fraction_non_alphanumeric': 0.12933306304480033, 'fraction_numerical': 0.0034461787958645854, 'mean_word_length': 2.9314741035856575, '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': '5179602', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1476, 'n_words': 353}