I just added some code to show tooltips with the values when you hover over a multigraph value, here is a screenshot:
To do this edit multigraph.php and add the checkbox code whereveer you want it
<p><input id="enableTooltip" type="checkbox" checked >Enable tooltips</p>
and the javascript at the end of javascript code, just before the </javascript> closing tag:
function showTooltip(x, y, contents) {
$('<div id="tooltip">' + contents + '</div>').css( {
position: 'absolute',
display: 'none',
top: y + 5,
left: x + 5,
border: '1px solid #fdd',
padding: '2px',
'background-color': '#fee',
opacity: 0.80
}).appendTo("body").fadeIn(200);
}
var previousPoint = null;
$("#placeholder").bind("plothover", function (event, pos, item) {
$("#x").text(pos.x.toFixed(2));
$("#y").text(pos.y.toFixed(2));
if ($("#enableTooltip:checked").length > 0) {
if (item) {
if (previousPoint != item.dataIndex) {
previousPoint = item.dataIndex;
$("#tooltip").remove();
var x = item.datapoint[0].toFixed(2),
y = item.datapoint[1].toFixed(2);
// create a new javascript Date object based on the timestamp
var date = new Date(parseInt(x));
// hours part from the timestamp
var hours = date.getHours();
// minutes part from the timestamp
var minutes = date.getMinutes();
// seconds part from the timestamp
var seconds = date.getSeconds();
// will display time in 10:30:23 format
var formattedTime = hours + ':' + minutes + ':' + seconds;
showTooltip(item.pageX, item.pageY,
item.series.label + " at " + formattedTime + " = " + y);
}
}
else {
$("#tooltip").remove();
previousPoint = null;
}
}
});
Re: Tooltips on values of multigraph
Thanks for that - it was just what I was looking for.
Lloyd
Re: Tooltips on values of multigraph
And interesting that the tooltip gives the correct time, whilst the axis is an hour behind.
I've also made as slight change to the code to format the time better:
Re: Tooltips on values of multigraph
ive got the same issue, my x axis are 2 hours off whilst the tooltip shows the correct hour. any idea why this could be?
I am using unix timestamp saved in a database of my own.
Thank you very much
Re: Tooltips on values of multigraph
Great addon, thanks
Re: Tooltips on values of multigraph
Mine is also off, quite irritating.
I did a temporary sort of fix,
I changed this part, added the text in yellow
Re: Tooltips on values of multigraph
Hi,
just inserted the code, but no tooltips at all.
Is this working with emoncms v3?
Kisskovi
Re: Tooltips on values of multigraph
v3 changed a bit, use this line
$("#graph").bind("plothover", function (event, pos, item) {
instead of
$("#placeholder").bind("plothover", function (event, pos, item) {
and it will work (tested)
Re: Tooltips on values of multigraph
Does this also work with the new modular version?
Re: Tooltips on values of multigraph
Haven't tested, but this is FLOT functionality, so should work, and if not - minimal effort would be required to get it going
Re: Tooltips on values of multigraph
it solved my problem,
thanks!
:-)
Re: Tooltips on values of multigraph
Hi
I try to do this code but i get no thing
I use emoncms V5
Re: Tooltips on values of multigraph
Just tried it in v5, one line needs to be changed:
$("#placeholder").bind("plothover", function (event, pos, item) {
to
$("#multigraph").bind("plothover", function (event, pos, item) {
Re: Tooltips on values of multigraph
Il get this committed into the next release, definitely a nice feature.
Re: Tooltips on values of multigraph
it solved my problem.
Thank you very much dear
Re: Tooltips on values of multigraph
Nice one Martin, a good addition to emoncms.
Paul
Re: Tooltips on values of multigraph
Hello again
How can I change a location buttons. it they appear on the graph and covered a part of it
I would like to be in the upper graph