line-area.js 2.7 KB

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