/**
 * 图表相关类型定义
 */

import type { EChartOption } from 'echarts'

/** 图表数据项 */
export interface ChartDataItem {
  name: string
  value: number
  [key: string]: any
}

/** 图表系列数据 */
export interface ChartSeries {
  name: string
  data: number[]
  color?: string
  [key: string]: any
}

/** 饼图配置 */
export interface PieChartConfig {
  data: ChartDataItem[]
  title?: string
  type?: 'pie' | 'doughnut'
  showLegend?: boolean
  showLabel?: boolean
  height?: string
  onClick?: (item: ChartDataItem) => void
}

/** 柱状图配置 */
export interface BarChartConfig {
  data: ChartDataItem[]
  title?: string
  type?: 'vertical' | 'horizontal'
  stacked?: boolean
  grouped?: boolean
  xAxisLabel?: string
  yAxisLabel?: string
  height?: string
  onClick?: (item: ChartDataItem) => void
}

/** 折线图配置 */
export interface LineChartConfig {
  data: ChartDataItem[]
  series?: ChartSeries[]
  title?: string
  area?: boolean
  smooth?: boolean
  xAxisLabel?: string
  yAxisLabel?: string
  height?: string
  onClick?: (item: ChartDataItem) => void
}

/** 仪表盘配置 */
export interface GaugeChartConfig {
  value: number
  min?: number
  max?: number
  title?: string
  unit?: string
  height?: string
  color?: string[]
}

/** 漏斗图配置 */
export interface FunnelChartConfig {
  data: ChartDataItem[]
  title?: string
  height?: string
  onClick?: (item: ChartDataItem) => void
}

/** 统计卡片配置 */
export interface StatCardConfig {
  title: string
  value: number | string
  unit?: string
  icon?: string
  trend?: 'up' | 'down' | 'flat'
  trendValue?: number
  color?: string
  loading?: boolean
  clickable?: boolean
  onClick?: () => void
}

/** 图表主题 */
export type ChartTheme = 'default' | 'dark' | 'custom'

/** 图表尺寸 */
export type ChartSize = 'small' | 'medium' | 'large'

/** 图表事件 */
export interface ChartEvents {
  onClick?: (params: any) => void
  onDoubleClick?: (params: any) => void
  onMouseOver?: (params: any) => void
  onMouseOut?: (params: any) => void
}

/** 资产状态统计 */
export interface AssetStatusStatistics {
  status: string
  statusName: string
  count: number
  percentage: number
  color: string
}

/** 资产分布统计 */
export interface AssetDistributionStatistics {
  organizationId: number
  organizationName: string
  count: number
  value: number
  percentage: number
}

/** 资产趋势数据 */
export interface AssetTrendData {
  date: string
  count: number
  value: number
  depreciation?: number
  netValue?: number
}

/** 资产类型统计 */
export interface AssetTypeStatistics {
  deviceTypeId: number
  typeName: string
  count: number
  value: number
  percentage: number
  icon?: string
}

/** 维修统计 */
export interface MaintenanceStatistics {
  date: string
  count: number
  cost: number
  completedCount: number
  pendingCount: number
}

/** 图表导出配置 */
export interface ChartExportConfig {
  filename?: string
  type?: 'png' | 'jpeg' | 'svg'
  quality?: number
  pixelRatio?: number
  backgroundColor?: string
}

/** 图表响应式配置 */
export interface ChartResponsiveConfig {
  width?: number | string
  height?: number | string
  autoResize?: boolean
  resizeDelay?: number
}

/** 图表加载状态 */
export interface ChartLoadingConfig {
  show?: boolean
  text?: string
  color?: string
  textColor?: string
  maskColor?: string
  zlevel?: number
}

/** 图表动画配置 */
export interface ChartAnimationConfig {
  enable?: boolean
  duration?: number
  easing?: string
  delay?: number
}

/** 图表性能配置 */
export interface ChartPerformanceConfig {
  progressive?: number
  progressiveThreshold?: number
  hoverLayerThreshold?: number
  useUTC?: boolean
}
