config.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { echartOptionProfixHandle, PublicConfigClass } from '@/packages/public'
  2. import { SScatterLogarithmicRegressionConfig } from './index'
  3. import { CreateComponentType } from '@/packages/index.d'
  4. import cloneDeep from 'lodash/cloneDeep'
  5. import dataJson from './data.json'
  6. export const includes = ['legend', 'xAxis', 'yAxis']
  7. export const option = {
  8. dataset: dataJson,
  9. tooltip: {
  10. showDelay: 0,
  11. formatter: (params: { value: string | any[]; seriesName: string; name: string }) => {
  12. // console.log(params)
  13. return params.value.length > 1
  14. ? `${params.seriesName}:<br />${params.value[0]} ${params.value[1]}`
  15. : `${params.seriesName}:<br />${params.name} ${params.value}`
  16. },
  17. axisPointer: {
  18. show: true,
  19. type: 'cross',
  20. lineStyle: {
  21. type: 'dashed',
  22. width: 1
  23. }
  24. }
  25. },
  26. legend: {
  27. data: dataJson
  28. .filter(i => i?.transform?.type === 'filter' && i?.transform?.config?.eq)
  29. .map(i => i.transform?.config?.eq?.toString())
  30. },
  31. xAxis: {
  32. show: true,
  33. type: 'value',
  34. splitLine: {
  35. lineStyle: {
  36. type: 'dashed'
  37. }
  38. }
  39. },
  40. yAxis: {
  41. show: true,
  42. type: 'value',
  43. splitLine: {
  44. lineStyle: {
  45. type: 'dashed'
  46. }
  47. }
  48. },
  49. visualMap: {
  50. show: false,
  51. dimension: 2,
  52. min: 20000,
  53. max: 1500000000,
  54. seriesIndex: [0, 1],
  55. inRange: {
  56. symbolSize: [10, 70]
  57. }
  58. },
  59. series: [
  60. {
  61. type: 'scatter',
  62. datasetIndex: 1
  63. },
  64. {
  65. type: 'scatter',
  66. datasetIndex: 2
  67. },
  68. {
  69. type: 'line',
  70. smooth: true,
  71. datasetIndex: 3,
  72. symbolSize: 0.1,
  73. symbol: 'circle',
  74. label: { show: true, fontSize: 16 },
  75. labelLayout: { dx: -20 },
  76. encode: { label: 2, tooltip: 1 }
  77. }
  78. ]
  79. }
  80. export default class Config extends PublicConfigClass implements CreateComponentType {
  81. public key = SScatterLogarithmicRegressionConfig.key
  82. public chartConfig = cloneDeep(SScatterLogarithmicRegressionConfig)
  83. // 图表配置项
  84. public option = echartOptionProfixHandle(option, includes)
  85. }