line.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*=========================================================================================
  2. File Name: line.js
  3. Description: Chartjs simple line 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 chart
  11. // ------------------------------
  12. $(window).on("load", function(){
  13. //Get the context of the Chart canvas element we want to select
  14. var ctx = $("#line-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: [65, 59, 80, 81, 56, 55, 40],
  60. fill: false,
  61. borderDash: [5, 5],
  62. borderColor: "#673AB7",
  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. fill: false,
  72. borderDash: [5, 5],
  73. borderColor: "#00BCD4",
  74. pointBorderColor: "#00BCD4",
  75. pointBackgroundColor: "#FFF",
  76. pointBorderWidth: 2,
  77. pointHoverBorderWidth: 2,
  78. pointRadius: 4,
  79. }, {
  80. label: "My Third dataset - No bezier",
  81. data: [45, 25, 16, 36, 67, 18, 76],
  82. lineTension: 0,
  83. fill: false,
  84. borderColor: "#FF5722",
  85. pointBorderColor: "#FF5722",
  86. pointBackgroundColor: "#FFF",
  87. pointBorderWidth: 2,
  88. pointHoverBorderWidth: 2,
  89. pointRadius: 4,
  90. }]
  91. };
  92. var config = {
  93. type: 'line',
  94. // Chart Options
  95. options : chartOptions,
  96. data : chartData
  97. };
  98. // Create the chart
  99. var lineChart = new Chart(ctx, config);
  100. });