jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
718 stars 147 forks source link

Show URL image in xAxis in xaringan slides #747

Closed robertogilsaura closed 1 year ago

robertogilsaura commented 2 years ago

Hi @jbkunst . I'm having an issue mixing highcharter & xaringan or rmarkdown. Images dont' show in document. If you run the script in Rstudio (chunk), images are in the xAxis., but if you knit doc, images dont'display.

Any help?

---
title: "Prueba"
subtitle: "Imagenes en x"  
author: 
  - "Rober"
date: '`r Sys.Date()`'
output:
  xaringan::moon_reader:
    nature:
      slideNumberFormat: "%current%"
      highlightStyle: github
      highlightLines: true
      ratio: 16:9
      countIncrementalSlides: true
---

```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
knitr::opts_chunk$set(
  fig.width=9, fig.height=3.5, fig.retina=3,
  out.width = "100%",
  cache = FALSE,
  echo = FALSE,
  message = FALSE, 
  warning = FALSE,
  hiline = TRUE
)
library(highcharter)

gráfico

x <- c(1,2,3,1,2,3,1,2,3,1,2,3)
y <- c(3,5,3,2,1,2,1,3,5,1,3,4)
logo <- c('psoe.png', 'pp.png', 'up.png','psoe.png', 'pp.png', 'up.png','psoe.png', 'pp.png', 'up.png','psoe.png', 'pp.png', 'up.png')
df <- data.frame(name=x,value=y, logo=logo)
hchart(df, 'column', hcaes(x=name, y=value)) %>%
     hc_xAxis(categories = paste('<img src="https://download.tesigandia.com/cis/',df$logo,'">', sep=''), labels=list(style=list(fontSize='0.8em'), useHTML=TRUE))

background-image: url(https://download.tesigandia.com/imagenes/logoCIS.png)



Thanks in advance for your help ...
jbkunst commented 2 years ago

Hola @robertogilsaura

There is something/issue with the xaringan css. I tried some few ideas but the only one that works is use {widgetframe} package.

x <- c(1,2,3,1,2,3,1,2,3,1,2,3)
y <- c(3,5,3,2,1,2,1,3,5,1,3,4)
logo <- c('psoe.png', 'pp.png', 'up.png','psoe.png', 'pp.png', 'up.png','psoe.png', 'pp.png', 'up.png','psoe.png', 'pp.png', 'up.png')
df <- data.frame(name=x,value=y, logo=logo)
w <- hchart(df, 'column', hcaes(x=name, y=value)) %>%
     hc_xAxis(categories = paste('<img src="https://download.tesigandia.com/cis/',df$logo,'">', sep=''), labels=list(style=list(fontSize='0.8em'), useHTML=TRUE))

widgetframe::frameWidget(w)

image

Hope it helps! Saludos!

robertogilsaura commented 2 years ago

Thanks for your answer @jbkunst .

It doesn't run properly in my test using widgetframe package; result in image. I put my question in xaringanthemer too, because I believe in a xaringan issue. 20211224081358

Felices fiestas y un mejor año 2022!!!

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Feel free to reopen it if you find it necessary.