plugin example
by wrxsti85
HTML
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
<div id="test"></div>
CSS
#test {
width: 100px;
height: 100px;
background-color: #e5e5e5;
}
JavaScript
(function($){
$.fn.extend({
chartGen: function() {
var defaults = {
title: 'Default Title (Please Change)',
width: 500,
height: 200
}
var options = $.extend(defaults, options);
return this.each(function() {
var o = options;
var obj = $(this);
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function(data) {
// Create the chart
obj.highcharts('StockChart', {
chart:{
width: o.width,
height: o.height
},
rangeSelector : {
selected : 1
},
title : {
text : o.title
},
series : [{
name : 'AAPL',
data : data,
tooltip: {
valueDecimals: 2
}
}]
});
});
});
}
});
})(jQuery);
$('#test').chartGen({height: 800});