2019-06-20 05:30:36 +00:00
|
|
|
use tui::backend::TestBackend;
|
|
|
|
use tui::layout::Rect;
|
|
|
|
use tui::style::{Color, Style};
|
2019-12-15 20:38:18 +00:00
|
|
|
use tui::widgets::{Axis, Block, Borders, Chart, Dataset, Marker};
|
2019-06-20 05:30:36 +00:00
|
|
|
use tui::Terminal;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn zero_axes_ok() {
|
|
|
|
let backend = TestBackend::new(100, 100);
|
|
|
|
let mut terminal = Terminal::new(backend).unwrap();
|
|
|
|
|
|
|
|
terminal
|
|
|
|
.draw(|mut f| {
|
2019-12-15 20:38:18 +00:00
|
|
|
let datasets = [Dataset::default()
|
|
|
|
.marker(Marker::Braille)
|
|
|
|
.style(Style::default().fg(Color::Magenta))
|
|
|
|
.data(&[(0.0, 0.0)])];
|
|
|
|
let chart = Chart::default()
|
2019-07-16 06:03:02 +00:00
|
|
|
.block(Block::default().title("Plot").borders(Borders::ALL))
|
|
|
|
.x_axis(Axis::default().bounds([0.0, 0.0]).labels(&["0.0", "1.0"]))
|
|
|
|
.y_axis(Axis::default().bounds([0.0, 1.0]).labels(&["0.0", "1.0"]))
|
2019-12-15 20:38:18 +00:00
|
|
|
.datasets(&datasets);
|
|
|
|
f.render_widget(
|
|
|
|
chart,
|
|
|
|
Rect {
|
|
|
|
x: 0,
|
|
|
|
y: 0,
|
|
|
|
width: 100,
|
|
|
|
height: 100,
|
|
|
|
},
|
|
|
|
);
|
2019-07-16 06:03:02 +00:00
|
|
|
})
|
|
|
|
.unwrap();
|
2019-06-20 05:30:36 +00:00
|
|
|
}
|