var args = {
	"type": "chart",
	"title": "BCWR by CAM",
	"L1": "1",
	"dataset" : "(|ContrName|) (|EndDate|) (|Structure|StruName|) (|Unit|UnitName|)",
	"sql" : [
		"select ProjOff, sum(Bac-BcwpCum) from EarnedValue inner join Element on Element.ElemID = EarnedValue.ElemID inner join Contract on Contract.ContrID = Element.ContrID where ElemType = CaSym and StruID = st_id and PeriodID = cd_id and UnitID = un_id group by ProjOff"
	],
	"cols": ["CAM", "BCWR"],
	"dtype": ["s", "n"],
};

(function() {
	"use strict";
	var options, s, arr, i, ilen, vals, val, o, decpl;
	options = {
		"series": [{
			"data": [],
			"type": "pie"
		}],
		"tooltip": false,
		"plotOptions": {
			"pie": {
				"allowPointSelect": true,
				"dataLabels": {
					"format": "{point.name}: {point.percentage:.1f} % = {point.s}",
					"enabled": true
				},
				"cursor": "pointer"
			},
			"series": {
				"animation": false
			}
		},
		"subtitle": {
			"style": {
				"font-size": "medium"
			},
			"text": null
		},
		"title": {
			"text": null
		}
	};
	s = args.L1 ? args.dataset : args.extra.title;
	if (args.sync && extra.pf && extra.pf.length) {
		s = s + ' (' + extra.pf + ')';
	}
	options.title.text = s;
	s = args.title;
	val = scale_chart_data(args.sql[0], +extra.scale.us, 0);
	decpl = 0;
	if (val.length) {
		s = s + ' (' + val + ')';
		decpl = (val === 'Thousands') ? 1 : 3;
	}
	options.subtitle.text = s;
	arr = args.sql[0];
	for (i = 0, ilen = arr.length; i < ilen; i++) {
		vals = arr[i];
		if (args.sync) {
			vals.shift();
		}
		val = vals[1];
		val = dtostr(val, decpl);
		o = {
			"name": vals[0],
			"y": +vals[1],
			"s": val
		};
		options.series[0].data.push(o);
	}
	return options;
})();
