1

I'm making a simple chart in Dygraphs R, and the title is too long to fit on one line. For example:

library(tibble)
library(dygraphs)

dat <- tibble(x = 1:10, y = 11:20)

dygraph(dat, 
    main = "THIS TITLE HAS ONE LINE <br> THIS TITLE HAS TWO LINES <br> THIRD LINE")

Example graph here

The second and third lines are all up in the graph's business and the legend obscures the title. How do I shorten the chart area to make room for the main title and the legend?

  • Is there a reason you aren't using `ggplot2`? I know through that you can completely customize the entire plot, plot area, title, etc. – Bear Nov 01 '18 at 15:43
  • I use ggplot for most things, but this is for an interactive dashboard that Dygraph looks great in. – Ryan Gentzler Nov 01 '18 at 17:05

1 Answers1

0

You should create a dygraph.css file in your working directory, and there to write following things:

.dygraph-title {
background-color: white;
color:black;
text-align: left;
margin-left: 5%;
}

after that to add call function to the main one:

    library(tibble)
    library(dygraphs)

    dat <- tibble(x = 1:10, y = 11:20)

    dygraph(dat, 
        main = "THIS TITLE HAS ONE LINE <br> THIS TITLE HAS TWO LINES <br> THIRD LINE")%>%
        dyCSS("dygraph.css")
Maksym Moroz
  • 306
  • 2
  • 14