@@ -11,24 +11,24 @@ assert('g2() accepts data and aesthetics', {
1111 df = data.frame (x = 1 : 3 , y = 4 : 6 )
1212 chart = g2(df , x = ' x' , y = ' y' )
1313 (identical(chart $ data , df ))
14- (chart $ aesthetics $ x == ' x' )
15- (chart $ aesthetics $ y == ' y' )
14+ (chart $ aesthetics $ x % == % ' x' )
15+ (chart $ aesthetics $ y % == % ' y' )
1616})
1717
1818# encode() maps aesthetics as character strings
1919assert(' encode() maps column names to aesthetics' , {
2020 chart = g2() | > encode(x = ' foo' , y = ' bar' , color = ' baz' )
21- (chart $ aesthetics $ x == ' foo' )
22- (chart $ aesthetics $ y == ' bar' )
23- (chart $ aesthetics $ color == ' baz' )
21+ (chart $ aesthetics $ x % == % ' foo' )
22+ (chart $ aesthetics $ y % == % ' bar' )
23+ (chart $ aesthetics $ color % == % ' baz' )
2424})
2525
2626# mark_*() functions add layers
2727assert(' mark_point() and mark_line() add layers' , {
2828 chart = g2() | > mark_point() | > mark_line()
29- (length(chart $ layers ) == 2 )
30- (chart $ layers [[1 ]]$ type == ' point' )
31- (chart $ layers [[2 ]]$ type == ' line' )
29+ (length(chart $ layers ) % == % 2L )
30+ (chart $ layers [[1 ]]$ type % == % ' point' )
31+ (chart $ layers [[2 ]]$ type % == % ' line' )
3232})
3333
3434# build_config() produces correct spec with column-major data
@@ -37,20 +37,20 @@ assert('build_config() produces correct spec', {
3737 chart = g2(df , x = ' x' , y = ' y' ) | >
3838 mark_interval() | >
3939 scale_of(' y' , nice = TRUE )
40- config = gglite ::: build_config(chart )
40+ config = build_config(chart )
4141
4242 # spec should NOT contain constructor options
4343 (is.null(config $ width ))
4444 (is.null(config $ height ))
4545 # data should be annotated as column-major
46- (config $ data $ type == ' column' )
46+ (config $ data $ type % == % ' column' )
4747 (is.data.frame(config $ data $ value ))
4848 # marks
49- (length(config $ children ) == 1 )
50- (config $ children [[1 ]]$ type == ' interval' )
51- (config $ children [[1 ]]$ encode $ x == ' x' )
52- (config $ children [[1 ]]$ encode $ y == ' y' )
53- (config $ scale $ y $ nice == TRUE )
49+ (length(config $ children ) % == % 1L )
50+ (config $ children [[1 ]]$ type % == % ' interval' )
51+ (config $ children [[1 ]]$ encode $ x % == % ' x' )
52+ (config $ children [[1 ]]$ encode $ y % == % ' y' )
53+ (config $ scale $ y $ nice % == % TRUE )
5454})
5555
5656# chart_html() generates valid HTML with G2.Chart constructor args
@@ -72,32 +72,32 @@ assert('chart_html() generates correct HTML structure', {
7272# transform_of() adds transforms to the last mark
7373assert(' transform_of() adds transforms' , {
7474 chart = g2() | > mark_interval() | > transform_of(' stackY' )
75- (length(chart $ layers [[1 ]]$ transform ) == 1 )
76- (chart $ layers [[1 ]]$ transform [[1 ]]$ type == ' stackY' )
75+ (length(chart $ layers [[1 ]]$ transform ) % == % 1L )
76+ (chart $ layers [[1 ]]$ transform [[1 ]]$ type % == % ' stackY' )
7777})
7878
7979# coord_transpose() adds transpose transform
8080assert(' coord_transpose() adds transpose transform' , {
8181 chart = g2() | > mark_interval() | > coord_transpose()
82- (length(chart $ coords $ transform ) == 1 )
83- (chart $ coords $ transform [[1 ]]$ type == ' transpose' )
82+ (length(chart $ coords $ transform ) % == % 1L )
83+ (chart $ coords $ transform [[1 ]]$ type % == % ' transpose' )
8484})
8585
8686# facet_rect() sets facet config
8787assert(' facet_rect() sets faceting' , {
8888 chart = g2() | > mark_point() | > facet_rect(x = ' Species' )
89- (chart $ facet $ type == ' facetRect' )
90- (chart $ facet $ encode $ x == ' Species' )
91- config = gglite ::: build_config(chart )
92- (config $ type == ' facetRect' )
93- (config $ encode $ x == ' Species' )
89+ (chart $ facet $ type % == % ' facetRect' )
90+ (chart $ facet $ encode $ x % == % ' Species' )
91+ config = build_config(chart )
92+ (config $ type % == % ' facetRect' )
93+ (config $ encode $ x % == % ' Species' )
9494})
9595
9696# animate() sets animation on last mark
9797assert(' animate() sets animation options' , {
9898 chart = g2() | > mark_interval() | >
9999 animate(enter = list (type = ' fadeIn' ))
100- (chart $ layers [[1 ]]$ animate $ enter $ type == ' fadeIn' )
100+ (chart $ layers [[1 ]]$ animate $ enter $ type % == % ' fadeIn' )
101101})
102102
103103# theme_of(), axis_of(), legend_of(), title_of() set chart options
@@ -108,10 +108,10 @@ assert('component functions set chart options', {
108108 axis_of(' x' , title = ' MPG' ) | >
109109 legend_of(' color' , position = ' right' ) | >
110110 title_of(' Cars' )
111- (chart $ theme $ type == ' dark' )
112- (chart $ axes $ x $ title == ' MPG' )
113- (chart $ legends $ color $ position == ' right' )
114- (chart $ chart_title == ' Cars' )
111+ (chart $ theme $ type % == % ' dark' )
112+ (chart $ axes $ x $ title % == % ' MPG' )
113+ (chart $ legends $ color $ position % == % ' right' )
114+ (chart $ chart_title % == % ' Cars' )
115115})
116116
117117# End-to-end pipe chaining
@@ -122,61 +122,61 @@ assert('pipe chaining works end-to-end', {
122122 coordinate(' polar' ) | >
123123 interact(' tooltip' )
124124 (inherits(chart , ' g2' ))
125- (length(chart $ layers ) == 1 )
126- (chart $ scales $ x $ type == ' linear' )
127- (chart $ coords $ type == ' polar' )
128- (length(chart $ interactions ) == 1 )
125+ (length(chart $ layers ) % == % 1L )
126+ (chart $ scales $ x $ type % == % ' linear' )
127+ (chart $ coords $ type % == % ' polar' )
128+ (length(chart $ interactions ) % == % 1L )
129129})
130130
131131# g2_cdn() is customizable via option
132132assert(' g2_cdn() respects gglite.g2_cdn option' , {
133133 old = getOption(' gglite.g2_cdn' )
134134 options(gglite.g2_cdn = ' https://example.com/g2.js' )
135- res = gglite ::: g2_cdn()
135+ res = g2_cdn()
136136 options(gglite.g2_cdn = old )
137- (res == ' https://example.com/g2.js' )
137+ (res % == % ' https://example.com/g2.js' )
138138})
139139
140140# annotate_df correctly wraps data frames
141141assert(' annotate_df() wraps data frames' , {
142142 x = list (data = data.frame (a = 1 : 3 ), children = list (
143143 list (type = ' point' , data = data.frame (b = 4 : 6 ))
144144 ))
145- res = gglite ::: annotate_df(x )
146- (res $ data $ type == ' column' )
145+ res = annotate_df(x )
146+ (res $ data $ type % == % ' column' )
147147 (is.data.frame(res $ data $ value ))
148- (res $ children [[1 ]]$ data $ type == ' column' )
148+ (res $ children [[1 ]]$ data $ type % == % ' column' )
149149})
150150
151151# coord_*() shortcut functions
152152assert(' coord_polar() sets polar coordinate' , {
153153 chart = g2() | > mark_interval() | > coord_polar()
154- (chart $ coords $ type == ' polar' )
154+ (chart $ coords $ type % == % ' polar' )
155155})
156156
157157assert(' coord_theta() sets theta coordinate' , {
158158 chart = g2() | > mark_interval() | > coord_theta(innerRadius = 0.5 )
159- (chart $ coords $ type == ' theta' )
160- (chart $ coords $ innerRadius == 0.5 )
159+ (chart $ coords $ type % == % ' theta' )
160+ (chart $ coords $ innerRadius % == % 0.5 )
161161})
162162
163163assert(' coord_radial() sets radial coordinate' , {
164164 chart = g2() | > mark_interval() | > coord_radial()
165- (chart $ coords $ type == ' radial' )
165+ (chart $ coords $ type % == % ' radial' )
166166})
167167
168168# theme_*() shortcut functions
169169assert(' theme_classic() sets classic theme' , {
170170 chart = g2() | > mark_point() | > theme_classic()
171- (chart $ theme $ type == ' classic' )
171+ (chart $ theme $ type % == % ' classic' )
172172})
173173
174174assert(' theme_dark() sets dark theme' , {
175175 chart = g2() | > mark_point() | > theme_dark()
176- (chart $ theme $ type == ' dark' )
176+ (chart $ theme $ type % == % ' dark' )
177177})
178178
179179assert(' theme_academy() sets academy theme' , {
180180 chart = g2() | > mark_point() | > theme_academy()
181- (chart $ theme $ type == ' academy' )
181+ (chart $ theme $ type % == % ' academy' )
182182})
0 commit comments