var plot_fuststatus = function() {
	$.get('/bomfustjson', function(data, textStatus) {
		if (textStatus == 'success') {
			var data = json_parse(data);
			if (data.success != false) {
				$("#chart_fuststatus").css("width", "680px"); 
				$("#chart_fuststatus").css("height", "300px");
				$("#chart_fuststatus").text("");
				plotFuststatus = $.jqplot('chart_fuststatus', data.chart, {
					stackSeries: true,
					legend: {
						show: true,
						location: 'nw'
					},
					title: 'Biersoort, huidige inhoud (per aangesloten fust, liters)',
					seriesDefaults: {
						renderer: $.jqplot.BarRenderer,
						rendererOptions: {
							barWidth: 50
						}
					},
					series: [{
						color: 'green',
						label: 'Vol'
					}, {
						color: 'red',
						label: 'Leeg'
					}],
					axes: {
						xaxis: {
							renderer: $.jqplot.CategoryAxisRenderer,
							ticks: data.axes_xaxis_ticks
						},
						yaxis: {
							min: 0,
							max: data.axes_yaxis_max,
							numberTicks: data.axes_yaxis_numberTicks,
							tickOptions: {
								formatString: '%d'
							}
						}
					},
					highlighter: {
						show: false
					},
					cursor: {
						show: false
					}
				});
			} else {
				$("#chart_fuststatus").replaceWith("<div class=\"chart\" id=\"chart_fuststatus\"><b>Doet 't niet! :( " + data.textStatus + "</b></div>");
			}
		}
	}, 'text');
};

$(document).ready(function() {

	$("#chart_fuststatus").dblclick(plot_fuststatus);
	
	plot_fuststatus();

});
