<template>
  <div class="chart-panel">
    <div class="chart-header">
      <h3>{{ title }}</h3>
    </div>
    <div
      ref="chartContainer"
      :style="{ height }"
      class="chart-container"
    >
      <div v-if="loading" class="chart-loading">
        <el-skeleton-item variant="circle" style="width: 100px; height: 100px"/>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ChartPanel',
  props: {
    title: {
      type: String,
      required: true
    },
    loading: {
      type: Boolean,
      default: false
    },
    height: {
      type: String,
      default: '300px'
    }
  }
};
</script>

<style lang="scss" scoped>
.chart-panel {
  width: 100%;
  height: 100%;

  .chart-header {
    padding: 12px 16px;
    border-bottom: 1px solid #ebeef5;

    h3 {
      font-size: 16px;
      font-weight: 600;
      margin: 0;
      color: #303133;
    }
  }

  .chart-container {
    position: relative;
    width: 100%;

    .chart-loading {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
  }
}
</style>
