基础桑基图.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * @description: 桑基图
  3. * @Date: 2024-0625
  4. * @Author: liu.shiyi
  5. */
  6. // 配置版本号
  7. const version = '2023111501'
  8. // 分类
  9. const category = 'Sankey'
  10. // 标题
  11. const title = '基础桑基图'
  12. // 类别, new Line()
  13. const chartType = 'Sankey'
  14. // 用于标识,唯一,和文件夹名称一致
  15. const name = 'JICHUSANGJITU'
  16. // 右侧配置项
  17. const setting = [
  18. {
  19. label: '起始节点',
  20. type: 'select', // 设置组件类型
  21. field: 'sourceField', // 字段
  22. optionField: 'sourceField', // 对应options中的字段
  23. // 是否多选
  24. multiple: false,
  25. value: '',
  26. tabName: 'data'
  27. },
  28. {
  29. label: '目标节点',
  30. type: 'select', // 设置组件类型
  31. field: 'targetField', // 字段
  32. optionField: 'targetField', // 对应options中的字段
  33. // 是否多选
  34. multiple: false,
  35. value: '',
  36. tabName: 'data'
  37. },
  38. {
  39. label: '权重',
  40. type: 'select', // 设置组件类型
  41. field: 'weightField', // 字段
  42. optionField: 'weightField', // 对应options中的字段
  43. // 是否多选
  44. multiple: false,
  45. value: '',
  46. tabName: 'data'
  47. },
  48. /** 样式配置 **/
  49. // 图表 graph
  50. {
  51. label: '背景颜色',
  52. // 设置组件类型
  53. type: 'colorSelect',
  54. // 字段
  55. field: 'color',
  56. // 对应options中的字段
  57. optionField: 'color',
  58. value: ['#6b74e4', '#4391f4', '#38bbe5', '#69d6fd', '#36c6a0'],
  59. tabName: 'custom',
  60. groupName: 'graph'
  61. },
  62. {
  63. label: '节点背景颜色',
  64. type: 'colorPicker',
  65. field: 'nodeStyle_fill',
  66. optionField: 'nodeStyle.fill',
  67. value: '#E5E6EB10',
  68. tabName: 'custom',
  69. groupName: 'graph'
  70. },
  71. {
  72. label: '节点边框颜色',
  73. type: 'colorPicker',
  74. field: 'nodeStyle_stroke',
  75. optionField: 'nodeStyle.stroke',
  76. value: '#E5E6EB10',
  77. tabName: 'custom',
  78. groupName: 'graph'
  79. }
  80. // X轴 xAxis
  81. ]
  82. // 模拟数据
  83. const data = [
  84. { source: '首次打开', target: '首页 UV', value: 160 },
  85. { source: '结果页', target: '首页 UV', value: 40 },
  86. { source: '验证页', target: '首页 UV', value: 10 },
  87. { source: '我的', target: '首页 UV', value: 10 },
  88. { source: '朋友', target: '首页 UV', value: 8 },
  89. { source: '其他来源', target: '首页 UV', value: 27 },
  90. { source: '首页 UV', target: '理财', value: 30 },
  91. { source: '首页 UV', target: '扫一扫', value: 40 },
  92. { source: '首页 UV', target: '服务', value: 35 },
  93. { source: '首页 UV', target: '蚂蚁森林', value: 25 },
  94. { source: '首页 UV', target: '跳失', value: 10 },
  95. { source: '首页 UV', target: '借呗', value: 30 },
  96. { source: '首页 UV', target: '花呗', value: 40 },
  97. { source: '首页 UV', target: '其他流向', value: 45 }
  98. ]
  99. // 配置处理脚本
  100. const optionHandler = ''
  101. // 数据处理脚本
  102. const dataHandler = ''
  103. // 图表配置 new Line('domName', option)
  104. const option = {
  105. // 数据将要放入到哪个字段中
  106. dataKey: 'data',
  107. // 图表内边距
  108. appendPadding: [0, 0, 0, 0],
  109. data,
  110. sourceField: 'source',
  111. targetField: 'target',
  112. weightField: 'value',
  113. nodeWidthRatio: 0.008,
  114. nodePaddingRatio: 0.03,
  115. color: ['#6b74e4', '#4391f4', '#38bbe5', '#69d6fd', '#36c6a0'],
  116. nodeStyle: {
  117. fill: '#72CC4A', // 设置节点颜色
  118. stroke: '#72CC4A'
  119. },
  120. // edgeStyle: {
  121. // fill: '#E6E6E6', // 设置边颜色
  122. // stroke: '#E6E6E6',
  123. // fillOpacity: 0.6
  124. // }
  125. }
  126. export default {
  127. category,
  128. version,
  129. title,
  130. chartType,
  131. name,
  132. option,
  133. setting,
  134. dataHandler,
  135. optionHandler
  136. }