
/*
* 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 * as graphic from '../../util/graphic.js';
import ComponentModel from '../../model/Component.js';
import ComponentView from '../../view/Component.js';
var BgRectModel = /** @class */function (_super) {
  __extends(BgRectModel, _super);
  function BgRectModel() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = BgRectModel.type;
    _this.layoutMode = {
      type: 'box',
      ignoreSize: true
    };
    return _this;
  }
  BgRectModel.type = 'bgRect';
  BgRectModel.defaultOption = {
    // zlevel: 0,
    z: 2,
    show: true,
    color: 'rgb(170, 130, 74)',
    bgColor: 'rgba(170, 130, 74, 0.3)',
    startIndex: 10
  };
  return BgRectModel;
}(ComponentModel);
// View
var BgRectView = /** @class */function (_super) {
  __extends(BgRectView, _super);
  function BgRectView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = BgRectView.type;
    return _this;
  }
  BgRectView.prototype.render = function (bgRectModel, ecModel, api) {
    this.group.removeAll();
    if (!bgRectModel.get('show')) {
      return;
    }
    var group = this.group;
    var grid = ecModel.getComponent('grid', 0);
    var z = bgRectModel.get('z');
    var rect = grid.coordinateSystem.getRect();
    var startIndex = bgRectModel.get('startIndex');
    var bgColor = bgRectModel.get('bgColor');
    var color = bgRectModel.get('color');
    // const coordSysList = api.getCoordinateSystems();
    var xAxis = ecModel.getComponent('xAxis', 0);
    var xAxis2D = xAxis.axis;
    var x = Math.floor(xAxis2D.toGlobalCoord(xAxis2D.dataToCoord(startIndex)) + xAxis2D.scale.barSpace / 2);
    var lineEl = new graphic.Line({
      shape: {
        x1: x,
        y1: rect.y,
        x2: x,
        y2: rect.height
      },
      style: {
        lineWidth: 2,
        stroke: color
      },
      z: z
    });
    var rectEl = new graphic.Rect({
      shape: {
        x: Math.max(rect.x, x),
        y: rect.y,
        height: rect.height,
        width: rect.width + rect.x - x
      },
      style: {
        fill: bgColor
      },
      z: z
    });
    group.add(lineEl);
    group.add(rectEl);
  };
  BgRectView.type = 'bgRect';
  return BgRectView;
}(ComponentView);
export function install(registers) {
  registers.registerComponentModel(BgRectModel);
  registers.registerComponentView(BgRectView);
}