import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
import { ZLLingZhongMianJiConfig } from './index'
import { chartInitConfig, requestSqlConfig } from '@/settings/designSetting'
import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'

export const includes = ['xAxis', 'yAxis', 'grid']
export const seriesItem = {
  type: 'bar',
  barWidth: 15,
  label: {
    show: true,
    position: 'top',
    color: '#fff',
    fontSize: 12
  },
  itemStyle: {
    color: '#70CC80',
    borderRadius: 2
  }
}
export const option = {
  tooltip: {
    show: true,
    trigger: 'axis',
    axisPointer: {
      show: true,
      type: 'shadow'
    }
  },
  xAxis: {
    show: true,
    type: 'category'
  },
  yAxis: {
    show: true,
    type: 'value'
  },
  dataset: { ...dataJson },
  series: [seriesItem]
}

export default class Config extends PublicConfigClass implements CreateComponentType {
  public key = ZLLingZhongMianJiConfig.key
  public chartConfig = cloneDeep(ZLLingZhongMianJiConfig)
  // 图表配置项
  public option = echartOptionProfixHandle(option, includes)
  public request = { ...requestSqlConfig, requestSQLContent: { sql: 'select * from ' }, }
  public filter = "return res.result;"
}
