I want to include some text above the graphics in the main area of a frame in Flexdashboard storyboard. Here's the minimal example.
---
title: "Title"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
horizontal_layout: scroll
runtime: shiny
---
Storyboard name {.storyboard}
=====================================================================
### Storyboard frame 1
```{r}
renderPlot({
plot(rnorm(1e3))
})
```
>Footnote
***
Data commentary text.
When I add the text just above and outside the R chunk, the graph gets truncated at the bottom.
The graph needs to be inside renderPlot() to include interactive elements. It appears the problem is because the height parameter of renderPlot() is "auto", which automatically sets the height of the graphic to the height of the whole frame, and since the text is included, the height that it sets means the graph doesn't fit the area less the text and gets truncated. I found by experimenting the height can be set to a fixed size in pixels. I can set the height in pixels by trial-and-error that would look OK on my screen, but unfortunately it doesn't fully solve the problem, because users who open the app in a different screen resolution would get a messed up layout.
Personally speaking, fixing the height is not a big issue, fixing the width is the bigger problem for users with different screens. Both overflow height and width can be converted to a scrollable page, but it is always comfortable to scroll the document vertically but not horizontally, and this is what most websites are doing. Anyhow, if you don't want to fix the height of the plot with px, the easiest way is to add a scroll bar to the left column so users can scroll and see the hidden content:
Add this chunk and you are all set.
```{css}
.chart-wrapper .chart-stage {
overflow-y: auto;
}
```
Related
I have a flexdasboard with a page that contains 1 plot then below it a table. The table currently is compressed, so whilst it shows 25 rows it has them all within a scroll option so you can only view 2 of those rows at a time. How can I change this?
I am currently coding this with:
---
title: "Plots and tables"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
---
{r setup, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(dplyr)
library(tidyverse)
library(data.table)
library(plotly)
library(htmlwidgets)
library(DT)
Page 1 {style="position:relative;"}
================================
{r fig.width=14, fig.height=10}
plotlyp1 <- ggplotly(p1)
plotlyp1
Row {style="height:100pc;"}
--------------------------------------------------------
### {data-height=10000}
{r}
DT::datatable(one.data_bp,
rownames = FALSE, options = list(pageLength = 25, lengthMenu = c(5, 10, 15, 20)), filter = 'top', height=10000
)
I've removed the back ticks so everything is visible as code. The table this outputs looks like this:
So this has the 25 rows like I code for, but they are condensed and need scrolling with only 1 or 2 rows immediately visible at a time, how do I change the height of the table so at least 5/25 of the rows are visible?
Edit: I've technically fixed it and increased the number of rows visible by changing the Row setting to:
Row {.tabset .tabset-fade}
--------------------------------------------------------
Luckily I don't mind the table looking like it's in a tab, but I feel like this isn't the best or most direct fix, is there anything I can do?
An answer to this had been posted in another forum: https://community.rstudio.com/t/dt-datatable-output-too-small-in-rmarkdown-flesxdashboard/124243/3. The datatable will be height-adjusted based on the available space. The following code has to be pasted after the YAML header (so the approach is similar to nap's answer).
<style>
.dataTables_scrollBody {
max-height: 100% !important;
}
</style>
I had the same problem as you, but only on one PC, not on another. Maybe something about the version of a package, but this code helped.
Had the same issue and I wasn't able to find an rmarkdown option or a DT option to fix this, but this worked for me - I put this CSS style to my rmarkdown:
<style>
.dataTables_scrollBody {
height:400px !important;
max-height:400px !important;
}
.chart-stage-flex {
overflow:auto !important;
}
</style>
Both height and max-height need to be there, but I don't believe they need to match. You can try different arguments for each, but for me, 100% created a container that was too large and didn't scroll. And there are other height arguments you may wish to try: https://developer.mozilla.org/en-US/docs/Web/CSS/height.
Since I used a fixed height, I added overflow:auto style to .chart-stage-flex so that a scroll bar would appear when the window is smaller than 400px.
I'd love to hear if anyone knows how to control this from DT or knitr, etc.
I am using RMarkdown to create an ioslide presentation with shiny.
Some of my slides do not actually fit on one page and are truncated.
Since this is a HTML output, I would like to add a scroll bar to make my long slides scrollable.
I have been googling a lot and found a partial solution to make R code chunks scrollable. However I want to make my slides scrollable regardless of the content.
This is a toy Rmd example giving slides not fitting on one page:
---
title: "Untitled"
date: "30 October 2018"
output: ioslides_presentation
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## Shiny Presentation
- A very long
- and boring
- list of
- bullet points
- just a
- toy example
- obviously
- not over yet
- almost
- not quite
- finally
- out of frame!
I would like to make this slide scrollable since it does not fit on one page.
Edit: I am not sure why this is being heavily downvoted - would appreciate a constructive comment :) In the meantime, I did remove the css tag which may have brought people not familiar with rmarkdown.
Self-answer:
The bit of CSS that will make the slide scrollable (both horizontally and vertically but you just have to remove one line if only vertical scrolling is needed) is:
slides > slide {
overflow-x: auto !important;
overflow-y: auto !important;
}
Note that the slide gets a height from ioslide so there is no need to specify a height (and in fact it seems to introduce visual glitches if you do). Using auto instead of scroll makes sure a scrollbar only appears when there is a need.
You can either add this CSS directly in the Rmd in between <style> tags or put the CSS in a separate file (e.g. scrollable_slides.css).
The CSS file can then be added to the Rmd like this (assuming scrollable_slides.css is in the same directory as the Rmd):
---
title: "..."
output:
ioslides_presentation:
css: 'scrollable_slides.css'
runtime: shiny
---
I want to have an image to fill the whole slide.
I have tried to use a div with absolute positioning, however, that will position the image partly outside of the slide.
I think I could make that work, if I hard code the resolution in, however, I would like to make it work on another machine as well. (and preferably even with the wide screen switching)
An example to reproduce/test:
---
title: "some title"
author: Me
company: Me
date: 21-02-2017
output:
ioslides_presentation
---
##
![test image](https://i.ytimg.com/vi/yaqe1qesQ8c/maxresdefault.jpg)
edit:
I am aware of:
Rpresentation in Rstudio - Make image fill out the whole screen
However, there they switched to slidy_presentation and I already have custom css for ioslides. If possible I would like to stay with ioslides. And it should be possible, right? :)
I got an idea when I was looking for getting my text output even smaller.
I found this: Markdown: Change default font size of code chunks in ioslides
Now I am using the following custom css:
.fullslide img {
margin-top: -85px;
margin-left: -60px;
}
Then in in the rmarkdown file I can do:
## {.fullslide}
![](image.jpg)
If you now want to make sure that you get the full image, make sure the image has the following dimensions:
widescreen: 1100 x 700
normal: 900 x 700
I just make sure I edit them using GIMP or something.
I have not yet figured out how I can suppress the page numbering, but apparently you cannot suppress page numbers on a per slide basis. :(
I have based a settings dialog on the Qt config dialog example found here:
http://doc.qt.io/qt-5/qtwidgets-dialogs-configdialog-example.html
I would like the QListWidget to fill the left of the window (except for the button bar at the bottom) regardless of the vertical size of the window. In Delphi there was a simple property to set. I can't find a similar thing in Qt.
Is this possible? If so, how?
--- edit ---
The example I linked to has the same behaviour. My code is virtually a copy of that example.
Here is a screen shot showing the problem:
This can be fixed by removing mainLayout->addStretch(1); from configdialog.cpp. This line adds empty space that stretches instead of other content when extra space is available.
I am trying to add a plot to a word document. I would like the plot to maximize the area available when the page size is set to legal with narrow margins. I can set the fig.width and fig.height but it seems the plots get automatically re-sized to fit the default page size (letter) with normal margins.
Here is a sample .rmd file that produces the same results:
---
title: "plot-resize"
output: word_document
---
Plot with the height set to 3" and the width to 7.5":
```{r, echo = FALSE, fig.height=3, fig.width=7.5, warning=FALSE, message=FALSE}
plot(cars)
```
However when the word document is created the image is automatically
re-sized to 79% of this.
I can re-size the plot in word, but it would be nice to not have to.
Is there a way to set the page size and margins in the .rmd file?
Is there a way to ensure that the plots stay at the specified size even if they do not fit within the margins of the created word document?
You can redo the MS Word template file - see http://rmarkdown.rstudio.com/articles_docx.html - you would have to change your margins to narrow (0.5") in the MS Word template file you are using (Under the Layout ribbon). Then, right click on the figure and select size and position, and then adjust scale height and width to 100%. You would then have to save your template file (and don't forget to close it!) and then add this to your YAML:
title: "plot-resize"
output:
word_document:
reference_docx: mynew_template.docx