
Setting | Type | Meaning |
|---|---|---|
ChartGraphic::text | Constructor | Creates a text graphic from a position, string and colour. |
ChartGraphic::rect | Constructor | Creates a plot-relative rectangular graphic. |
ChartGraphic::line | Constructor | Creates a line from a plot-relative position and extent. |
Chart::graphics field | Vec<ChartGraphic> | Supplies the overlay graphics. |
use fission::prelude::*;
use fission::charts::{Axis, Chart, ChartGraphic, LineSeries};
// The parent resolves display labels from its translation bundles.
fission_component! {
pub GraphicBandChart<()> {
props {
chart_title: String,
series_label: String,
category_labels: Vec<String>,
values: Vec<f32>,
note: String,
}
}
view(report, _state, cx) {
let colors = &cx.view.env().theme.tokens.colors;
let band = ChartGraphic::rect(
0.10, 0.05, 0.55, 0.18, colors.primary_subtle.with_alpha(80),
).stroke(colors.primary);
let note = ChartGraphic {
width: 0.50,
height: 0.12,
..ChartGraphic::text(0.12, 0.08, report.note.clone(), colors.text_primary)
};
let graphics = vec![band, note];
} =>
Chart(
title: Some(report.chart_title.clone()),
x_axis: Some(Axis::category(
report.category_labels.iter().map(String::as_str).collect(),
)),
y_axis: Some(Axis::value()),
graphics: graphics,
series: vec![LineSeries::new(&report.series_label)
.data(report.values.clone())
.into()],
)
}