<commit_before>/**
 * Created by Administrator on 2017/5/7.
 */
echarts = require('echarts');
require('echarts-wordcloud');

// do not change the function name

exports.draw_age_chart = function(data) {
    let range;
    let age_chart = echarts.init(document.getElementById('age-chart'));
    age_chart.setOption({
        title: {
            text: 'age'
        },
        toolbox: {
            show: true,
            right: 25,
            feature: {
                //自定义组件只能以 my 开头, WTF
                'myTool': {
                    show: true,
                    title: 'Select',
                    icon: 'image://../img/select.png',
                    onclick: function() {
                        //console.log(range);
                        //reload_all_charts('age', [range[0] + 18, range[1] + 18]);
                    }
                },
                'magicType': {
                    show: true,
                    type: ['line', 'bar']
                }
            }
        },
        tooltip: {},
        brush: {
            toolbox: ['lineX', 'clear'],
            xAxisIndex: 'all',
            outOfBrush: {
                colorAlpha: 0.3
            }
        },
        xAxis: {
            data: data.map(d => d.name)
        },
        yAxis: {},
        series: [{
            name: '人数',
            type: 'line',
            data: data
        }]
    });

    age_chart.on('brushselected', function(params) {
        try {
            //console.log(params.batch[0]);
            range = params.batch[0].areas[0].coordRange;
        } catch (err) {

        }
    });
    // age_chart.dispatchAction({
    //     type: 'brush',
    //     areas: [{
    //         brushType: 'lineX',
    //         coordRange: [10, 30],
    //         xAxisIndex: 0
    //     }]
    // });
    // age_chart.dispatchAction({
    //     type: 'brushselected',
    //     areas: [{
    //         brushType: 'lineX',
    //         coordRange: [10, 30],
    //         xAxisIndex: 0
    //     }]
    // });
};

exports.draw_job_chart = function(data) {
    //console.log(data);
    let job_chart = echarts.init(document.getElementById('job-chart'));
    job_chart.setOption({
        title: {
            text: 'type of job'
        },
        tooltip: {},
        series: [{
            type: 'wordCloud',
            gridSize: 10,
            sizeRange: [15, 45],
            rotationRange: [-30, 30],
            shape: 'circle',
            textStyle: {
                normal: {
                    color: function() {
                        return 'rgb(' + [
                            Math.round(Math.random() * 160),
                            Math.round(Math.random() * 160),
                            Math.round(Math.random() * 160)
                        ].join(',') + ')';
                    }
                },
                emphasis: {
                    shadowBlur: 10,
                    shadowColor: '#333'
                }
            },
            data: data
        }]
    });
    job_chart.on('dblclick', function(params) {
        //console.log(params.data);
        reload_all_charts(['job'], [params.data.name]);
    });
}

exports.draw_marital_chart = function(data) {
    let marital_chart = echarts.init(document.getElementById('marital-chart'));
    marital_chart.setOption({
        title: {
            text: 'marital status'
        },
        tooltip: {},
        legend: {
            orient: 'vertical',
            x: 'right',
            data: (data.map(d => d.name))
        },
        series: [{
            name: '婚姻',
            type: 'pie',<commit_msg>bug repair<commit_after>/**
 * Created by Administrator on 2017/5/7.
 */
echarts = require('echarts');
require('echarts-wordcloud');

// do not change the function name

exports.draw_age_chart = function(data) {
    let range;
    let age_chart = echarts.init(document.getElementById('age-chart'));
    age_chart.setOption({
        title: {
            text: 'age'
        },
        toolbox: {
            show: true,
            right: 25,
            feature: {
                //自定义组件只能以 my 开头, WTF
                'myTool': {
                    show: true,
                    title: 'Select',
                    icon: 'image://../img/select.png',
                    onclick: function() {
                        //console.log(range);
                        //reload_all_charts('age', [range[0] + 18, range[1] + 18]);
                    }
                },
                'magicType': {
                    show: true,
                    type: ['line', 'bar']
                }
            }
        },
        tooltip: {},
        brush: {
            toolbox: ['lineX', 'clear'],
            xAxisIndex: 'all',
            outOfBrush: {
                colorAlpha: 0.3
            }
        },
        xAxis: {
            data: data.map(d => d.name)
        },
        yAxis: {},
        series: [{
            name: '人数',
            type: 'line',
            data: data
        }]
    });

    age_chart.on('brushselected', function(params) {
        try {
            //console.log(params.batch[0]);
            range = params.batch[0].areas[0].coordRange;
        } catch (err) {

        }
    });
    // age_chart.dispatchAction({
    //     type: 'brush',
    //     areas: [{
    //         brushType: 'lineX',
    //         coordRange: [10, 30],
    //         xAxisIndex: 0
    //     }]
    // });
    // age_chart.dispatchAction({
    //     type: 'brushselected',
    //     areas: [{
    //         brushType: 'lineX',
    //         coordRange: [10, 30],
    //         xAxisIndex: 0
    //     }]
    // });
};

exports.draw_job_chart = function(data) {
    //console.log(data);
    let job_chart = echarts.init(document.getElementById('job-chart'));
    job_chart.setOption({
        title: {
            text: 'type of job'
        },
        tooltip: {},
        series: [{
            type: 'wordCloud',
            gridSize: 10,
            sizeRange: [15, 45],
            rotationRange: [-30, 30],
            shape: 'circle',
            textStyle: {
                normal: {
                    color: function() {
                        return 'rgb(' + [
                            Math.round(Math.random() * 160),
                            Math.round(Math.random() * 160),
                            Math.round(Math.random() * 160)
                        ].join(',') + ')';
                    }
                },
                emphasis: {
                    shadowBlur: 10,
                    shadowColor: '#333'
                }
            },
            data: data
        }]
    });
    // job_chart.on('dblclick', function(params) {
    //     //console.log(params.data);
    //     reload_all_charts(['job'], [params.data.name]);
    // });
}

exports.draw_marital_chart = function(data) {
    let marital_chart = echarts.init(document.getElementById('marital-chart'));
    marital_chart.setOption({
        title: {
            text: 'marital status'
        },
        tooltip: {},
        legend: {
            orient: 'vertical',
            x: 'right',
            data: (data.map(d => d.name))
        },
        series: [{
            name: '婚姻',
            type: 'pie',
{'fraction_non_alphanumeric': 0.14731345334615914, 'fraction_numerical': 0.014566442215198571, 'mean_word_length': 1.0961981566820276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7088807', 'n_tokens_mistral': 2196, 'n_tokens_neox': 2029, 'n_words': 368}