<template>
  <section class="motion-section">
    <div class="container mx-auto px-4">
      <div class="data-current quiet-panel">
        <div>
          <span class="eyebrow">数据流</span>
          <h2>经营数据不是报表，是每天都在流动的水位。</h2>
          <p>从线索到成交，从复诊到复购，系统持续描绘诊所的经营温度。</p>
        </div>
        <div ref="chartRef" class="data-chart"></div>
      </div>
    </div>
  </section>
</template>

<script setup>
import * as echarts from 'echarts'
import { onBeforeUnmount, onMounted, ref } from 'vue'

const chartRef = ref(null)
let chart

// 初始化轻量动态曲线，用于表达经营流动而不是堆砌仪表盘卡片。
onMounted(() => {
  chart = echarts.init(chartRef.value)
  chart.setOption({
    grid: { left: 20, right: 20, top: 26, bottom: 24 },
    xAxis: { type: 'category', show: false, data: ['一', '二', '三', '四', '五', '六', '日'] },
    yAxis: { type: 'value', show: false },
    series: [
      { type: 'line', smooth: true, symbol: 'none', data: [18, 26, 22, 38, 46, 42, 58], lineStyle: { width: 4, color: '#b48a58' }, areaStyle: { color: 'rgba(180,138,88,.18)' } },
      { type: 'line', smooth: true, symbol: 'none', data: [8, 16, 20, 24, 31, 36, 44], lineStyle: { width: 3, color: '#1f5f50' }, areaStyle: { color: 'rgba(31,95,80,.12)' } }
    ]
  })
  window.addEventListener('resize', chart.resize)
})

onBeforeUnmount(() => {
  window.removeEventListener('resize', chart?.resize)
  chart?.dispose()
})
</script>
