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

Function plot_widget

examples/themes_and_styles.rs:108–142  ·  view source on GitHub ↗
(style_choice: StyleChoice)

Source from the content-addressed store, hash-verified

106}
107
108fn plot_widget(style_choice: StyleChoice) -> PlotWidget {
109 let line = Series::line_only(
110 (0..320)
111 .map(|i| {
112 let x = i as f64 * 0.04;
113 [x, (x * 0.85).sin() + 0.2 * (x * 0.2).cos()]
114 })
115 .collect(),
116 LineStyle::solid(),
117 )
118 .with_label("signal")
119 .with_color(Color::from_rgb(0.2, 0.72, 0.98));
120
121 let markers = Series::markers_only(
122 (0..70)
123 .map(|i| {
124 let x = i as f64 * 0.18;
125 [x, 0.65 * (x * 0.6).cos() - 0.1]
126 })
127 .collect(),
128 MarkerStyle::square(5.5),
129 )
130 .with_label("samples")
131 .with_color(Color::from_rgb(1.0, 0.55, 0.3));
132
133 PlotWidgetBuilder::new()
134 .with_x_label("X label")
135 .with_cursor_overlay(true)
136 .with_crosshairs(true)
137 .with_style(style_choice.style_fn())
138 .add_series(line)
139 .add_series(markers)
140 .build()
141 .unwrap()
142}
143
144#[derive(Debug, Clone, Copy, PartialEq, Eq)]
145enum ThemeChoice {

Callers 1

newMethod · 0.70

Calls 11

mapMethod · 0.80
buildMethod · 0.80
with_crosshairsMethod · 0.80
with_cursor_overlayMethod · 0.80
with_x_labelMethod · 0.80
style_fnMethod · 0.80
newFunction · 0.70
with_colorMethod · 0.45
with_labelMethod · 0.45
add_seriesMethod · 0.45
with_styleMethod · 0.45

Tested by

no test coverage detected