• Demos
    • JavaScript Charts
    • JavaScript StockCharts
  • Download/NPM
    • Download CanvasJS
    • Install via NPM
  • Integrations
    Front End Technology Samples
    • React Charts
    • Angular Charts
    • Vue.js Charts New!
    • jQuery Charts
    • Dashboards
    Server Side Technology Samples
    • PHP Charts
    • Python Charts New!
    • ASP.NET MVC Charts
    • Spring MVC Charts
    • JSP Charts
  • License
  • Blog
  • Docs
    • Chart Documentation
    • StockChart Documentation
  • Support Forum
    • Chart Support
    • StockChart Support
  • My Account
My Account
  • KEY FEATURES
    • Chart with Index / Data Label
    • Chart with Zooming / Panning
    • Chart using JSON Data
    • Chart with Animation
    • Multi Series Chart
    • Chart with Multiple Axes
    • Chart with Crosshair
    • Chart with Scale Breaks
    • Chart with Logarithmic Axis
    • Performance with 50,000 Data Points
    • Responsive Charts
    • Chart with Drilldown
  • LINE CHARTS
    • Line Chart
    • Spline Chart
    • Step Line Chart
  • AREA CHARTS
    • Area Chart
    • Multi Series Area Chart with Date Time Axis
    • Spline Area Chart
    • Step Area Chart
    • Range Area Chart
    • Range Spline Area Chart
    • Stacked Area Chart
    • Stacked Area 100% Chart
  • COLUMN & BAR CHARTS
    • Column Chart
    • Bar Chart
    • Range Column Chart
    • Stacked Column Chart
    • Stacked Column 100% Chart
    • Range Bar Chart
    • Stacked Bar Chart
    • Stacked Bar 100% Chart
    • Waterfall Chart
  • PIE & FUNNEL CHARTS
    • Pie Chart
    • Pie Chart with Index Labels Placed Inside
    • Doughnut Chart
    • Funnel Chart
    • Funnel Chart with Custom Neck
    • Pyramid Chart
  • FINANCIAL CHARTS
    • Candlestick Chart
    • Candlestick Chart from JSON
    • OHLC Chart
  • SCATTER & BUBBLE CHARTS
    • Scatter Chart
    • Scatter Chart with Custom Markers
    • Bubble Chart
  • BOX & WHISKER CHARTS
    • Box and Whisker Chart
    • Box and Whisker Chart with Customization
  • COMBINATION CHARTS
    • Error chart
    • Error Line Chart
    • Combination of Range, Area and Line Charts
  • DYNAMIC CHARTS
    • Dynamic Line Chart
    • Dynamic Column Chart
    • Dynamic Multi Series Chart
  • DATA BINDING
    • Chart from CSV
    • Chart from XML
    • Chart Data from Database
  • REACT, ANGULAR, VUE.JS, JQUERY
    • React Charts
    • Angular Charts
    • Vue.js Charts
    • jQuery Charts
    • JavaScript Charts
  • SERVER SIDE TECHNOLOGIES
    • Python Charts
    • JSP Charts
    • Spring MVC Charts
    • ASP.NET MVC Charts

PHP Stacked Column Charts & Graphs

Download PHP Chart Samples
  • PHP Chart Samples
  • JavaScript Chart Samples
  • React Chart Samples
  • Angular Chart Samples
  • Vue.js Chart Samples
  • jQuery Chart Samples
  • Python Django Chart Samples
  • ASP.NET Chart Samples
  • JSP Chart Samples
  • Spring MVC Chart Samples
  • Dashboard Samples
  • JavaScript StockChart Samples

Stacked Column Chart, also referred to as Vertical Stacked Bar Chart, is formed by stacking one data-series on top of the another. The below example shows PHP Stacked Column Chart along with source code that you can try running locally.

  • PHP Code
<?php

$dataPoints1 = array(
	array("label"=> "2006", "y"=> 3289),
	array("label"=> "2007", "y"=> 5312),
	array("label"=> "2008", "y"=> 11020),
	array("label"=> "2009", "y"=> 16854),
	array("label"=> "2010", "y"=> 30505),
	array("label"=> "2011", "y"=> 52764),
	array("label"=> "2012", "y"=> 70513),
	array("label"=> "2013", "y"=> 81488),
	array("label"=> "2014", "y"=> 88636),
	array("label"=> "2015", "y"=> 95092),
	array("label"=> "2016", "y"=> 103000)
);

$dataPoints2 = array(
	array("label"=> "2006", "y"=> 1827),
	array("label"=> "2007", "y"=> 2098),
	array("label"=> "2008", "y"=> 2628),
	array("label"=> "2009", "y"=> 3373),
	array("label"=> "2010", "y"=> 4951),
	array("label"=> "2011", "y"=> 7513),
	array("label"=> "2012", "y"=> 12159),
	array("label"=> "2013", "y"=> 21992),
	array("label"=> "2014", "y"=> 34991),
	array("label"=> "2015", "y"=> 50776),
	array("label"=> "2016", "y"=> 68000)
);

$dataPoints3 = array(
	array("label"=> "2006", "y"=> 355),
	array("label"=> "2007", "y"=> 522),
	array("label"=> "2008", "y"=> 828),
	array("label"=> "2009", "y"=> 1328),
	array("label"=> "2010", "y"=> 2410),
	array("label"=> "2011", "y"=> 4590),
	array("label"=> "2012", "y"=> 8365),
	array("label"=> "2013", "y"=> 13727),
	array("label"=> "2014", "y"=> 20534),
	array("label"=> "2015", "y"=> 29639),
	array("label"=> "2016", "y"=> 49000)
);

