Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

72 linhas
2.8 KiB

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