///|
fn chart_bounds(analysis : Analysis) -> (Double, Double) {
let mut low = 0.0
let mut high = maximum(0.0, analysis.filtration.cutoff)
for cell in analysis.filtration.cells {
if cell.value < low {
low = cell.value
}
if cell.value > high {
high = cell.value
}
}
if high <= low {
high = low + maximum(1.0, low.abs() * 0.1)
}
(low, high)
}
///|
fn color(dimension : Int) -> String {
if dimension == 0 {
"#38bdf8"
} else {
"#fb923c"
}
}
///|
/// Standalone SVG barcode. Drawing is capped at 80 rows; JSON retains all bars.
/// Essential bars have a dashed ending, indicating the input cutoff.
pub fn barcode_svg(analysis : Analysis) -> String {
let (low, high) = chart_bounds(analysis)
let count = if analysis.intervals.length() > 80 {
80
} else {
analysis.intervals.length()
}
let height = 120 + count * 22
let mut svg = ""
}
///|
/// Standalone birth/death scatter plot with essential classes shown at the top.
pub fn diagram_svg(analysis : Analysis) -> String {
let (low, high) = chart_bounds(analysis)
let mut svg = ""
}