Remove "Edit Chart" from embedded HTML graph made in R

I feel like the answer to this question should be on this site somewhere, but it only seems to relate to Plotly charts made in iframes or another coding. Anyway, I have created a Plotly chart in R Studio and uploaded it to my Plotly account directly from the program. I have taken the given HTML code from the Plotly website for embedding the graph on my Squarespace website and it works great. However, I cannot seem to find any way described online to manipulate the HTML to hide “Edit Chart.” I came across a StackExchange post indicating I could do:

p %>% config(showLink = F)

I tried this in R Studio before uploading it again to my online Plotly account, but the embedded chart on Squarespace still shows the “Edit Chart” button. Anyone have any luck hiding the link in HTML embeds?

1 Like

Thanks for writing in.

The config options set via our API libraries are overrode on graphs hosted on plot.ly. In other words, the config options only have an effect for offline users.

To remove the “Edit Chart” link, try adding ?showlink=false to the URL of the graph you want to embed. For example,

Hi Etienne–

Thank you for the advice. I tried this out and it still doesn’t appear to be working. The embed is on Squarespace inside one of their code blocks. Here is the HTML I’m inserting (including your suggestion of adding “?showlink=false”

Probability of Continued Purchase by # of Transactions (1 Year)

Is there somewhere else I should add the “?showlink=false” or anything else I can change?

Thanks!
John

Hi Etienne–

I’ve solved the problem. Specifically in Squarespace, you need to embed the Plotly chart as an iframe. You do this by using an “Embed” code block rather than “Code.” If you insert the iframe code by clicking on the “</>” in the Embed block and pasting in. Then the “?showlink=false” piece works!

Thanks,
John

2 Likes

If embedding as an iframe isn’t an option for you (it wasn’t formatting well for me on our system), I’ve figured out the way to do it using the generated HTML code.

So for anyone who was flummoxed as I was, I just wanted to share what I finally figured out by reading through the current embed.js code:
In the set of attributes fed over to the script:

<script data-plotly="something:21" sharekey-plotly="YOURSHAREKEY" src="https://plot.ly/embed.js" async=""></script>

Simply add:

<script data-plotly="something:21" sharekey-plotly="YOURSHAREKEY&link=false" src="https://plot.ly/embed.js" async=""></script>
2 Likes

Thanks for this tbenyaliion! It also works for the other embed options, such as modebar=false.

Plotly mods, this should be added to the documentation please! It could sit alongside the bit about customising the iframe.