constant.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { get } from '@antv/util';
  2. export var X_FIELD = 'x';
  3. export var Y_FIELD = 'y';
  4. export var NODE_COLOR_FIELD = 'name';
  5. export var EDGE_COLOR_FIELD = 'source';
  6. export var DEFAULT_OPTIONS = {
  7. nodeStyle: {
  8. opacity: 1,
  9. fillOpacity: 1,
  10. lineWidth: 1,
  11. },
  12. edgeStyle: {
  13. opacity: 0.5,
  14. lineWidth: 2,
  15. },
  16. label: {
  17. fields: ['x', 'name'],
  18. callback: function (x, name) {
  19. var centerX = (x[0] + x[1]) / 2;
  20. var offsetX = centerX > 0.5 ? -4 : 4;
  21. return {
  22. offsetX: offsetX,
  23. content: name,
  24. };
  25. },
  26. labelEmit: true,
  27. style: {
  28. fill: '#8c8c8c',
  29. },
  30. },
  31. tooltip: {
  32. showTitle: false,
  33. showMarkers: false,
  34. fields: ['source', 'target', 'value', 'isNode'],
  35. // 内置:node 不显示 tooltip (业务层自行处理),edge 显示 tooltip
  36. showContent: function (items) {
  37. return !get(items, [0, 'data', 'isNode']);
  38. },
  39. formatter: function (datum) {
  40. var source = datum.source, target = datum.target, value = datum.value;
  41. return {
  42. name: "".concat(source, " -> ").concat(target),
  43. value: value,
  44. };
  45. },
  46. },
  47. interactions: [
  48. {
  49. type: 'element-active',
  50. },
  51. ],
  52. weight: true,
  53. nodePaddingRatio: 0.1,
  54. nodeWidthRatio: 0.05,
  55. };
  56. //# sourceMappingURL=constant.js.map