declare var jUIPromise: Promise<void>;

setup.skillHistoryDrawGraph = function(domElementId:string,skillID:string,title=undefined){
	jUIPromise.then(function () {
			google.charts.load('current', {'packages':['corechart']});

			google.charts.setOnLoadCallback(drawChart);


			function drawChart() {
				let pc = State.variables.pc;
				let rawdata:(number|string)[][] = [['Day', 'Experience', 'Min']];
				rawdata = rawdata.concat(pc.skillExperienceHistoryDayExpTuple(skillID));

				let skillFloor = pc.skillFloor(skillID);
				for(let i in rawdata){
					let index:number;
					if(typeof i =="string")
						index = parseInt(i);
					else
						index = i;
					if(index > 0)
						rawdata[index].push(skillFloor);
				}

				var data = google.visualization.arrayToDataTable(rawdata);

				var graph_title = skillID;
				if(title)
					graph_title = title;

				var options:google.visualization.LineChartOptions = {
					title: graph_title,
					hAxis: {title: 'Day'},
					vAxis: {title: 'Experience'},
					legend: "none",

					series: {
						0: { pointShape: 'diamond',pointSize: 10, }
					}

				};

				var chart = new google.visualization.LineChart(document.getElementById(domElementId));
				chart.draw(data, options);
			}
	});
}