I have a problem. When I create an interactive heatmap or line chart, the output graphic does not behave dynamically; the SVG is always set to a fixed size. This problem cannot be solved with opts_sizing(rescale = TRUE, width = 1) either.
interactive_heatmap = function(data){
df = data[[1]] # data
print(df)
days = unique(data[[1]]["Tag"]) # tage
sequenz = max(days$Tag) # last day
s_min = min(days$Tag) # fist day
color = data[[2]] # cols
textcol = "#303665"
ddd = data[[1]]["date"][,1][11,] # pick date
ddd[, "month"] = format(ddd$date, format = "%m") # pick date
ddd[, "Year"] = format(ddd$date, format = "%Y") #pick date
mon = return_month(ddd$month) # mon
#heatmap
plt <-ggplot(df, aes(x=hours_only , y=Tag, fill=countfactor ))+
geom_tile_interactive(aes(tooltip = text_new, data_id = text_new), colour = "white")+
geom_text(aes(label=round(temperature)), size = 4)+
scale_fill_manual(values=color, na.value = "grey90")+
guides(fill=guide_legend(title="T [°C]"))+
theme_linedraw(base_size=10)+
labs(x = "Hour", y = "Day", size = 2)+
ggtitle(paste0("Hourly Temperature in ", mon," ", ddd$Year))+
theme(legend.position="right", legend.direction="vertical",
legend.title=element_text(size = 10,colour=textcol),
legend.margin=margin(grid::unit(0, "cm")),
legend.text=element_text(colour=textcol, size=9, face="bold"),
legend.key.height=grid::unit(0.8, "cm"),
legend.key.width=grid::unit(0.2, "cm"),
axis.text.x=element_text(size=10, colour=textcol),
axis.text.y=element_text(size = 10, vjust=0.2, colour=textcol),
axis.ticks=element_line(size=0.4, colour = textcol),
axis.title = element_text(size = 12, color = textcol),
plot.background=element_blank(),
panel.border=element_blank(),
plot.margin=margin(0.7, 0.4, 0.1, 0.2, "cm"),
plot.title=element_text(colour=textcol, hjust=0, size=20, face="bold"))+
scale_x_continuous(breaks = seq(from = 0, to = 23, by = 3))+
scale_y_continuous(breaks = seq(s_min,sequenz+s_min-1,1))
return(plt)
}
dd = interactive_heatmap(gd)
date temperature testdate text_new hours hours_only Tag Index countfactor
1 2022-07-01 00:00:00 13.7 01.07.2022 00:00 01.07.2022 00:00
13.7 °C 00:00:00 0 1 NA 13 - 15
2 2022-07-01 01:00:00 13.4 01.07.2022 01:00 01.07.2022 01:00
13.4 °C 01:00:00 1 1 NA 13 - 15
3 2022-07-01 02:00:00 13.0 01.07.2022 02:00 01.07.2022 02:00
13 °C 02:00:00 2 1 NA 11 - 13
4 2022-07-01 03:00:00 12.4 01.07.2022 03:00 01.07.2022 03:00
12.4 °C 03:00:00 3 1 NA 11 - 13
5 2022-07-01 04:00:00 12.0 01.07.2022 04:00 01.07.2022 04:00
12 °C 04:00:00 4 1 NA 11 - 13
6 2022-07-01 05:00:00 11.7 01.07.2022 05:00 01.07.2022 05:00
11.7 °C 05:00:00 5 1 NA 11 - 13
7 2022-07-01 06:00:00 11.9 01.07.2022 06:00 01.07.2022 06:00
11.9 °C 06:00:00 6 1 NA 11 - 13
8 2022-07-01 07:00:00 12.9 01.07.2022 07:00 01.07.2022 07:00
12.9 °C 07:00:00 7 1 NA 11 - 13
9 2022-07-01 08:00:00 14.4 01.07.2022 08:00 01.07.2022 08:00
14.4 °C 08:00:00 8 1 NA 13 - 15
10 2022-07-01 09:00:00 15.5 01.07.2022 09:00 01.07.2022 09:00
15.5 °C 09:00:00 9 1 NA 15 - 17
ℹ 734 more rows
girafe(ggobj = dd, options = list(
opts_tooltip(css = "background-color:rgba(51, 51, 51, 0.75); color:white; padding:2px; border-radius:5px; font-size:12px; border:1px solid #303665;", opacity = 1),
opts_sizing(rescale =TRUE, width = 1)
))
[enter image description here](https://i.stack.imgur.com/ZolJn.jpg)