<commit_before>function init(args) {
    'use strict';
    var defaults = {
        target: null,
        title: null,
        description: null
    };

    args = arguments[0];
    if (!args) { args = {}; }
    args = merge_with_defaults(args, defaults);

    if (d3.select(args.target).empty()) {
        console.warn('The specified target element "' + args.target + '" could not be found in the page. The chart will not be rendered.');
        return;
    }

    var container = d3.select(args.target);
    var svg = container.selectAll('svg');

    //this is how we're dealing with passing in a single array of data,
    //but with the intention of using multiple values for multilines, etc.

    //do we have a time_series?
    if (args.data[0][0][args.x_accessor] instanceof Date) {
        args.time_series = true;
    } else {
        args.time_series = false;
    }

    var svg_width = args.width;
    var svg_height = args.height;

    //are we setting the aspect ratio
    if (args.full_width) {
        // get parent element
        svg_width = get_width(args.target);
    }

    if (args.fill_height) {
        svg_height = get_height(args.target);
    }

    if (args.chart_type === 'bar' && svg_height === null) {
        svg_height = args.height = args.data[0].length * args.bar_height + args.top + args.bottom;
    }

    //remove the svg if the chart type has changed
    if ((!svg.selectAll('.mg-main-line').empty() && args.chart_type !== 'line')
            || (!svg.selectAll('.mg-points').empty() && args.chart_type !== 'point')
            || (!svg.selectAll('.mg-histogram').empty() && args.chart_type !== 'histogram')
            || (!svg.selectAll('.mg-barplot').empty() && args.chart_type !== 'bar')
        ) {
        svg.remove();
    }

    //add svg if it doesn't already exist
    //using trim on html rather than :empty to ignore white spaces if they exist
    if (mg_get_svg_child_of(args.target).empty()) {
        //add svg
        svg = d3.select(args.target)
            .append('svg')
                .classed('linked', args.linked)
                .attr('width', svg_width)
                .attr('height', svg_height);
    }

    args.width = svg_width;
    args.height = svg_height;

    // add clip path element to svg
    svg.selectAll('.mg-clip-path').remove();

    svg.append('defs')
        .attr('class', 'mg-clip-path')
        .append('clipPath')
            .attr('class', 'mg-plot-window-' + mg_strip_punctuation(args.target))
        .append('svg:rect')
            .attr('x', args.left)
            .attr('y', args.top)
            .attr('width', args.width - args.left - args.right - args.buffer)
            .attr('height', args.height - args.top - args.bottom - args.buffer + 1);

    //has the width or height changed?
    if (svg_width !== Number(svg.attr('width'))) {
        svg.attr('width', svg_width);
    }

    if (svg_height !== Number(svg.attr('height'))) {
        svg.attr('height', svg_height);
    }

    // This is an unfinished feature. Need to reconsider how we handle automatic scaling.
    svg.attr('viewBox', '0 0 ' + svg_width + ' ' + svg_height);

    if (args.full_width || args.full_height) {
        svg.attr('preserveAspectRatio', 'xMinYMin meet');
    }

    // remove missing class
    svg.classed('mg-missing', false);
    
    // remove missing text
    svg.selectAll('.mg-missing-text').remove();
    svg.selectAll('.mg-missing-pane').remove();

    //add chart title if it's different than existing one
    chart_title(args);

    //draw axes
    args.use_small_class = args.height - args.top - args.bottom - args.buffer
            <= args.small_height_threshold && args.width - args.left-args.right - args.buffer * 2
            <= args.small_width_threshold || args.small_text;

    //if we're updating an existing chart and we have fewer lines than
    //before, remove the outdated lines, e.g. if we had 3 lines, and we're calling
    //data_graphic() on the same target with 2 lines, remove the 3rd line

    var i = 0;
    if (args.data.length < svg.selectAll('.mg-main-line')[0].length) {
        //now, the thing is we can't just remove, say, line3 if we have a custom
        //line-color map, instead, see which are the lines to be removed, and delete those
        if (args.custom_line_color_map.length > 0) {<commit_msg>Setting id on the clip-path<commit_after>function init(args) {
    'use strict';
    var defaults = {
        target: null,
        title: null,
        description: null
    };

    args = arguments[0];
    if (!args) { args = {}; }
    args = merge_with_defaults(args, defaults);

    if (d3.select(args.target).empty()) {
        console.warn('The specified target element "' + args.target + '" could not be found in the page. The chart will not be rendered.');
        return;
    }

    var container = d3.select(args.target);
    var svg = container.selectAll('svg');

    //this is how we're dealing with passing in a single array of data,
    //but with the intention of using multiple values for multilines, etc.

    //do we have a time_series?
    if (args.data[0][0][args.x_accessor] instanceof Date) {
        args.time_series = true;
    } else {
        args.time_series = false;
    }

    var svg_width = args.width;
    var svg_height = args.height;

    //are we setting the aspect ratio
    if (args.full_width) {
        // get parent element
        svg_width = get_width(args.target);
    }

    if (args.fill_height) {
        svg_height = get_height(args.target);
    }

    if (args.chart_type === 'bar' && svg_height === null) {
        svg_height = args.height = args.data[0].length * args.bar_height + args.top + args.bottom;
    }

    //remove the svg if the chart type has changed
    if ((!svg.selectAll('.mg-main-line').empty() && args.chart_type !== 'line')
            || (!svg.selectAll('.mg-points').empty() && args.chart_type !== 'point')
            || (!svg.selectAll('.mg-histogram').empty() && args.chart_type !== 'histogram')
            || (!svg.selectAll('.mg-barplot').empty() && args.chart_type !== 'bar')
        ) {
        svg.remove();
    }

    //add svg if it doesn't already exist
    //using trim on html rather than :empty to ignore white spaces if they exist
    if (mg_get_svg_child_of(args.target).empty()) {
        //add svg
        svg = d3.select(args.target)
            .append('svg')
                .classed('linked', args.linked)
                .attr('width', svg_width)
                .attr('height', svg_height);
    }

    args.width = svg_width;
    args.height = svg_height;

    // add clip path element to svg
    svg.selectAll('.mg-clip-path').remove();

    svg.append('defs')
        .attr('class', 'mg-clip-path')
        .append('clipPath')
            .attr('id', 'mg-plot-window-' + mg_strip_punctuation(args.target))
        .append('svg:rect')
            .attr('x', args.left)
            .attr('y', args.top)
            .attr('width', args.width - args.left - args.right - args.buffer)
            .attr('height', args.height - args.top - args.bottom - args.buffer + 1);

    //has the width or height changed?
    if (svg_width !== Number(svg.attr('width'))) {
        svg.attr('width', svg_width);
    }

    if (svg_height !== Number(svg.attr('height'))) {
        svg.attr('height', svg_height);
    }

    // This is an unfinished feature. Need to reconsider how we handle automatic scaling.
    svg.attr('viewBox', '0 0 ' + svg_width + ' ' + svg_height);

    if (args.full_width || args.full_height) {
        svg.attr('preserveAspectRatio', 'xMinYMin meet');
    }

    // remove missing class
    svg.classed('mg-missing', false);

    // remove missing text
    svg.selectAll('.mg-missing-text').remove();
    svg.selectAll('.mg-missing-pane').remove();

    //add chart title if it's different than existing one
    chart_title(args);

    //draw axes
    args.use_small_class = args.height - args.top - args.bottom - args.buffer
            <= args.small_height_threshold && args.width - args.left-args.right - args.buffer * 2
            <= args.small_width_threshold || args.small_text;

    //if we're updating an existing chart and we have fewer lines than
    //before, remove the outdated lines, e.g. if we had 3 lines, and we're calling
    //data_graphic() on the same target with 2 lines, remove the 3rd line

    var i = 0;
    if (args.data.length < svg.selectAll('.mg-main-line')[0].length) {
        //now, the thing is we can't just remove, say, line3 if we have a custom
        //line-color map, instead, see which are the lines to be removed, and delete those
        if (args.custom_line_color_map.length > 0) {
{'fraction_non_alphanumeric': 0.1442763081899041, 'fraction_numerical': 0.004158484463439991, 'mean_word_length': 2.3402777777777777, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '6235670', 'n_tokens_mistral': 2764, 'n_tokens_neox': 2640, 'n_words': 724}