@@ -2,52 +2,64 @@ import * as Plot from "@observablehq/plot";
2
2
import * as d3 from "d3" ;
3
3
4
4
export async function aaplClose ( ) {
5
- const AAPL = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
5
+ const aapl = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
6
6
return Plot . plot ( {
7
- y : {
8
- grid : true
9
- } ,
7
+ y : { grid : true } ,
10
8
marks : [
11
- Plot . areaY ( AAPL , { x : "Date" , y : "Close" , fillOpacity : 0.1 } ) ,
12
- Plot . lineY ( AAPL , { x : "Date" , y : "Close" } ) ,
9
+ Plot . areaY ( aapl , { x : "Date" , y : "Close" , fillOpacity : 0.1 } ) ,
10
+ Plot . lineY ( aapl , { x : "Date" , y : "Close" } ) ,
13
11
Plot . ruleY ( [ 0 ] )
14
12
]
15
13
} ) ;
16
14
}
17
15
16
+ export async function aaplCloseClip ( ) {
17
+ const aapl = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
18
+ return Plot . plot ( {
19
+ clip : true ,
20
+ x : { domain : [ new Date ( Date . UTC ( 2015 , 0 , 1 ) ) , new Date ( Date . UTC ( 2015 , 3 , 1 ) ) ] } ,
21
+ y : { grid : true } ,
22
+ marks : [
23
+ Plot . areaY ( aapl , { x : "Date" , y : "Close" , fillOpacity : 0.1 } ) ,
24
+ Plot . lineY ( aapl , { x : "Date" , y : "Close" } ) ,
25
+ Plot . ruleY ( [ 0 ] , { clip : false } )
26
+ ]
27
+ } ) ;
28
+ }
29
+
18
30
export async function aaplCloseDataTicks ( ) {
19
- const AAPL = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
31
+ const aapl = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
20
32
return Plot . plot ( {
21
- marks : [ Plot . axisY ( d3 . ticks ( 0 , 200 , 10 ) , { anchor : "left" } ) , Plot . lineY ( AAPL , { x : "Date" , y : "Close" } ) ]
33
+ marks : [ Plot . axisY ( d3 . ticks ( 0 , 200 , 10 ) , { anchor : "left" } ) , Plot . lineY ( aapl , { x : "Date" , y : "Close" } ) ]
22
34
} ) ;
23
35
}
24
36
25
37
export async function aaplCloseImplicitGrid ( ) {
26
- const AAPL = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
38
+ const aapl = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
27
39
return Plot . plot ( {
28
40
y : { grid : true } , // appears even though there’s an explicit axis
29
- marks : [ Plot . axisY ( { anchor : "left" } ) , Plot . lineY ( AAPL , { x : "Date" , y : "Close" } ) ]
41
+ marks : [ Plot . axisY ( { anchor : "left" } ) , Plot . lineY ( aapl , { x : "Date" , y : "Close" } ) ]
30
42
} ) ;
31
43
}
32
44
33
45
export async function aaplCloseGridColor ( ) {
34
- const AAPL = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
35
- return Plot . lineY ( AAPL , { x : "Date" , y : "Close" } ) . plot ( { y : { grid : "red" } } ) ;
46
+ const aapl = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
47
+ return Plot . lineY ( aapl , { x : "Date" , y : "Close" } ) . plot ( { y : { grid : "red" } } ) ;
36
48
}
37
49
38
50
export async function aaplCloseGridInterval ( ) {
39
- const AAPL = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
40
- return Plot . lineY ( AAPL , { x : "Date" , y : "Close" } ) . plot ( { x : { grid : "3 months" } } ) ;
51
+ const aapl = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
52
+ return Plot . lineY ( aapl , { x : "Date" , y : "Close" } ) . plot ( { x : { grid : "3 months" } } ) ;
41
53
}
42
54
43
55
export async function aaplCloseGridIntervalName ( ) {
44
- const AAPL = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
45
- return Plot . lineY ( AAPL , { x : "Date" , y : "Close" } ) . plot ( { x : { grid : "month" } } ) ;
56
+ const aapl = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
57
+ return Plot . lineY ( aapl , { x : "Date" , y : "Close" } ) . plot ( { x : { grid : "month" } } ) ;
46
58
}
47
59
48
60
export async function aaplCloseGridIterable ( ) {
49
- const AAPL = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
50
- return Plot . lineY ( AAPL , { x : "Date" , y : "Close" } ) . plot ( { y : { grid : [ 100 , 120 , 140 ] } } ) ;
61
+ const aapl = await d3 . csv < any > ( "data/aapl.csv" , d3 . autoType ) ;
62
+ return Plot . lineY ( aapl , { x : "Date" , y : "Close" } ) . plot ( { y : { grid : [ 100 , 120 , 140 ] } } ) ;
51
63
}
52
64
53
65
export async function aaplCloseNormalize ( ) {
0 commit comments