Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 _treemapLeaf = require('./treemap-leaf');
  27. var _treemapLeaf2 = _interopRequireDefault(_treemapLeaf);
  28. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29. function TreemapDOM(props) {
  30. var animation = props.animation,
  31. className = props.className,
  32. height = props.height,
  33. hideRootNode = props.hideRootNode,
  34. getLabel = props.getLabel,
  35. mode = props.mode,
  36. nodes = props.nodes,
  37. width = props.width,
  38. scales = props.scales,
  39. style = props.style;
  40. var useCirclePacking = mode === 'circlePack';
  41. return _react2.default.createElement(
  42. 'div',
  43. {
  44. className: 'rv-treemap ' + (useCirclePacking ? 'rv-treemap-circle-packed' : '') + ' ' + className,
  45. style: { height: height, width: width }
  46. },
  47. nodes.map(function (node, index) {
  48. // throw out the rootest node
  49. if (hideRootNode && !index) {
  50. return null;
  51. }
  52. var nodeProps = _extends({
  53. animation: animation,
  54. node: node,
  55. getLabel: getLabel
  56. }, props, {
  57. x0: useCirclePacking ? node.x : node.x0,
  58. x1: useCirclePacking ? node.x : node.x1,
  59. y0: useCirclePacking ? node.y : node.y0,
  60. y1: useCirclePacking ? node.y : node.y1,
  61. r: useCirclePacking ? node.r : 1,
  62. scales: scales,
  63. style: style
  64. });
  65. return _react2.default.createElement(_treemapLeaf2.default, _extends({}, nodeProps, { key: 'leaf-' + index }));
  66. })
  67. );
  68. }
  69. TreemapDOM.displayName = 'TreemapDOM';
  70. exports.default = TreemapDOM;