$dataPoints4 = array(
	array("label"=> "2006", "y"=> 80),
	array("label"=> "2007", "y"=> 100),
	array("label"=> "2008", "y"=> 140),
	array("label"=> "2009", "y"=> 300),
	array("label"=> "2010", "y"=> 800),
	array("label"=> "2011", "y"=> 3300),
	array("label"=> "2012", "y"=> 6800),
	array("label"=> "2013", "y"=> 18600),
	array("label"=> "2014", "y"=> 28199),
	array("label"=> "2015", "y"=> 43530),
	array("label"=> "2016", "y"=> 78000)
);

$dataPoints5 = array(
	array("label"=> "2006", "y"=> 1),
	array("label"=> "2007", "y"=> 2),
	array("label"=> "2008", "y"=> 3),
	array("label"=> "2009", "y"=> 25),
	array("label"=> "2010", "y"=> 80),
	array("label"=> "2011", "y"=> 205),
	array("label"=> "2012", "y"=> 570),
	array("label"=> "2013", "y"=> 953),
	array("label"=> "2014", "y"=> 1711),
	array("label"=> "2015", "y"=> 2420),
	array("label"=> "2016", "y"=> 6000)
);

$dataPoints6 = array(
	array("label"=> "2006", "y"=> 1108),
	array("label"=> "2007", "y"=> 1150),
	array("label"=> "2008", "y"=> 1226),
	array("label"=> "2009", "y"=> 1306),
	array("label"=> "2010", "y"=> 1590),
	array("label"=> "2011", "y"=> 2098),
	array("label"=> "2012", "y"=> 2098),
	array("label"=> "2013", "y"=> 2098),
	array("label"=> "2014", "y"=> 4155),
	array("label"=> "2015", "y"=> 7843),
	array("label"=> "2016", "y"=> 7843)
);

?>
<!DOCTYPE HTML>
<html>
<head>  
<script>
window.onload = function () {

var chart = new CanvasJS.Chart("chartContainer", {
	title: {
		text: "Growth of Solar Photovoltaics"
	},
	theme: "light2",
	animationEnabled: true,
	toolTip:{
		shared: true,
		reversed: true
	},
	axisY: {
		title: "Cumulative Capacity",
		suffix: " MW"
	},
	legend: {
		cursor: "pointer",
		itemclick: toggleDataSeries
	},
	data: [
		{
			type: "stackedColumn",
			name: "Europe",
			showInLegend: true,
			yValueFormatString: "#,##0 MW",
			dataPoints: <?php echo json_encode($dataPoints1, JSON_NUMERIC_CHECK); ?>
		},{
			type: "stackedColumn",
			name: "Asia-Pacific",
			showInLegend: true,
			yValueFormatString: "#,##0 MW",
			dataPoints: <?php echo json_encode($dataPoints2, JSON_NUMERIC_CHECK); ?>
		},{
			type: "stackedColumn",
			name: "Americas",
			showInLegend: true,
			yValueFormatString: "#,##0 MW",
			dataPoints: <?php echo json_encode($dataPoints3, JSON_NUMERIC_CHECK); ?>
		},{
			type: "stackedColumn",
			name: "China",
			showInLegend: true,
			yValueFormatString: "#,##0 MW",
			dataPoints: <?php echo json_encode($dataPoints4, JSON_NUMERIC_CHECK); ?>
		},{
			type: "stackedColumn",
			name: "Middle East and Africa",
			showInLegend: true,
			yValueFormatString: "#,##0 MW",
			dataPoints: <?php echo json_encode($dataPoints5, JSON_NUMERIC_CHECK); ?>
		},{
			type: "stackedColumn",
			name: "Rest of the world",
			showInLegend: true,
			yValueFormatString: "#,##0 MW",
			dataPoints: <?php echo json_encode($dataPoints6, JSON_NUMERIC_CHECK); ?>
		}
	]
});

chart.render();

function toggleDataSeries(e) {
	if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
		e.dataSeries.visible = false;
	} else {
		e.dataSeries.visible = true;
	}
	e.chart.render();
}

}
</script>
</head>
<body>
<div id="chartContainer" style="height: 370px; width: 100%;"></div>
<script src="https://cdn.canvasjs.com/canvasjs.min.js"></script>
</body>
</html>                              

Chart Customizations

The readability of the chart can be enhanced by enabling legends of data-series. You can do so by setting showInLegend to true at data-series level. Other commonly used customization options include setting color, showInLegend, etc.

Quick Links

  • Chart Docs
  • StockChart Docs
  • About Us
  • FAQs

Server Side Technologies

  • ASP.NET MVC Charts
  • PHP Charts
  • JSP Charts
  • Spring MVC Charts

Front Side Technologies

  • JavaScript Charts
  • jQuery Charts
  • React Charts
  • Angular Charts
  • JavaScript StockCharts

Contact

  • Fenopix, Inc.
  • 2093 Philadelphia Pike,
  • #5678, Claymont,
  • Delaware 19703
  • United States Of America

©2025 Fenopix Privacy Policy Cookies Policy Careers