
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 AnnotationCalloutChart<()> {
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 note = ChartGraphic {
width: 0.45,
height: 0.12,
..ChartGraphic::text(0.05, 0.06, report.note.clone(), colors.text_primary)
};
let graphics = vec![note,
ChartGraphic::line(0.28, 0.20, 0.12, 0.18, colors.primary),
];
} =>
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()],
)
}