JavaScript Bar graph is represented by rectangular bars where length of bar is proportional to the values that they represent. It is used to compare values between different categories. Charts are highly customizable, interactive, support animation, zooming, panning & exporting as image. Given example shows simple JavaScript Bar Chart along with HTML / JavaScript 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:"Fortune 500 Companies by Country" }, axisX:{ interval: 1 }, axisY2:{ interlacedColor: "rgba(1,77,101,.2)", gridColor: "rgba(1,77,101,.1)", title: "Number of Companies" }, data: [{ type: "bar", name: "companies", axisYType: "secondary", color: "#014D65", dataPoints: [ { y: 3, label: "Sweden" }, { y: 7, label: "Taiwan" }, { y: 5, label: "Russia" }, { y: 9, label: "Spain" }, { y: 7, label: "Brazil" }, { y: 7, label: "India" }, { y: 9, label: "Italy" }, { y: 8, label: "Australia" }, { y: 11, label: "Canada" }, { y: 15, label: "South Korea" }, { y: 12, label: "Netherlands" }, { y: 15, label: "Switzerland" }, { y: 25, label: "Britain" }, { y: 28, label: "Germany" }, { y: 29, label: "France" }, { y: 52, label: "Japan" }, { y: 103, label: "China" }, { y: 134, label: "US" } ] }] }); chart.render(); }
Bar Charts can be customized using various options like color, fillOpacity, indexLabel etc. You can also enable zooming capability by setting zoomEnabled property to true.