-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwithout_builders.rs
42 lines (38 loc) · 1.47 KB
/
without_builders.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
35
36
37
38
39
40
41
42
use vega_lite_4::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// the chart
let chart = Vegalite {
title: Some(TitleUnion::String("Stock price".to_string())),
description: Some("Google's stock price over time.".to_string()),
data: RemovableValue::Specified(UrlData {
url: Some("https://raw.githubusercontent.com/procyon-rs/vega_lite_4.rs/master/examples/res/data/stocks.csv".to_string()),
..Default::default()
}),
transform: Some(vec![Transform {
filter: Some(ConditionalValueDefNumberExprRefPredicateComposition::String("datum.symbol==='GOOG'".to_string())),
..Default::default()
}]),
mark: Some(AnyMark::Enum(Mark::Line)),
encoding: Some(Box::new(
EdEncoding {
x: Some(XClass {
field: Some(Field::String("date".to_string())),
position_def_type: Some(Type::Temporal),
..Default::default()
}),
y: Some(YClass {
field: Some(Field::String("price".to_string())),
position_def_type: Some(Type::Quantitative),
..Default::default()
}),
..Default::default()
},
)),
..Default::default()
};
// display the chart using `showata`
chart.show()?;
// print the vega lite spec
eprint!("{}", chart.to_string()?);
Ok(())
}