use super::*;
pub(crate) fn canvas_size(canvas: &HtmlCanvasElement) -> (f64, f64) {
let width: f64 = canvas.client_width() as f64;
let height: f64 = canvas.client_height() as f64;
if width > 0.0 && height > 0.0 {
return (width, height);
}
(canvas.width() as f64, canvas.height() as f64)
}
pub(crate) fn detect_dpr() -> f64 {
let Some(window) = web_sys::window() else {
return 1.0;
};
window.device_pixel_ratio().max(1.0)
}
pub(crate) fn draws_own_line(axis: &AxisLayout, grid: &GridLayout, horizontal: bool) -> bool {
match axis.kind {
AxisType::Category => true,
_ => {
let other: Option<&AxisLayout> = if horizontal {
grid.y_axes.first()
} else {
grid.x_axes.first()
};
matches!(
other.map(|axis: &AxisLayout| { axis.kind }),
Some(AxisType::Value) | Some(AxisType::Log)
)
}
}
}