UNPKG

@devexperts/dxcharts-lite

Version:
29 lines (28 loc) 1.24 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/. */ import { floor } from '../../utils/math.utils'; import { setLineWidth } from '../data-series.drawer'; export class HistogramDrawer { constructor() { } draw(ctx, allPoints, model, hitTestDrawerConfig) { const zero = model.view.toY(0); allPoints.forEach((points, idx) => { var _a; // odd width is crucial to draw histogram without antialiasing const config = model.getPaintConfig(idx); setLineWidth(ctx, config.lineWidth, model, hitTestDrawerConfig, config.hoveredLineWidth); ctx.strokeStyle = (_a = hitTestDrawerConfig.color) !== null && _a !== void 0 ? _a : config.color; ctx.beginPath(); points.forEach(p => { const x = model.view.toX(p.centerUnit); const y = model.view.toY(p.close); ctx.moveTo(x, floor(zero)); ctx.lineTo(x, floor(y)); }); ctx.stroke(); }); } }