window-frame
Loading Example... ⏳
Specification
js
import * as vg from "@uwdata/vgplot";
await vg.coordinator().exec([
vg.loadParquet("aapl", "data/stocks.parquet", {where: "Symbol = 'AAPL'"})
]);
export default vg.plot(
vg.lineY(
vg.from("aapl"),
{stroke: "#ccc", x: "Date", y: "Close"}
),
vg.lineY(
vg.from("aapl"),
{
stroke: "black",
x: "Date",
y: vg.avg("Close").orderby("Date").frame(vg.frameRange([vg.days(15), vg.days(15)]))
}
),
vg.lineY(
vg.from("aapl"),
{
stroke: "firebrick",
x: "Date",
y: vg.avg("Close").orderby("Date").frame(vg.frameRange([vg.months(3), vg.months(3)]))
}
),
vg.yLabel("Close"),
vg.width(680),
vg.height(200)
);yaml
data:
aapl: { file: data/stocks.parquet, where: Symbol = 'AAPL' }
plot:
- mark: lineY
data: { from: aapl }
stroke: '#ccc'
x: Date
y: Close
- mark: lineY
data: { from: aapl }
stroke: black
x: Date
y: { avg: Close, orderby: Date, range: [{days: 15}, {days: 15}] }
- mark: lineY
data: { from: aapl }
stroke: firebrick
x: Date
y: { avg: Close, orderby: Date, range: [{months: 3}, {months: 3}] }
yLabel: Close
width: 680
height: 200json
{
"data": {
"aapl": {
"file": "data/stocks.parquet",
"where": "Symbol = 'AAPL'"
}
},
"plot": [
{
"mark": "lineY",
"data": {
"from": "aapl"
},
"stroke": "#ccc",
"x": "Date",
"y": "Close"
},
{
"mark": "lineY",
"data": {
"from": "aapl"
},
"stroke": "black",
"x": "Date",
"y": {
"avg": "Close",
"orderby": "Date",
"range": [
{
"days": 15
},
{
"days": 15
}
]
}
},
{
"mark": "lineY",
"data": {
"from": "aapl"
},
"stroke": "firebrick",
"x": "Date",
"y": {
"avg": "Close",
"orderby": "Date",
"range": [
{
"months": 3
},
{
"months": 3
}
]
}
}
],
"yLabel": "Close",
"width": 680,
"height": 200
}py
import vgplot as vg
aapl = vg.parquet("data/stocks.parquet", where="Symbol = 'AAPL'")
view = vg.plot(
vg.line_y(aapl, stroke="#ccc", x="Date", y="Close"),
vg.line_y(
aapl,
stroke="black",
x="Date",
y=vg.avg(
"Close",
orderby="Date",
range=[
{"days": 15},
{"days": 15},
],
),
),
vg.line_y(
aapl,
stroke="firebrick",
x="Date",
y=vg.avg(
"Close",
orderby="Date",
range=[
{"months": 3},
{"months": 3},
],
),
),
vg.y_label("Close"),
vg.width(680),
vg.height(200),
)