A bar chart example for chart.js.
$(document).ready(function () {
var data = {
labels: ["Taipei", "Tainan", "Kaohsiung", "Pintung", "Taoyuan", "Miaoli", "Chiayi"],
datasets: [
{
label: "# of store",
fillColor: "rgba(220,220,220,0.5)",
strokeColor: "rgba(220,220,220,0.8)",
highlightFill: "rgba(220,220,220,0.75)",
highlightStroke: "rgba(220,220,220,1)",
data: [20, 40, 30, 21, 56, 45, 60]
},
{
label: "# of staff ",
fillColor: "rgba(151,187,205,0.5)",
strokeColor: "rgba(151,187,205,0.8)",
highlightFill: "rgba(151,187,205,0.75)",
highlightStroke: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
]
};
var option = {
scaleBeginAtZero : true,
//Boolean - Whether grid lines are shown across the chart
scaleShowGridLines : true,
//String - Colour of the grid lines
scaleGridLineColor : "rgba(0,0,0,.05)",
//Number - Width of the grid lines
scaleGridLineWidth : 1,
//Boolean - Whether to show horizontal lines (except X axis)
scaleShowHorizontalLines: true,
//Boolean - Whether to show vertical lines (except Y axis)
scaleShowVerticalLines: true,
//Boolean - If there is a stroke on each bar
barShowStroke : true,
//Number - Pixel width of the bar stroke
barStrokeWidth : 2,
//Number - Spacing between each of the X value sets
barValueSpacing : 5,
//Number - Spacing between data sets within X values
barDatasetSpacing : 1,
};
var ctx = document.getElementById("myChart").getContext("2d");
var myLineChart = new Chart(ctx).Bar(data, option);
});
2015-09-22
Chart.js Example - Bar Chart
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment