"use strict";

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

var _d3Array = require("d3-array");

var _d3Scale = require("d3-scale");

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

var ScaleFinder =
/*#__PURE__*/
function () {
  function ScaleFinder(data) {
    _classCallCheck(this, ScaleFinder);

    this.data = data;
  }

  _createClass(ScaleFinder, [{
    key: "getInterval",
    value: function getInterval() {
      var MAX = (0, _d3Array.max)(this.data, function (d) {
        return d;
      });
      var MIN = (0, _d3Array.min)(this.data, function (d) {
        return d;
      });
      var interval = [MIN, MAX];
      return interval;
    }
  }, {
    key: "getLinearScale",
    value: function getLinearScale() {
      var interval = this.getInterval();
      var scale = (0, _d3Scale.scaleLinear)().domain(interval);
      return scale;
    }
  }, {
    key: "getTimeScale",
    value: function getTimeScale() {
      var interval = this.getInterval();
      var scale = (0, _d3Scale.scaleTime)().domain(interval);
      return scale;
    }
  }, {
    key: "getOrdinalScale",
    value: function getOrdinalScale(binWidth) {
      var scale = (0, _d3Scale.scaleBand)().domain(this.data);
      scale.padding([binWidth]);
      return scale;
    }
  }]);

  return ScaleFinder;
}();

var _default = ScaleFinder;
exports.default = _default;