MCPcopy Create free account
hub / github.com/emilk/egui_plot / RectElement

Interface RectElement

egui_plot/src/rect_elem.rs:8–54  ·  view source on GitHub ↗

Trait that abstracts from rectangular 'Value'-like elements, such as bars or boxes

Source from the content-addressed store, hash-verified

6/// Trait that abstracts from rectangular 'Value'-like elements, such as bars or
7/// boxes
8pub(super) trait RectElement {
9 fn name(&self) -> &str;
10
11 fn bounds_min(&self) -> PlotPoint;
12
13 fn bounds_max(&self) -> PlotPoint;
14
15 fn bounds(&self) -> PlotBounds {
16 let mut bounds = PlotBounds::NOTHING;
17 bounds.extend_with(&self.bounds_min());
18 bounds.extend_with(&self.bounds_max());
19 bounds
20 }
21
22 /// At which argument (input; usually X) there is a ruler (usually vertical)
23 fn arguments_with_ruler(&self) -> Vec<PlotPoint> {
24 // Default: one at center
25 vec![self.bounds().center()]
26 }
27
28 /// At which value (output; usually Y) there is a ruler (usually horizontal)
29 fn values_with_ruler(&self) -> Vec<PlotPoint>;
30
31 /// The diagram's orientation (vertical/horizontal)
32 fn orientation(&self) -> Orientation;
33
34 /// Get X/Y-value for (argument, value) pair, taking into account
35 /// orientation
36 fn point_at(&self, argument: f64, value: f64) -> PlotPoint {
37 match self.orientation() {
38 Orientation::Horizontal => PlotPoint::new(value, argument),
39 Orientation::Vertical => PlotPoint::new(argument, value),
40 }
41 }
42
43 /// Right top of the rectangle (position of text)
44 fn corner_value(&self) -> PlotPoint {
45 PlotPoint {
46 x: self.bounds_max().x,
47 y: self.bounds_max().y,
48 }
49 }
50
51 /// Debug formatting for hovered-over value, if none is specified by the
52 /// user
53 fn default_values_format(&self, transform: &PlotTransform) -> String;
54}
55
56// ----------------------------------------------------------------------------
57// Helper functions

Callers 9

add_rulers_and_textFunction · 0.80
bounds_minMethod · 0.80
bounds_maxMethod · 0.80
values_with_rulerMethod · 0.80
add_shapesMethod · 0.80
bounds_minMethod · 0.80
bounds_maxMethod · 0.80
values_with_rulerMethod · 0.80
corner_valueMethod · 0.80

Implementers 2

bar_chart.rsegui_plot/src/items/bar_chart.rs
box_plot.rsegui_plot/src/items/box_plot.rs

Calls

no outgoing calls

Tested by

no test coverage detected