import { PublicConfigClass } from '../../../../../utils/PublicConfigClass';

import { echartOptionProfixHandle } from '../../../chart';
import { BarLineConfig } from './basis';
import { cloneDeep } from 'lodash-es';
import dataJson from './data.json';

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

export const barSeriesItem = {
  type: 'bar',
  barWidth: 15,
  label: {
    show: true,
    position: 'top',
    color: '#fff',
    fontSize: 12
  },
  itemStyle: {
    color: null,
    borderRadius: 2
  }
};

export const lineSeriesItem = {
  type: 'line',
  symbol: 'circle',
  label: {
    show: true,
    position: 'top',
    color: '#fff',
    fontSize: 12
  },
  yAxisIndex: 1,
  symbolSize: 5, //设定实心点的大小
  itemStyle: {
    borderWidth: 1
  },
  lineStyle: {
    type: 'solid',
    width: 3,
    color: null
  }
};

export const option = {
  tooltip: {
    show: true,
    trigger: 'axis',
    axisPointer: {
      show: true,
      type: 'shadow'
    }
  },
  legend: {
    data: null
  },
  xAxis: {
    show: true,
    type: 'category'
  },
  yAxis: [
    {
      type: 'value',
      name: dataJson.dimensions[2],
      axisLabel: {
        formatter: '{value} ml'
      }
    },
    {
      type: 'value',
      name: dataJson.dimensions[3],
      axisLabel: {
        formatter: '{value} °C'
      }
    }
  ],
  dataset: { ...dataJson },
  series: [barSeriesItem, barSeriesItem, lineSeriesItem]
};

export default class Config extends PublicConfigClass {
  key = BarLineConfig.key;
  chartConfig = cloneDeep(BarLineConfig);
  // 图表配置项
  option = echartOptionProfixHandle(option, includes);
}
