import { ArcPathHoverGenerator } from '../interacting-entry-generator/arc-path-hover-generator';
import { BaseDrawer } from './base-drawer';
/** The PathDrawer class draws a path on a chart using provided data and color options. */
export class ArcPathDrawer extends BaseDrawer {
  constructor() {
    super(...arguments);
    this.arcPathHoverEntryGenerator = new ArcPathHoverGenerator();
  }
  /**
   * This function adds interaction support to a given drawPiece using an interactor and an arcPathHoverEntryGenerator.
   *
   * @param {(SVGPathElement | HTMLCanvasElement)[]} drawPiece - drawPiece is an array of SVGPathElement
   * or HTMLCanvasElement objects that represent the pieces to be drawn on the screen. These elements
   * are used to render the game board and interact with the user. The addInteractionSupport method
   * registers the current object as an interactive element with the interactor
   */
  addInteractionSupport(drawPiece) {
    this.interactor.register(this, drawPiece, this.arcPathHoverEntryGenerator.generate());
  }
  /**
   * This function draws a chart with arcs using data and options provided, and returns an array of SVGPathElement or HTMLCanvasElement.
   *
   * @returns {(SVGPathElement | HTMLCanvasElement)[]} An array of either SVGPathElement or HTMLCanvasElement, depending on the result of the map function.
   */
  draw() {
    const { data, colors, donutRadius, outerRadius, center } = this.options.renderOptions;
    return data.map((item, index) => {
      const color = this.getColorFromToken(this.getColorByIndex(index, colors));
      return this.renderer.drawArcPath(center, item, color, outerRadius, donutRadius);
    });
  }
}
