
$(document).ready(function() {
    chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container-1',
            defaultSeriesType: 'column',
            margin: [30, 0, 30, 50]
        },
        title:    { text: null },
        subtitle: { text: 'Número de Palavras por Letra' },
        xAxis: {
            categories: ['A','B','C','D','E','F','G','H',
                         'I','J','K','L','M','N','O','P',
                         'Q','R','S','T','U','V','W','X','Y','Z',],
            title: { text: null }
        },
        yAxis: {
            min: 0,
            title: {
                text: null,
                align: 'middle'
            }
        },
        tooltip: {
            formatter: function() {
                return '<b>'+ this.x +'</b> &mdash; '+ this.y + ' entradas';
            }
        },
        legend:  { enabled: false },
        credits: { enabled: false },
        series: [{
            name: '',
            dataURL: '/ajax/wordsByLetter',
        }]
    });


    $.post('/ajax/wordsBySize', function(data) { 
        chart2 = new Highcharts.Chart({
            chart: {
                renderTo: 'container-2',
                defaultSeriesType: 'column',
                margin: [30, 0, 30, 50]
            },
            title:    { text: null },
            subtitle: { text: 'Número de Palavras por Tamanho' },
            xAxis: {
                categories: data['axis'],
                title: { text: null }
            },
            yAxis: {
                min: 0,
                max: 20000,
                title: {
                    text: null,
                    align: 'middle'
                }
            },
            tooltip: {
                formatter: function() {
                    return '<b>'+ this.x +'</b> &mdash; '+ this.y + ' entradas';
                }
            },
            legend:  { enabled: false },
            credits: { enabled: false },
            series: [{
                name: '',
                data: data['values'],
            }]
        });
    });


    $.post('/ajax/top10', function(data) { 
        chart3 = new Highcharts.Chart({
            chart: {
                renderTo: 'container-3',
                defaultSeriesType: 'bar',
                margin: [30, 13, 30, 90]
            },
            title:    { text: null },
            subtitle: { text: 'Palavras Mais Procuradas' },
            xAxis: {
                categories: data['axis'],
                title: { text: null }
            },
            yAxis: {
                min: 0,
                title: {
                    text: null,
                    align: 'middle'
                }
            },
            tooltip: {
                formatter: function() {
                    return '<b>'+ this.x +'</b> &mdash; '+ this.y + ' pesquisas';
                }
            },
            legend:  { enabled: false },
            credits: { enabled: false },
            series: [{
                name: '',
                data: data['values'],
            }]
        });
    });


});