DHTMLX Docs & Samples Explorer

Example (Stacked Horizontal Bar)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>Stacked Horizontal Bar</title>
	<script src="../../codebase/dhtmlxchart.js" type="text/javascript"></script>
	<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxchart.css">
		<script>
	var data = [
		{ sales:"3.0",sales1:"3.4",sales2:"1.2",sales3:"6.9", year:"2000" },
		{ sales:"5.0",sales1:"5.0",sales2:"5.0",sales3:"5.0", year:"2001" },
		{ sales:"3.4",sales1:"4.7",sales2:"1.9",sales3:"5.5", year:"2002" }
	];
		window.onload = function(){
        var barChart =  new dhtmlXChart({
		view:"stackedBarH",
		container:"chart_container",
	    value:"#sales#",
		width:30,
		label: "#sales#",
		gradient:"3d",
		color: "#00FF22",
		xAxis:{
			title:"Sales per year",
			lines: true
		},
		yAxis:{
			title:"Year",
			template:"#year#"
		}
	}) 
	barChart.addSeries({
	    value:"#sales1#",
		color:"#FFFF00",
		label:"#sales1#",
	});
	barChart.addSeries({
	    value:"#sales2#",
		color:"#ff520c",
		label:"#sales2#",
	});
	barChart.addSeries({
	    value:"#sales3#",
		color:"#66ffcc",
		label:"#sales3#",
	});
	barChart.parse(data,"json");
	}
	</script>
</head>
<body >
	<h1>Stacked Horizontal Bar</h1>
 
	<div id="chart_container" style="width:500px;height:300px;;border:1px solid #A4BED4;"></div>
</body>
</html>