<commit_before>(function() {


    var columnDefs = [
        {headerName: 'Product', field: 'product', chartType: 'category'},
        {headerName: 'Book', field: 'book', chartType: 'category'},

        {headerName: 'Current', field: 'current', type: 'measure'},
        {headerName: 'Previous', field: 'previous', type: 'measure'},
        {headerName: 'PL 1', field: 'pl1', type: 'measure'},
        {headerName: 'PL 2', field: 'pl2', type: 'measure'},
        {headerName: 'Gain-DX', field: 'gainDx', type: 'measure'},
        {headerName: 'SX / PX', field: 'sxPx', type: 'measure'},

        {headerName: 'Trade', field: 'trade', type: 'measure'},
        {headerName: 'Submitter ID', field: 'submitterID', type: 'measure'},
        {headerName: 'Submitted Deal ID', field: 'submitterDealID', type: 'measure', width: 150},

        {headerName: 'Portfolio', field: 'portfolio'},
        {headerName: 'Deal Type', field: 'dealType'},
        {headerName: 'Bid', field: 'bidFlag'}
    ];

    var chartRef;

    var gridOptions = {
        columnDefs: columnDefs,
        defaultColDef: {
            width: 120,
            sortable: true,
            resizable: true
        },
        columnTypes: {
            measure: {
                chartType: 'series',
                cellClass: 'number',
                valueFormatter: numberCellFormatter,
                cellRenderer:'agAnimateShowChangeCellRenderer'
            }
        },
        animateRows: true,
        enableCharts: true,
        suppressAggFuncInHeader: true,
        getRowNodeId: function(data) { return data.trade; },
        onFirstDataRendered: function(params) {
            var chartRangeParams = {
                cellRange: {
                    columns: ['product', 'current', 'previous', 'pl1', 'pl2', 'gainDx', 'sxPx']
                },
                chartType: 'groupedBar',
                chartContainer: document.querySelector('#integrated-charting-chart'),
                suppressChartRanges: true,
                aggregate: true
            };

            chartRef = params.api.chartRange(chartRangeParams);
        },
        processChartOptions: function(params) {
            var opts = params.options;

            opts.legendPosition = 'bottom';
            opts.yAxis.labelFormatter = yAxisLabelFormatter;
            opts.seriesDefaults.tooltipEnabled = true;
            opts.seriesDefaults.fills =['#c16068', '#a2bf8a', '#ebcc87', '#80a0c3', '#b58dae', '#85c0d1'];
            opts.seriesDefaults.strokes =['#874349', '#718661', '#a48f5f', '#5a7088', '#7f637a', '#5d8692'];

            opts.seriesDefaults.tooltipRenderer = (params) => {
                var strArr = params.yField.replace(/([A-Z])/g, " $1");
                var seriesName = strArr.charAt(0).toUpperCase() + strArr.slice(1);
                var value = params.datum[params.yField].toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
                return `<b>${seriesName}</b>: ${value}`;
            };

            return opts;
        },
        getChartToolbarItems: function() {
            return []; // hide toolbar items
        }
    };

    function createChart(type) {

        // destroy existing chart
        if (chartRef) {
            chartRef.destroyChart();
        }

        var params = {
            cellRange: {
                columns: ['product', 'current', 'previous', 'pl1', 'pl2', 'gainDx', 'sxPx']
            },
            chartContainer: document.querySelector('#myChart'),
            chartType: type,
            suppressChartRanges: true,
            aggregate: true
        };

        chartRef = gridOptions.api.chartRange(params);
    }<commit_msg>AG-3002 - updated integrated charting example on main page.<commit_after>(function() {


    var columnDefs = [
        {headerName: 'Product', field: 'product', chartType: 'category'},
        {headerName: 'Book', field: 'book', chartType: 'category'},

        {headerName: 'Current', field: 'current', type: 'measure'},
        {headerName: 'Previous', field: 'previous', type: 'measure'},
        {headerName: 'PL 1', field: 'pl1', type: 'measure'},
        {headerName: 'PL 2', field: 'pl2', type: 'measure'},
        {headerName: 'Gain-DX', field: 'gainDx', type: 'measure'},
        {headerName: 'SX / PX', field: 'sxPx', type: 'measure'},

        {headerName: 'Trade', field: 'trade', type: 'measure'},
        {headerName: 'Submitter ID', field: 'submitterID', type: 'measure'},
        {headerName: 'Submitted Deal ID', field: 'submitterDealID', type: 'measure', width: 150},

        {headerName: 'Portfolio', field: 'portfolio'},
        {headerName: 'Deal Type', field: 'dealType'},
        {headerName: 'Bid', field: 'bidFlag'}
    ];

    var chartRef;

    var gridOptions = {
        columnDefs: columnDefs,
        defaultColDef: {
            width: 120,
            sortable: true,
            resizable: true
        },
        columnTypes: {
            measure: {
                chartType: 'series',
                cellClass: 'number',
                valueFormatter: numberCellFormatter,
                cellRenderer:'agAnimateShowChangeCellRenderer'
            }
        },
        animateRows: true,
        enableCharts: true,
        suppressAggFuncInHeader: true,
        getRowNodeId: function(data) { return data.trade; },
        onFirstDataRendered: function(params) {
            var chartRangeParams = {
                cellRange: {
                    columns: ['product', 'current', 'previous', 'pl1', 'pl2', 'gainDx', 'sxPx']
                },
                chartType: 'groupedBar',
                chartContainer: document.querySelector('#integrated-charting-chart'),
                suppressChartRanges: true,
                aggregate: true
            };

            chartRef = params.api.chartRange(chartRangeParams);
        },
        processChartOptions: function(params) {
            var opts = params.options;

            opts.legendPosition = 'bottom';
            opts.yAxis.labelFormatter = yAxisLabelFormatter;
            opts.xAxis.labelRotation = 0;

            opts.seriesDefaults.fills =['#c16068', '#a2bf8a', '#ebcc87', '#80a0c3', '#b58dae', '#85c0d1'];
            opts.seriesDefaults.strokes =['#874349', '#718661', '#a48f5f', '#5a7088', '#7f637a', '#5d8692'];

            opts.seriesDefaults.tooltipEnabled = false;
            // opts.seriesDefaults.tooltipRenderer = (params) => {
            //
            //     var strArr = params.yField.replace(/([A-Z])/g, " $1");
            //     var seriesName = strArr.charAt(0).toUpperCase() + strArr.slice(1);
            //     var value = params.datum[params.yField].toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
            //     return `<b>${seriesName}</b>: ${value}`;
            // };

            return opts;
        },
        getChartToolbarItems: function() {
            return []; // hide toolbar items
        }
    };
{'fraction_non_alphanumeric': 0.15363531448355452, 'fraction_numerical': 0.019763416041546453, 'mean_word_length': 2.0555310709563686, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '6884343', 'n_tokens_mistral': 2110, 'n_tokens_neox': 1967, 'n_words': 428}