chartjs-custom.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. $(function () {
  2. "use strict";
  3. // chart 1
  4. var ctx = document.getElementById('chart1').getContext('2d');
  5. var myChart = new Chart(ctx, {
  6. type: 'line',
  7. data: {
  8. labels: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
  9. datasets: [{
  10. label: 'Google',
  11. data: [6, 20, 14, 12, 17, 8, 10],
  12. backgroundColor: "transparent",
  13. borderColor: "#3461ff",
  14. pointRadius: "0",
  15. borderWidth: 4
  16. }, {
  17. label: 'Facebook',
  18. data: [5, 30, 16, 23, 8, 14, 11],
  19. backgroundColor: "transparent",
  20. borderColor: "#0c971a",
  21. pointRadius: "0",
  22. borderWidth: 4
  23. }]
  24. },
  25. options: {
  26. maintainAspectRatio: false,
  27. legend: {
  28. display: true,
  29. labels: {
  30. fontColor: '#585757',
  31. boxWidth: 40
  32. }
  33. },
  34. tooltips: {
  35. enabled: false
  36. },
  37. scales: {
  38. xAxes: [{
  39. ticks: {
  40. beginAtZero: true,
  41. fontColor: '#585757'
  42. },
  43. gridLines: {
  44. display: true,
  45. color: "rgba(0, 0, 0, 0.07)"
  46. },
  47. }],
  48. yAxes: [{
  49. ticks: {
  50. beginAtZero: true,
  51. fontColor: '#585757'
  52. },
  53. gridLines: {
  54. display: true,
  55. color: "rgba(0, 0, 0, 0.07)"
  56. },
  57. }]
  58. }
  59. }
  60. });
  61. // chart 2
  62. var ctx = document.getElementById("chart2").getContext('2d');
  63. var myChart = new Chart(ctx, {
  64. type: 'bar',
  65. data: {
  66. labels: ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'],
  67. datasets: [{
  68. label: 'Google',
  69. data: [13, 8, 20, 4, 18, 29, 25],
  70. barPercentage: .5,
  71. backgroundColor: "#3461ff"
  72. }, {
  73. label: 'Facebook',
  74. data: [31, 20, 6, 16, 21, 4, 11],
  75. barPercentage: .5,
  76. backgroundColor: "#7997ff"
  77. }]
  78. },
  79. options: {
  80. maintainAspectRatio: false,
  81. legend: {
  82. display: true,
  83. labels: {
  84. fontColor: '#585757',
  85. boxWidth: 40
  86. }
  87. },
  88. tooltips: {
  89. enabled: true
  90. },
  91. scales: {
  92. xAxes: [{
  93. barPercentage: .4,
  94. ticks: {
  95. beginAtZero: true,
  96. fontColor: '#585757'
  97. },
  98. gridLines: {
  99. display: true,
  100. color: "rgba(0, 0, 0, 0.07)"
  101. },
  102. }],
  103. yAxes: [{
  104. ticks: {
  105. beginAtZero: true,
  106. fontColor: '#585757'
  107. },
  108. gridLines: {
  109. display: true,
  110. color: "rgba(0, 0, 0, 0.07)"
  111. },
  112. }]
  113. }
  114. }
  115. });
  116. // chart 3
  117. new Chart(document.getElementById("chart3"), {
  118. type: 'pie',
  119. data: {
  120. labels: ["Africa", "Asia", "Europe", "Latin America", "North America"],
  121. datasets: [{
  122. label: "Population (millions)",
  123. backgroundColor: ["#0d6efd", "#212529", "#17a00e", "#f41127", "#ffc107"],
  124. data: [2478, 5267, 734, 784, 433]
  125. }]
  126. },
  127. options: {
  128. maintainAspectRatio: false,
  129. title: {
  130. display: true,
  131. text: 'Predicted world population (millions) in 2050'
  132. }
  133. }
  134. });
  135. // chart 4
  136. new Chart(document.getElementById("chart4"), {
  137. type: 'radar',
  138. data: {
  139. labels: ["Africa", "Asia", "Europe", "Latin America", "North America"],
  140. datasets: [{
  141. label: "1950",
  142. fill: true,
  143. backgroundColor: "rgb(13 110 253 / 23%)",
  144. borderColor: "#0d6efd",
  145. pointBorderColor: "#fff",
  146. pointBackgroundColor: "rgba(179,181,198,1)",
  147. data: [8.77, 55.61, 21.69, 6.62, 6.82]
  148. }, {
  149. label: "2050",
  150. fill: true,
  151. backgroundColor: "rgba(255,99,132,0.2)",
  152. borderColor: "rgba(255,99,132,1)",
  153. pointBorderColor: "#fff",
  154. pointBackgroundColor: "rgba(255,99,132,1)",
  155. pointBorderColor: "#fff",
  156. data: [25.48, 54.16, 7.61, 8.06, 4.45]
  157. }]
  158. },
  159. options: {
  160. maintainAspectRatio: false,
  161. title: {
  162. display: true,
  163. text: 'Distribution in % of world population'
  164. }
  165. }
  166. });
  167. // chart 5
  168. new Chart(document.getElementById("chart5"), {
  169. type: 'polarArea',
  170. data: {
  171. labels: ["Africa", "Asia", "Europe", "Latin America", "North America"],
  172. datasets: [{
  173. label: "Population (millions)",
  174. backgroundColor: ["#0d6efd", "#212529", "#17a00e", "#f41127", "#ffc107"],
  175. data: [2478, 5267, 734, 784, 433]
  176. }]
  177. },
  178. options: {
  179. maintainAspectRatio: false,
  180. title: {
  181. display: true,
  182. text: 'Predicted world population (millions) in 2050'
  183. }
  184. }
  185. });
  186. // chart 6
  187. new Chart(document.getElementById("chart6"), {
  188. type: 'doughnut',
  189. data: {
  190. labels: ["Africa", "Asia", "Europe", "Latin America", "North America"],
  191. datasets: [{
  192. label: "Population (millions)",
  193. backgroundColor: ["#0d6efd", "#212529", "#17a00e", "#f41127", "#ffc107"],
  194. data: [2478, 5267, 734, 784, 433]
  195. }]
  196. },
  197. options: {
  198. maintainAspectRatio: false,
  199. title: {
  200. display: true,
  201. text: 'Predicted world population (millions) in 2050'
  202. }
  203. }
  204. });
  205. // chart 7
  206. new Chart(document.getElementById("chart7"), {
  207. type: 'horizontalBar',
  208. data: {
  209. labels: ["Africa", "Asia", "Europe", "Latin America", "North America"],
  210. datasets: [{
  211. label: "Population (millions)",
  212. backgroundColor: ["#0d6efd", "#212529", "#17a00e", "#f41127", "#ffc107"],
  213. data: [2478, 5267, 734, 784, 433]
  214. }]
  215. },
  216. options: {
  217. maintainAspectRatio: false,
  218. legend: {
  219. display: false
  220. },
  221. title: {
  222. display: true,
  223. text: 'Predicted world population (millions) in 2050'
  224. }
  225. }
  226. });
  227. // chart 8
  228. new Chart(document.getElementById("chart8"), {
  229. type: 'bar',
  230. data: {
  231. labels: ["1900", "1950", "1999", "2050"],
  232. datasets: [{
  233. label: "Africa",
  234. backgroundColor: "#0d6efd",
  235. data: [133, 221, 783, 2478]
  236. }, {
  237. label: "Europe",
  238. backgroundColor: "#f41127",
  239. data: [408, 547, 675, 734]
  240. }]
  241. },
  242. options: {
  243. maintainAspectRatio: false,
  244. title: {
  245. display: true,
  246. text: 'Population growth (millions)'
  247. }
  248. }
  249. });
  250. // chart 9
  251. new Chart(document.getElementById("chart9"), {
  252. type: 'bar',
  253. data: {
  254. labels: ["1900", "1950", "1999", "2050"],
  255. datasets: [{
  256. label: "Europe",
  257. type: "line",
  258. borderColor: "#673ab7",
  259. data: [408, 547, 675, 734],
  260. fill: false
  261. }, {
  262. label: "Africa",
  263. type: "line",
  264. borderColor: "#f02769",
  265. data: [133, 221, 783, 2478],
  266. fill: false
  267. }, {
  268. label: "Europe",
  269. type: "bar",
  270. backgroundColor: "rgba(0,0,0,0.2)",
  271. data: [408, 547, 675, 734],
  272. }, {
  273. label: "Africa",
  274. type: "bar",
  275. backgroundColor: "rgba(0,0,0,0.2)",
  276. backgroundColorHover: "#3e95cd",
  277. data: [133, 221, 783, 2478]
  278. }]
  279. },
  280. options: {
  281. maintainAspectRatio: false,
  282. title: {
  283. display: true,
  284. text: 'Population growth (millions): Europe & Africa'
  285. },
  286. legend: {
  287. display: false
  288. }
  289. }
  290. });
  291. // chart 10
  292. new Chart(document.getElementById("chart10"), {
  293. type: 'bubble',
  294. data: {
  295. labels: "Africa",
  296. datasets: [{
  297. label: ["China"],
  298. backgroundColor: "#17a00e",
  299. borderColor: "#17a00e",
  300. data: [{
  301. x: 21269017,
  302. y: 5.245,
  303. r: 15
  304. }]
  305. }, {
  306. label: ["Denmark"],
  307. backgroundColor: "#ffc107",
  308. borderColor: "#ffc107",
  309. data: [{
  310. x: 258702,
  311. y: 7.526,
  312. r: 10
  313. }]
  314. }, {
  315. label: ["Germany"],
  316. backgroundColor: "#17a00e",
  317. borderColor: "#17a00e",
  318. data: [{
  319. x: 3979083,
  320. y: 6.994,
  321. r: 15
  322. }]
  323. }, {
  324. label: ["Japan"],
  325. backgroundColor: "#f41127",
  326. borderColor: "#f41127",
  327. data: [{
  328. x: 4931877,
  329. y: 5.921,
  330. r: 15
  331. }]
  332. }]
  333. },
  334. options: {
  335. maintainAspectRatio: false,
  336. title: {
  337. display: true,
  338. text: 'Predicted world population (millions) in 2050'
  339. },
  340. scales: {
  341. yAxes: [{
  342. scaleLabel: {
  343. display: true,
  344. labelString: "Happiness"
  345. }
  346. }],
  347. xAxes: [{
  348. scaleLabel: {
  349. display: true,
  350. labelString: "GDP (PPP)"
  351. }
  352. }]
  353. }
  354. }
  355. });
  356. });