column-stacked.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*=========================================================================================
  2. File Name: column-stacked.js
  3. Description: Chartjs column stacked chart
  4. ----------------------------------------------------------------------------------------
  5. Item Name: Robust - Responsive Admin Theme
  6. Version: 1.2
  7. Author: PIXINVENT
  8. Author URL: http://www.themeforest.net/user/pixinvent
  9. ==========================================================================================*/
  10. // Column stacked chart
  11. // ------------------------------
  12. $(window).on("load", function(){
  13. // Get the context of the Chart canvas element we want to select
  14. var ctx = $("#column-stacked");
  15. // Chart Options
  16. var chartOptions = {
  17. title:{
  18. display:false,
  19. text:"Chart.js Column Chart - Stacked"
  20. },
  21. tooltips: {
  22. mode: 'label'
  23. },
  24. responsive: true,
  25. maintainAspectRatio: false,
  26. responsiveAnimationDuration:500,
  27. scales: {
  28. xAxes: [{
  29. stacked: true,
  30. display: true,
  31. gridLines: {
  32. color: "#f3f3f3",
  33. drawTicks: false,
  34. },
  35. scaleLabel: {
  36. display: true,
  37. }
  38. }],
  39. yAxes: [{
  40. stacked: true,
  41. display: true,
  42. gridLines: {
  43. color: "#f3f3f3",
  44. drawTicks: false,
  45. },
  46. scaleLabel: {
  47. display: true,
  48. }
  49. }]
  50. }
  51. };
  52. // Chart Data
  53. var chartData = {
  54. labels: ["January", "February", "March", "April", "May"],
  55. datasets: [{
  56. label: "My First dataset",
  57. data: [65, 59, 80, 81, 56],
  58. backgroundColor: "#00BFA5",
  59. hoverBackgroundColor: "rgba(0,191,165,.8)",
  60. borderColor: "transparent"
  61. }, {
  62. label: "My Second dataset",
  63. data: [28, 48, 40, 19, 86],
  64. backgroundColor: "#1DE9B6",
  65. hoverBackgroundColor: "rgba(29,233,182,.8)",
  66. borderColor: "transparent"
  67. },
  68. {
  69. label: "My Third dataset",
  70. data: [80, 25, 16, 36, 67],
  71. backgroundColor: "#64FFDA",
  72. hoverBackgroundColor: "rgba(100,255,218,.8)",
  73. borderColor: "transparent"
  74. }]
  75. };
  76. var config = {
  77. type: 'bar',
  78. // Chart Options
  79. options : chartOptions,
  80. data : chartData
  81. };
  82. // Create the chart
  83. var lineChart = new Chart(ctx, config);
  84. });