[Enhancement Request] jQuery selector friendly implementation #734

dnschnur opened this Issue Sep 28, 2012 · 2 comments


None yet

1 participant


Original author: den...@gmail.com (December 22, 2011 09:17:28)

The current implementation is extending the plot function into original jQuery object,
i.e. $.plot( $("#placeholder"), data );

But we can actually enables the friendly code as such,
$("#placeholder").plot( data );

It can be easily done by adding one more assignment in jquery.flot.js, right after the assignment "$.plot = function( ... )" as follows,

$.fn.plot = function(data, options) {
return $.plot(this, data, options);

I attached an updated file, see if you guys wanna merge it.

Original issue: http://code.google.com/p/flot/issues/detail?id=655


From den...@gmail.com on December 22, 2011 09:40:49
In order to maintain the chainable behavior in jQuery, the script should actually returns "this" after function call.

So here comes another updated script. ;)

It's just chainable as,

") // Creates an anonymous div node
.width(600).height(300) // Custom sizing
.appendTo("body") // Append for chart calculations
.plot(data) // Render the chart
.hide().fadeIn(300); // Shows up afterwards


From trucy.p...@gmail.com on July 14, 2012 21:39:51

We attempted to implement this enhancement using the above suggestion.

The additional code handles friendly jQuery syntax for plotting, e.g. $("#placeholder").plot( .... ) by constructing a function that passes the arguments to the (unchanged) plot function.

Using either syntax, however, passing in a class returns only one plot object instead of a plot object for each element of that class.

We can either modify the additional code to handle classes by looping, or we can change the way flot handles the placeholder object, depending on whether it contains a single object or multiple.

What do you think is the best way to proceed?


@dnschnur dnschnur was assigned Feb 8, 2013
@dnschnur dnschnur closed this in 49cce02 Feb 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment