import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
import { RightBox03Config } from './index'
import { CreateComponentType } from '@/packages/index.d'
import { chartInitConfig, requestSqlConfig } from '@/settings/designSetting'
import { graphic } from 'echarts/core'
import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'

export const includes = ['legend', 'xAxis', 'yAxis', 'grid']

const option = {
  textBtnArr: [
    { label: '按日', value: '1' },
    { label: '按月', value: '2' },
    { label: '按年', value: '3' },
  ],
  color: [],
  legend: {
    left: 'right',
    data: ['未处理', '已处理'],
    textStyle:{
      fontSize: 12
    }
  },
  tooltip: {
    show: true,
    trigger: 'axis',
    axisPointer: {
      type: 'line'
    }
  },
  xAxis: {
    show: true,
    type: 'category'
  },
  yAxis: {
    show: true,
    type: 'value'
  },
  dataset: { ...dataJson },
  series: [
    {
      type: 'line',
      name: '未处理',
      smooth: false,
      symbolSize: 10, //设定实心点的大小
      itemStyle: {
        // 设置symbol的颜色
        normal: {
          color: '#08EE73FF'
        }
      },
      label: {
        show: true,
        position: 'top',
        color: '#fff',
        fontSize: 12
      },
      lineStyle: {
        width: 3,
        type: 'solid',
        color: '#08EE73FF'
      },
      areaStyle: {
        opacity: 0.8,
        color: new graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: '#08EE73FF'
          },
          {
            offset: 1,
            color: 'rgba(0,0,0,0)'
          }
        ])
      }
    },
    {
      type: 'line',
      name: '已处理',
      smooth: false,
      symbolSize: 10, //设定实心点的大小
      itemStyle: {
        // 设置symbol的颜色
        normal: {
          color: '#DC9D15FF'
        }
      },
      label: {
        show: true,
        position: 'top',
        color: '#fff',
        fontSize: 12
      },
      lineStyle: {
        width: 3,
        type: 'solid',
        color: '#DC9D15FF'
      },
      areaStyle: {
        opacity: 0.8,
        color: new graphic.LinearGradient(0, 0, 0, 1, [
          {
            offset: 0,
            color: '#DC9D15FF'
          },
          {
            offset: 1,
            color: 'rgba(0,0,0,0)'
          }
        ])
      }
    },
    
  ]
}

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