You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

85 lines
3.1 KiB

  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Copyright (c) 2016 - 2017 Uber Technologies, Inc.
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining a copy
  8. // of this software and associated documentation files (the "Software"), to deal
  9. // in the Software without restriction, including without limitation the rights
  10. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. // copies of the Software, and to permit persons to whom the Software is
  12. // furnished to do so, subject to the following conditions:
  13. //
  14. // The above copyright notice and this permission notice shall be included in
  15. // all copies or substantial portions of the Software.
  16. //
  17. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. // THE SOFTWARE.
  24. var _react = require('react');
  25. var _react2 = _interopRequireDefault(_react);
  26. var _theme = require('../theme');
  27. var _animation = require('../animation');
  28. var _animation2 = _interopRequireDefault(_animation);
  29. var _seriesUtils = require('../utils/series-utils');
  30. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  31. var DEFAULT_LINK_COLOR = _theme.DISCRETE_COLOR_RANGE[1];
  32. var DEFAULT_LINK_OPACITY = 0.7;
  33. function SankeyLink(props) {
  34. var animation = props.animation,
  35. data = props.data,
  36. node = props.node,
  37. opacity = props.opacity,
  38. color = props.color,
  39. strokeWidth = props.strokeWidth,
  40. style = props.style,
  41. onLinkClick = props.onLinkClick,
  42. onLinkMouseOver = props.onLinkMouseOver,
  43. onLinkMouseOut = props.onLinkMouseOut;
  44. if (animation) {
  45. return _react2.default.createElement(
  46. _animation2.default,
  47. _extends({}, props, { animatedProps: _seriesUtils.ANIMATED_SERIES_PROPS }),
  48. _react2.default.createElement(SankeyLink, _extends({}, props, { animation: null }))
  49. );
  50. }
  51. return _react2.default.createElement('path', _extends({
  52. d: data
  53. }, style, {
  54. className: 'rv-sankey__link',
  55. opacity: Number.isFinite(opacity) ? opacity : DEFAULT_LINK_OPACITY,
  56. stroke: color || DEFAULT_LINK_COLOR,
  57. onClick: function onClick(e) {
  58. return onLinkClick(node, e);
  59. },
  60. onMouseOver: function onMouseOver(e) {
  61. return onLinkMouseOver(node, e);
  62. },
  63. onMouseOut: function onMouseOut(e) {
  64. return onLinkMouseOut(node, e);
  65. },
  66. strokeWidth: strokeWidth,
  67. fill: 'none'
  68. }));
  69. }
  70. SankeyLink.displayName = 'SankeyLink';
  71. SankeyLink.requiresSVG = true;
  72. exports.default = SankeyLink;