line-stacked-area.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*=========================================================================================
  2. File Name: line-stacked-area.js
  3. Description: Chartjs line stacked area 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. // Line stacked area chart
  11. // ------------------------------
  12. $(window).on("load", function(){
  13. //Get the context of the Chart canvas element we want to select
  14. // var ctx = document.getElementById("line-stacked-area").getContext("2d");
  15. var ctx = $('#line-stacked-area');
  16. // Chart Options
  17. var chartOptions = {
  18. responsive: true,
  19. maintainAspectRatio: false,
  20. legend: {
  21. position: 'bottom',
  22. },
  23. hover: {
  24. mode: 'label'
  25. },
  26. scales: {
  27. xAxes: [{
  28. display: true,
  29. gridLines: {
  30. color: "#f3f3f3",
  31. drawTicks: false,
  32. },
  33. scaleLabel: {
  34. display: true,
  35. labelString: 'Month'
  36. }
  37. }],
  38. yAxes: [{
  39. display: true,
  40. gridLines: {
  41. color: "#f3f3f3",
  42. drawTicks: false,
  43. },
  44. scaleLabel: {
  45. display: true,
  46. labelString: 'Value'
  47. }
  48. }]
  49. },
  50. title: {
  51. display: true,
  52. text: 'Chart.js Line Chart - Legend'
  53. }
  54. };
  55. // Chart Data
  56. var chartData = {
  57. labels: ["January", "February", "March", "April", "May", "June", "July"],
  58. datasets: [{
  59. label: "My First dataset",
  60. data: [65, 59, 80, 81, 56, 55, 40],
  61. backgroundColor: "rgba(103, 58, 183,.4)",
  62. borderColor: "transparent",
  63. pointBorderColor: "#673AB7",
  64. pointBackgroundColor: "#FFF",
  65. pointBorderWidth: 2,
  66. pointHoverBorderWidth: 2,
  67. pointRadius: 4,
  68. }, {
  69. label: "My Second dataset",
  70. data: [28, 48, 40, 19, 86, 27, 90],
  71. backgroundColor: "rgba(0,188,212,.4)",
  72. borderColor: "transparent",
  73. pointBorderColor: "#00BCD4",
  74. pointBackgroundColor: "#FFF",
  75. pointBorderWidth: 2,
  76. pointHoverBorderWidth: 2,
  77. pointRadius: 4,
  78. }, {
  79. label: "My Third dataset",
  80. data: [80, 25, 16, 36, 67, 18, 76],
  81. backgroundColor: "rgba(255,87,34,.4)",
  82. borderColor: "transparent",
  83. pointBorderColor: "#FF5722",
  84. pointBackgroundColor: "#FFF",
  85. pointBorderWidth: 2,
  86. pointHoverBorderWidth: 2,
  87. pointRadius: 4,
  88. }]
  89. };
  90. var config = {
  91. type: 'line',
  92. // Chart Options
  93. options : chartOptions,
  94. // Chart Data
  95. data : chartData
  96. };
  97. // Create the chart
  98. var stackedAreaChart = new Chart(ctx, config);
  99. });