use tui;
use tui::chart;
use tui::text;
let data: Array<(f64, f64)> = {
let clock = time::timer(duration:0.5s, true);
let x = 0.0;
x <- (clock ~ x) + 1.0;
let y = rand::rand(#clock, #start: f64:0., #end: f64:100.);
let a = [];
a <- array::window(#n: 32, clock ~ a, (x, y));
a
};
let ds = dataset(
#style: &style(#fg: `Cyan),
#graph_type: &`Line,
#marker: &`Dot,
&data
);
let label_style = style(#fg: `Yellow);
chart(
#style: &style(#bg: `Rgb({r: 20, g: 20, b: 20})),
#x_axis: &axis(
#title: line(#style: label_style, "Time (s)"),
#labels: [
line(#style: label_style, "[(data[0]$).0]"),
line(#style: label_style, "[(data[-1]$).0]")
],
{min: (data[0]$).0, max: (data[-1]$).0}
),
#y_axis: &axis(
#title: line(#style: label_style, "Value"),
#labels: [
line("0"), line("50"), line("100")
],
{min: 0.0, max: 100.0}
),
&[ds]
)