<commit_before>/*global jQuery, google */

(function ($, g) {
    'use strict';

    g.load('visualization', '1', {
        packages: ['corechart'],
        callback: function () {
            var options = {
                    backgroundColor: '#eee',
                    hAxis: {title: 'Risk %'},
                    legend: 'none',
                    title: 'Graph based on the latest 100 portfolios',
                    vAxis: {title: 'Return %'}
                },
                chart = new g.visualization.ScatterChart(
                    $('#efficient-frontier').get()[0]);

            chart.setAction({
                id: "portfolioDetails",
                text: "",
                action: function () {
                    console.log(chart.getSelection());
                }
            });

            function percentageFormatter(number) {
                return (number * 100).toFixed(2) * 1;
            }

            function handleRender(e, data) {
                var dataArray = [
                    ['Risk', 'Return']
                ];

                data.rows.forEach(function (ptf) {
                    dataArray.push([
                        percentageFormatter(parseFloat(ptf.value.risk)),
                        percentageFormatter(parseFloat(ptf.value.ret))
                    ]);
                });

                chart.draw(g.visualization.arrayToDataTable(dataArray),
                    options);
            }

            $.subscribe('render.latestptfschart.conpa', handleRender);

        }
    });

}(jQuery, google));<commit_msg>Add tooltip to the latest ptf chart.<commit_after>/*global jQuery, google */

(function ($, g) {
    'use strict';

    g.load('visualization', '1', {
        packages: ['corechart'],
        callback: function () {
            function percentageFormatter(number) {
                return (number * 100).toFixed(2) * 1;
            }

            function handleRender(e, data) {
                var options = {
                        backgroundColor: '#eee',
                        title: 'Graph based on the latest 100 portfolios',
                        hAxis: {title: 'Risk %'},
                        vAxis: {title: 'Return %'},
                        legend: 'none'
                    },
                    dataArray = [],
                    dataTable = new google.visualization.DataTable(),
                    chart = new g.visualization.ScatterChart(
                        $('#efficient-frontier').get()[0]);

                dataTable.addColumn('number', 'Risk');
                dataTable.addColumn('number', 'Return');
                dataTable.addColumn({type: 'string', role: 'tooltip'});

                data.rows.forEach(function (ptf) {
                    var risk = percentageFormatter(parseFloat(ptf.value.risk)),
                        ret = percentageFormatter(parseFloat(ptf.value.ret)),
                        perf = percentageFormatter(parseFloat(ptf.value.perf));

                    dataArray.push([risk, ret,
                        "Risk: " + risk + "%\n" +
                        "Return: " + ret + "%\n" +
                        "Performance: " + perf + "%"
                    ]);
                });
                dataTable.addRows(dataArray);

                chart.draw(dataTable, options);
            }

            $.subscribe('render.latestptfschart.conpa', handleRender);
        }
    });

}(jQuery, google));
{'fraction_non_alphanumeric': 0.12735166425470332, 'fraction_numerical': 0.005788712011577424, 'mean_word_length': 1.247074122236671, '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': '4724506', 'n_tokens_mistral': 899, 'n_tokens_neox': 804, 'n_words': 157}