Theme Inspinia
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

chartjs-demo.js 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. $(function () {
  2. var lineData = {
  3. labels: ["January", "February", "March", "April", "May", "June", "July"],
  4. datasets: [
  5. {
  6. label: "Example dataset",
  7. fillColor: "rgba(220,220,220,0.5)",
  8. strokeColor: "rgba(220,220,220,1)",
  9. pointColor: "rgba(220,220,220,1)",
  10. pointStrokeColor: "#fff",
  11. pointHighlightFill: "#fff",
  12. pointHighlightStroke: "rgba(220,220,220,1)",
  13. data: [65, 59, 80, 81, 56, 55, 40]
  14. },
  15. {
  16. label: "Example dataset",
  17. fillColor: "rgba(26,179,148,0.5)",
  18. strokeColor: "rgba(26,179,148,0.7)",
  19. pointColor: "rgba(26,179,148,1)",
  20. pointStrokeColor: "#fff",
  21. pointHighlightFill: "#fff",
  22. pointHighlightStroke: "rgba(26,179,148,1)",
  23. data: [28, 48, 40, 19, 86, 27, 90]
  24. }
  25. ]
  26. };
  27. var lineOptions = {
  28. scaleShowGridLines: true,
  29. scaleGridLineColor: "rgba(0,0,0,.05)",
  30. scaleGridLineWidth: 1,
  31. bezierCurve: true,
  32. bezierCurveTension: 0.4,
  33. pointDot: true,
  34. pointDotRadius: 4,
  35. pointDotStrokeWidth: 1,
  36. pointHitDetectionRadius: 20,
  37. datasetStroke: true,
  38. datasetStrokeWidth: 2,
  39. datasetFill: true,
  40. responsive: true,
  41. };
  42. var ctx = document.getElementById("lineChart").getContext("2d");
  43. var myNewChart = new Chart(ctx).Line(lineData, lineOptions);
  44. var barData = {
  45. labels: ["January", "February", "March", "April", "May", "June", "July"],
  46. datasets: [
  47. {
  48. label: "My First dataset",
  49. fillColor: "rgba(220,220,220,0.5)",
  50. strokeColor: "rgba(220,220,220,0.8)",
  51. highlightFill: "rgba(220,220,220,0.75)",
  52. highlightStroke: "rgba(220,220,220,1)",
  53. data: [65, 59, 80, 81, 56, 55, 40]
  54. },
  55. {
  56. label: "My Second dataset",
  57. fillColor: "rgba(26,179,148,0.5)",
  58. strokeColor: "rgba(26,179,148,0.8)",
  59. highlightFill: "rgba(26,179,148,0.75)",
  60. highlightStroke: "rgba(26,179,148,1)",
  61. data: [28, 48, 40, 19, 86, 27, 90]
  62. }
  63. ]
  64. };
  65. var barOptions = {
  66. scaleBeginAtZero: true,
  67. scaleShowGridLines: true,
  68. scaleGridLineColor: "rgba(0,0,0,.05)",
  69. scaleGridLineWidth: 1,
  70. barShowStroke: true,
  71. barStrokeWidth: 2,
  72. barValueSpacing: 5,
  73. barDatasetSpacing: 1,
  74. responsive: true
  75. }
  76. var ctx = document.getElementById("barChart").getContext("2d");
  77. var myNewChart = new Chart(ctx).Bar(barData, barOptions);
  78. var polarData = [
  79. {
  80. value: 300,
  81. color: "#a3e1d4",
  82. highlight: "#1ab394",
  83. label: "App"
  84. },
  85. {
  86. value: 140,
  87. color: "#dedede",
  88. highlight: "#1ab394",
  89. label: "Software"
  90. },
  91. {
  92. value: 200,
  93. color: "#b5b8cf",
  94. highlight: "#1ab394",
  95. label: "Laptop"
  96. }
  97. ];
  98. var polarOptions = {
  99. scaleShowLabelBackdrop: true,
  100. scaleBackdropColor: "rgba(255,255,255,0.75)",
  101. scaleBeginAtZero: true,
  102. scaleBackdropPaddingY: 1,
  103. scaleBackdropPaddingX: 1,
  104. scaleShowLine: true,
  105. segmentShowStroke: true,
  106. segmentStrokeColor: "#fff",
  107. segmentStrokeWidth: 2,
  108. animationSteps: 100,
  109. animationEasing: "easeOutBounce",
  110. animateRotate: true,
  111. animateScale: false,
  112. responsive: true,
  113. };
  114. var ctx = document.getElementById("polarChart").getContext("2d");
  115. var myNewChart = new Chart(ctx).PolarArea(polarData, polarOptions);
  116. var doughnutData = [
  117. {
  118. value: 300,
  119. color: "#a3e1d4",
  120. highlight: "#1ab394",
  121. label: "App"
  122. },
  123. {
  124. value: 50,
  125. color: "#dedede",
  126. highlight: "#1ab394",
  127. label: "Software"
  128. },
  129. {
  130. value: 100,
  131. color: "#b5b8cf",
  132. highlight: "#1ab394",
  133. label: "Laptop"
  134. }
  135. ];
  136. var doughnutOptions = {
  137. segmentShowStroke: true,
  138. segmentStrokeColor: "#fff",
  139. segmentStrokeWidth: 2,
  140. percentageInnerCutout: 45, // This is 0 for Pie charts
  141. animationSteps: 100,
  142. animationEasing: "easeOutBounce",
  143. animateRotate: true,
  144. animateScale: false,
  145. responsive: true,
  146. };
  147. var ctx = document.getElementById("doughnutChart").getContext("2d");
  148. var myNewChart = new Chart(ctx).Doughnut(doughnutData, doughnutOptions);
  149. var radarData = {
  150. labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
  151. datasets: [
  152. {
  153. label: "My First dataset",
  154. fillColor: "rgba(220,220,220,0.2)",
  155. strokeColor: "rgba(220,220,220,1)",
  156. pointColor: "rgba(220,220,220,1)",
  157. pointStrokeColor: "#fff",
  158. pointHighlightFill: "#fff",
  159. pointHighlightStroke: "rgba(220,220,220,1)",
  160. data: [65, 59, 90, 81, 56, 55, 40]
  161. },
  162. {
  163. label: "My Second dataset",
  164. fillColor: "rgba(26,179,148,0.2)",
  165. strokeColor: "rgba(26,179,148,1)",
  166. pointColor: "rgba(26,179,148,1)",
  167. pointStrokeColor: "#fff",
  168. pointHighlightFill: "#fff",
  169. pointHighlightStroke: "rgba(151,187,205,1)",
  170. data: [28, 48, 40, 19, 96, 27, 100]
  171. }
  172. ]
  173. };
  174. var radarOptions = {
  175. scaleShowLine: true,
  176. angleShowLineOut: true,
  177. scaleShowLabels: false,
  178. scaleBeginAtZero: true,
  179. angleLineColor: "rgba(0,0,0,.1)",
  180. angleLineWidth: 1,
  181. pointLabelFontFamily: "'Arial'",
  182. pointLabelFontStyle: "normal",
  183. pointLabelFontSize: 10,
  184. pointLabelFontColor: "#666",
  185. pointDot: true,
  186. pointDotRadius: 3,
  187. pointDotStrokeWidth: 1,
  188. pointHitDetectionRadius: 20,
  189. datasetStroke: true,
  190. datasetStrokeWidth: 2,
  191. datasetFill: true,
  192. responsive: true,
  193. }
  194. var ctx = document.getElementById("radarChart").getContext("2d");
  195. var myNewChart = new Chart(ctx).Radar(radarData, radarOptions);
  196. });