"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const tslib_es6 = require("../../../node_modules/tslib/tslib.es6.js");
const util = require("../../../../../../zrender@5.4.4/node_modules/zrender/lib/core/util.js");
const createSeriesDataSimply = require("../helper/createSeriesDataSimply.js");
const model = require("../../util/model.js");
const sourceHelper = require("../../data/helper/sourceHelper.js");
const LegendVisualProvider = require("../../visual/LegendVisualProvider.js");
const Series = require("../../model/Series.js");
var FunnelSeriesModel = (
  /** @class */
  function(_super) {
    tslib_es6.__extends(FunnelSeriesModel2, _super);
    function FunnelSeriesModel2() {
      var _this = _super !== null && _super.apply(this, arguments) || this;
      _this.type = FunnelSeriesModel2.type;
      return _this;
    }
    FunnelSeriesModel2.prototype.init = function(option) {
      _super.prototype.init.apply(this, arguments);
      this.legendVisualProvider = new LegendVisualProvider.default(util.bind(this.getData, this), util.bind(this.getRawData, this));
      this._defaultLabelLine(option);
    };
    FunnelSeriesModel2.prototype.getInitialData = function(option, ecModel) {
      return createSeriesDataSimply.default(this, {
        coordDimensions: ["value"],
        encodeDefaulter: util.curry(sourceHelper.makeSeriesEncodeForNameBased, this)
      });
    };
    FunnelSeriesModel2.prototype._defaultLabelLine = function(option) {
      model.defaultEmphasis(option, "labelLine", ["show"]);
      var labelLineNormalOpt = option.labelLine;
      var labelLineEmphasisOpt = option.emphasis.labelLine;
      labelLineNormalOpt.show = labelLineNormalOpt.show && option.label.show;
      labelLineEmphasisOpt.show = labelLineEmphasisOpt.show && option.emphasis.label.show;
    };
    FunnelSeriesModel2.prototype.getDataParams = function(dataIndex) {
      var data = this.getData();
      var params = _super.prototype.getDataParams.call(this, dataIndex);
      var valueDim = data.mapDimension("value");
      var sum = data.getSum(valueDim);
      params.percent = !sum ? 0 : +(data.get(valueDim, dataIndex) / sum * 100).toFixed(2);
      params.$vars.push("percent");
      return params;
    };
    FunnelSeriesModel2.type = "series.funnel";
    FunnelSeriesModel2.defaultOption = {
      // zlevel: 0,                  // 一级层叠
      z: 2,
      legendHoverLink: true,
      colorBy: "data",
      left: 80,
      top: 60,
      right: 80,
      bottom: 60,
      // width: {totalWidth} - left - right,
      // height: {totalHeight} - top - bottom,
      // 默认取数据最小最大值
      // min: 0,
      // max: 100,
      minSize: "0%",
      maxSize: "100%",
      sort: "descending",
      orient: "vertical",
      gap: 0,
      funnelAlign: "center",
      label: {
        show: true,
        position: "outer"
        // formatter: 标签文本格式器，同Tooltip.formatter，不支持异步回调
      },
      labelLine: {
        show: true,
        length: 20,
        lineStyle: {
          // color: 各异,
          width: 1
        }
      },
      itemStyle: {
        // color: 各异,
        borderColor: "#fff",
        borderWidth: 1
      },
      emphasis: {
        label: {
          show: true
        }
      },
      select: {
        itemStyle: {
          borderColor: "#212121"
        }
      }
    };
    return FunnelSeriesModel2;
  }(Series.default)
);
const FunnelSeriesModel$1 = FunnelSeriesModel;
exports.default = FunnelSeriesModel$1;
