【问题标题】:How can I prevent the hover data from displaying in Chart.JS?如何防止悬停数据显示在 Chart.JS 中?
【发布时间】:2016-09-20 23:24:56
【问题描述】:

我有一个如下所示的水平条形图:

...但是当我将它悬停时就像这样:

我试图阻止“悬停数据”显示如下:

var priceBarChart = new Chart(ctxBarChart, {
    type: 'horizontalBar',
    showTooltips: false,
    data: barChartData,
    options: optionsBar
});

...像这样:

var optionsBar = {
    scales: {
        xAxes: [
            {
                stacked: true
            }
        ],
        yAxes: [
            {
                stacked: true
            }
        ]
    },
    showTooltips: false
};

...但两者都不起作用 - 无论如何都会显示皱缩的提示。

如何防止悬停数据在 Chart.JS 中显示?

【问题讨论】:

    标签: jquery hover tooltip chart.js chart.js2


    【解决方案1】:

    您应该将此添加到您的选项中:

    tooltips: {
        enabled: false
    }
    

    Codepen example

    更多信息here

    【讨论】:

      【解决方案2】:

      2022 年的答案:

      options: {
        plugins: {
            tooltip: {
                enabled: false
                     },
                 }
               },
      

      Documentation here 在 Charts.js 上

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-11-02
        • 1970-01-01
        • 1970-01-01
        • 2015-10-16
        • 2014-12-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多