
/*
* 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 { createClipPath } from '../helper/createClipPathFromCoordSys.js';
import BarPath from './BarPath.js';
import { getECData } from '../../util/innerStore.js';
import { toggleHoverEmphasis } from '../../util/states.js';
// const SKIP_PROPS = ['color', 'borderColor'] as const;
var BarPlotView = /** @class */function (_super) {
  __extends(BarPlotView, _super);
  function BarPlotView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = BarPlotView.type;
    return _this;
  }
  BarPlotView.prototype.render = function (seriesModel, ecModel, api) {
    // If there is clipPath created in large mode. Remove it.
    // this.group.removeClipPath();
    // Clear previously rendered progressive elements.
    this._progressiveEls = null;
    // this._updateDrawMode(seriesModel);
    this._renderNormal(seriesModel);
  };
  BarPlotView.prototype.eachRendered = function (cb) {
    graphic.traverseElements(this._progressiveEls || this.group, cb);
  };
  BarPlotView.prototype._renderNormal = function (seriesModel) {
    var data = seriesModel.getData();
    // const oldData = this._data;
    var group = this.group;
    group.removeAll();
    var candleWidth = data.getLayout('candleWidth');
    var isSimpleBox = data.getLayout('isSimpleBox');
    var emphasisState = seriesModel.get('emphasis').emphasisState;
    var groupId = seriesModel.get('groupId');
    var isMobile = seriesModel.get('isMobile');
    var ishlc = seriesModel.get('ishlc');
    var isSmall = seriesModel.get('isSmall');
    var lineWidth = 1;
    if (!isSmall) {
      var barWidth = Math.max(1, Math.floor(candleWidth / 3));
      lineWidth = barWidth % 2 === 0 ? barWidth - 1 : barWidth;
    }
    var offset = Math.floor(lineWidth / 2);
    var bodyPointsByColor = data.getLayout('bodyPointsByColor');
    bodyPointsByColor.forEach(function (typeArray, stroke) {
      var el = new BarPath({
        shape: {
          typeArray: typeArray,
          isSimpleBox: isSimpleBox,
          candleWidth: candleWidth,
          stroke: stroke,
          isWebviewRender: isMobile,
          ishlc: ishlc,
          offset: offset
        },
        style: {
          stroke: stroke,
          fill: 'none',
          lineWidth: lineWidth
        }
      });
      el.states.emphasis = emphasisState;
      group.add(el);
    });
    var clipPath = seriesModel.get('clip', true) ? createClipPath(seriesModel.coordinateSystem, false, seriesModel) : null;
    if (clipPath) {
      this.group.setClipPath(clipPath);
    } else {
      this.group.removeClipPath();
    }
    toggleHoverEmphasis(this.group, null, null, false);
    getECData(this.group).groupId = groupId;
  };
  BarPlotView.prototype.remove = function (ecModel) {
    this._clear();
  };
  BarPlotView.prototype._clear = function () {
    this.group.removeAll();
    // this._data = null;
  };

  BarPlotView.type = 'barPlot';
  return BarPlotView;
}(ChartView);
export default BarPlotView;