Skip to content
89 changes: 0 additions & 89 deletions .github/workflows/release.yml

This file was deleted.

54 changes: 53 additions & 1 deletion src/bin/kuva/layout_args.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::Args;
use kuva::render::layout::{AxisLabelOverlap, Layout, TickFormat};
use kuva::render::layout::{AxisLabelOverlap, AxisLine, Layout, TickAlign, TickFormat, TickPos};
use kuva::render::palette::Palette;
use kuva::render::theme::Theme;

Expand Down Expand Up @@ -131,6 +131,18 @@ pub struct AxisArgs {
#[arg(long)]
pub no_grid: bool,

/// Axis line style: left or box.
#[arg(long, value_name = "FRAME")]
pub axis_line: Option<String>,

/// Tick alignment relative to the axis line: outside, inside, or center.
#[arg(long, value_name = "ALIGN")]
pub tick_align: Option<String>,

/// Tick position: primary (bottom/left) or both.
#[arg(long, value_name = "POS")]
pub tick_pos: Option<String>,

/// Fix the X axis lower bound; overrides auto-range.
#[arg(long)]
pub x_min: Option<f64>,
Expand Down Expand Up @@ -285,6 +297,21 @@ pub fn apply_axis_args(mut layout: Layout, args: &AxisArgs) -> Layout {
if args.no_grid {
layout = layout.with_show_grid(false);
}
if let Some(ref line) = args.axis_line {
if let Some(line) = parse_axis_line(line) {
layout = layout.with_axis_line(line);
}
}
if let Some(ref align) = args.tick_align {
if let Some(align) = parse_tick_align(align) {
layout = layout.with_tick_align(align);
}
}
if let Some(ref pos) = args.tick_pos {
if let Some(pos) = parse_tick_pos(pos) {
layout = layout.with_tick_pos(pos);
}
}
if let Some(v) = args.x_min {
layout = layout.with_x_axis_min(v);
}
Expand Down Expand Up @@ -373,6 +400,31 @@ fn colourblind_palette(condition: &str) -> Option<Palette> {
}
}

fn parse_axis_line(s: &str) -> Option<AxisLine> {
match s.to_ascii_lowercase().replace('_', "-").as_str() {
"open" | "left" | "primary" => Some(AxisLine::Open),
"box" | "frame" | "enclosed" => Some(AxisLine::Box),
_ => None,
}
}

fn parse_tick_align(s: &str) -> Option<TickAlign> {
match s.to_ascii_lowercase().replace('_', "-").as_str() {
"inside" | "in" => Some(TickAlign::Inside),
"outside" | "out" => Some(TickAlign::Outside),
"center" | "centre" | "middle" => Some(TickAlign::Center),
_ => None,
}
}

fn parse_tick_pos(s: &str) -> Option<TickPos> {
match s.to_ascii_lowercase().replace('_', "-").as_str() {
"primary" | "left" | "bottom" | "lower" => Some(TickPos::Primary),
"both" | "mirror" | "mirrored" => Some(TickPos::Both),
_ => None,
}
}

fn parse_label_overlap(s: &str) -> Option<AxisLabelOverlap> {
match s {
"allow" => Some(AxisLabelOverlap::Allow),
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ pub use render::render_utils::silverman_bandwidth;
/// [`simple_kde_reflect`] instead.
pub use render::render_utils::simple_kde;

pub use render::layout::AxisLabelOverlap;
pub use render::layout::TickFormat;
pub use render::layout::{AxisLabelOverlap, AxisLine, TickAlign, TickFormat, TickPos};
pub use render::palette::Palette;
pub use render::render::render_calendar;
pub use render::render::render_phylo_tree;
Expand Down
2 changes: 1 addition & 1 deletion src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub use crate::plot::{
pub use crate::render::plots::Plot;

// ── Layout & rendering ───────────────────────────────────────────────────────
pub use crate::render::layout::{Layout, TickFormat};
pub use crate::render::layout::{AxisLine, Layout, TickAlign, TickFormat, TickPos};
pub use crate::render::render::{
collect_legend_entries, render_bump, render_forest, render_funnel, render_gantt,
render_jointplot, render_lollipop, render_mosaic, render_multiple, render_parallel,
Expand Down
Loading
Loading