@@ -2,52 +2,64 @@ import * as Plot from "@observablehq/plot";
22import * as d3 from "d3" ;
33
44export 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 ) ;
66 return Plot . plot ( {
7- y : {
8- grid : true
9- } ,
7+ y : { grid : true } ,
108 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" } ) ,
1311 Plot . ruleY ( [ 0 ] )
1412 ]
1513 } ) ;
1614}
1715
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+
1830export 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 ) ;
2032 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" } ) ]
2234 } ) ;
2335}
2436
2537export 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 ) ;
2739 return Plot . plot ( {
2840 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" } ) ]
3042 } ) ;
3143}
3244
3345export 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" } } ) ;
3648}
3749
3850export 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" } } ) ;
4153}
4254
4355export 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" } } ) ;
4658}
4759
4860export 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 ] } } ) ;
5163}
5264
5365export async function aaplCloseNormalize ( ) {
0 commit comments