@@ -1392,6 +1392,52 @@ it("plot(…).scale(name) reflects the given custom interpolator", async () => {
1392
1392
} ) ;
1393
1393
} ) ;
1394
1394
1395
+ it ( "plot(…).scale(name).interval changes the domain and sets the transform option for ordinal scales" , async ( ) => {
1396
+ const requests = [ [ 2002 , 9 ] , [ 2003 , 17 ] , [ 2004 , 12 ] , [ 2005 , 5 ] , [ 2006 , 12 ] , [ 2007 , 18 ] , [ 2008 , 16 ] , [ 2009 , 11 ] , [ 2010 , 9 ] , [ 2011 , 8 ] , [ 2012 , 9 ] , [ 2019 , 20 ] ] ;
1397
+ const plot = Plot . barY ( requests , { x : "0" , y : "1" } ) . plot ( { x : { interval : 1 } } ) ;
1398
+ scaleEqual ( plot . scale ( "x" ) , {
1399
+ align : 0.5 ,
1400
+ bandwidth : 29 ,
1401
+ domain : d3 . range ( 2002 , 2020 ) ,
1402
+ interval : 1 ,
1403
+ label : "0" ,
1404
+ paddingInner : 0.1 ,
1405
+ paddingOuter : 0.1 ,
1406
+ range : [ 40 , 620 ] ,
1407
+ round : true ,
1408
+ step : 32 ,
1409
+ type : "band"
1410
+ } ) ;
1411
+ } ) ;
1412
+
1413
+ it ( "plot(…).scale(name).interval reflects the interval option for quantitative scales" , async ( ) => {
1414
+ const penguins = await d3 . csv ( "data/penguins.csv" , d3 . autoType ) ;
1415
+ const plot = Plot . dotX ( penguins , { x : "body_mass_g" } ) . plot ( { x : { interval : 50 } } ) ;
1416
+ scaleEqual ( plot . scale ( "x" ) , {
1417
+ clamp : false ,
1418
+ domain : [ 2700 , 6300 ] ,
1419
+ interpolate : d3 . interpolateNumber ,
1420
+ interval : 50 ,
1421
+ label : "body_mass_g →" ,
1422
+ range : [ 20 , 620 ] ,
1423
+ type : "linear"
1424
+ } ) ;
1425
+ } ) ;
1426
+
1427
+ it ( "The interval option is reusable for ordinal scales" , async ( ) => {
1428
+ const requests = [ [ 2002 , 9 ] , [ 2003.5 , 17 ] , [ 2005.9 , 5 ] ] ;
1429
+ const plot1 = Plot . barY ( requests , { x : "0" , y : "1" } ) . plot ( { x : { interval : 1 } , className : "a" } ) ;
1430
+ const plot2 = Plot . barY ( requests , { x : "0" , y : "1" } ) . plot ( { x : plot1 . scale ( "x" ) , className : "a" } ) ;
1431
+ assert . strictEqual ( plot1 . innerHTML , plot2 . innerHTML ) ;
1432
+ } ) ;
1433
+
1434
+ it ( "The interval option is reusable for quantitative scales" , async ( ) => {
1435
+ const requests = [ [ 2002 , 9 ] , [ 2003.5 , 17 ] , [ 2005.9 , 5 ] ] ;
1436
+ const plot1 = Plot . dot ( requests , { x : "0" , y : "1" } ) . plot ( { x : { interval : 1 } , className : "a" } ) ;
1437
+ const plot2 = Plot . dot ( requests , { x : "0" , y : "1" } ) . plot ( { x : plot1 . scale ( "x" ) , className : "a" } ) ;
1438
+ assert . strictEqual ( plot1 . innerHTML , plot2 . innerHTML ) ;
1439
+ } ) ;
1440
+
1395
1441
it ( "plot(…).scale('color') allows a range to be specified in conjunction with a scheme" , async ( ) => {
1396
1442
const gistemp = await d3 . csv ( "data/gistemp.csv" , d3 . autoType ) ;
1397
1443
const plot = Plot . dot ( gistemp , { x : "Date" , fill : "Anomaly" } ) . plot ( { color : { range : [ 0 , 0.5 ] , scheme : "cool" } } ) ;
0 commit comments