TanStack Table with Nuxt3, Cell Formatting - nuxtjs3

I want to use TanStack table with Nuxt3.
I have tried Cell Formatting with the following link.
https://tanstack.com/table/v8/docs/guide/column-defs
columnHelper.accessor('firstName', {
cell: props => <span>{props.getValue().toUpperCase()}</span>,
})
But I get an error TS2304 cannot find name 'span'.
can you tell me how to use Cell Formatting in Nuxt3 (Vue3)?
I wrote the code in accordance with your question.
Ultimately, I would like to use the html code to put hyperlinks in the cells

Related

Add hyperlinks to cells (and/or rows) of DT table in flexdashboard

I have a large table which I would like to present in interactive (filterable and sortable) form within a flexdashboard. I have achieved this using the DT package. One of the columns contains URLs, which currently are not 'clickable', so users will have to copy and paste into their browser. Is there a way to make these URLs into hyperlinks?
I have tried adding html tags in this format:
Link text
But the tags themselves display in the table, with no hyperlink.
Another related question - as these URLs are taking up a large proportion of the width of the table, is it possible to make an entire row 'clickable', directing users to the URL stored in 'column B' of the table, without displaying 'column B'?
The other answers I have found apply to using DT in JavaScript or shiny, and seem not to match my code.
Thank you :)
You can use escape=FAlSEarguement in datatable() function.
Here is an example:
df <- data.frame(textLink=paste0('Link text'))
datatable(df, escape = FALSE)

How can I wrap Jupyter output in custom HTML?

I want to be able to take the normal output for an object and insert it into custom HTML components. Specifically, I want to allow things like putting several charts into an accordion UI element, or having hidden dataframes that are shown when a button is clicked. Is there a way to get the HTML that would normally be output, wrap it in my own HTML components, and then output that?
I have tried:
import IPython.display as dp
dp.display(dp.HTML('<div id="mycontainer">')) # Just a simple div,
# but ideally would be e.g. bootstrap component
dp.display(my_obj) # my_obj here could be a (potentially styled) dataframe
# or a plot from matplotlib/altair/etc.
dp.display(dp.HTML('</div>'))
However, the unclosed <div> just gets automatically closed, so my_obj doesn't get inserted into it. Some objects have _repr_html_(), but not all do (particularly charts). Still, Jupyter obviously has some way of extracting HTML from arbitrary objects.
It seems from trying to read the source that nbconvert is used to change the object to HTML, but I'm not sure if A) I'm understanding that right or B) how to get HTML from an arbitrary object that is not in a notebook node object (or how to construct such an object myself).
this seams to work for me :
from IPython.core.display import display, HTML
myString = 'Hello, world!'
prependHtmlTag = '<h1>'
appendHtmlTag = '</h1>'
display(HTML(prependHtmlTag + myString + appendHtmlTag )
just put any html formated string in the display(HTML([yourString]))

Exclude part of R markdown documents based on output document type

Is it possible to render part of an Rmarkdown document only for a specific output?
For example, I would like to use the same analysis both to write a report and a presentation.
I would like to be able to have some part of the document only to be rendered when the output is html_document, but not when the output is slidy_presentation; I do not mean necessarily a chunk of code, but text too.
You can alter the action depending on document, using rmarkdown.pandoc.to. Regarding text, I don't know another way than embedding that text into a code chunk.
my_output <- knitr::opts_knit$get("rmarkdown.pandoc.to")
if (my_output=="html"){
cat('<h2>My header</h2>\n')
} else {
cat('## My header\n')
}
if (my_output == "latex"){
opts_chunk$set(dev='cairo_pdf', dev.args=list(cairo_pdf = list(family='Times New Roman')))
}

Generate chart as an html file with custom name

I like to create bunch of googleVis charts and one I create the charts, I like to create a different html files with custom names so that I can reference them in my front page with divs.
For example, I am doing this:
x <- gvisTable(mtcars)
writeLines(x, "cars.html")
I get this error:
Error in writeLines(x, "cars.html") : invalid 'text' argument
Ideas how would I address this problem?
I got the answer, I can simply to this and write it to any html file I like:
cat(x$html$chart, file="tmp.html")

Qwraps2- row group label not showing up in summary table

Built a summary table, but the labels of the row groups are not showing up.
args(data)
summary1 <- list("Gender"= list("Female"
=~qwraps2::n_perc0(Sex==0, na_rm=TRUE))
table1 <- summary_table(data, summary1)
My table looks like this: table1:
How do I get the "Gender" group name to show-up in the table?
It looks like you are viewing the table in RStuido via double clicking on the table1 in the "Environment" tab. The display is as expected. The structure of the qwraps2_summary_table object is a character matrix. In or outside of RStudio you can get the same result shown in the question post via View(table1).
To see the well rendered html you'll need to knit a .Rmd to html. Or, in RStuido you can upon a "R Notebook." A screen capture of of a simple example from an R Notebook follows:
This may be related to how you "show" your table (You did not write anything about how you got it). When I use qwraps in rmarkdown in edit mode. When I just select the table (in your case table1) and press ctrl + enter I get the result you're asking for. If I use kable(table1) this removes this labelling.
I think the print() function recognized the qwrap table and prints it with the group names.
Ask a minimally reproducible example if you want more help.

Resources