"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=histogram.js.map