fmmattioni / downloadthis

Implement Download Buttons in rmarkdown 💾
https://fmmattioni.github.io/downloadthis/
Other
147 stars 5 forks source link

Plotly #16

Closed Csmolarchuk closed 3 years ago

Csmolarchuk commented 3 years ago

Hi,

I tried to use this package because it would be super useful. However, when I try to use it with plotly instead of ggplot2 it seems to shift all the text on the axes, so I haven't been able to use it.

Thanks

fmmattioni commented 3 years ago

Hi @Csmolarchuk!

Thanks! Could you please provide a reproducible example?

Csmolarchuk commented 3 years ago

Sure! Below is some code that I ran in an rmd. When it gets knitted the y axis text gets shifted below the button. I had tried separating the graph and the button into separate chunks and that didn't seem to fix the issue either.


title: "Untitled" output: html_document

knitr::opts_chunk$set(echo = TRUE)
library(downloadthis)
library(plotly)
library(tidyverse)

data(mtcars)

plot_ly(mtcars %>% group_by(cyl, am) %>% tally(),
                          x= ~am, 
                          y= ~cyl,
                          type="bar") %>%
  layout( title ="mtcars", 
          xaxis=list(tickangle=90, title="AM"),
          yaxis=list (title="Here is some text for the axis"))

mtcars %>% 
  download_this(
    output_name = "mtcars dataset",
    output_extension = ".csv",
    button_label = "Download data as csv",
    button_type = "default",
    has_icon = TRUE,
    icon = "fa fa-save"
  )
fmmattioni commented 3 years ago

Hi @Csmolarchuk,

I am sorry for the delay. I haven't been able to find a solution for this yet, so I am including in here the help wanted label. I will look at it further this week.

alf-ken commented 3 years ago

Hi,

I've got the same problem. Interestingly, this happens, if you place the buttons under the plot. Placing it above the plot, the issue doesn't occur.

Chris

laugon10 commented 2 years ago

Same problem here! Any solution?