gpt4 book ai didi

css - 如何更改某些 textOutput 元素的字体?

转载 作者:行者123 更新时间:2023-11-28 11:26:45 25 4
gpt4 key购买 nike

在 server.R 中,我在输出中存储了本周的大量指标以及之前测量的指标。

output$x1_current_week  <- renderText(values[['x1']])
output$x2_current_week <- renderText(values[['x2']])
...
output$x1_previous_week <- renderText(values_previous_week[['x1']])
output$x2_previous_week <- renderText(values_previous_week[['x2']])
...

在我的 ui.R 中,我想在一个框中显示当前和前一周的值,当前周位于中心,使用 css 中定义的自定义字体/颜色,前一周使用与普通字体相同的字体html.

下面显示的是我正在努力实现的目标。我已经硬编码了前一周的值(value)。

enter image description here

实现的ui代码如下

box(
...
html("<p align='center'>x2</p>"),
h3(textOutput('x2_current_week'), align='center'),
html("<p align='center'>previous week: A</br>")
)

如何在 html 显示的字体中打印前一周的值并在值周围添加文本?我试过使用 paste() 但 textOutput 是唯一显示的部分。

最佳答案

您可以将 CSS 添加到带有样式标签的元素中。 (或者将它们作为 CSS 文件包含在内,请参阅 here。)我认为这可以指导您朝着正确的方向前进:

ui <- shinyUI(
fluidPage(
tags$style("#x1_current_week {font-size:20px;
color:red;
display:block; }"),
tags$style("#x1_previous_week {font-size:15px;
display:block;
bottom: 12px;
position:absolute;
width: 100%;
left:0px;}"),
div(style="text-align:center;
box-shadow: 10px 10px 5px #888888;
width:200px;
height:200px;
padding-top:70px;
position:relative;",
textOutput("x1_current_week"),
textOutput("x1_previous_week")
)
)
)

server <- function(input,output)
{
output$x1_current_week <- renderText("x1 this week")
output$x1_previous_week <- renderText("x1 prev week")

}


shinyApp(ui,server)

希望这对您有所帮助!

enter image description here

关于css - 如何更改某些 textOutput 元素的字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45421327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com