@@ -4,17 +4,17 @@ import {JSDOM} from "jsdom";
44const { window} = new JSDOM ( "" ) ;
55global . document = window . document ;
66
7- tape ( "plot(…).scales() exposes the plot’s scales" , test => {
7+ tape ( "plot(…).scales exposes the plot’s scales" , test => {
88 const plot = Plot . dot ( [ 1 , 2 ] , { x : d => d , y : d => d } ) . plot ( ) ;
9- test . equal ( typeof plot . scales , "function " ) ;
10- const scales = plot . scales ( ) ;
9+ test . equal ( typeof plot . scales , "object " ) ;
10+ const scales = plot . scales ;
1111 test . equal ( Object . entries ( scales ) . length , 2 ) ;
1212 test . assert ( "x" in scales ) ;
1313 test . assert ( "y" in scales ) ;
1414} ) ;
1515
16- tape ( "plot(…).scales('x') exposes the plot’s x scale" , test => {
17- const x = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales ( 'x' ) ;
16+ tape ( "plot(…).scales.x exposes the plot’s x scale" , test => {
17+ const x = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales . x ;
1818 test . deepEqual ( x . domain , [ 1 , 2 ] ) ;
1919 test . deepEqual ( x . range , [ 20 , 620 ] ) ;
2020 test . equal ( typeof x . interpolate , "function" ) ;
@@ -23,10 +23,10 @@ tape("plot(…).scales('x') exposes the plot’s x scale", test => {
2323 test . equal ( typeof x . scale , "function" ) ;
2424} ) ;
2525
26- tape ( "plot(…).scales('y') exposes the plot’s y scale" , test => {
27- const y0 = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales ( 'y' ) ;
26+ tape ( "plot(…).scales.y exposes the plot’s y scale" , test => {
27+ const y0 = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales . y ;
2828 test . equal ( y0 , undefined ) ;
29- const y = Plot . dot ( [ 1 , 2 ] , { y : d => d } ) . plot ( ) . scales ( 'y' ) ;
29+ const y = Plot . dot ( [ 1 , 2 ] , { y : d => d } ) . plot ( ) . scales . y ;
3030 test . deepEqual ( y . domain , [ 1 , 2 ] ) ;
3131 test . deepEqual ( y . range , [ 380 , 20 ] ) ;
3232 test . equal ( typeof y . interpolate , "function" ) ;
@@ -35,11 +35,11 @@ tape("plot(…).scales('y') exposes the plot’s y scale", test => {
3535 test . equal ( typeof y . scale , "function" ) ;
3636} ) ;
3737
38- tape ( "plot(…).scales('fx') exposes the plot’s fx scale" , test => {
39- const fx0 = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales ( 'fx' ) ;
38+ tape ( "plot(…).scales.fx exposes the plot’s fx scale" , test => {
39+ const fx0 = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales . fx ;
4040 test . equal ( fx0 , undefined ) ;
4141 const data = [ 1 , 2 ] ;
42- const fx = Plot . dot ( data , { y : d => d } ) . plot ( { facet : { data, x : data } } ) . scales ( 'fx' ) ;
42+ const fx = Plot . dot ( data , { y : d => d } ) . plot ( { facet : { data, x : data } } ) . scales . fx ;
4343 test . deepEqual ( fx . domain , [ 1 , 2 ] ) ;
4444 test . deepEqual ( fx . range , [ 40 , 620 ] ) ;
4545 test . equal ( typeof fx . interpolate , "undefined" ) ;
@@ -48,11 +48,11 @@ tape("plot(…).scales('fx') exposes the plot’s fx scale", test => {
4848 test . equal ( typeof fx . scale , "function" ) ;
4949} ) ;
5050
51- tape ( "plot(…).scales('fy') exposes the plot’s fy scale" , test => {
52- const fy0 = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales ( 'fy' ) ;
51+ tape ( "plot(…).scales.fy exposes the plot’s fy scale" , test => {
52+ const fy0 = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales . fy ;
5353 test . equal ( fy0 , undefined ) ;
5454 const data = [ 1 , 2 ] ;
55- const fy = Plot . dot ( data , { y : d => d } ) . plot ( { facet : { data, y : data } } ) . scales ( 'fy' ) ;
55+ const fy = Plot . dot ( data , { y : d => d } ) . plot ( { facet : { data, y : data } } ) . scales . fy ;
5656 test . deepEqual ( fy . domain , [ 1 , 2 ] ) ;
5757 test . deepEqual ( fy . range , [ 20 , 380 ] ) ;
5858 test . equal ( typeof fy . interpolate , "undefined" ) ;
@@ -61,11 +61,11 @@ tape("plot(…).scales('fy') exposes the plot’s fy scale", test => {
6161 test . equal ( typeof fy . scale , "function" ) ;
6262} ) ;
6363
64- tape ( "plot(…).scales(' color') exposes a continuous color scale" , test => {
65- const color0 = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales ( ' color' ) ;
64+ tape ( "plot(…).scales. color exposes a continuous color scale" , test => {
65+ const color0 = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales . color ;
6666 test . equal ( color0 , undefined ) ;
6767 const data = [ 1 , 2 , 3 , 4 , 5 ] ;
68- const color = Plot . dot ( data , { y : d => d , fill : d => d } ) . plot ( ) . scales ( ' color' ) ;
68+ const color = Plot . dot ( data , { y : d => d , fill : d => d } ) . plot ( ) . scales . color ;
6969 test . deepEqual ( color . domain , [ 1 , 5 ] ) ;
7070 test . deepEqual ( color . range , [ 0 , 1 ] ) ;
7171 test . equal ( typeof color . interpolate , "function" ) ;
@@ -74,9 +74,9 @@ tape("plot(…).scales('color') exposes a continuous color scale", test => {
7474 test . equal ( typeof color . scale , "function" ) ;
7575} ) ;
7676
77- tape ( "plot(…).scales(' color') exposes an ordinal color scale" , test => {
77+ tape ( "plot(…).scales. color exposes an ordinal color scale" , test => {
7878 const data = [ "a" , "b" , "c" , "d" ] ;
79- const color = Plot . dot ( data , { y : d => d , fill : d => d } ) . plot ( ) . scales ( ' color' ) ;
79+ const color = Plot . dot ( data , { y : d => d , fill : d => d } ) . plot ( ) . scales . color ;
8080 test . deepEqual ( color . domain , data ) ;
8181 test . deepEqual ( color . range , [ '#4e79a7' , '#f28e2c' , '#e15759' , '#76b7b2' , '#59a14f' , '#edc949' , '#af7aa1' , '#ff9da7' , '#9c755f' , '#bab0ab' ] ) ;
8282 test . equal ( typeof color . interpolate , "undefined" ) ;
@@ -85,11 +85,11 @@ tape("plot(…).scales('color') exposes an ordinal color scale", test => {
8585 test . equal ( typeof color . scale , "function" ) ;
8686} ) ;
8787
88- tape ( "plot(…).scales('r') exposes a radius scale" , test => {
89- const r0 = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales ( 'r' ) ;
88+ tape ( "plot(…).scales.r exposes a radius scale" , test => {
89+ const r0 = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales . r ;
9090 test . equal ( r0 , undefined ) ;
9191 const data = [ 1 , 2 , 3 , 4 , 9 ] ;
92- const r = Plot . dot ( data , { r : d => d } ) . plot ( ) . scales ( 'r' ) ;
92+ const r = Plot . dot ( data , { r : d => d } ) . plot ( ) . scales . r ;
9393 test . deepEqual ( r . domain , [ 0 , 9 ] ) ;
9494 test . deepEqual ( r . range , [ 0 , Math . sqrt ( 40.5 ) ] ) ;
9595 test . equal ( typeof r . interpolate , "function" ) ;
@@ -98,11 +98,11 @@ tape("plot(…).scales('r') exposes a radius scale", test => {
9898 test . equal ( typeof r . scale , "function" ) ;
9999} ) ;
100100
101- tape ( "plot(…).scales(' opacity') exposes a linear scale" , test => {
102- const opacity0 = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales ( ' opacity' ) ;
101+ tape ( "plot(…).scales. opacity exposes a linear scale" , test => {
102+ const opacity0 = Plot . dot ( [ 1 , 2 ] , { x : d => d } ) . plot ( ) . scales . opacity ;
103103 test . equal ( opacity0 , undefined ) ;
104104 const data = [ 1 , 2 , 3 , 4 , 9 ] ;
105- const opacity = Plot . dot ( data , { fillOpacity : d => d } ) . plot ( ) . scales ( ' opacity' ) ;
105+ const opacity = Plot . dot ( data , { fillOpacity : d => d } ) . plot ( ) . scales . opacity ;
106106 test . deepEqual ( opacity . domain , [ 0 , 9 ] ) ;
107107 test . deepEqual ( opacity . range , [ 0 , 1 ] ) ;
108108 test . equal ( typeof opacity . interpolate , "function" ) ;
@@ -133,19 +133,19 @@ tape("plot(…).scales expose label", test => {
133133} ) ;
134134
135135tape ( "plot(…).scales expose color label" , test => {
136- const x = Plot . dot ( [ { x : 1 } , { x : 2 } , { x : 3 } ] , { fill : "x" } ) . plot ( ) . scales ( " color" ) ;
136+ const x = Plot . dot ( [ { x : 1 } , { x : 2 } , { x : 3 } ] , { fill : "x" } ) . plot ( ) . scales . color ;
137137 test . equal ( x . label , "x" ) ;
138- const y = Plot . dot ( [ { x : 1 } , { x : 2 } , { x : 3 } ] , { fill : "x" } ) . plot ( { color : { label : "y" } } ) . scales ( " color" ) ;
138+ const y = Plot . dot ( [ { x : 1 } , { x : 2 } , { x : 3 } ] , { fill : "x" } ) . plot ( { color : { label : "y" } } ) . scales . color ;
139139 test . equal ( y . label , "y" ) ;
140140} ) ;
141141
142142tape ( "plot(…).scales expose radius label" , test => {
143- const x = Plot . dot ( [ { x : 1 } , { x : 2 } , { x : 3 } ] , { r : "x" } ) . plot ( ) . scales ( "r" ) ;
143+ const x = Plot . dot ( [ { x : 1 } , { x : 2 } , { x : 3 } ] , { r : "x" } ) . plot ( ) . scales . r ;
144144 test . equal ( x . label , "x" ) ;
145- const r = Plot . dot ( [ { x : 1 } , { x : 2 } , { x : 3 } ] , { r : "x" } ) . plot ( { color : { label : "radius" } } ) . scales ( "color" ) ;
145+ const r = Plot . dot ( [ { x : 1 } , { x : 2 } , { x : 3 } ] , { r : "x" } ) . plot ( { r : { label : "radius" } } ) . scales . r ;
146146 test . equal ( r . label , "radius" ) ;
147147} ) ;
148148
149149function scaleOpt ( x ) {
150- return Plot . dot ( [ { x : 1 } , { x : 2 } , { x : 3 } ] , { x : "x" } ) . plot ( { x} ) . scales ( "x" ) ;
150+ return Plot . dot ( [ { x : 1 } , { x : 2 } , { x : 3 } ] , { x : "x" } ) . plot ( { x} ) . scales . x ;
151151}
0 commit comments