gauravkumar13337 / flot

Automatically exported from code.google.com/p/flot
MIT License
0 stars 0 forks source link

Enhancement: bind event handlers using options object #613

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'd like the ability to pass in handlers like a lot of jq plugins allow. 
Something like this:

$.plot($("#placeholder"), [
        { label: "sin(x)",  data: d1},
        { label: "cos(x)",  data: d2},
        { label: "tan(x)",  data: d3}
    ], {
        series: {
            lines: { show: true },
            points: { show: true }
        },
        plothover:  function (event, pos, item) {
            $("#x").text(pos.x.toFixed(2));
            $("#y").text(pos.y.toFixed(2));

            if (item) {
                if (previousPoint != item.dataIndex) {
                    previousPoint = item.dataIndex;

                    $("#tooltip").remove();
                    var x = item.datapoint[0].toFixed(2),
                        y = item.datapoint[1].toFixed(2);

                    showTooltip(item.pageX, item.pageY,
                                item.series.label + " of " + x + " = " + y);
                }
            }
            else {
                $("#tooltip").remove();
                previousPoint = null;            
            }
        },
        plotclick: someFunction

}

Original issue reported on code.google.com by matt.mot...@gmail.com on 4 Oct 2011 at 11:00

GoogleCodeExporter commented 8 years ago

Original comment by dnsch...@gmail.com on 1 May 2012 at 12:11

GoogleCodeExporter commented 8 years ago

Original comment by dnsch...@gmail.com on 7 May 2012 at 11:54