UNPKG

@devexperts/dxcharts-lite

Version:
28 lines (27 loc) 1.08 kB
/* * Copyright (C) 2019 - 2025 Devexperts Solutions IE Limited * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. * If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. */ export class TriangleDrawer { constructor() { } draw(ctx, allPoints, model, hitTestDrawerConfig) { allPoints.forEach((points, idx) => { var _a; const config = model.getPaintConfig(idx); ctx.fillStyle = (_a = hitTestDrawerConfig.color) !== null && _a !== void 0 ? _a : config.color; points.forEach(p => { const x = model.view.toX(p.centerUnit); const y = model.view.toY(p.close); this.drawCandleTriangle(ctx, x, y, config.lineWidth); }); }); } drawCandleTriangle(ctx, x, y, triangleWidth) { ctx.beginPath(); ctx.moveTo(x - triangleWidth / 2, y); ctx.lineTo(x, y - triangleWidth); ctx.lineTo(x + triangleWidth / 2, y); ctx.fill(); } }