<commit_before>define(function(require) {
    'use strict';

    const bowser = require('bowser');
    const {britechartsGreySchema : colors} = require('./colors.js');
    const constants = require('./constants.js');
    const serializeWithStyles = require('./serializeWithStyles.js');

    let encoder = window.btoa;

    if (!encoder) {
        encoder = require('base-64').encode;
    }

    const config = {
        styleClass : 'britechartStyle',
        defaultFilename: 'britechart.png',
        chartBackground: 'white',
        imageSourceBase: 'data:image/svg+xml;base64,',
        titleFontSize: '15px',
        titleFontFamily: '\'Heebo-thin\', sans-serif',
        titleTopOffset: 40,
        get styleBackgroundString () {
            return `<style>svg{background:${this.chartBackground};}</style>`;
        }
    };

    /**
     * Main function to be used as a method by chart instances to export charts to png
     * @param  {array} svgs (or an svg element) pass in both chart & legend as array or just chart as svg or in array
     * @param  {string} filename [download to be called <filename>.png]
     */
    function exportChart(d3svg, filename, title) {
        console.log('mounted')
        let img = createImage(convertSvgToHtml(d3svg, title));

        img.onload = handleImageLoad.bind(
                img,
                createCanvas(this.width(), this.height()),
                filename
            );
    }

    /**
     * adds background styles to raw html
     * @param {string} html raw html
     */
    function addBackground(html) {
        return html.replace('>',`>${config.styleBackgroundString}`);
    }

    /**
     * takes d3 svg el, adds proper svg tags, adds inline styles
     * from stylesheets, adds white background and returns string
     * @param  {object} d3svg TYPE d3 svg element
     * @return {string} string of passed d3
     */
    function convertSvgToHtml (d3svg, title) {
        if (!d3svg) {
            return;
        }<commit_msg>remove console.log<commit_after>define(function(require) {
    'use strict';

    const bowser = require('bowser');
    const {britechartsGreySchema : colors} = require('./colors.js');
    const constants = require('./constants.js');
    const serializeWithStyles = require('./serializeWithStyles.js');

    let encoder = window.btoa;

    if (!encoder) {
        encoder = require('base-64').encode;
    }

    const config = {
        styleClass : 'britechartStyle',
        defaultFilename: 'britechart.png',
        chartBackground: 'white',
        imageSourceBase: 'data:image/svg+xml;base64,',
        titleFontSize: '15px',
        titleFontFamily: '\'Heebo-thin\', sans-serif',
        titleTopOffset: 40,
        get styleBackgroundString () {
            return `<style>svg{background:${this.chartBackground};}</style>`;
        }
    };

    /**
     * Main function to be used as a method by chart instances to export charts to png
     * @param  {array} svgs (or an svg element) pass in both chart & legend as array or just chart as svg or in array
     * @param  {string} filename [download to be called <filename>.png]
     */
    function exportChart(d3svg, filename, title) {
        let img = createImage(convertSvgToHtml(d3svg, title));

        img.onload = handleImageLoad.bind(
                img,
                createCanvas(this.width(), this.height()),
                filename
            );
    }

    /**
     * adds background styles to raw html
     * @param {string} html raw html
     */
    function addBackground(html) {
        return html.replace('>',`>${config.styleBackgroundString}`);
    }

    /**
     * takes d3 svg el, adds proper svg tags, adds inline styles
     * from stylesheets, adds white background and returns string
     * @param  {object} d3svg TYPE d3 svg element
     * @return {string} string of passed d3
     */
    function convertSvgToHtml (d3svg, title) {
        if (!d3svg) {
            return;
        }
{'fraction_non_alphanumeric': 0.11933534743202417, 'fraction_numerical': 0.008056394763343404, 'mean_word_length': 2.3870417732310316, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2116586', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1122, 'n_words': 318}