import { formatNumber as e, niceScale as t } from "./utils.js";
//#region src/charts/axis.ts
var n = "#94a3b8", r = "#e2e8f0", i = "#64748b", a = "11px system-ui, sans-serif", o = "12px system-ui, sans-serif", s = 5;
function c(e, t, c, l) {
	let { x: u, y: d, width: f, height: p } = t, m = d + p;
	e.save(), e.strokeStyle = n, e.lineWidth = 1, e.beginPath(), e.moveTo(u, m), e.lineTo(u + f, m), e.stroke(), e.fillStyle = i, e.font = a, e.textAlign = "center", e.textBaseline = "top";
	let h = c.length > 0 ? f / c.length : 0;
	for (let t = 0; t < c.length; t++) {
		let a = c[t];
		if (a === void 0) continue;
		let o = u + h * t + h / 2;
		e.strokeStyle = n, e.beginPath(), e.moveTo(o, m), e.lineTo(o, m + s), e.stroke(), e.fillStyle = i, e.fillText(a, o, m + s + 3), l?.gridLines === !0 && (e.strokeStyle = r, e.lineWidth = .5, e.beginPath(), e.moveTo(o, d), e.lineTo(o, m), e.stroke(), e.lineWidth = 1);
	}
	l?.label !== void 0 && (e.fillStyle = i, e.font = o, e.textAlign = "center", e.textBaseline = "top", e.fillText(l.label, u + f / 2, m + s + 18)), e.restore();
}
function l(c, l, u, d, f) {
	let { x: p, y: m, width: h, height: g } = l, _ = m + g, v = f?.tickCount ?? 5, y = f?.format ?? e, b = t(u, d, v);
	c.save(), c.strokeStyle = n, c.lineWidth = 1, c.beginPath(), c.moveTo(p, m), c.lineTo(p, _), c.stroke(), c.fillStyle = i, c.font = a, c.textAlign = "right", c.textBaseline = "middle";
	let x = b.step > 0 ? Math.round((b.max - b.min) / b.step) : 0, S = b.max - b.min;
	for (let e = 0; e <= x; e++) {
		let t = b.min + e * b.step, a = _ - (S > 0 ? (t - b.min) / S : 0) * g;
		c.strokeStyle = n, c.beginPath(), c.moveTo(p - s, a), c.lineTo(p, a), c.stroke(), c.fillStyle = i, c.fillText(y(t), p - s - 3, a), f?.gridLines === !0 && (c.strokeStyle = r, c.lineWidth = .5, c.beginPath(), c.moveTo(p, a), c.lineTo(p + h, a), c.stroke(), c.lineWidth = 1);
	}
	f?.label !== void 0 && (c.fillStyle = i, c.font = o, c.textAlign = "center", c.textBaseline = "bottom", c.save(), c.translate(p - s - 30, m + g / 2), c.rotate(-Math.PI / 2), c.fillText(f.label, 0, 0), c.restore()), c.restore();
}
function u(e, t, n, i) {
	let { x: a, y: o, width: s, height: c } = t;
	e.save(), e.strokeStyle = r, e.lineWidth = .5;
	for (let t of n) e.beginPath(), e.moveTo(a, t), e.lineTo(a + s, t), e.stroke();
	for (let t of i) e.beginPath(), e.moveTo(t, o), e.lineTo(t, o + c), e.stroke();
	e.restore();
}
//#endregion
export { u as drawGridLines, c as drawXAxis, l as drawYAxis };

//# sourceMappingURL=axis.js.map