Dashboard sipadu mbip
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.

float-chart-custom.js 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. "use strict";
  2. $(document).ready(function() {
  3. setTimeout(function(){
  4. $(window).on('resize',function() {
  5. categoryChart();
  6. strackingChart();
  7. pieChart();
  8. donutChart();
  9. });
  10. categoryChart();
  11. strackingChart();
  12. pieChart();
  13. donutChart();
  14. },350);
  15. /*categories chart*/
  16. function categoryChart() {
  17. var data = [
  18. ["January", 20],
  19. ["February", 8],
  20. ["March", 4],
  21. ["April", 13],
  22. ["May", 5],
  23. ["June", 9]
  24. ];
  25. $.plot("#placeholder", [data], {
  26. series: {
  27. bars: {
  28. show: true,
  29. barWidth: 0.6,
  30. align: "center",
  31. }
  32. },
  33. xaxis: {
  34. mode: "categories",
  35. tickLength: 0,
  36. tickColor: '#f5f5f5',
  37. },
  38. colors: ["#ff5252", "#83D6DE"],
  39. labelBoxBorderColor: "red"
  40. });
  41. };
  42. /*Stracking chart*/
  43. function strackingChart() {
  44. var d1 = [];
  45. for (var i = 0; i <= 10; i += 1) {
  46. d1.push([i, parseInt(Math.random() * 30)]); /*yellow*/
  47. }
  48. var d2 = [];
  49. for (var i = 0; i <= 10; i += 1) {
  50. d2.push([i, parseInt(Math.random() * 30)]); /*blue*/
  51. }
  52. var d3 = [];
  53. for (var i = 0; i <= 10; i += 1) {
  54. d3.push([i, parseInt(Math.random() * 30)]); /*red*/
  55. }
  56. var stack = 0,
  57. bars = false,
  58. lines = true,
  59. steps = false;
  60. function plotWithOptions() {
  61. $.plot("#placeholder1", [d1, d2, d3], {
  62. series: {
  63. stack: stack,
  64. lines: {
  65. show: lines,
  66. fill: true,
  67. steps: steps
  68. },
  69. bars: {
  70. show: bars,
  71. barWidth: 0.6
  72. }
  73. }
  74. });
  75. }
  76. plotWithOptions();
  77. };
  78. /*pie chart-Withour legend*/
  79. function pieChart() {
  80. var data1 = [{
  81. label: "Sales & Marketing",
  82. data: 2034,
  83. color: "#25A6F7"
  84. }, {
  85. label: "Research & Development",
  86. data: 16410,
  87. color: "#01C0C8"
  88. }, {
  89. label: "General & Administration",
  90. data: 4670,
  91. color: "#42E1FE"
  92. }];
  93. $.plot('#placeholder2', data1, {
  94. series: {
  95. pie: {
  96. show: true
  97. }
  98. },
  99. legend: {
  100. show: false
  101. }
  102. });
  103. };
  104. /*Donut Hole*/
  105. function donutChart() {
  106. var data2 = [{
  107. label: "Sales & Marketing",
  108. data: 2034,
  109. color: "#FB9678"
  110. }, {
  111. label: "Research & Development",
  112. data: 16410,
  113. color: "#4F5467"
  114. }, {
  115. label: "General & Administration",
  116. data: 4670,
  117. color: "#01C0C8"
  118. }];
  119. $.plot('#placeholder3', data2, {
  120. series: {
  121. pie: {
  122. innerRadius: 0.7,
  123. show: true
  124. },
  125. legend: {
  126. show: true,
  127. position: "center"
  128. }
  129. }
  130. });
  131. }
  132. // series types chart
  133. $(function() {
  134. var d1 = [];
  135. for (var i = 0; i < 14; i += 0.5) {
  136. d1.push([i, Math.sin(i)]);
  137. }
  138. var d2 = [
  139. [0, 3],
  140. [4, 8],
  141. [8, 5],
  142. [9, 13]
  143. ];
  144. var d3 = [];
  145. for (var i = 0; i < 14; i += 0.5) {
  146. d3.push([i, Math.cos(i)]);
  147. }
  148. var d4 = [];
  149. for (var i = 0; i < 14; i += 0.1) {
  150. d4.push([i, Math.sqrt(i * 10)]);
  151. }
  152. var d5 = [];
  153. for (var i = 0; i < 14; i += 0.5) {
  154. d5.push([i, Math.sqrt(i)]);
  155. }
  156. var d6 = [];
  157. for (var i = 0; i < 14; i += 0.5 + Math.random()) {
  158. d6.push([i, Math.sqrt(2 * i + Math.sin(i) + 5)]);
  159. }
  160. $.plot("#seriestypes", [{
  161. data: d1,
  162. lines: { show: true, fill: true }
  163. }, {
  164. data: d2,
  165. bars: { show: true }
  166. }, {
  167. data: d3,
  168. points: { show: true }
  169. }, {
  170. data: d4,
  171. lines: { show: true }
  172. }, {
  173. data: d5,
  174. lines: { show: true },
  175. points: { show: true }
  176. }, {
  177. data: d6,
  178. lines: { show: true, steps: true }
  179. }]);
  180. // Add the Flot version string to the footer
  181. $("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
  182. });
  183. //real-time update
  184. $(function() {
  185. // We use an inline data source in the example, usually data would
  186. // be fetched from a server
  187. var data = [],
  188. totalPoints = 300;
  189. function getRandomData() {
  190. if (data.length > 0)
  191. data = data.slice(1);
  192. // Do a random walk
  193. while (data.length < totalPoints) {
  194. var prev = data.length > 0 ? data[data.length - 1] : 50,
  195. y = prev + Math.random() * 10 - 5;
  196. if (y < 0) {
  197. y = 0;
  198. } else if (y > 100) {
  199. y = 100;
  200. }
  201. data.push(y);
  202. }
  203. // Zip the generated y values with the x values
  204. var res = [];
  205. for (var i = 0; i < data.length; ++i) {
  206. res.push([i, data[i]])
  207. }
  208. return res;
  209. }
  210. // Set up the control widget
  211. var updateInterval = 30;
  212. $("#updateInterval").val(updateInterval).change(function() {
  213. var v = $(this).val();
  214. if (v && !isNaN(+v)) {
  215. updateInterval = +v;
  216. if (updateInterval < 1) {
  217. updateInterval = 1;
  218. } else if (updateInterval > 2000) {
  219. updateInterval = 2000;
  220. }
  221. $(this).val("" + updateInterval);
  222. }
  223. });
  224. var plot = $.plot("#realtimeupdate", [getRandomData()], {
  225. series: {
  226. shadowSize: 0 // Drawing is faster without shadows
  227. },
  228. yaxis: {
  229. min: 0,
  230. max: 100
  231. },
  232. xaxis: {
  233. show: false
  234. }
  235. });
  236. function update() {
  237. plot.setData([getRandomData()]);
  238. // Since the axes don't change, we don't need to call plot.setupGrid()
  239. plot.draw();
  240. setTimeout(update, updateInterval);
  241. }
  242. update();
  243. // Add the Flot version string to the footer
  244. $("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
  245. });
  246. //Percentiles
  247. $(function() {
  248. var males = { "8%": [
  249. [2, 20.0],
  250. [3, 30.3],
  251. [4, 40.0],
  252. [5, 50.5],
  253. [6, 60.7],
  254. [7, 70.6],
  255. [8, 80.6],
  256. [9, 90.3],
  257. [10, 100.3],
  258. [11, 110.4],
  259. [12, 146.5],
  260. [13, 151.7],
  261. [14, 159.9],
  262. [15, 165.4],
  263. [16, 167.8],
  264. [17, 168.7],
  265. [18, 169.5],
  266. [19, 168.0]
  267. ], "90%": [
  268. [2, 96.8],
  269. [3, 105.2],
  270. [4, 113.9],
  271. [5, 120.8],
  272. [6, 127.0],
  273. [7, 133.1],
  274. [8, 139.1],
  275. [9, 143.9],
  276. [10, 151.3],
  277. [11, 161.1],
  278. [12, 164.8],
  279. [13, 173.5],
  280. [14, 179.0],
  281. [15, 182.0],
  282. [16, 186.9],
  283. [17, 185.2],
  284. [18, 186.3],
  285. [19, 186.6]
  286. ], "25%": [
  287. [2, 89.2],
  288. [3, 94.9],
  289. [4, 104.4],
  290. [5, 111.4],
  291. [6, 117.5],
  292. [7, 120.2],
  293. [8, 127.1],
  294. [9, 132.9],
  295. [10, 136.8],
  296. [11, 144.4],
  297. [12, 149.5],
  298. [13, 154.1],
  299. [14, 163.1],
  300. [15, 169.2],
  301. [16, 170.4],
  302. [17, 171.2],
  303. [18, 172.4],
  304. [19, 170.8]
  305. ], "10%": [
  306. [2, 86.9],
  307. [3, 92.6],
  308. [4, 99.9],
  309. [5, 107.0],
  310. [6, 114.0],
  311. [7, 113.5],
  312. [8, 123.6],
  313. [9, 129.2],
  314. [10, 133.0],
  315. [11, 140.6],
  316. [12, 145.2],
  317. [13, 149.7],
  318. [14, 158.4],
  319. [15, 163.5],
  320. [16, 166.9],
  321. [17, 167.5],
  322. [18, 167.1],
  323. [19, 165.3]
  324. ], "mean": [
  325. [2, 91.9],
  326. [3, 98.5],
  327. [4, 107.1],
  328. [5, 114.4],
  329. [6, 120.6],
  330. [7, 124.7],
  331. [8, 131.1],
  332. [9, 136.8],
  333. [10, 142.3],
  334. [11, 150.0],
  335. [12, 154.7],
  336. [13, 161.9],
  337. [14, 168.7],
  338. [15, 173.6],
  339. [16, 175.9],
  340. [17, 176.6],
  341. [18, 176.8],
  342. [19, 176.7]
  343. ], "75%": [
  344. [2, 94.5],
  345. [3, 102.1],
  346. [4, 110.8],
  347. [5, 117.9],
  348. [6, 124.0],
  349. [7, 129.3],
  350. [8, 134.6],
  351. [9, 141.4],
  352. [10, 147.0],
  353. [11, 156.1],
  354. [12, 160.3],
  355. [13, 168.3],
  356. [14, 174.7],
  357. [15, 178.0],
  358. [16, 180.2],
  359. [17, 181.7],
  360. [18, 181.3],
  361. [19, 182.5]
  362. ], "85%": [
  363. [2, 96.2],
  364. [3, 103.8],
  365. [4, 111.8],
  366. [5, 119.6],
  367. [6, 125.6],
  368. [7, 131.5],
  369. [8, 138.0],
  370. [9, 143.3],
  371. [10, 149.3],
  372. [11, 159.8],
  373. [12, 162.5],
  374. [13, 171.3],
  375. [14, 177.5],
  376. [15, 180.2],
  377. [16, 183.8],
  378. [17, 183.4],
  379. [18, 183.5],
  380. [19, 185.5]
  381. ], "50%": [
  382. [2, 91.9],
  383. [3, 98.2],
  384. [4, 106.8],
  385. [5, 114.6],
  386. [6, 120.8],
  387. [7, 125.2],
  388. [8, 130.3],
  389. [9, 137.1],
  390. [10, 141.5],
  391. [11, 149.4],
  392. [12, 153.9],
  393. [13, 162.2],
  394. [14, 169.0],
  395. [15, 174.8],
  396. [16, 176.0],
  397. [17, 176.8],
  398. [18, 176.4],
  399. [19, 177.4]
  400. ] };
  401. var females = { "15%": [
  402. [2, 84.8],
  403. [3, 93.7],
  404. [4, 100.6],
  405. [5, 105.8],
  406. [6, 113.3],
  407. [7, 119.3],
  408. [8, 124.3],
  409. [9, 131.4],
  410. [10, 136.9],
  411. [11, 143.8],
  412. [12, 149.4],
  413. [13, 151.2],
  414. [14, 152.3],
  415. [15, 155.9],
  416. [16, 154.7],
  417. [17, 157.0],
  418. [18, 156.1],
  419. [19, 155.4]
  420. ], "90%": [
  421. [2, 95.6],
  422. [3, 104.1],
  423. [4, 111.9],
  424. [5, 119.6],
  425. [6, 127.6],
  426. [7, 133.1],
  427. [8, 138.7],
  428. [9, 147.1],
  429. [10, 152.8],
  430. [11, 161.3],
  431. [12, 166.6],
  432. [13, 167.9],
  433. [14, 169.3],
  434. [15, 170.1],
  435. [16, 172.4],
  436. [17, 169.2],
  437. [18, 171.1],
  438. [19, 172.4]
  439. ], "25%": [
  440. [2, 87.2],
  441. [3, 95.9],
  442. [4, 101.9],
  443. [5, 107.4],
  444. [6, 114.8],
  445. [7, 121.4],
  446. [8, 126.8],
  447. [9, 133.4],
  448. [10, 138.6],
  449. [11, 146.2],
  450. [12, 152.0],
  451. [13, 153.8],
  452. [14, 155.7],
  453. [15, 158.4],
  454. [16, 157.0],
  455. [17, 158.5],
  456. [18, 158.4],
  457. [19, 158.1]
  458. ], "10%": [
  459. [2, 84.0],
  460. [3, 91.9],
  461. [4, 99.2],
  462. [5, 105.2],
  463. [6, 112.7],
  464. [7, 118.0],
  465. [8, 123.3],
  466. [9, 130.2],
  467. [10, 135.0],
  468. [11, 141.1],
  469. [12, 148.3],
  470. [13, 150.0],
  471. [14, 150.7],
  472. [15, 154.3],
  473. [16, 153.6],
  474. [17, 155.6],
  475. [18, 154.7],
  476. [19, 153.1]
  477. ], "mean": [
  478. [2, 90.2],
  479. [3, 98.3],
  480. [4, 105.2],
  481. [5, 112.2],
  482. [6, 119.0],
  483. [7, 125.8],
  484. [8, 131.3],
  485. [9, 138.6],
  486. [10, 144.2],
  487. [11, 151.3],
  488. [12, 156.7],
  489. [13, 158.6],
  490. [14, 160.5],
  491. [15, 162.1],
  492. [16, 162.9],
  493. [17, 162.2],
  494. [18, 163.0],
  495. [19, 163.1]
  496. ], "75%": [
  497. [2, 93.2],
  498. [3, 101.5],
  499. [4, 107.9],
  500. [5, 116.6],
  501. [6, 122.8],
  502. [7, 129.3],
  503. [8, 135.2],
  504. [9, 143.7],
  505. [10, 148.7],
  506. [11, 156.9],
  507. [12, 160.8],
  508. [13, 163.0],
  509. [14, 165.0],
  510. [15, 165.8],
  511. [16, 168.7],
  512. [17, 166.2],
  513. [18, 167.6],
  514. [19, 168.0]
  515. ], "85%": [
  516. [2, 94.5],
  517. [3, 102.8],
  518. [4, 110.4],
  519. [5, 119.0],
  520. [6, 125.7],
  521. [7, 131.5],
  522. [8, 137.9],
  523. [9, 146.0],
  524. [10, 151.3],
  525. [11, 159.9],
  526. [12, 164.0],
  527. [13, 166.5],
  528. [14, 167.5],
  529. [15, 168.5],
  530. [16, 171.5],
  531. [17, 168.0],
  532. [18, 169.8],
  533. [19, 170.3]
  534. ], "50%": [
  535. [2, 90.2],
  536. [3, 98.1],
  537. [4, 105.2],
  538. [5, 111.7],
  539. [6, 118.2],
  540. [7, 125.6],
  541. [8, 130.5],
  542. [9, 138.3],
  543. [10, 143.7],
  544. [11, 151.4],
  545. [12, 156.7],
  546. [13, 157.7],
  547. [14, 161.0],
  548. [15, 162.0],
  549. [16, 162.8],
  550. [17, 162.2],
  551. [18, 162.8],
  552. [19, 163.3]
  553. ] };
  554. var dataset = [
  555. { label: "Female mean", data: females["mean"], lines: { show: true }, color: "rgb(255,50,50)" },
  556. { id: "f15%", data: females["1%"], lines: { show: true, lineWidth: 0, fill: false }, color: "rgb(255,50,50)" },
  557. { id: "f25%", data: females["3%"], lines: { show: true, lineWidth: 0, fill: 0.2 }, color: "rgb(255,50,50)", fillBetween: "f15%" },
  558. { id: "f50%", data: females["6%"], lines: { show: true, lineWidth: 0.5, fill: 0.4, shadowSize: 0 }, color: "rgb(255,50,50)", fillBetween: "f25%" },
  559. { id: "f75%", data: females["8%"], lines: { show: true, lineWidth: 0, fill: 0.4 }, color: "rgb(255,50,50)", fillBetween: "f50%" },
  560. { id: "f85%", data: females["12%"], lines: { show: true, lineWidth: 0, fill: 0.2 }, color: "rgb(255,50,50)", fillBetween: "f75%" },
  561. { label: "Male mean", data: males["mean"], lines: { show: true }, color: "#01C0C8producxt" },
  562. { id: "m15%", data: males["10%"], lines: { show: true, lineWidth: 0, fill: false }, color: "#99E6E9" },
  563. { id: "m25%", data: males["12%"], lines: { show: true, lineWidth: 0, fill: 0.2 }, color: "#99E6E9", fillBetween: "m15%" },
  564. { id: "m50%", data: males["20%"], lines: { show: true, lineWidth: 0.5, fill: 0.4, shadowSize: 0 }, color: "rgb(50,50,255)", fillBetween: "m25%" },
  565. { id: "m75%", data: males["22%"], lines: { show: true, lineWidth: 0, fill: 0.4 }, color: "#99E6E9", fillBetween: "m50%" },
  566. { id: "m85%", data: males["25%"], lines: { show: true, lineWidth: 0, fill: 0.2 }, color: "#99E6E9", fillBetween: "m75%" }
  567. ];
  568. $.plot($("#percentiles"), dataset, {
  569. xaxis: {
  570. tickDecimals: 0
  571. },
  572. yaxis: {
  573. tickFormatter: function(v) {
  574. return v + " cm";
  575. }
  576. },
  577. legend: {
  578. position: "se"
  579. }
  580. });
  581. // Add the Flot version string to the footer
  582. $("#footer").prepend("Flot " + $.plot.version + " &ndash; ");
  583. });
  584. });