config.ts 1.36 KB
import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
import { AddLinePlotConfig } 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']
export const seriesItem = {
  type: 'line',
  showSymbol: false,
  clip: true,
  data: dataJson
}

export const option = {
  animation: false,
  grid: {
    top: 40,
    left: 50,
    right: 40,
    bottom: 50
  },
  xAxis: {
    name: 'x',
    minorTick: {
      show: true
    },
    minorSplitLine: {
      show: true
    }
  },
  yAxis: {
    name: 'y',
    minorTick: {
      show: true
    },
    minorSplitLine: {
      show: true
    }
  },
  dataZoom: [
    {
      show: true,
      type: 'inside',
      filterMode: 'none',
      xAxisIndex: [0],
      startValue: -20,
      endValue: 20
    },
    {
      show: true,
      type: 'inside',
      filterMode: 'none',
      yAxisIndex: [0],
      startValue: -20,
      endValue: 20
    }
  ],
  dataset:dataJson,
  series: [seriesItem]
}

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