Stacked Bar Chart with Index Labels placed inside - CanvasJS
HTML5 Stacked Bar Chart with Index Labels placed inside
by canvasjs
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<div id="chartContainer" style="height: 360px; width: 100%;"></div>
<p class="description">Built using <a href="http://canvasjs.com" title="CanvasJS HTML5 Charts" target="_blank">CanvasJS HTML5 Charts</a>
</p>
CSS
.description{
margin-top: 50px;
text-align:left;
font-family: calibri;
font-size: 16px;
color: gray;
}
a:link, a:visited, a:active{color: #4F81BC;}
JavaScript
var chart = new CanvasJS.Chart("chartContainer",
{
data: [
{
indexLabel: "{y}",
indexLabelFontColor:"white",
indexLabelPlacement:"inside",
type: "stackedBar",
dataPoints: [
{ x: 10, y: 71 },
{ x: 20, y: 55},
{ x: 30, y: 50 },
{ x: 40, y: 65 },
{ x: 50, y: 95 },
{ x: 60, y: 68 },
{ x: 70, y: 48 },
{ x: 80, y: 34 },
{ x: 90, y: 44}
]
},
{
indexLabel: "{y}",
indexLabelFontColor:"white",
indexLabelPlacement:"inside",
type: "stackedBar",
dataPoints: [
{ x: 10, y: 41 },
{ x: 20, y: 55},
{ x: 30, y: 40 },
{ x: 40, y: 65 },
{ x: 50, y: 55 },
{ x: 60, y: 48 },
{ x: 70, y: 28 },
{ x: 80, y: 34 },
{ x: 90, y: 34}
]
}
]
});
chart.render();