function _assert_this_initialized(self) {
    if (self === void 0) {
        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    }
    return self;
}
function _call_super(_this, derived, args) {
    derived = _get_prototype_of(derived);
    return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
}
function _class_call_check(instance, Constructor) {
    if (!(instance instanceof Constructor)) {
        throw new TypeError("Cannot call a class as a function");
    }
}
function _get_prototype_of(o) {
    _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
        return o.__proto__ || Object.getPrototypeOf(o);
    };
    return _get_prototype_of(o);
}
function _inherits(subClass, superClass) {
    if (typeof superClass !== "function" && superClass !== null) {
        throw new TypeError("Super expression must either be null or a function");
    }
    subClass.prototype = Object.create(superClass && superClass.prototype, {
        constructor: {
            value: subClass,
            writable: true,
            configurable: true
        }
    });
    if (superClass) _set_prototype_of(subClass, superClass);
}
function _instanceof(left, right) {
    "@swc/helpers - instanceof";
    if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
        return !!right[Symbol.hasInstance](left);
    } else {
        return left instanceof right;
    }
}
function _possible_constructor_return(self, call) {
    if (call && (_type_of(call) === "object" || typeof call === "function")) {
        return call;
    }
    return _assert_this_initialized(self);
}
function _set_prototype_of(o, p) {
    _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
        o.__proto__ = p;
        return o;
    };
    return _set_prototype_of(o, p);
}
function _type_of(obj) {
    "@swc/helpers - typeof";
    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
}
function _is_native_reflect_construct() {
    try {
        var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
    } catch (_) {}
    return (_is_native_reflect_construct = function() {
        return !!result;
    })();
}
import { constant } from "../utils/index.js";
import { default as Plot } from "./Plot.js";
var BumpChart = /*#__PURE__*/ function(Plot) {
    "use strict";
    _inherits(BumpChart, Plot);
    function BumpChart() {
        _class_call_check(this, BumpChart);
        var _this;
        _this = _call_super(this, BumpChart);
        _this._discrete = "x";
        _this._shape = constant("Line");
        _this.y2(function(d) {
            return _this._y(d);
        });
        _this.yConfig({
            tickFormat: function tickFormat(val) {
                var data = _this._formattedData;
                var xMin = _instanceof(data[0].x, Date) ? data[0].x.getTime() : data[0].x;
                var startData = data.filter(function(d) {
                    return (_instanceof(d.x, Date) ? d.x.getTime() : d.x) === xMin;
                });
                var d = startData.find(function(d) {
                    return d.y === val;
                });
                return d ? _this._drawLabel(d, d.i) : "";
            }
        });
        _this.y2Config({
            tickFormat: function tickFormat(val) {
                var data = _this._formattedData;
                var xMax = _instanceof(data[data.length - 1].x, Date) ? data[data.length - 1].x.getTime() : data[data.length - 1].x;
                var endData = data.filter(function(d) {
                    return (_instanceof(d.x, Date) ? d.x.getTime() : d.x) === xMax;
                });
                var d = endData.find(function(d) {
                    return d.y === val;
                });
                return d ? _this._drawLabel(d, d.i) : "";
            }
        });
        _this.ySort(function(a, b) {
            return _this._y(b) - _this._y(a);
        });
        _this.y2Sort(function(a, b) {
            return _this._y(b) - _this._y(a);
        });
        return _this;
    }
    return BumpChart;
}(Plot);
/**
    Creates a bump chart based on an array of data.
    @example <caption>the equivalent of calling:</caption>
new d3plus.Plot()
  .discrete("x")
  .shape("Line")
  .y2(d => this._y(d))
  .yConfig({
    tickFormat: val => {
      const data = this._formattedData;
      const xDomain = this._xDomain;
      const startData = data.filter(d => d.x === xDomain[0]);
      const d = startData.find(d => d.y === val);
      return this._drawLabel(d, d.i);
     }
   })
  .y2Config({
    tickFormat: val => {
      const data = this._formattedData;
      const xDomain = this._xDomain;
      const endData = data.filter(d => d.x === xDomain[xDomain.length - 1]);
      const d = endData.find(d => d.y === val);
      return this._drawLabel(d, d.i);
     }
   })
  .ySort((a, b) => b.y - a.y)
  .y2Sort((a, b) => b.y - a.y)
*/ export { BumpChart as default };
