Panics · P15 Charts: values within charts::LIMIT; scales, shares and tangents stay finite at the edges; entries past their lists are skipped

This commit is contained in:
ZacharyZhang-NY committed 2026-10-06 19:05:05 -04:00
1 parent 2ea16f4541
commit defbec006e
23 files changed
+483 -95

No files matched your search

+11 -6
View File
@@ -10,6 +10,7 @@ use super::{
geometry::{Categories, Ink, Mark, categories, scatter},
plot::{Format, Layout, Pick, Plot, Scene, Tips, plot},
scale::compact,
series::drawable,
series::{Points, Series, csv, points_csv},
};
use crate::theme::ActiveTheme;
@@ -173,18 +174,22 @@ macro_rules! category_chart {
/// A dashed level across the chart with its label, as a target or a limit.
pub fn rule(mut self, value: f64, label: impl Into<SharedString>) -> Self {
assert!(value.is_finite(), "a rule needs a finite value");
assert!(
drawable(value),
"a rule needs a value, within charts::LIMIT"
);
self.chart.rules.push((value, label.into()));
self
}
/// A mark at category `ix` with its label, as a release or an incident.
pub fn note(mut self, ix: usize, label: impl Into<SharedString>) -> Self {
assert!(
ix < self.chart.labels.len(),
"note {ix} is past the last label"
);
self.chart.notes.push((ix, label.into()));
let label = label.into();
if ix >= self.chart.labels.len() {
log::error!("chart: note {label} at {ix} is past the last label; skipped");
return self;
}
self.chart.notes.push((ix, label));
self
}