TreeView.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. var zrUtil = require("zrender/lib/core/util");
  20. var graphic = require("../../util/graphic");
  21. var SymbolClz = require("../helper/Symbol");
  22. var _layoutHelper = require("./layoutHelper");
  23. var radialCoordinate = _layoutHelper.radialCoordinate;
  24. var echarts = require("../../echarts");
  25. var bbox = require("zrender/lib/core/bbox");
  26. var View = require("../../coord/View");
  27. var roamHelper = require("../../component/helper/roamHelper");
  28. var RoamController = require("../../component/helper/RoamController");
  29. var _cursorHelper = require("../../component/helper/cursorHelper");
  30. var onIrrelevantElement = _cursorHelper.onIrrelevantElement;
  31. var _config = require("../../config");
  32. var __DEV__ = _config.__DEV__;
  33. var _number = require("../../util/number");
  34. var parsePercent = _number.parsePercent;
  35. /*
  36. * Licensed to the Apache Software Foundation (ASF) under one
  37. * or more contributor license agreements. See the NOTICE file
  38. * distributed with this work for additional information
  39. * regarding copyright ownership. The ASF licenses this file
  40. * to you under the Apache License, Version 2.0 (the
  41. * "License"); you may not use this file except in compliance
  42. * with the License. You may obtain a copy of the License at
  43. *
  44. * http://www.apache.org/licenses/LICENSE-2.0
  45. *
  46. * Unless required by applicable law or agreed to in writing,
  47. * software distributed under the License is distributed on an
  48. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49. * KIND, either express or implied. See the License for the
  50. * specific language governing permissions and limitations
  51. * under the License.
  52. */
  53. var TreeShape = graphic.extendShape({
  54. shape: {
  55. parentPoint: [],
  56. childPoints: [],
  57. orient: '',
  58. forkPosition: ''
  59. },
  60. style: {
  61. stroke: '#000',
  62. fill: null
  63. },
  64. buildPath: function (ctx, shape) {
  65. var childPoints = shape.childPoints;
  66. var childLen = childPoints.length;
  67. var parentPoint = shape.parentPoint;
  68. var firstChildPos = childPoints[0];
  69. var lastChildPos = childPoints[childLen - 1];
  70. if (childLen === 1) {
  71. ctx.moveTo(parentPoint[0], parentPoint[1]);
  72. ctx.lineTo(firstChildPos[0], firstChildPos[1]);
  73. return;
  74. }
  75. var orient = shape.orient;
  76. var forkDim = orient === 'TB' || orient === 'BT' ? 0 : 1;
  77. var otherDim = 1 - forkDim;
  78. var forkPosition = parsePercent(shape.forkPosition, 1);
  79. var tmpPoint = [];
  80. tmpPoint[forkDim] = parentPoint[forkDim];
  81. tmpPoint[otherDim] = parentPoint[otherDim] + (lastChildPos[otherDim] - parentPoint[otherDim]) * forkPosition;
  82. ctx.moveTo(parentPoint[0], parentPoint[1]);
  83. ctx.lineTo(tmpPoint[0], tmpPoint[1]);
  84. ctx.moveTo(firstChildPos[0], firstChildPos[1]);
  85. tmpPoint[forkDim] = firstChildPos[forkDim];
  86. ctx.lineTo(tmpPoint[0], tmpPoint[1]);
  87. tmpPoint[forkDim] = lastChildPos[forkDim];
  88. ctx.lineTo(tmpPoint[0], tmpPoint[1]);
  89. ctx.lineTo(lastChildPos[0], lastChildPos[1]);
  90. for (var i = 1; i < childLen - 1; i++) {
  91. var point = childPoints[i];
  92. ctx.moveTo(point[0], point[1]);
  93. tmpPoint[forkDim] = point[forkDim];
  94. ctx.lineTo(tmpPoint[0], tmpPoint[1]);
  95. }
  96. }
  97. });
  98. var _default = echarts.extendChartView({
  99. type: 'tree',
  100. /**
  101. * Init the chart
  102. * @override
  103. * @param {module:echarts/model/Global} ecModel
  104. * @param {module:echarts/ExtensionAPI} api
  105. */
  106. init: function (ecModel, api) {
  107. /**
  108. * @private
  109. * @type {module:echarts/data/Tree}
  110. */
  111. this._oldTree;
  112. /**
  113. * @private
  114. * @type {module:zrender/container/Group}
  115. */
  116. this._mainGroup = new graphic.Group();
  117. /**
  118. * @private
  119. * @type {module:echarts/componet/helper/RoamController}
  120. */
  121. this._controller = new RoamController(api.getZr());
  122. this._controllerHost = {
  123. target: this.group
  124. };
  125. this.group.add(this._mainGroup);
  126. },
  127. render: function (seriesModel, ecModel, api, payload) {
  128. var data = seriesModel.getData();
  129. var layoutInfo = seriesModel.layoutInfo;
  130. var group = this._mainGroup;
  131. var layout = seriesModel.get('layout');
  132. if (layout === 'radial') {
  133. group.attr('position', [layoutInfo.x + layoutInfo.width / 2, layoutInfo.y + layoutInfo.height / 2]);
  134. } else {
  135. group.attr('position', [layoutInfo.x, layoutInfo.y]);
  136. }
  137. this._updateViewCoordSys(seriesModel, layoutInfo, layout);
  138. this._updateController(seriesModel, ecModel, api);
  139. var oldData = this._data;
  140. var seriesScope = {
  141. expandAndCollapse: seriesModel.get('expandAndCollapse'),
  142. layout: layout,
  143. edgeShape: seriesModel.get('edgeShape'),
  144. edgeForkPosition: seriesModel.get('edgeForkPosition'),
  145. orient: seriesModel.getOrient(),
  146. curvature: seriesModel.get('lineStyle.curveness'),
  147. symbolRotate: seriesModel.get('symbolRotate'),
  148. symbolOffset: seriesModel.get('symbolOffset'),
  149. hoverAnimation: seriesModel.get('hoverAnimation'),
  150. useNameLabel: true,
  151. fadeIn: true
  152. };
  153. data.diff(oldData).add(function (newIdx) {
  154. if (symbolNeedsDraw(data, newIdx)) {
  155. // Create node and edge
  156. updateNode(data, newIdx, null, group, seriesModel, seriesScope);
  157. }
  158. }).update(function (newIdx, oldIdx) {
  159. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  160. if (!symbolNeedsDraw(data, newIdx)) {
  161. symbolEl && removeNode(oldData, oldIdx, symbolEl, group, seriesModel, seriesScope);
  162. return;
  163. } // Update node and edge
  164. updateNode(data, newIdx, symbolEl, group, seriesModel, seriesScope);
  165. }).remove(function (oldIdx) {
  166. var symbolEl = oldData.getItemGraphicEl(oldIdx); // When remove a collapsed node of subtree, since the collapsed
  167. // node haven't been initialized with a symbol element,
  168. // you can't found it's symbol element through index.
  169. // so if we want to remove the symbol element we should insure
  170. // that the symbol element is not null.
  171. if (symbolEl) {
  172. removeNode(oldData, oldIdx, symbolEl, group, seriesModel, seriesScope);
  173. }
  174. }).execute();
  175. this._nodeScaleRatio = seriesModel.get('nodeScaleRatio');
  176. this._updateNodeAndLinkScale(seriesModel);
  177. if (seriesScope.expandAndCollapse === true) {
  178. data.eachItemGraphicEl(function (el, dataIndex) {
  179. el.off('click').on('click', function () {
  180. api.dispatchAction({
  181. type: 'treeExpandAndCollapse',
  182. seriesId: seriesModel.id,
  183. dataIndex: dataIndex
  184. });
  185. });
  186. });
  187. }
  188. this._data = data;
  189. },
  190. _updateViewCoordSys: function (seriesModel) {
  191. var data = seriesModel.getData();
  192. var points = [];
  193. data.each(function (idx) {
  194. var layout = data.getItemLayout(idx);
  195. if (layout && !isNaN(layout.x) && !isNaN(layout.y)) {
  196. points.push([+layout.x, +layout.y]);
  197. }
  198. });
  199. var min = [];
  200. var max = [];
  201. bbox.fromPoints(points, min, max); // If don't Store min max when collapse the root node after roam,
  202. // the root node will disappear.
  203. var oldMin = this._min;
  204. var oldMax = this._max; // If width or height is 0
  205. if (max[0] - min[0] === 0) {
  206. min[0] = oldMin ? oldMin[0] : min[0] - 1;
  207. max[0] = oldMax ? oldMax[0] : max[0] + 1;
  208. }
  209. if (max[1] - min[1] === 0) {
  210. min[1] = oldMin ? oldMin[1] : min[1] - 1;
  211. max[1] = oldMax ? oldMax[1] : max[1] + 1;
  212. }
  213. var viewCoordSys = seriesModel.coordinateSystem = new View();
  214. viewCoordSys.zoomLimit = seriesModel.get('scaleLimit');
  215. viewCoordSys.setBoundingRect(min[0], min[1], max[0] - min[0], max[1] - min[1]);
  216. viewCoordSys.setCenter(seriesModel.get('center'));
  217. viewCoordSys.setZoom(seriesModel.get('zoom')); // Here we use viewCoordSys just for computing the 'position' and 'scale' of the group
  218. this.group.attr({
  219. position: viewCoordSys.position,
  220. scale: viewCoordSys.scale
  221. });
  222. this._viewCoordSys = viewCoordSys;
  223. this._min = min;
  224. this._max = max;
  225. },
  226. _updateController: function (seriesModel, ecModel, api) {
  227. var controller = this._controller;
  228. var controllerHost = this._controllerHost;
  229. var group = this.group;
  230. controller.setPointerChecker(function (e, x, y) {
  231. var rect = group.getBoundingRect();
  232. rect.applyTransform(group.transform);
  233. return rect.contain(x, y) && !onIrrelevantElement(e, api, seriesModel);
  234. });
  235. controller.enable(seriesModel.get('roam'));
  236. controllerHost.zoomLimit = seriesModel.get('scaleLimit');
  237. controllerHost.zoom = seriesModel.coordinateSystem.getZoom();
  238. controller.off('pan').off('zoom').on('pan', function (e) {
  239. roamHelper.updateViewOnPan(controllerHost, e.dx, e.dy);
  240. api.dispatchAction({
  241. seriesId: seriesModel.id,
  242. type: 'treeRoam',
  243. dx: e.dx,
  244. dy: e.dy
  245. });
  246. }, this).on('zoom', function (e) {
  247. roamHelper.updateViewOnZoom(controllerHost, e.scale, e.originX, e.originY);
  248. api.dispatchAction({
  249. seriesId: seriesModel.id,
  250. type: 'treeRoam',
  251. zoom: e.scale,
  252. originX: e.originX,
  253. originY: e.originY
  254. });
  255. this._updateNodeAndLinkScale(seriesModel);
  256. }, this);
  257. },
  258. _updateNodeAndLinkScale: function (seriesModel) {
  259. var data = seriesModel.getData();
  260. var nodeScale = this._getNodeGlobalScale(seriesModel);
  261. var invScale = [nodeScale, nodeScale];
  262. data.eachItemGraphicEl(function (el, idx) {
  263. el.attr('scale', invScale);
  264. });
  265. },
  266. _getNodeGlobalScale: function (seriesModel) {
  267. var coordSys = seriesModel.coordinateSystem;
  268. if (coordSys.type !== 'view') {
  269. return 1;
  270. }
  271. var nodeScaleRatio = this._nodeScaleRatio;
  272. var groupScale = coordSys.scale;
  273. var groupZoom = groupScale && groupScale[0] || 1; // Scale node when zoom changes
  274. var roamZoom = coordSys.getZoom();
  275. var nodeScale = (roamZoom - 1) * nodeScaleRatio + 1;
  276. return nodeScale / groupZoom;
  277. },
  278. dispose: function () {
  279. this._controller && this._controller.dispose();
  280. this._controllerHost = {};
  281. },
  282. remove: function () {
  283. this._mainGroup.removeAll();
  284. this._data = null;
  285. }
  286. });
  287. function symbolNeedsDraw(data, dataIndex) {
  288. var layout = data.getItemLayout(dataIndex);
  289. return layout && !isNaN(layout.x) && !isNaN(layout.y) && data.getItemVisual(dataIndex, 'symbol') !== 'none';
  290. }
  291. function getTreeNodeStyle(node, itemModel, seriesScope) {
  292. seriesScope.itemModel = itemModel;
  293. seriesScope.itemStyle = itemModel.getModel('itemStyle').getItemStyle();
  294. seriesScope.hoverItemStyle = itemModel.getModel('emphasis.itemStyle').getItemStyle();
  295. seriesScope.lineStyle = itemModel.getModel('lineStyle').getLineStyle();
  296. seriesScope.labelModel = itemModel.getModel('label');
  297. seriesScope.hoverLabelModel = itemModel.getModel('emphasis.label');
  298. if (node.isExpand === false && node.children.length !== 0) {
  299. seriesScope.symbolInnerColor = seriesScope.itemStyle.fill;
  300. } else {
  301. seriesScope.symbolInnerColor = '#fff';
  302. }
  303. return seriesScope;
  304. }
  305. function updateNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope) {
  306. var isInit = !symbolEl;
  307. var node = data.tree.getNodeByDataIndex(dataIndex);
  308. var itemModel = node.getModel();
  309. var seriesScope = getTreeNodeStyle(node, itemModel, seriesScope);
  310. var virtualRoot = data.tree.root;
  311. var source = node.parentNode === virtualRoot ? node : node.parentNode || node;
  312. var sourceSymbolEl = data.getItemGraphicEl(source.dataIndex);
  313. var sourceLayout = source.getLayout();
  314. var sourceOldLayout = sourceSymbolEl ? {
  315. x: sourceSymbolEl.position[0],
  316. y: sourceSymbolEl.position[1],
  317. rawX: sourceSymbolEl.__radialOldRawX,
  318. rawY: sourceSymbolEl.__radialOldRawY
  319. } : sourceLayout;
  320. var targetLayout = node.getLayout();
  321. if (isInit) {
  322. symbolEl = new SymbolClz(data, dataIndex, seriesScope);
  323. symbolEl.attr('position', [sourceOldLayout.x, sourceOldLayout.y]);
  324. } else {
  325. symbolEl.updateData(data, dataIndex, seriesScope);
  326. }
  327. symbolEl.__radialOldRawX = symbolEl.__radialRawX;
  328. symbolEl.__radialOldRawY = symbolEl.__radialRawY;
  329. symbolEl.__radialRawX = targetLayout.rawX;
  330. symbolEl.__radialRawY = targetLayout.rawY;
  331. group.add(symbolEl);
  332. data.setItemGraphicEl(dataIndex, symbolEl);
  333. graphic.updateProps(symbolEl, {
  334. position: [targetLayout.x, targetLayout.y]
  335. }, seriesModel);
  336. var symbolPath = symbolEl.getSymbolPath();
  337. if (seriesScope.layout === 'radial') {
  338. var realRoot = virtualRoot.children[0];
  339. var rootLayout = realRoot.getLayout();
  340. var length = realRoot.children.length;
  341. var rad;
  342. var isLeft;
  343. if (targetLayout.x === rootLayout.x && node.isExpand === true) {
  344. var center = {};
  345. center.x = (realRoot.children[0].getLayout().x + realRoot.children[length - 1].getLayout().x) / 2;
  346. center.y = (realRoot.children[0].getLayout().y + realRoot.children[length - 1].getLayout().y) / 2;
  347. rad = Math.atan2(center.y - rootLayout.y, center.x - rootLayout.x);
  348. if (rad < 0) {
  349. rad = Math.PI * 2 + rad;
  350. }
  351. isLeft = center.x < rootLayout.x;
  352. if (isLeft) {
  353. rad = rad - Math.PI;
  354. }
  355. } else {
  356. rad = Math.atan2(targetLayout.y - rootLayout.y, targetLayout.x - rootLayout.x);
  357. if (rad < 0) {
  358. rad = Math.PI * 2 + rad;
  359. }
  360. if (node.children.length === 0 || node.children.length !== 0 && node.isExpand === false) {
  361. isLeft = targetLayout.x < rootLayout.x;
  362. if (isLeft) {
  363. rad = rad - Math.PI;
  364. }
  365. } else {
  366. isLeft = targetLayout.x > rootLayout.x;
  367. if (!isLeft) {
  368. rad = rad - Math.PI;
  369. }
  370. }
  371. }
  372. var textPosition = isLeft ? 'left' : 'right';
  373. var rotate = seriesScope.labelModel.get('rotate');
  374. var labelRotateRadian = rotate * (Math.PI / 180);
  375. symbolPath.setStyle({
  376. textPosition: seriesScope.labelModel.get('position') || textPosition,
  377. textRotation: rotate == null ? -rad : labelRotateRadian,
  378. textOrigin: 'center',
  379. verticalAlign: 'middle'
  380. });
  381. }
  382. drawEdge(seriesModel, node, virtualRoot, symbolEl, sourceOldLayout, sourceLayout, targetLayout, group, seriesScope);
  383. }
  384. function drawEdge(seriesModel, node, virtualRoot, symbolEl, sourceOldLayout, sourceLayout, targetLayout, group, seriesScope) {
  385. var edgeShape = seriesScope.edgeShape;
  386. var edge = symbolEl.__edge;
  387. if (edgeShape === 'curve') {
  388. if (node.parentNode && node.parentNode !== virtualRoot) {
  389. if (!edge) {
  390. edge = symbolEl.__edge = new graphic.BezierCurve({
  391. shape: getEdgeShape(seriesScope, sourceOldLayout, sourceOldLayout),
  392. style: zrUtil.defaults({
  393. opacity: 0,
  394. strokeNoScale: true
  395. }, seriesScope.lineStyle)
  396. });
  397. }
  398. graphic.updateProps(edge, {
  399. shape: getEdgeShape(seriesScope, sourceLayout, targetLayout),
  400. style: zrUtil.defaults({
  401. opacity: 1
  402. }, seriesScope.lineStyle)
  403. }, seriesModel);
  404. }
  405. } else if (edgeShape === 'polyline') {
  406. if (seriesScope.layout === 'orthogonal') {
  407. if (node !== virtualRoot && node.children && node.children.length !== 0 && node.isExpand === true) {
  408. var children = node.children;
  409. var childPoints = [];
  410. for (var i = 0; i < children.length; i++) {
  411. var childLayout = children[i].getLayout();
  412. childPoints.push([childLayout.x, childLayout.y]);
  413. }
  414. if (!edge) {
  415. edge = symbolEl.__edge = new TreeShape({
  416. shape: {
  417. parentPoint: [targetLayout.x, targetLayout.y],
  418. childPoints: [[targetLayout.x, targetLayout.y]],
  419. orient: seriesScope.orient,
  420. forkPosition: seriesScope.edgeForkPosition
  421. },
  422. style: zrUtil.defaults({
  423. opacity: 0,
  424. strokeNoScale: true
  425. }, seriesScope.lineStyle)
  426. });
  427. }
  428. graphic.updateProps(edge, {
  429. shape: {
  430. parentPoint: [targetLayout.x, targetLayout.y],
  431. childPoints: childPoints
  432. },
  433. style: zrUtil.defaults({
  434. opacity: 1
  435. }, seriesScope.lineStyle)
  436. }, seriesModel);
  437. }
  438. } else {}
  439. }
  440. group.add(edge);
  441. }
  442. function removeNode(data, dataIndex, symbolEl, group, seriesModel, seriesScope) {
  443. var node = data.tree.getNodeByDataIndex(dataIndex);
  444. var virtualRoot = data.tree.root;
  445. var itemModel = node.getModel();
  446. var seriesScope = getTreeNodeStyle(node, itemModel, seriesScope);
  447. var source = node.parentNode === virtualRoot ? node : node.parentNode || node;
  448. var edgeShape = seriesScope.edgeShape;
  449. var sourceLayout;
  450. while (sourceLayout = source.getLayout(), sourceLayout == null) {
  451. source = source.parentNode === virtualRoot ? source : source.parentNode || source;
  452. }
  453. graphic.updateProps(symbolEl, {
  454. position: [sourceLayout.x + 1, sourceLayout.y + 1]
  455. }, seriesModel, function () {
  456. group.remove(symbolEl);
  457. data.setItemGraphicEl(dataIndex, null);
  458. });
  459. symbolEl.fadeOut(null, {
  460. keepLabel: true
  461. });
  462. var sourceSymbolEl = data.getItemGraphicEl(source.dataIndex);
  463. var sourceEdge = sourceSymbolEl.__edge; // 1. when expand the sub tree, delete the children node should delete the edge of
  464. // the source at the same time. because the polyline edge shape is only owned by the source.
  465. // 2.when the node is the only children of the source, delete the node should delete the edge of
  466. // the source at the same time. the same reason as above.
  467. var edge = symbolEl.__edge || (source.isExpand === false || source.children.length === 1 ? sourceEdge : undefined);
  468. var edgeShape = seriesScope.edgeShape;
  469. if (edge) {
  470. if (edgeShape === 'curve') {
  471. graphic.updateProps(edge, {
  472. shape: getEdgeShape(seriesScope, sourceLayout, sourceLayout),
  473. style: {
  474. opacity: 0
  475. }
  476. }, seriesModel, function () {
  477. group.remove(edge);
  478. });
  479. } else if (edgeShape === 'polyline' && seriesScope.layout === 'orthogonal') {
  480. graphic.updateProps(edge, {
  481. shape: {
  482. parentPoint: [sourceLayout.x, sourceLayout.y],
  483. childPoints: [[sourceLayout.x, sourceLayout.y]]
  484. },
  485. style: {
  486. opacity: 0
  487. }
  488. }, seriesModel, function () {
  489. group.remove(edge);
  490. });
  491. }
  492. }
  493. }
  494. function getEdgeShape(seriesScope, sourceLayout, targetLayout) {
  495. var cpx1;
  496. var cpy1;
  497. var cpx2;
  498. var cpy2;
  499. var orient = seriesScope.orient;
  500. var x1;
  501. var x2;
  502. var y1;
  503. var y2;
  504. if (seriesScope.layout === 'radial') {
  505. x1 = sourceLayout.rawX;
  506. y1 = sourceLayout.rawY;
  507. x2 = targetLayout.rawX;
  508. y2 = targetLayout.rawY;
  509. var radialCoor1 = radialCoordinate(x1, y1);
  510. var radialCoor2 = radialCoordinate(x1, y1 + (y2 - y1) * seriesScope.curvature);
  511. var radialCoor3 = radialCoordinate(x2, y2 + (y1 - y2) * seriesScope.curvature);
  512. var radialCoor4 = radialCoordinate(x2, y2);
  513. return {
  514. x1: radialCoor1.x,
  515. y1: radialCoor1.y,
  516. x2: radialCoor4.x,
  517. y2: radialCoor4.y,
  518. cpx1: radialCoor2.x,
  519. cpy1: radialCoor2.y,
  520. cpx2: radialCoor3.x,
  521. cpy2: radialCoor3.y
  522. };
  523. } else {
  524. x1 = sourceLayout.x;
  525. y1 = sourceLayout.y;
  526. x2 = targetLayout.x;
  527. y2 = targetLayout.y;
  528. if (orient === 'LR' || orient === 'RL') {
  529. cpx1 = x1 + (x2 - x1) * seriesScope.curvature;
  530. cpy1 = y1;
  531. cpx2 = x2 + (x1 - x2) * seriesScope.curvature;
  532. cpy2 = y2;
  533. }
  534. if (orient === 'TB' || orient === 'BT') {
  535. cpx1 = x1;
  536. cpy1 = y1 + (y2 - y1) * seriesScope.curvature;
  537. cpx2 = x2;
  538. cpy2 = y2 + (y1 - y2) * seriesScope.curvature;
  539. }
  540. }
  541. return {
  542. x1: x1,
  543. y1: y1,
  544. x2: x2,
  545. y2: y2,
  546. cpx1: cpx1,
  547. cpy1: cpy1,
  548. cpx2: cpx2,
  549. cpy2: cpy2
  550. };
  551. }
  552. module.exports = _default;