gauravkumar13337 / flot

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

[Enhancement Request] jQuery selector friendly implementation #655

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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 reported on code.google.com by den...@gmail.com on 22 Dec 2011 at 9:17

Attachments:

GoogleCodeExporter commented 8 years ago
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,
$("<div/>")                 // 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

Original comment by den...@gmail.com on 22 Dec 2011 at 9:40

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by dnsch...@gmail.com on 1 May 2012 at 10:30

GoogleCodeExporter commented 8 years ago

Original comment by dnsch...@gmail.com on 15 May 2012 at 3:32

GoogleCodeExporter commented 8 years ago
Hi,

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?

Thanks,
Trucy

Original comment by trucy.p...@gmail.com on 14 Jul 2012 at 9:39