[英]Timevis - use custom css to change font size
我想生成一個timevis圖,其中字體大小根據變量的重要性而變化。
使用源數據框中的“樣式”選項,我可以更改字體顏色。 但是,當我使用相同的方法嘗試更改字體大小時,R無法正確呈現變量。
這是我的數據樣本:
data <- structure(list(groups = c("Deadline.1", "Deadline.1", "Deadline.1",
"Deadline.1", "Deadline.1"), content = c("Geography Tutorials: Critical
Thinking & Techniques", "Principles of Geographical Inquiry I", "Geography
in Action",
"Physical Geography: Earth Surface Processes & Landforms", "Biogeography &
Ecology"
), start = structure(c(17459, 17505, 17631, 17911, 18048), class = "Date"),
end = structure(c(17459, 17505, 17631, 17911, 18048), class = "Date"),
type = c("point", "point", "point", "point", "point"), id = c(1L,
2L, 7L, 9L, 10L), Assessment = c("1500 word essay ", "Group survey",
"20% attendance (5% per block)", "2 hr exam ", "2 hr exam "
), Percentage = c(15, 15, 20, 100, 100), style = c("'font-size:15px;'",
"'font-size:15px;'", "'font-size:20px;'", "'font-size:100px;'",
"'font-size:100px;'")), row.names = c(NA, 5L), class = "data.frame")
這是我的代碼的相關部分。 顯然,在最終版本中,我將在“百分比”和字體大小之間建立一個更微妙的鏈接功能。 但這不管字體大小如何都行不通。
library(shiny)
library(timevis)
library(tidyr)
library(plyr)
library(dplyr)
data$style <- paste0("'font-size:", data$Percentage, "px;'")
### example time vis rendering (doesn't work)
timevis(data = data[2:3, ]) ### random variable choice
### but this works
data$style <- 'color: red'
timevis(data = data[2:3, ])
任何建議都非常歡迎。 我主要是建模人員,而不是應用程序開發人員,因此,如果這是由於瑣碎的HTML錯誤所致,我們深表歉意。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.