javascript - how to set tooltip text color in flot chart? -
i using flot chart multi series data.i want change tooltip text color in flot chart. using code:
$("#placeholder").bind("plothover", function (event, pos, item) { if (item) { $("#tooltip").remove(); var hoverseries = item.series; var x = item.datapoint[0], y = item.datapoint[1]; var strtip = x + " / " + y + " " + item.series.label; var allseries = plot.getdata(); $.each(allseries, function(i,s){ if (s == hoverseries) return; $.each(s.data, function(j,p){ if (p[0] == x){ strtip += "</br>" + p[0] + " / " + p[1] + " " + s.label; } }); }); showtooltip(item.pagex, item.pagey, strtip); } });
any 1 color taking in tooltip?
flot chart supports html tags in tooltip
you can use html tag:<span>
flot chart tooltip support html tags.
with <span>
tag can use s.clor
style. js.
$("#placeholder").bind("plothover", function (event, pos, item) { if (item) { $("#tooltip").remove(); var hoverseries = item.series; var x = item.datapoint[0], y = item.datapoint[1]; var strtip = "<span style=\"color:" + item.series.color + ";\""+x + " / " + y + " " + item.series.label + "</span>"; var allseries = plot.getdata(); $.each(allseries, function(i,s){ if (s == hoverseries) return; $.each(s.data, function(j,p){ if (p[0] == x){ strtip += "</br><span style=\"color:" + s.color + ";\"" + p[0] + " / " + p[1] + " " + s.label + "</span>"; } }); }); showtooltip(item.pagex, item.pagey, strtip); } });
here clearly, have used item.series.color
, s.color
in strtip
string of tooltip
Comments
Post a Comment