animint
animint copied to clipboard
vjust support
- [ ] a test for values of 0, 0.5, 1-- draw an hline at say y=5, then draw some text at x=1,2,3 and y=5 with vjust=0,0.5,1. Test that bounding box of text element is on either side or in the middle of the bounding box for the hline.
- [ ] similar test for hjust.
- [ ] use the
measureTextJS function to get the height and width of a text element, and use that to compute vjust. - [ ] also use that for hjust instead of
text-anchorproperty. - [ ] also use that for text elements that are not geoms, for example axis tick labels.
line.df <- data.frame(just=c(0, 0.5, 1))
text.df <- expand.grid(
vjust=line.df$just,
hjust=line.df$just)
gg.lines <- ggplot()+
theme_bw()+
geom_vline(aes(xintercept=just), data=line.df, color="grey")+
geom_hline(aes(yintercept=just), data=line.df, color="grey")
gg.vjust <- gg.lines+
ggtitle("animint does not support aes(vjust)")+
geom_text(aes(hjust, vjust, label="qwerty", hjust=hjust, vjust=vjust),
data=text.df)
no.vjust <- gg.lines+
ggtitle("workaround: no aes(vjust), add to y")+
geom_text(aes(hjust, vjust + (0.5-vjust)*0.03 - 0.01,
label="qwerty", hjust=hjust),
data=text.df)
viz.just <- list(
vjust=gg.vjust,
workaround=no.vjust)
viz.just
structure(viz.just, class="animint")