将工具提示添加到特定的数据表列

时间:2017-04-26 18:57:29

标签: javascript jquery css datatables tooltip

我在html中将表定义为<table id="tableDynamic"></table>

我正在动态更新表格

    $('#tableDynamic').DataTable( {
        columns: [
            { title: data[0] },
            { title: data[1] },
            { title: data[2] },
],

        "columnDefs": [
            {
                "render": function (data, type, row){
                    return '<a>' + row[0]  +'</a>';

                },
                "targets": 0
            },
        ]
    } );
}

如何将工具提示添加到特定列data[2]

1 个答案:

答案 0 :(得分:1)

您也可以这样做(在Datable初始化完成后调用任何其他javascript):

# Install devtools
install.packages('devtools')

# Install dependency of scales package
install.packages(c("RColorBrewer", "stringr", "dichromat", 
                   "munsell", "plyr", "colorspace"))

# Load devtools
library(devtools)

# Move to development mode
# This installed scales and ggplot2 in the "~/R-dev" directory, 
# so CRAN version of ggplot2 is not removed.
dev_mode(TRUE)

# Install scales
install_github("hadley/scales")

# Main branch of development
install_github("hadley/ggplot2", "hadley/develop")

# load development version of ggplot2
library(dplyr)
library(ggplot2)

mtcars %>%
  select(mpg, cyl,am) %>%
  filter(!(cyl == 8 & am == 0)) %>%
  ggplot(aes(factor(cyl),mpg,fill=factor(am))) + 
  stat_boxplot(geom = "errorbar",
               position =  position_dodge2(width = 0.75, preserve = "single")) + 
  geom_boxplot(outlier.shape=1, outlier.size=3, 
               position =  position_dodge2(width = 0.75, preserve = "single")) +
  geom_text(data = mtcars %>%
              select(mpg, cyl, am) %>%
              filter(!(cyl == 8 & am == 0)) %>%
              group_by(cyl, am) %>%
              summarize(Count = n(),
                        q3 = quantile(mpg, 0.75),
                        iqr = IQR(mpg),
                        lab_pos = max(mpg)),
            aes(x= factor(cyl), y = lab_pos,label = paste0("n = ",Count, "\n")),
            position = position_dodge2(width = 0.75, preserve = "single"))

我问了一个类似的问题here。请查看YouneL答案以获取更多详细信息,并通过回调查看相同的示例。