<script setup lang="ts">
import { ref } from 'vue'
import PlaneLoader from "@/Components/FlightsGoneBy/PlaneLoader.vue";
import VueApexCharts from 'vue3-apexcharts'
import {ChartType} from "@/Types/types";

defineProps<{
    type: ChartType
    title: string
    height: number | string
    options: object
    series: unknown[]
}>()

const ready = ref(false)
</script>

<template>
    <div class="chart-wrap">
        <div class="chart-title">{{title}}</div>
        <PlaneLoader v-if="!ready" />
        <VueApexCharts
            :type="type"
            :height="height"
            :options="options"
            :series="series"
            :class="{ 'chart-hidden': !ready }"
            @mounted="ready = true"
        />
    </div>
</template>

<style scoped>
.chart-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chart-title {
    font-size: 13px;
    font-weight: 500;
    color: #556677;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.chart-empty {
    height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #445566;
}
</style>
