config.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { echartOptionProfixHandle, publicConfig } 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 dataJson from './data.json'
  7. export const includes = ['legend', 'xAxis', 'yAxis']
  8. const option = {
  9. legend: {
  10. show: true
  11. },
  12. tooltip: {
  13. show: true,
  14. trigger: 'axis',
  15. axisPointer: {
  16. type: 'line'
  17. }
  18. },
  19. xAxis: {
  20. show: true,
  21. type: 'category',
  22. data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  23. },
  24. yAxis: {
  25. show: true,
  26. type: 'value'
  27. },
  28. dataset: { ...dataJson },
  29. series: [
  30. {
  31. type: 'line',
  32. smooth: false,
  33. lineStyle: {
  34. normal: {
  35. width: 3
  36. }
  37. },
  38. areaStyle: {
  39. opacity: 0.8,
  40. color: new graphic.LinearGradient(0, 0, 0, 1, [
  41. {
  42. offset: 0,
  43. color: chartColorsSearch[defaultTheme][3]
  44. },
  45. {
  46. offset: 1,
  47. color: 'rgba(0,0,0,0)'
  48. }
  49. ])
  50. },
  51. },
  52. {
  53. type: 'line',
  54. smooth: false,
  55. lineStyle: {
  56. normal: {
  57. width: 3
  58. }
  59. },
  60. areaStyle: {
  61. opacity: 0.8,
  62. color: new graphic.LinearGradient(0, 0, 0, 1, [
  63. {
  64. offset: 0,
  65. color: chartColorsSearch[defaultTheme][4]
  66. },
  67. {
  68. offset: 1,
  69. color: 'rgba(0,0,0,0)'
  70. }
  71. ])
  72. },
  73. }
  74. ]
  75. }
  76. export default class Config extends publicConfig
  77. implements CreateComponentType {
  78. public key: string = LineGradientsConfig.key
  79. public chartConfig = LineGradientsConfig
  80. // 图表配置项
  81. public option = echartOptionProfixHandle(option, includes)
  82. }