
/*
* 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";
// FIXME step not support polar
import { each } from 'tvrender/lib/core/util.js';
import ChartView from '../../view/Chart.js';
import * as graphic from '../../util/graphic.js';
import { createClipPath } from '../helper/createClipPathFromCoordSys.js';
import BgColorPath from './BgColorPath.js';
var BgColorView = /** @class */function (_super) {
  __extends(BgColorView, _super);
  function BgColorView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = BgColorView.type;
    return _this;
  }
  // init(ecModel: GlobalModel, api: ExtensionAPI): void {
  //   this._bgColorGroup = new graphic.Group();
  //   this.group.add(this._bgColorGroup);
  // }
  BgColorView.prototype.render = function (seriesModel, ecModel, api) {
    var data = seriesModel.getData();
    var rectsByColor = data.getLayout('rectsByColor');
    var height = data.getLayout('height');
    if (!this._bgColorGroup) {
      this._bgColorGroup = new graphic.Group();
      this.group.add(this._bgColorGroup);
    } else {
      this._bgColorGroup.removeAll();
    }
    // const emphasisState = seriesModel.get('emphasis').emphasisState;
    var isMobile = seriesModel.get('isMobile');
    var bgColorGroup = this._bgColorGroup;
    var barWidth = Math.ceil(seriesModel.coordinateSystem.getBaseAxis().scale.barSpace) || 5;
    var isLine = barWidth <= 4;
    each(rectsByColor, function (rects, color) {
      // const [color, width] = key.split(':');
      var el = new BgColorPath({
        shape: {
          points: rects,
          isLine: isLine,
          height: height,
          fill: isLine ? null : color,
          stroke: isLine ? color : 'none',
          isWebviewRender: isMobile
        },
        style: {
          fill: isLine ? null : color,
          stroke: isLine ? color : 'none',
          lineWidth: isLine ? +barWidth : void 0
        }
      });
      // el.states.emphasis = emphasisState;
      bgColorGroup.add(el);
    });
    var clipPath = seriesModel.get('clip', true) && createClipPath(seriesModel.coordinateSystem, false, seriesModel);
    if (clipPath) {
      this.group.setClipPath(clipPath);
    } else {
      this.group.removeClipPath();
    }
    // toggleHoverEmphasis(this.group, null, null, false);
    // getECData(this.group).groupId = groupId;
  };

  BgColorView.prototype.eachRendered = function (cb) {
    graphic.traverseElements(this._bgColorGroup, cb);
  };
  BgColorView.prototype.remove = function (ecModel, api) {
    if (this._bgColorGroup) {
      this.group.remove(this._bgColorGroup);
      this._bgColorGroup = null;
    }
  };
  BgColorView.prototype.dispose = function (ecModel, api) {
    this.remove(ecModel, api);
  };
  BgColorView.type = 'bgcolor';
  return BgColorView;
}(ChartView);
export default BgColorView;