@if($PocetKontrolPodlaHodnoteniaEChartSource->isNotEmpty())
    <div id="EChartPocetKontrolPodlaHodnotenia" style="height:400px"></div>

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

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

                EChartPocetKontrolPodlaHodnotenia.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: 'tek-pocet-kontrol-podla-hodnotenia-kontroly',
                                backgroundColor: 'white',
                                show: true,
                                title: 'Uložiť ako obrázok',
                            },
                            restore: {
                                show: true,
                                title: 'Obnoviť',
                            },
                        },
                    },
                    dataset: [
                        {
                            dimensions: [
                                {
                                    name: 'label',
                                    type: 'ordinal',
                                },
                                {
                                    name: 'SPOSOBILE',
                                    type: 'number',
                                    displayName: 'Spôsobilé',
                                },
                                {
                                    name: 'NEHODNOTENE',
                                    type: 'number',
                                    displayName: 'Nehodnotené',
                                },
                                {
                                    name: 'NESPOSOBILE',
                                    type: 'number',
                                    displayName: 'Nespôsobilé',
                                },
                                {
                                    name: 'DOCASNE_SPOSOBILE',
                                    type: 'number',
                                    displayName: 'Dočasne spôsobilé',
                                },
                                {
                                    name: 'pocet',
                                    type: 'number',
                                }
                            ],
                            source: @json($PocetKontrolPodlaHodnoteniaEChartSource ?? []),
                        },
                    ],
                    xAxis: {
                        type: 'category',
                        axisTick: {
                            alignWithLabel: true
                        },
                        axisLabel: {
                            rotate: -30,
                            margin: 15,
                            overflow: 'truncate',
                        },
                    },
                    yAxis: {
                        type: 'value',
                        minInterval: 1,
                    },
                    series: [
                        {
                            type: 'bar',
                            stack: 'total',
                        },
                        {
                            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
