JavaScript Area Charts are based on Line Charts but it shades the area that it covers with color. This allows you to visualize cumulative values over a period of time / range. Charts are cross-browser compatible, interactive, supports animation, zooming, panning & exporting as image. Given example shows JavaScript Area Chart along with HTML source code that you can edit in-browser or save to run it locally.
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
title: {
text: "Number of iPhones Sold in Different Quarters"
},
axisX: {
minimum: new Date(2015, 01, 25),
maximum: new Date(2017, 02, 15),
valueFormatString: "MMM YY"
},
axisY: {
title: "Number of Sales",
titleFontColor: "#4F81BC",
includeZero: true,
suffix: "mn"
},
data: [{
indexLabelFontColor: "darkSlateGray",
name: "views",
type: "area",
yValueFormatString: "#,##0.0mn",
dataPoints: [
{ x: new Date(2015, 02, 1), y: 74.4, label: "Q1-2015" },
{ x: new Date(2015, 05, 1), y: 61.1, label: "Q2-2015" },
{ x: new Date(2015, 08, 1), y: 47.0, label: "Q3-2015" },
{ x: new Date(2015, 11, 1), y: 48.0, label: "Q4-2015" },
{ x: new Date(2016, 02, 1), y: 74.8, label: "Q1-2016" },
{ x: new Date(2016, 05, 1), y: 51.1, label: "Q2-2016" },
{ x: new Date(2016, 08, 1), y: 40.4, label: "Q3-2016" },
{ x: new Date(2016, 11, 1), y: 45.5, label: "Q4-2016" },
{ x: new Date(2017, 02, 1), y: 78.3, label: "Q1-2017", indexLabel: "Highest", markerColor: "red" }
]
}]
});
chart.render();
}
You can change opacity of filled area using fillOpacity property. Some other modifications include color, lineColor, lineThickness, markerType etc.