// graphite.js

(function ($) {
    $.fn.graphite = function (options) {
        if (options === "update") {
            $.fn.graphite.update(this);
            return this;
        }

        // Initialize plugin //
        options = options || {};
        var settings = $.extend({}, $.fn.graphite.defaults, options);

        return this.each(function () {
            $this = $(this);

            $this.data("graphOptions", settings);
            $.fn.graphite.render($this, settings);
        });

    };

    $.fn.graphite.render = function($img, options) {
        // Render a new image. //
        var src = options.url + "?";
        // use random parameter to force image refresh
        options['_t'] = Math.random();
        $.each(options, function (key, value) {
            if (key === "target") {
                $.each(value, function (index, value) {
                    src += "&target=" + value;
                });
            } else if (value !== null && key !== "url") {
                src += "&" + key + "=" + value;
            }
        });

        src = src.replace(/\?&/, "?");
        $img.attr("src", src);
        $img.attr("height", options.height);
        $img.attr("width", options.width);
    };

    $.fn.graphite.update = function($img, options) {
        options = options || {};
        var settings = $.extend({}, $img.data("graphOptions"), options);
        $.fn.graphite.render($img, settings);
    };

    // Default settings. 
    // Override with the options argument for per-case setup
    // or set $.fn.graphite.defaults.<value> for global changes
    $.fn.graphite.defaults = {
        from: "-1hour",
        height: "300",
        until: "now",
        url: "/render/",
        width: "940",
    };

}(jQuery));

@@ -139,16 +139,30 @@
 ate(this
+, arguments%5B1%5D
 );%0A     
@@ -1321,32 +1321,97 @@
  options %7C%7C %7B%7D;%0A
+        $img.each(function () %7B%0A            $this = $(this);%0A    
         var sett
@@ -1431,19 +1431,20 @@
 nd(%7B%7D, $
-img
+this
 .data(%22g
@@ -1464,24 +1464,78 @@
 , options);%0A
+            $this.data(%22graphOptions%22, settings);%0A    
         $.fn
@@ -1552,19 +1552,20 @@
 render($
-img
+this
 , settin
@@ -1565,24 +1565,36 @@
  settings);%0A
+        %7D);%0A
     %7D;%0A%0A    
@@ -1885,17 +1885,16 @@
 h: %22940%22
-,
 %0A    %7D;%0A

update multiple images, with own config