;(function( $, window, document, undefined ){

  // our plugin constructor
  var Chart = function( elem, options ){
    this.elem = elem;
    this.$elem = $(elem);
    this.options = options;
 
    // This next line takes advantage of HTML5 data attributes
    // to support customization of the plugin on a per-element
    // basis. For example,
    // <div class="item" data-plugin-options="{'message':'Goodbye World!'}"></div>
    this.metadata = this.$elem.data( "plugin-options" );
  };
 
  // the plugin prototype
  Chart.prototype = {
    defaults: {
      message: "Hello world!"
    },
 
    init: function() {
      // Introduce defaults that can be extended either
      // globally or using an object literal.
      this.config = $.extend( {}, this.defaults, this.options,
      this.metadata );
 
      // Sample usage:
      // Set the message per instance:
      // $( "#elem" ).plugin( { message: "Goodbye World!"} );
      // or
      // var p = new Plugin( document.getElementById( "elem" ),
      // { message: "Goodbye World!"}).init()
      // or, set the global default message:
      // Plugin.defaults.message = "Goodbye World!"
 
      this.sampleMethod();
      return this;
    },
 
    sampleMethod: function() {
      // console.log(this.config.message);
    }
  }
 
  Chart.defaults = Plugin.prototype.defaults;
 
  $.fn.chart = function( options ) {
    return this.each(function() {
      new Chart( this, options ).init();
    });
  };
 
})( jQuery, window , document );