MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / new

Function new

examples/high_precision.rs:27–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25}
26
27fn new() -> PlotWidget {
28 // Suppose we're plotting some time-series data which is nanoseconds apart, but the first timestamp
29 // is very large.
30 let mut t = Duration::from_secs(60 * 60 * 24 * 7); // 1 week
31
32 let mut positions = Vec::new();
33 for i in 0..100 {
34 let y = 100.0 + (i as f64 / 10.0).cos() / 10000.0;
35 positions.push([t.as_secs_f64(), y]);
36 t += Duration::from_nanos(10);
37 }
38
39 PlotWidgetBuilder::new()
40 .with_hover_highlight_provider(|_ctx, point| {
41 point.color = Color::from_rgb(1.0, 0.0, 0.0);
42 Some(format!("t = {:.9} s\nvalue = {:.4}", point.x, point.y))
43 })
44 .with_cursor_provider(|x, y| format!("Cursor:\nt = {:.9} s\nvalue = {:.6}", x, y))
45 .add_series(
46 Series::new(positions, MarkerStyle::square(4.0), LineStyle::dashed(10.0))
47 .with_label("both_markers_and_lines")
48 .with_color(Color::from_rgb(0.3, 0.9, 0.3)),
49 )
50 .with_cursor_overlay(true)
51 .with_crosshairs(true)
52 .with_y_label("cool data")
53 .with_x_label("time (s)\n\n\n")
54 .build()
55 .unwrap()
56}

Callers

nothing calls this directly

Calls 10

buildMethod · 0.80
with_x_labelMethod · 0.80
with_y_labelMethod · 0.80
with_crosshairsMethod · 0.80
with_cursor_overlayMethod · 0.80
with_cursor_providerMethod · 0.80
add_seriesMethod · 0.45
with_colorMethod · 0.45
with_labelMethod · 0.45

Tested by

no test coverage detected