One way to show a highcharter chart in a blogdown website is:
- Create the chart using highcharter and save it as a variable, for example "mychart".
- Use the "htmlwidgets" package to save the chart as an HTML file:
saveWidget(mychart, "mychart.html")
- Save the "mychart.html" file in the "static" folder of your blogdown project. Note: if your chart uses data that is generated dynamically, you may need to create an R script that generates the data and the chart, and then use the
blogdown::serve_site()
function to update the chart in the HTML file whenever the data changes. - In your blogdown post or page where you want to show the chart, use the "htmltools" package to embed the HTML file in an iframe:
htmltools::tags$iframe(src="mychart.html", width=800, height=600)
(adjust the "width" and "height" values as needed). - Use the "blogdown::serve_site()" function to preview your post or page in a local web browser, or deploy your website to a hosting service to make it accessible to the public.