@extends('layouts.auth')

@section('content')
    <h4>График прироста {{$bot}}</h4>
    <hr>

    <div class="preloader w-100 text-center">
        <h4>Загрузка графика</h4>
        <div class="spinner-border" role="status">
            <span class="sr-only">Loading...</span>
        </div>
    </div>



    @if($bot=="storm")

        <script>
            $.get('https://stormbot.teleadmin.ru/get_chart',function(data){
                $('.preloader').remove();

                labels = [];
                data.chart.map(function(item,key){
                    labels.push(item.date);
                });

                values = [];
                data.chart.map(function(item,key){
                    values.push(item.count);
                });

                $('.last_day').html("За последние сутки: " + data.last_day);
                var options = {
                    maintainAspectRatio: false,
                    spanGaps: false,
                    elements: {
                        line: {
                            tension: 0.000001
                        }
                    },
                    plugins: {
                        filler: {
                            propagate: false
                        }
                    },
                    scales: {
                        xAxes: [{
                            ticks: {
                                autoSkip: false,
                                maxRotation: 0
                            }
                        }]
                    }
                };
                new Chart('chart', {
                    type: 'line',
                    data: {
                        labels: labels,
                        datasets: [{
                            backgroundColor: "rgba(255, 99, 132, 0.5)",
                            borderColor: "rgb(255, 99, 132)",
                            data: values,
                            label: 'Новых за час',
                            fill: "start"
                        }]
                    },
                    options: Chart.helpers.merge(options, {
                        title: {
                            text: 'График прироста',
                            display: true
                        },
                        scales: {
                            xAxes: [{
                                scaleLabel: {
                                    display: true,
                                    labelString: 'Время'
                                }
                            }],
                        }
                    })
                });
            });



        </script>
    @endif



    @if($bot=="smotrikino")

        <script>
            $.get('https://smotrikino.teleadmin.ru/get_chart',function(data){
                $('.preloader').remove();

                labels = [];
                data.chart.map(function(item,key){
                    labels.push(item.date);
                });

                values = [];
                data.chart.map(function(item,key){
                    values.push(item.count);
                });

                $('.last_day').html("За последние сутки: " + data.last_day);
                var options = {
                    maintainAspectRatio: false,
                    spanGaps: false,
                    elements: {
                        line: {
                            tension: 0.000001
                        }
                    },
                    plugins: {
                        filler: {
                            propagate: false
                        }
                    },
                    scales: {
                        xAxes: [{
                            ticks: {
                                autoSkip: false,
                                maxRotation: 0
                            }
                        }]
                    }
                };
                new Chart('chart', {
                    type: 'line',
                    data: {
                        labels: labels,
                        datasets: [{
                            backgroundColor: "rgba(255, 99, 132, 0.5)",
                            borderColor: "rgb(255, 99, 132)",
                            data: values,
                            label: 'Новых за час',
                            fill: "start"
                        }]
                    },
                    options: Chart.helpers.merge(options, {
                        title: {
                            text: 'График прироста',
                            display: true
                        },
                        scales: {
                            xAxes: [{
                                scaleLabel: {
                                    display: true,
                                    labelString: 'Время'
                                }
                            }],
                        }
                    })
                });




            });
        </script>
    @endif



    @if($bot=="vksound")
        <script>
            $.get('https://vksound.teleadmin.ru/get_chart',function(data){
                $('.preloader').remove();

                labels = [];
                data.chart.map(function(item,key){
                    labels.push(item.date);
                });

                values = [];
                data.chart.map(function(item,key){
                    values.push(item.count);
                });

                $('.last_day').html("За последние сутки: " + data.last_day);
                var options = {
                    maintainAspectRatio: false,
                    spanGaps: false,
                    elements: {
                        line: {
                            tension: 0.000001
                        }
                    },
                    plugins: {
                        filler: {
                            propagate: false
                        }
                    },
                    scales: {
                        xAxes: [{
                            ticks: {
                                autoSkip: false,
                                maxRotation: 0
                            }
                        }]
                    }
                };
                new Chart('chart', {
                    type: 'line',
                    data: {
                        labels: labels,
                        datasets: [{
                            backgroundColor: "rgba(255, 99, 132, 0.5)",
                            borderColor: "rgb(255, 99, 132)",
                            data: values,
                            label: 'Новых за час',
                            fill: "start"
                        }]
                    },
                    options: Chart.helpers.merge(options, {
                        title: {
                            text: 'График прироста',
                            display: true
                        },
                        scales: {
                            xAxes: [{
                                scaleLabel: {
                                    display: true,
                                    labelString: 'Время'
                                }
                            }],
                        }
                    })
                });
            });
        </script>

    @endif


    @if($bot=="reader")

        <script>
            $.get('https://booksbot.teleadmin.ru/get_chart',function(data){
                $('.preloader').remove();

                labels = [];
                data.chart.map(function(item,key){
                    labels.push(item.date);
                });

                values = [];
                data.chart.map(function(item,key){
                    values.push(item.count);
                });

                $('.last_day').html("За последние сутки: " + data.last_day);

                var options = {
                    maintainAspectRatio: false,
                    spanGaps: false,
                    elements: {
                        line: {
                            tension: 0.000001
                        }
                    },
                    plugins: {
                        filler: {
                            propagate: false
                        }
                    },
                    scales: {
                        xAxes: [{
                            ticks: {
                                autoSkip: false,
                                maxRotation: 0
                            }
                        }]
                    }
                };
                new Chart('chart', {
                    type: 'line',
                    data: {
                        labels: labels,
                        datasets: [{
                            backgroundColor: "rgba(255, 99, 132, 0.5)",
                            borderColor: "rgb(255, 99, 132)",
                            data: values,
                            label: 'Новых за час',
                            fill: "start"
                        }]
                    },
                    options: Chart.helpers.merge(options, {
                        title: {
                            text: 'График прироста',
                            display: true
                        },
                        scales: {
                            xAxes: [{
                                scaleLabel: {
                                    display: true,
                                    labelString: 'Время'
                                }
                            }],
                        }
                    })
                });




            });
        </script>

    @endif
    @if($bot=="goodlib")

        <script>
            $.get('https://goodlib.teleadmin.ru/get_chart',function(data){
                $('.preloader').remove();

                labels = [];
                data.chart.map(function(item,key){
                    labels.push(item.date);
                });

                values = [];
                data.chart.map(function(item,key){
                    values.push(item.count);
                });

                $('.last_day').html("За последние сутки: " + data.last_day);

                var options = {
                    maintainAspectRatio: false,
                    spanGaps: false,
                    elements: {
                        line: {
                            tension: 0.000001
                        }
                    },
                    plugins: {
                        filler: {
                            propagate: false
                        }
                    },
                    scales: {
                        xAxes: [{
                            ticks: {
                                autoSkip: false,
                                maxRotation: 0
                            }
                        }]
                    }
                };
                new Chart('chart', {
                    type: 'line',
                    data: {
                        labels: labels,
                        datasets: [{
                            backgroundColor: "rgba(255, 99, 132, 0.5)",
                            borderColor: "rgb(255, 99, 132)",
                            data: values,
                            label: 'Новых за час',
                            fill: "start"
                        }]
                    },
                    options: Chart.helpers.merge(options, {
                        title: {
                            text: 'График прироста',
                            display: true
                        },
                        scales: {
                            xAxes: [{
                                scaleLabel: {
                                    display: true,
                                    labelString: 'Время'
                                }
                            }],
                        }
                    })
                });




            });
        </script>

    @endif



@endsection
