pub enum ChartData {
Category {
categories: Vec<String>,
series: Vec<ChartSeries>,
},
Xy {
series: Vec<XySeries>,
},
}Expand description
Chart data — either category-based or XY-based.
§Examples
use hwpforge_core::chart::ChartData;
let cat = ChartData::category(
&["A", "B"],
&[("Series1", &[10.0, 20.0])],
);
assert!(matches!(cat, ChartData::Category { .. }));
let xy = ChartData::xy(&[("Points", &[1.0, 2.0], &[3.0, 4.0])]);
assert!(matches!(xy, ChartData::Xy { .. }));Variants§
Category
Category-based data (bar, line, pie, area, radar, etc.).
Fields
§
series: Vec<ChartSeries>Data series, each with a name and values.
Xy
XY-based data (scatter, bubble).
Implementations§
Source§impl ChartData
impl ChartData
Sourcepub fn category(cats: &[&str], series: &[(&str, &[f64])]) -> Self
pub fn category(cats: &[&str], series: &[(&str, &[f64])]) -> Self
Creates category-based chart data from slices.
§Examples
use hwpforge_core::chart::ChartData;
let data = ChartData::category(
&["Jan", "Feb", "Mar"],
&[("Revenue", &[100.0, 200.0, 300.0])],
);
match &data {
ChartData::Category { categories, series } => {
assert_eq!(categories.len(), 3);
assert_eq!(series.len(), 1);
}
_ => unreachable!(),
}Sourcepub fn xy(series: &[(&str, &[f64], &[f64])]) -> Self
pub fn xy(series: &[(&str, &[f64], &[f64])]) -> Self
Creates XY-based chart data from slices.
§Examples
use hwpforge_core::chart::ChartData;
let data = ChartData::xy(&[("Points", &[1.0, 2.0], &[3.0, 4.0])]);
match &data {
ChartData::Xy { series } => {
assert_eq!(series.len(), 1);
assert_eq!(series[0].x_values.len(), 2);
}
_ => unreachable!(),
}Sourcepub fn has_no_series(&self) -> bool
pub fn has_no_series(&self) -> bool
Returns true if the chart data contains no series.
A chart with zero series cannot be rendered. This is checked during
document validation (see ValidationError::EmptyChartData).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ChartData
impl<'de> Deserialize<'de> for ChartData
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for ChartData
impl JsonSchema for ChartData
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreimpl StructuralPartialEq for ChartData
Auto Trait Implementations§
impl Freeze for ChartData
impl RefUnwindSafe for ChartData
impl Send for ChartData
impl Sync for ChartData
impl Unpin for ChartData
impl UnwindSafe for ChartData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more