UNPKG

@devexperts/dxcharts-lite

Version:
25 lines (24 loc) 1.06 kB
/* * Copyright (C) 2019 - 2026 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/. */ import { flat } from '../../utils/array.utils'; const SCATTER_PLOT_RADIUS = 1.5; export class ScatterPlotDrawer { constructor(config) { this.config = config; } draw(ctx, points, model, hitTestDrawerConfig) { var _a; const radius = hitTestDrawerConfig.hoverWidth ? hitTestDrawerConfig.hoverWidth / 2 : SCATTER_PLOT_RADIUS; ctx.fillStyle = (_a = hitTestDrawerConfig.color) !== null && _a !== void 0 ? _a : this.config.mainColor; for (const visualCandle of flat(points)) { ctx.beginPath(); const lineX = model.view.toX(visualCandle.centerUnit); const closeY = model.view.toY(visualCandle.close); ctx.arc(lineX, closeY, radius, 0, Math.PI * 2, true); ctx.fill(); } } }