config.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
  2. import { LineLinearSingleConfig } from './index'
  3. import { CreateComponentType } from '@/packages/index.d'
  4. import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
  5. import cloneDeep from 'lodash/cloneDeep'
  6. import dataJson from './data.json'
  7. export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
  8. export const option = {
  9. tooltip: {
  10. show: true,
  11. trigger: 'axis',
  12. axisPointer: {
  13. type: 'line'
  14. }
  15. },
  16. xAxis: {
  17. show: true,
  18. type: 'category'
  19. },
  20. yAxis: {
  21. show: true,
  22. type: 'value'
  23. },
  24. dataset: { ...dataJson },
  25. series: [
  26. {
  27. type: 'line',
  28. symbolSize: 5, //设定实心点的大小
  29. lineStyle: {
  30. type: 'solid',
  31. width: 3,
  32. color: {
  33. type: 'linear',
  34. colorStops: [
  35. {
  36. offset: 0,
  37. color: chartColorsSearch[defaultTheme][0] // 0% 处的颜色
  38. },
  39. {
  40. offset: 1,
  41. color: chartColorsSearch[defaultTheme][1] // 100% 处的颜色
  42. }
  43. ],
  44. globalCoord: false // 缺省为 false
  45. },
  46. shadowColor: chartColorsSearch[defaultTheme][2],
  47. shadowBlur: 10,
  48. shadowOffsetY: 20
  49. }
  50. }
  51. ]
  52. }
  53. export default class Config extends PublicConfigClass implements CreateComponentType {
  54. public key: string = LineLinearSingleConfig.key
  55. public chartConfig = cloneDeep(LineLinearSingleConfig)
  56. // 图表配置项
  57. public option = echartOptionProfixHandle(option, includes)
  58. }