
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/


/**
 * AUTO-GENERATED FILE. DO NOT MODIFY.
 */

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { __extends } from "tslib";
import ChartView from '../../view/Chart.js';
import * as graphic from '../../util/graphic.js';
import { createSymbol } from '../../util/symbol.js';
import { getECData } from '../../util/innerStore.js';
import { toggleHoverEmphasis } from '../../util/states.js';
import { each } from 'tvrender/lib/core/util.js';
import ArrowSymbolPath from './ArrowSymbolPath.js';
var ArrowsPlotView = /** @class */function (_super) {
  __extends(ArrowsPlotView, _super);
  function ArrowsPlotView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = ArrowsPlotView.type;
    return _this;
  }
  ArrowsPlotView.prototype.render = function (seriesModel, ecModel, api) {
    var data = seriesModel.getData();
    this._renderArrows(data, seriesModel);
    this._finished = true;
  };
  ArrowsPlotView.prototype._renderArrows = function (data, seriesModel) {
    if (!this._symbolGroup) {
      this._symbolGroup = new graphic.Group();
      this.group.add(this._symbolGroup);
    } else {
      this._symbolGroup.removeAll();
    }
    var symbolGroup = this._symbolGroup;
    var bandWidth = seriesModel.coordinateSystem.getAxesByScale('ordinal')[0].scale.barSpace;
    var maxheight = seriesModel.get('maxheight');
    var minheight = seriesModel.get('minheight');
    var emphasisState = seriesModel.get('emphasis').emphasisState;
    var groupId = seriesModel.get('groupId');
    var isMobile = seriesModel.get('isMobile');
    var upArrowsByColor = data.getLayout('upArrowsByColor');
    var maxValue = data.getLayout('maxValue');
    each(upArrowsByColor, function (item, color) {
      var el = new ArrowSymbolPath({
        shape: {
          points: item,
          barWidth: bandWidth,
          minHeight: minheight,
          valueLength: maxheight / maxValue,
          fill: color,
          isWebviewRender: isMobile
        },
        style: {
          fill: color
        }
      });
      el.states.emphasis = emphasisState;
      el.symbolProxy = createSymbol('arrowUp', 0, 0, 0, 0);
      symbolGroup.add(el);
    });
    var downArrowsByColor = data.getLayout('downArrowsByColor');
    var minValue = data.getLayout('minValue');
    each(downArrowsByColor, function (item, color) {
      var el = new ArrowSymbolPath({
        shape: {
          points: item,
          barWidth: bandWidth,
          minHeight: minheight,
          valueLength: maxheight / minValue
        },
        style: {
          fill: color
        }
      });
      el.states.emphasis = emphasisState;
      el.symbolProxy = createSymbol('arrowDown', 0, 0, 0, 0);
      symbolGroup.add(el);
    });
    toggleHoverEmphasis(this.group, null, null, false);
    getECData(this.group).groupId = groupId;
  };
  ArrowsPlotView.prototype._getClipShape = function (seriesModel) {
    if (!seriesModel.get('clip', true)) {
      return;
    }
    var coordSys = seriesModel.coordinateSystem;
    // PENDING make `0.1` configurable, for example, `clipTolerance`?
    return coordSys && coordSys.getArea && coordSys.getArea(.1);
  };
  ArrowsPlotView.prototype.remove = function (ecModel, api) {
    this._symbolGroup && this._symbolGroup.removeAll();
    this._symbolGroup = null;
  };
  ArrowsPlotView.prototype.dispose = function () {};
  ArrowsPlotView.type = 'arrowsPlot';
  return ArrowsPlotView;
}(ChartView);
export default ArrowsPlotView;