:ここ
$(function() {
var sin = [];
for (var i = 0; i < 14; i += 1) {
sin.push([i, Math.sin(i)]);
}
var plot = $.plot("#placeholder", [
{ data: sin, label: "sin(x)"}
], {
series: {
bars: {
show: true
},
},
grid: {
hoverable: true,
clickable: true
},
});
$("#placeholder").bind("plotclick", function (event, pos, item) {
if (item) {
$("#clickdata").text(" - click point " + item.dataIndex + " in " + item.series.label);
plot.highlight(item.series, item.datapoint);
}
});
});
は完全なコードです既に強調表示されており、その場合は強調表示を解除します。
更新されたコード(この更新fiddleでフルコード):
var highlights = {};
$("#placeholder").bind("plotclick", function(event, pos, item) {
if (item) {
$("#clickdata").text(" - click point " + item.dataIndex + " in " + item.series.label);
var indices = item.seriesIndex + '_' + item.dataIndex;
if (highlights[indices]) {
plot.unhighlight(item.series, item.datapoint);
highlights[indices] = false;
} else {
plot.highlight(item.series, item.datapoint);
highlights[indices] = true;
}
}
});
は、お返事ありがとうございました – PVL