
Setting | Type | Meaning |
|---|---|---|
TreemapSeries::data | Vec<TreemapNode> | Supplies the roots of the hierarchy. |
TreemapNode::children | Vec<TreemapNode> | Supplies each node's next level. |
TreemapNode::value | f32 | Carries the numeric value associated with the node. |
Chart::series | Vec<Series> | Presents the hierarchy without Cartesian axes. |
use fission::charts::{Chart, TreemapSeries, TreemapNode};
let nodes = vec![TreemapNode {
name: "Operating cost".into(),
value: 60000.0,
children: vec![
TreemapNode {
name: "Hosting".into(),
value: 22000.0,
children: vec![],
},
TreemapNode {
name: "Support".into(),
value: 38000.0,
children: vec![],
},
],
}];
let chart = Chart::new()
.title("Monthly cost by centre (GBP)")
.series(vec![TreemapSeries::new("Cost (GBP)")
.data(nodes)
.into()]);
use fission::prelude::*;
use fission::charts::{Chart, TreemapSeries, TreemapNode};
// The parent resolves display labels from its translation bundles.
fission_component! {
pub CostCenterTreemapChart<()> {
props {
chart_title: String,
series_label: String,
nodes: Vec<TreemapNode>,
}
}
view(hierarchy, _state, _cx) =>
Chart(
title: Some(hierarchy.chart_title.clone()),
series: vec![TreemapSeries::new(&hierarchy.series_label)
.data(hierarchy.nodes.clone())
.into()],
)
}