@if(isset($PocetKontrolPodlaStavuEChartSource) && $PocetKontrolPodlaStavuEChartSource->isNotEmpty())
    <div id="EChartPocetKontrolPodlaStavu" style="height:400px"></div>

    @push('scripts')
        <script type="text/javascript">
            $(document).ready(function () {
                const EChartPocetKontrolPodlaStavu = echarts.init(document.getElementById('EChartPocetKontrolPodlaStavu'), 'macarons');

                window.addEventListener('resize', function () {
                    EChartPocetKontrolPodlaStavu.resize();
                });

                EChartPocetKontrolPodlaStavu.setOption({
                    backgroundColor: 'transparent',
                    grid: {
                        height: 200,
                        top: 'auto',
                    },
                    legend: {
                        show: true,
                        type: 'plain',
                        orient: 'horizontal',
                        align: 'left',
                        top: 0,
                        zlevel: 100,
                        width: '80%',
                    },
                    tooltip: {
                        trigger: 'axis',
                    },
                    toolbox: {
                        show: true,
                        orient: 'horizontal',
                        top: 0,
                        right: 0,
                        zlevel: 100,
                        feature: {
                            saveAsImage: {
                                type: 'png',
                                name: 'pek-pocet-kontrol-podla-stavu',
                                backgroundColor: 'white',
                                show: true,
                                title: 'Uložiť ako obrázok',
                            },
                            restore: {
                                show: true,
                                title: 'Obnoviť',
                            },
                        },
                    },
                    dataset: [
                        {
                            dimensions: [
                                {
                                    name: 'label',
                                    type: 'ordinal',
                                    displayName: 'Stav',
                                },
                                {
                                    name: 'ARCHIV',
                                    type: 'int',
                                    displayName: 'Archív',
                                },
                                {
                                    name: 'ROZPRACOVANE',
                                    type: 'int',
                                    displayName: 'Rozpracované',
                                },
                                {
                                    name: 'STORNO',
                                    type: 'int',
                                    displayName: 'Storno',
                                },
                            ],
                            source: @json($PocetKontrolPodlaStavuEChartSource ?? []),
                        },
                    ],
                    xAxis: {
                        type: 'category',
                    },
                    yAxis: {
                        type: 'value',
                        minInterval: 1
                    },
                    series: [
                        {
                            type: 'bar',
                            stack: 'total',
                        },
                        {
                            type: 'bar',
                            stack: 'total',
                        },
                        {
                            type: 'bar',
                            stack: 'total',
                        },
                    ],
                });
            });
        </script>
    @endpush
@else
    <p class="h4 text-center text-muted">Nie sú k dispozícii žiadne údaje...</p>
@endif
