pub struct PieChart { /* private fields */ }Expand description
Pie chart block representation.
§Fields and Validations
For more details, see the official documentation.
| Field | Type | Required | Validation |
|---|---|---|---|
| segments | Vec<Segment> | Yes | Min 1, Max 6 items |
§Example
use slack_messaging::blocks::data_visualization::charts::{segments, PieChart};
let pie_chart = PieChart::builder()
.segments(segments(vec![
("Kit Kat", 45),
("Twix", 28),
("Crunch", 18),
("Milky Way", 9),
])?)
.build()?;
let expected = serde_json::json!({
"type": "pie",
"segments": [
{ "label": "Kit Kat", "value": 45 },
{ "label": "Twix", "value": 28 },
{ "label": "Crunch", "value": 18 },
{ "label": "Milky Way", "value": 9 }
]
});
let json = serde_json::to_value(pie_chart).unwrap();
assert_eq!(json, expected);Implementations§
Source§impl PieChart
impl PieChart
Sourcepub fn builder() -> PieChartBuilder
pub fn builder() -> PieChartBuilder
constract PieChartBuilder object.
Trait Implementations§
impl StructuralPartialEq for PieChart
Auto Trait Implementations§
impl Freeze for PieChart
impl RefUnwindSafe for PieChart
impl Send for PieChart
impl Sync for PieChart
impl Unpin for PieChart
impl UnsafeUnpin for PieChart
impl UnwindSafe for PieChart
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