@amcharts/amcharts5
Version:
amCharts 5
38 lines • 1.15 kB
JavaScript
import { Graphics } from "./Graphics";
/**
* Draws a triangle.
*
* @see {@link https://www.amcharts.com/docs/v5/concepts/common-elements/graphics/} for more info
* @important
*/
export class Triangle extends Graphics {
_beforeChanged() {
super._beforeChanged();
if (this.isDirty("width") || this.isDirty("height") || this.isPrivateDirty("width") || this.isPrivateDirty("height")) {
this._clear = true;
}
}
_changed() {
super._changed();
if (this._clear && !this.get("draw")) {
this._draw();
}
}
_draw() {
const w = this.width();
const h = this.height();
const display = this._display;
display.moveTo(-w / 2, h / 2);
display.lineTo(0, -h / 2);
display.lineTo(w / 2, h / 2);
display.lineTo(-w / 2, h / 2);
display.closePath();
}
_updateSize() {
this.markDirty();
this._clear = true;
}
}
Triangle.className = "Triangle";
Triangle.classNames = Graphics.classNames.concat([Triangle.className]);
//# sourceMappingURL=Triangle.js.map