Closed awgymer closed 1 year ago
Just a heads up, you can get scrolling for gt
or other arbitrary output by wrapping gt
in a div()
:
div(style='height:100%; overflow-y:scroll', gt(mtcars))
This was a while back now, but the issue was I think I explicitly didn't want scrolling. Like with a kable
table it just expands the divs to the size of the largest table. I ended up adding some custom JS to create an extra component finder:
// gt tables
window.FlexDashboardComponents.push({
find: function(container) {
return container.find('.gt-no-scroll');
},
flex: function(fillPage) {
return fillPage;
}
});
Then wrapping my gt
tables in a div with that class (I think that maybe now gt
supports adding classes to top-level divs itself?).
You can see an example of it in practice here
I'm facing the same issue
Using jthomasmock's approach with div() inserts a scroll bar but it doesn't scroll. My html knowledge is zero
I have the output as: orientation: rows vertical_layout: scroll
Edit: Actually thanks @awgymer I was able to use your custom JS to blindly achieve my aim
This was a while back now, but the issue was I think I explicitly didn't want scrolling. Like with a
kable
table it just expands the divs to the size of the largest table. I ended up adding some custom JS to create an extra component finder:// gt tables window.FlexDashboardComponents.push({ find: function(container) { return container.find('.gt-no-scroll'); }, flex: function(fillPage) { return fillPage; } });
Then wrapping my
gt
tables in a div with that class (I think that maybe nowgt
supports adding classes to top-level divs itself?).You can see an example of it in practice here
This is so so close to helping me address my problem, except the "fillpage" fix doesn't allow the content to scroll. By which I mean, it prevents it from being placed in the chart-shim div and instead places it in the main div, but I cannot see all of the content.
I am trying to embed responsive HTML into a flexdashboard storyboard.
Rmd:
---
title: "Title"
output:
flexdashboard::flex_dashboard:
theme:
version: 5
bootswatch: litera
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
load("my_work_space.RData")
library(tidyverse)
library(dplyr)
library(htmltools)
library(shiny)
htmltools::includeHTML('www/timeline.html') %>% HTML()
timeline.html:
<!DOCTYPE html>
He was born in 1881 (probably in the spring) in Salonica, then an Ottoman city, now inGreece. His father Ali Riza, a customs official turned lumber merchant, died when Mustafawas still a boy. His mother Zubeyde, adevout and strong-willed woman, raised him and his sister.
First enrolled in a traditionalreligious school, he soon switched to a modern school. In 1893, he entered a military highschool where his mathematics teacher gave him the second name Kemal (meaning perfection)in recognition of young Mustafa's superior achievement.
In 1905, Mustafa Kemal graduated from the War Academy in Istanbul with the rank of Staff Captain. Posted in Damascus, he started with several colleagues, a clandestinesociety called "Homeland and Freedom" to fight against the Sultan'sdespotism.
In 1908 he helped the group of officers who toppled the Sultan. Mustafa Kemal'scareer flourished as he won his heroism in the far corners of the Ottoman Empire,including Albania and Tripoli. He also briefly served as a staff officer in Salonica andIstanbul and as a military attache in Sofia.
In 1915, when Dardanelles campaign was launched, Colonel Mustafa Kemal became anational hero by winning successive victories and finally repelling the invaders.
Promotedto general in 1916, at age 35, he liberated two major provinces in eastern Turkey thatyear. In the next two years, he served as commander of several Ottoman armies inPalestine, Aleppo, and elsewhere, achieving another major victory by stopping the enemyadvance at Aleppo.
On May 19, 1919, Mustafa Kemal Pasha landed in the Black Sea port of Samsun to startthe War of Independence. In defiance of the Sultan's government, he rallied a liberationarmy in Anatolia and convened the Congress of Erzurum and Sivas which established thebasis for the new national effort under his leadership.
On April 23, 1920, the GrandNational Assembly was inaugurated. Mustafa Kemal Pasha was elected to its Presidency. Fighting on many fronts, he led his forces to victory against rebels and invadingarmies. Following the Turkish triumph at the two major battles at Inonu in Western Turkey,the Grand National Assembly conferred on Mustafa Kemal Pasha the title ofCommander-in-Chief with the rank of Marshal.
At the end of August 1922, the Turkish armieswon their ultimate victory. Within a few weeks, the Turkish mainland was completelyliberated, the armistice signed, and the rule of the Ottoman dynasty abolished
In July 1923, the national government signed the Lausanne Treaty with Great Britain,France, Greece, Italy, and others. In mid-October, Ankara became the capital of the new Turkish State. On October 29, the Republic was proclaimed and Mustafa Kemal Pasha wasunanimously elected President of the Republic.
The account of Atatürk's fifteen year Presidency is a saga of dramatic modernization.With indefatigable determination, he created a new political and legal system, abolished the Caliphate and made both government and education secular, gave equal rights to women,changed the alphabet and the attire, and advanced the arts and the sciences, agricultureand industry. In 1934, when the surname law was adopted, the national parliament gave him the name"Atatürk" (Father of the Turks)
On November 10, 1938, following an illness of a few months, the national liberator and the Father of modern Turkey died. But his legacy to his people and to the world endures.
@lstarkey yes, per above I didn't want it to scroll so that doesn't surprise me.
Not sure exactly what you are trying to achieve but I have a scrollable table on the page I linked at the end of my previous comment (Where in the world? Section) that might be what you are after so you could look at what I did there (this was ages ago so off the top of my head I can't tell you)
I actually can't even remember what fillpage does but perhaps that is a setting you can change to get what you need?
Sigh, not quite. My issue is that the responsive JS doesn't work when the HTML is placed in the chart-shim div, because it responds to the div's scroll and not the larger page scroll (if that makes sense?). I need some way to override placement in the chart-shim div so that window scroll is the only one available. Thank you anyhow!
Hmm I seem to remember when I was trying to make this work I spent a lot of time working in chrome devtools to adjust the css until I had the layout I wanted and then worked out how to make flexdashboard generate that.
Do you know what actual settings you need the table/div to have yet?
nope, not sure. Thanks anyway!
It seems this has been resolved for everyone! If you're facing a similar challenge, definitely check out Tom's comment here. If you happen to have a similar problem, please open a new issue with a reprex and we'll be happy to look into it.
It seems that
flexdashboard
doesn't recognise tables generated with thegt
package as tables, I believe because they are wrapped indiv
and thetable
element isn't at the top level of the content. This leads to them being put insidechart-shim
wrappers which cause long tables to be cut off.I think this is a more general problem with the way
flexdashboard
decides what sort of container to put content in, because I've noticed the same thing happen when I generate custom HTML content for a section withhtmltools
.An example is when I tried to put an image and a guage in the same section:
It would be useful if there was some way to force a row/column section to behave in a fixed manner rather than relying on its guesswork. Perhaps something like being able to do:
### Custom Table Section {tabular}
or
### Custom HTML section {noshim}