chart.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. $(function() {
  2. "use strict";
  3. /*LIne-Chart */
  4. var ctx = document.getElementById("chartLine").getContext('2d');
  5. var myChart = new Chart(ctx, {
  6. type: 'line',
  7. data: {
  8. labels: ["Sun", "Mon", "Tus", "Wed", "Thu", "Fri", "Sat"],
  9. datasets: [{
  10. label: 'Profits',
  11. data: [100, 420, 210, 420, 210, 320, 350],
  12. borderWidth: 2,
  13. backgroundColor: 'transparent',
  14. borderColor: '#6c5ffc',
  15. borderWidth: 3,
  16. lineTension:0.3,
  17. pointBackgroundColor: '#ffffff',
  18. pointRadius: 2
  19. }, {
  20. label: 'Expenses',
  21. data: [450, 200, 350, 250, 480, 200, 400],
  22. borderWidth: 2,
  23. backgroundColor: 'transparent',
  24. borderColor: '#05c3fb',
  25. borderWidth: 3,
  26. lineTension:0.3,
  27. pointBackgroundColor: '#ffffff',
  28. pointRadius: 2
  29. }]
  30. },
  31. options: {
  32. responsive: true,
  33. maintainAspectRatio: false,
  34. scales: {
  35. x: {
  36. ticks: {
  37. color: "#9ba6b5",
  38. },
  39. display: true,
  40. grid: {
  41. color: 'rgba(119, 119, 142, 0.2)'
  42. }
  43. },
  44. y: {
  45. ticks: {
  46. color: "#9ba6b5",
  47. },
  48. display: true,
  49. grid: {
  50. color: 'rgba(119, 119, 142, 0.2)'
  51. },
  52. scaleLabel: {
  53. display: false,
  54. labelString: 'Thousands',
  55. fontColor: 'rgba(119, 119, 142, 0.2)'
  56. }
  57. }
  58. },
  59. legend: {
  60. labels: {
  61. fontColor: "#9ba6b5"
  62. },
  63. },
  64. }
  65. });
  66. /* Bar-Chart1 */
  67. var ctx = document.getElementById("chartBar1").getContext('2d');
  68. var myChart = new Chart(ctx, {
  69. type: 'bar',
  70. data: {
  71. labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"],
  72. datasets: [{
  73. label: 'Sales',
  74. data: [200, 450, 290, 367, 256, 543, 345, 290, 367],
  75. borderWidth: 2,
  76. backgroundColor: '#6c5ffc',
  77. borderColor: '#6c5ffc',
  78. borderWidth: 2.0,
  79. pointBackgroundColor: '#ffffff',
  80. }]
  81. },
  82. options: {
  83. responsive: true,
  84. maintainAspectRatio: false,
  85. legend: {
  86. display: true
  87. },
  88. scales: {
  89. y: {
  90. ticks: {
  91. beginAtZero: true,
  92. stepSize: 150,
  93. color: "#9ba6b5",
  94. },
  95. grid: {
  96. color: 'rgba(119, 119, 142, 0.2)'
  97. }
  98. },
  99. x: {
  100. barPercentage: 0.4,
  101. barValueSpacing: 0,
  102. barDatasetSpacing: 0,
  103. barRadius: 0,
  104. ticks: {
  105. display: true,
  106. color: "#9ba6b5",
  107. },
  108. grid: {
  109. display: false,
  110. color: 'rgba(119, 119, 142, 0.2)'
  111. }
  112. }
  113. },
  114. legend: {
  115. labels: {
  116. fontColor: "#9ba6b5"
  117. },
  118. },
  119. }
  120. });
  121. /* Bar-Chart2*/
  122. var ctx = document.getElementById("chartBar2");
  123. var myChart = new Chart(ctx, {
  124. type: 'bar',
  125. data: {
  126. labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul"],
  127. datasets: [{
  128. label: "Data1",
  129. data: [65, 59, 80, 81, 56, 55, 40],
  130. borderColor: "#6c5ffc",
  131. borderWidth: "0",
  132. backgroundColor: "#6c5ffc"
  133. }, {
  134. label: "Data2",
  135. data: [28, 48, 40, 19, 86, 27, 90],
  136. borderColor: "#05c3fb",
  137. borderWidth: "0",
  138. backgroundColor: "#05c3fb"
  139. }]
  140. },
  141. options: {
  142. responsive: true,
  143. maintainAspectRatio: false,
  144. scales: {
  145. x: {
  146. barPercentage: 0.4,
  147. barValueSpacing: 0,
  148. barDatasetSpacing: 0,
  149. barRadius: 0,
  150. ticks: {
  151. color: "#9ba6b5",
  152. },
  153. grid: {
  154. color: 'rgba(119, 119, 142, 0.2)'
  155. }
  156. },
  157. y: {
  158. ticks: {
  159. beginAtZero: true,
  160. color: "#9ba6b5",
  161. },
  162. grid: {
  163. color: 'rgba(119, 119, 142, 0.2)'
  164. },
  165. }
  166. },
  167. legend: {
  168. labels: {
  169. color: "#9ba6b5"
  170. },
  171. },
  172. }
  173. });
  174. /* Area Chart*/
  175. var ctx = document.getElementById("chartArea");
  176. var myChart = new Chart(ctx, {
  177. type: 'line',
  178. data: {
  179. labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul"],
  180. datasets: [{
  181. label: "Data1",
  182. borderColor: "#6c5ffc",
  183. borderWidth: "3",
  184. lineTension:0.3,
  185. backgroundColor: "rgba(108, 95, 252, .1)",
  186. fill: true,
  187. data: [22, 44, 67, 43, 76, 45, 12]
  188. }, {
  189. label: "Data2",
  190. borderColor: "rgba(5, 195, 251 ,0.9)",
  191. borderWidth: "3",
  192. lineTension:0.3,
  193. backgroundColor: "rgba(5, 195, 251, 0.7)",
  194. pointHighlightStroke: "rgba(5, 195, 251 ,1)",
  195. fill: true,
  196. data: [16, 32, 18, 26, 42, 33, 44]
  197. }]
  198. },
  199. options: {
  200. responsive: true,
  201. maintainAspectRatio: false,
  202. tooltips: {
  203. mode: 'index',
  204. intersect: false
  205. },
  206. hover: {
  207. mode: 'nearest',
  208. intersect: true
  209. },
  210. scales: {
  211. x: {
  212. ticks: {
  213. color: "#9ba6b5",
  214. },
  215. grid: {
  216. color: 'rgba(119, 119, 142, 0.2)'
  217. }
  218. },
  219. yAxes: {
  220. ticks: {
  221. beginAtZero: true,
  222. color: "#9ba6b5",
  223. },
  224. grid: {
  225. color: 'rgba(119, 119, 142, 0.2)'
  226. },
  227. }
  228. },
  229. legend: {
  230. labels: {
  231. color: "#9ba6b5"
  232. },
  233. },
  234. }
  235. });
  236. /* Pie Chart*/
  237. var datapie = {
  238. labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
  239. datasets: [{
  240. data: [20, 20, 30, 5, 25],
  241. backgroundColor: ['#6c5ffc', '#05c3fb', '#09ad95', '#1170e4', '#e82646']
  242. }]
  243. };
  244. var optionpie = {
  245. maintainAspectRatio: false,
  246. responsive: true,
  247. legend: {
  248. display: false,
  249. },
  250. animation: {
  251. animateScale: true,
  252. animateRotate: true
  253. }
  254. };
  255. /* Doughbut Chart*/
  256. var ctx6 = document.getElementById('chartPie');
  257. var myPieChart6 = new Chart(ctx6, {
  258. type: 'doughnut',
  259. data: datapie,
  260. options: optionpie
  261. });
  262. /* Pie Chart*/
  263. var ctx7 = document.getElementById('chartDonut');
  264. var myPieChart7 = new Chart(ctx7, {
  265. type: 'pie',
  266. data: datapie,
  267. options: optionpie
  268. });
  269. /* Radar chart*/
  270. var ctx = document.getElementById("chartRadar");
  271. var myChart = new Chart(ctx, {
  272. type: 'radar',
  273. data: {
  274. labels: [
  275. ["Eating", "Dinner"],
  276. ["Drinking", "Water"], "Sleeping", ["Designing", "Graphics"], "Coding", "Cycling", "Running",
  277. ],
  278. datasets: [{
  279. label: "Data1",
  280. data: [65, 59, 66, 45, 56, 55, 40],
  281. borderColor: "rgba(108, 95, 252, .8)",
  282. borderWidth: "1",
  283. backgroundColor: "rgba(108, 95, 252, .4)"
  284. }, {
  285. label: "Data2",
  286. data: [28, 12, 40, 19, 63, 27, 87],
  287. borderColor: "rgba(5, 195, 251,0.8)",
  288. borderWidth: "1",
  289. backgroundColor: "rgba(5, 195, 251,0.4)"
  290. }]
  291. },
  292. options: {
  293. responsive: true,
  294. maintainAspectRatio: false,
  295. legend: {
  296. display: false
  297. },
  298. scale: {
  299. angleLines: { color: '#9ba6b5' },
  300. grid: {
  301. color: 'rgba(119, 119, 142, 0.2)'
  302. },
  303. ticks: {
  304. beginAtZero: true,
  305. color: 'rgba(119, 119, 142, 0.2)'
  306. },
  307. pointLabels: {
  308. color: '#9ba6b5',
  309. },
  310. },
  311. }
  312. });
  313. /* polar chart */
  314. var ctx = document.getElementById("chartPolar");
  315. var myChart = new Chart(ctx, {
  316. type: 'polarArea',
  317. data: {
  318. datasets: [{
  319. data: [18, 15, 9, 6, 19],
  320. backgroundColor: ['#6c5ffc', '#05c3fb', '#09ad95', '#1170e4', '#e82646'],
  321. hoverBackgroundColor: ['#6c5ffc', '#05c3fb', '#09ad95', '#1170e4', '#e82646'],
  322. borderColor: 'transparent',
  323. }],
  324. labels: ["Data1", "Data2", "Data3", "Data4"]
  325. },
  326. options: {
  327. scale: {
  328. grid: {
  329. color: 'rgba(119, 119, 142, 0.2)'
  330. }
  331. },
  332. responsive: true,
  333. maintainAspectRatio: false,
  334. legend: {
  335. labels: {
  336. color: "#9ba6b5"
  337. },
  338. },
  339. }
  340. });
  341. });