jQuery flotcharts - 仅用于一个系列的工具提示

jQuery flotcharts - tooltip only for one series

如何禁用给定系列的工具提示? 我有 2 个数据系列。我只想要一个工具提示。

我的工具提示选项:

tooltip: true,
        tooltipOpts: {
            id: 'flotTip',
            content: '%x : %y km/h',
            shifts: {
                x: 10,
                y: 20,
            },
            defaultTheme: true,
            lines: {
                track: false,
                threshold: 0.05,
            },
        }
    };

PLOT = $.plot($("#route-plot"), [V, PRK], options);

您可以使用简单的 if 语句来完成。

如果您已经知道特定的系列标签及其静态,您可以使用如下所示的内容。

 if(item.series.label != "Your Series Label you don't want to show")
{
 //Do tooltip show work
}

看看这个fiddle - Example Fiddle

除了格式字符串,您还可以使用 content 选项的函数。替换

content: '%x : %y km/h',

像这样

content: function(label, xval, yval, flotItem) {
    if (flotItem.seriesIndex == 0) { // you could also use the label
        return xval.toString() + ' : ' + yval.toString() + ' km/h';
    }
    else {
        return false; // this means no tooltip is generated
    }
},

请参阅此 fiddle 示例(只有黄色图表有工具提示)。