constant.js 1.7 KB

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