"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.Histogram = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _plot = require("../../plot");

var _utils = require("../utils");

var _bars = _interopRequireDefault(require("./common/bars"));

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

var Histogram = /*#__PURE__*/function (_React$Component) {
  (0, _inherits2["default"])(Histogram, _React$Component);

  var _super = _createSuper(Histogram);

  function Histogram() {
    (0, _classCallCheck2["default"])(this, Histogram);
    return _super.apply(this, arguments);
  }

  (0, _createClass2["default"])(Histogram, [{
    key: "render",
    value: function render() {
      var props = this.props;
      var data = props.data,
          graphProps = props.graphProps;

      var _ref = graphProps || {},
          _ref$scale = _ref.scale,
          scale = _ref$scale === void 0 ? {} : _ref$scale,
          _ref$size = _ref.size,
          size = _ref$size === void 0 ? {} : _ref$size;

      var xBand = (0, _utils.dataToXBand)(scale.x, data, size.width, 'histogram');
      return /*#__PURE__*/_react["default"].createElement(_bars["default"], (0, _extends2["default"])({}, props, {
        xBand: xBand,
        histogram: true
      }));
    }
  }]);
  return Histogram;
}(_react["default"].Component);

exports.Histogram = Histogram;
(0, _defineProperty2["default"])(Histogram, "propTypes", {
  data: _propTypes["default"].array,
  onChange: _propTypes["default"].func,
  graphProps: _plot.types.GraphPropsType.isRequired
});

var _default = function _default() {
  return {
    type: 'histogram',
    Component: Histogram,
    name: 'Histogram'
  };
};

exports["default"] = _default;
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb2RlL2NoYXJ0aW5nL2JhcnMvaGlzdG9ncmFtLmpzIl0sIm5hbWVzIjpbIkhpc3RvZ3JhbSIsInByb3BzIiwiZGF0YSIsImdyYXBoUHJvcHMiLCJzY2FsZSIsInNpemUiLCJ4QmFuZCIsIngiLCJ3aWR0aCIsIlJlYWN0IiwiQ29tcG9uZW50IiwiUHJvcFR5cGVzIiwiYXJyYXkiLCJvbkNoYW5nZSIsImZ1bmMiLCJ0eXBlcyIsIkdyYXBoUHJvcHNUeXBlIiwiaXNSZXF1aXJlZCIsInR5cGUiLCJuYW1lIl0sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBOztBQUNBOztBQUNBOztBQUNBOztBQUNBOzs7Ozs7SUFFYUEsUzs7Ozs7Ozs7Ozs7O1dBT1gsa0JBQVM7QUFDUCxVQUFNQyxLQUFLLEdBQUcsS0FBS0EsS0FBbkI7QUFDQSxVQUFRQyxJQUFSLEdBQTZCRCxLQUE3QixDQUFRQyxJQUFSO0FBQUEsVUFBY0MsVUFBZCxHQUE2QkYsS0FBN0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