config.ts 1.21 KB
import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
import { OverrideBarCommonConfig } from './index'
import { CreateComponentType } from '@/packages/index.d'
import cloneDeep from 'lodash/cloneDeep'
import dataJson from './data.json'

export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
// 其它配置项比如新增(动画)
const otherConfig = {
  // 轮播动画
  isCarousel: false
}
export const seriesItem = {
  type: 'bar',
  barWidth: 15,
  label: {
    show: true,
    position: 'top',
    color: '#fff',
    fontSize: 12
  },
  itemStyle: {
    color: null,
    borderRadius: 2
  }
}
export const option = {
  ...otherConfig,
  tooltip: {
    show: true,
    trigger: 'axis',
    axisPointer: {
      show: true,
      type: 'shadow'
    }
  },
  xAxis: {
    show: true,
    type: 'category'
  },
  yAxis: {
    show: true,
    type: 'value'
  },
  dataset: { ...dataJson },
  series: [seriesItem, seriesItem]
}

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