
/*
* 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 { each } from 'tvrender/lib/core/util.js';
import { getECData } from '../../util/innerStore.js';
import { toggleHoverEmphasis } from '../../util/states.js';
var CharPlotView = /** @class */function (_super) {
  __extends(CharPlotView, _super);
  function CharPlotView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = CharPlotView.type;
    return _this;
  }
  CharPlotView.prototype.render = function (seriesModel, ecModel, api) {
    var data = seriesModel.getData();
    this._renderText(data, seriesModel);
    this._finished = true;
  };
  CharPlotView.prototype._renderText = function (data, seriesModel) {
    if (!this._textGroup) {
      this._textGroup = new graphic.Group();
      this.group.add(this._textGroup);
    } else {
      this._textGroup.removeAll();
    }
    var textGroup = this._textGroup;
    var charList = data.getLayout('charList');
    var fontSize = data.getLayout('fontSize');
    var textList = data.getLayout('textList');
    var char = seriesModel.get('char');
    var text = seriesModel.get('text');
    var emphasisState = seriesModel.get('emphasis').emphasisState;
    var groupId = seriesModel.get('groupId');
    each(charList, function (item) {
      var el = new graphic.Text({
        style: {
          text: char,
          verticalAlign: 'middle',
          align: 'center',
          fill: item.textColor,
          fontSize: fontSize
        },
        x: item.x,
        y: item.y
      });
      el.states.emphasis = emphasisState;
      textGroup.add(el);
    });
    var location = seriesModel.get('location');
    var vAlign = 'middle';
    if (['abovebar', 'bottom', 'absolute'].includes(location)) {
      vAlign = 'bottom';
    }
    each(textList, function (item) {
      var el = new graphic.Text({
        style: {
          text: text,
          verticalAlign: vAlign,
          align: 'center',
          fill: item.textColor,
          fontSize: 12
        },
        x: item.x,
        y: item.y
      });
      el.states.emphasis = emphasisState;
      textGroup.add(el);
    });
    toggleHoverEmphasis(this.group, null, null, false);
    getECData(this.group).groupId = groupId;
  };
  CharPlotView.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);
  };
  CharPlotView.prototype.remove = function (ecModel, api) {
    // this._symbolDraw && this._symbolDraw.remove(true);
    // this._symbolDraw = null;
    // this._symbolGroup && this._symbolGroup.removeAll();
    // this._symbolGroup = null;
    this._textGroup && this._textGroup.removeAll();
    this._textGroup = null;
  };
  CharPlotView.prototype.dispose = function () {};
  CharPlotView.type = 'charPlot';
  return CharPlotView;
}(ChartView);
export default CharPlotView;