@@ -209,3 +209,43 @@ test_that("span/size controls errorbar thickness/width", {
209209 expect_true(d [[1 ]]$ error_y $ width == 10 )
210210 expect_true(d [[1 ]]$ error_y $ color == toRGB(" red" ))
211211})
212+
213+
214+ test_that(" Vector of redundant text is reduced to string when hoveron=fills" , {
215+
216+ # see https://github.com/ropensci/plotly/issues/1233
217+ d <- data.frame (
218+ AA = c(2 ,3 ,3 ,2 , NA , 6 ,7 ,7 ,6 , NA ),
219+ BB = c(2 ,2 ,3 ,2 , NA , 6 ,6 ,7 ,6 , NA ),
220+ CC = c(rep(' abc' , 5 ), rep(' xyz' , 5 )),
221+ LL = c(rep(' A' , 5 ), rep(' B' , 5 ))
222+ )
223+
224+
225+ p <- plot_ly(d ) %> %
226+ add_trace(x = ~ AA ,
227+ y = ~ BB ,
228+ text = ~ paste(' <br> <b>Example</b> of <em>custom</em> hover text <br>' , LL , ' <br>' , CC , ' <br>.' ),
229+ split = ~ LL ,
230+ mode = " lines" ,
231+ fill = " toself" ,
232+ hoveron = ' fills' ,
233+ type = " scatter" ,
234+ color = I(c(rep(toRGB(" black" , 1 ), 5 ),
235+ rep(toRGB(" red" , 1 ), 5 )))
236+ )
237+
238+ b <- plotly_build(p )
239+ d <- b $ x $ data
240+ expect_length(d , 2 )
241+ expect_true(d [[1 ]]$ line $ color == toRGB(" black" ))
242+ expect_true(d [[1 ]]$ fillcolor == toRGB(" black" , 0.5 ))
243+ expect_true(d [[2 ]]$ line $ color == toRGB(" red" ))
244+ expect_true(d [[2 ]]$ fillcolor == toRGB(" red" , 0.5 ))
245+ expect_true(
246+ d [[1 ]]$ text == ' <br> <b>Example</b> of <em>custom</em> hover text <br> A <br> abc <br>.'
247+ )
248+ expect_true(
249+ d [[2 ]]$ text == ' <br> <b>Example</b> of <em>custom</em> hover text <br> B <br> xyz <br>.'
250+ )
251+ })
0 commit comments