0

I am trying to use plotly to develop a gannet chart with detailed information as hoverinfo. However, due to the length of the text string, the hoverinfo is too hard to read (as below). I wonder if I can somehow wrap the hoverinfo to make it more readable. enter image description here

Here is the code that I have come up with:

df = data.frame(a='High',
                info="this text doesn't mean anything and it's only here as a demonstration. You can replace this with anything else
                and I want to somehow wrap this text",
                start=as.Date("31/12/2015","%d/%m/%Y"),
                end = as.Date("31/12/2016","%d/%m/%Y"))
p = plot_ly()

p <- add_trace(p,
                 x = c(df$start[1], df$end[1]),  # x0, x1
                 y = c(1,1),  # y0, y1
                 mode = "lines",
                 line = list(color ="#FF6600", width = 20),
                 showlegend = F,
                 hoverinfo = "text",
                 text = df$info[1],
                 evaluate = T
                 #hoverinfo = "value"
)
p
Cypress
  • 357
  • 1
  • 2
  • 10
  • Just use `
    ` in between along with `paste` like HTML text, and it should render properly. I say `paste` not for this specific case, but in general when you want to create custom hover with multiple fields and values, and line breaks, you can do so.
    – Gopala Jun 26 '16 at 04:18
  • Hi.I think my question is slightly different from the other post. The "info" var is one string and I need to somehow insert `
    ` in it (may be at the end of each sentence). However, the other post is to insert `
    ` in between two different strings.
    – Cypress Jun 26 '16 at 09:35

0 Answers0