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

3 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  6. var _react = require('react');
  7. var _react2 = _interopRequireDefault(_react);
  8. var _propTypes = require('prop-types');
  9. var _propTypes2 = _interopRequireDefault(_propTypes);
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  13. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Copyright (c) 2018 Uber Technologies, Inc.
  14. //
  15. // Permission is hereby granted, free of charge, to any person obtaining a copy
  16. // of this software and associated documentation files (the "Software"), to deal
  17. // in the Software without restriction, including without limitation the rights
  18. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19. // copies of the Software, and to permit persons to whom the Software is
  20. // furnished to do so, subject to the following conditions:
  21. //
  22. // The above copyright notice and this permission notice shall be included in
  23. // all copies or substantial portions of the Software.
  24. //
  25. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  27. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  28. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  29. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  30. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  31. // THE SOFTWARE.
  32. var ChartLabel = function (_React$PureComponent) {
  33. _inherits(ChartLabel, _React$PureComponent);
  34. function ChartLabel() {
  35. _classCallCheck(this, ChartLabel);
  36. return _possibleConstructorReturn(this, (ChartLabel.__proto__ || Object.getPrototypeOf(ChartLabel)).apply(this, arguments));
  37. }
  38. _createClass(ChartLabel, [{
  39. key: 'render',
  40. value: function render() {
  41. var _props = this.props,
  42. innerHeight = _props.innerHeight,
  43. innerWidth = _props.innerWidth,
  44. marginBottom = _props.marginBottom,
  45. marginLeft = _props.marginLeft,
  46. marginRight = _props.marginRight,
  47. marginTop = _props.marginTop,
  48. className = _props.className,
  49. includeMargin = _props.includeMargin,
  50. style = _props.style,
  51. text = _props.text,
  52. xPercent = _props.xPercent,
  53. yPercent = _props.yPercent;
  54. var width = innerWidth + (includeMargin ? marginLeft + marginRight : 0);
  55. var height = innerHeight + (includeMargin ? marginTop + marginBottom : 0);
  56. var xPos = width * xPercent + (includeMargin ? 0 : marginLeft);
  57. var yPos = height * yPercent + (includeMargin ? marginLeft : 0);
  58. return _react2.default.createElement(
  59. 'g',
  60. {
  61. transform: 'translate(' + xPos + ', ' + yPos + ')',
  62. className: 'rv-xy-plot__axis__title ' + className },
  63. _react2.default.createElement(
  64. 'text',
  65. style,
  66. text
  67. )
  68. );
  69. }
  70. }], [{
  71. key: 'requiresSVG',
  72. get: function get() {
  73. return true;
  74. }
  75. }]);
  76. return ChartLabel;
  77. }(_react2.default.PureComponent);
  78. ChartLabel.displayName = 'ChartLabel';
  79. ChartLabel.propTypes = {
  80. className: _propTypes2.default.string,
  81. includeMargin: _propTypes2.default.bool,
  82. style: _propTypes2.default.object,
  83. text: _propTypes2.default.string.isRequired,
  84. xPercent: _propTypes2.default.number.isRequired,
  85. yPercent: _propTypes2.default.number.isRequired
  86. };
  87. ChartLabel.defaultProps = {
  88. className: '',
  89. includeMargin: true,
  90. text: '',
  91. xPercent: 0,
  92. yPercent: 0,
  93. style: {}
  94. };
  95. exports.default = ChartLabel;