-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfrom_rulinalg.rs
34 lines (29 loc) · 957 Bytes
/
from_rulinalg.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use vega_lite_4::*;
use rulinalg::matrix::Matrix;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// A new matrix with 4 rows and 2 columns.
let values = Matrix::new(4, 2, (1..9).collect::<Vec<usize>>());
// the chart
let chart = VegaliteBuilder::default()
.title("Random points")
.data(values)
.mark(Mark::Point)
.encoding(
EdEncodingBuilder::default()
.x(XClassBuilder::default()
.field("0")
.position_def_type(Type::Quantitative)
.build()?)
.y(YClassBuilder::default()
.field("1")
.position_def_type(Type::Quantitative)
.build()?)
.build()?,
)
.build()?;
// display the chart using `showata`
chart.show()?;
// print the vega lite spec
eprint!("{}", chart.to_string()?);
Ok(())
}