config.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
  2. import { LineGradientsConfig } from './index'
  3. import { CreateComponentType } from '@/packages/index.d'
  4. import { graphic } from 'echarts/core'
  5. import { defaultTheme, chartColorsSearch } from '@/settings/chartThemes/index'
  6. import cloneDeep from 'lodash/cloneDeep'
  7. import dataJson from './data.json'
  8. export const includes = ['legend', 'xAxis', 'yAxis', 'grid']
  9. const option = {
  10. tooltip: {
  11. show: true,
  12. trigger: 'axis',
  13. axisPointer: {
  14. type: 'line'
  15. }
  16. },
  17. xAxis: {
  18. show: true,
  19. type: 'category'
  20. },
  21. yAxis: {
  22. show: true,
  23. type: 'value'
  24. },
  25. dataset: { ...dataJson },
  26. series: [
  27. {
  28. type: 'line',
  29. smooth: false,
  30. symbolSize: 5, //设定实心点的大小
  31. label: {
  32. show: true,
  33. position: 'top',
  34. color: '#fff',
  35. fontSize: 12
  36. },
  37. lineStyle: {
  38. width: 3,
  39. type: 'solid'
  40. },
  41. areaStyle: {
  42. opacity: 0.8,
  43. color: new graphic.LinearGradient(0, 0, 0, 1, [
  44. {
  45. offset: 0,
  46. color: chartColorsSearch[defaultTheme][3]
  47. },
  48. {
  49. offset: 1,
  50. color: 'rgba(0,0,0,0)'
  51. }
  52. ])
  53. }
  54. },
  55. {
  56. type: 'line',
  57. smooth: false,
  58. label: {
  59. show: true,
  60. position: 'top',
  61. color: '#fff',
  62. fontSize: 12
  63. },
  64. lineStyle: {
  65. width: 3,
  66. type: 'solid'
  67. },
  68. areaStyle: {
  69. opacity: 0.8,
  70. color: new graphic.LinearGradient(0, 0, 0, 1, [
  71. {
  72. offset: 0,
  73. color: chartColorsSearch[defaultTheme][4]
  74. },
  75. {
  76. offset: 1,
  77. color: 'rgba(0,0,0,0)'
  78. }
  79. ])
  80. }
  81. }
  82. ]
  83. }
  84. export default class Config extends PublicConfigClass implements CreateComponentType {
  85. public key: string = LineGradientsConfig.key
  86. public chartConfig = cloneDeep(LineGradientsConfig)
  87. // 图表配置项
  88. public option = echartOptionProfixHandle(option, includes)
  89. }