如何mouseover text
在R闪亮数据表显示中为列名创建.我正在尝试为用户提供一些文本来理解列名称.我也检查了DT包,我找不到解决方案.我可以为列名创建标签,并在用户选中一个框时显示所有这些标签,这需要大量的空间,我不希望这样.有小费吗?
Yih*_*Xie 18
为了扩展我上面的评论,这里有一个示例,通过使用title
属性显示我的意思:
library(DT)
sketch = htmltools::withTags(table(
class = 'display',
thead(
tr(
th('', title = 'Row Names'),
th('Sepal.Length', title = 'The Sepal Length'),
th('Sepal.Width', title = 'The Sepal Width'),
th('Petal.Length', title = 'The Petal Length'),
th('Petal.Width', title = 'The Petal Width'),
th('Species', title = 'Iris Species')
)
)
))
datatable(iris, container = sketch)
Run Code Online (Sandbox Code Playgroud)
这是使用JavaScript(jQuery)添加title
属性的另一种方法:
library(DT)
datatable(iris, callback = JS("
var tips = ['Row Names', 'The Sepal Length', 'The Sepal Width',
'The Petal Length', 'The Petal Width'],
header = table.columns().header();
for (var i = 0; i < tips.length; i++) {
$(header[i]).attr('title', tips[i]);
}
"))
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4921 次 |
最近记录: |