
/*
* 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";
/**
 * Line path for bezier and straight line draw
 */
import * as graphic from '../../util/graphic.js';
// const straightLineProto = graphic.Line.prototype;
// const bezierCurveProto = graphic.BezierCurve.prototype;
var GradientHistogramPlotShape = /** @class */function () {
  function GradientHistogramPlotShape() {
    this.points = [];
    this.baseY = 0;
  }
  return GradientHistogramPlotShape;
}();
function isPointNull(point) {
  if (point instanceof Array) {
    return isNaN(point[0]) || isNaN(point[1]);
  }
  return false;
}
var GradientHistogramPlotPath = /** @class */function (_super) {
  __extends(GradientHistogramPlotPath, _super);
  function GradientHistogramPlotPath(opts) {
    var _this = _super.call(this, opts) || this;
    _this.type = 'GradientHistogramPlot';
    return _this;
  }
  GradientHistogramPlotPath.prototype.getDefaultStyle = function () {
    return {
      stroke: 'transparent',
      fill: '#000'
    };
  };
  GradientHistogramPlotPath.prototype.getDefaultShape = function () {
    return new GradientHistogramPlotShape();
  };
  GradientHistogramPlotPath.prototype.buildPath = function (ctx, shape) {
    var points = shape.points,
      baseY = shape.baseY;
    var prevColor = '';
    for (var index = 0; index < points.length; index++) {
      // const { point, color } = points[index];
      if (isPointNull(points[index].point)) {
        continue;
      }
      var isColorChange = prevColor !== points[index].color;
      if (prevColor && isColorChange) {
        ctx.strokeStyle(prevColor);
        ctx.beginPathFill();
      }
      ctx.moveTo(points[index].point[0], points[index].point[1]);
      ctx.lineTo(points[index].point[0], baseY);
      if (isColorChange) {
        prevColor = points[index].color;
      }
    }
    if (prevColor) {
      ctx.strokeStyle(prevColor);
    }
  };
  return GradientHistogramPlotPath;
}(graphic.Path);
export default GradientHistogramPlotPath;