dragonfeet2012 dragonfeet2012 - 2 months ago 24
jQuery Question

jQuery Flot - Display accurate values

I notice that jQuery Flot is rounding down the results. But I want to show the actual decimal value for the result when you hover over the peaks and valleys in the tooltip. But not the x or y axis labels, but the graph result itself.

So instead of "44", I want "44.05".

Is there anything I can do to make that work? Everything I'm seeing is just for the axis labels.


The tool tip should allow you to do this - have a look at this fiddle http://jsfiddle.net/Rnusy/

 var previousPoint = null;
        $("#placeholder").bind("plothover", function (event, pos, item){
            if (item) {
                if (previousPoint != item.dataIndex){
                    previousPoint = item.dataIndex;

                    var x = item.datapoint[0].toFixed(2),
                        y = item.datapoint[1].toFixed(2);

                        showTooltip(item.pageX, item.pageY, y);
                else {
                    previousPoint = null;