chart.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define("/widgets/chart", ["jquery", "Site"], factory);
  4. } else if (typeof exports !== "undefined") {
  5. factory(require("jquery"), require("Site"));
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory(global.jQuery, global.Site);
  11. global.widgetsChart = mod.exports;
  12. }
  13. })(this, function (_jquery, _Site) {
  14. "use strict";
  15. _jquery = babelHelpers.interopRequireDefault(_jquery);
  16. // Widget Chart
  17. (0, _jquery.default)(document).ready(function (jQuery) {
  18. (0, _Site.run)();
  19. }); // Chart Three Linearea
  20. // --------------------------
  21. (function () {
  22. new Chartist.Line('#chartThreeLinearea .ct-chart', {
  23. labels: ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'],
  24. series: [[4, 4.5, 4.3, 4, 5, 6, 5.5], [3, 2.5, 3, 3.5, 4.2, 4, 5], [1, 2, 2.5, 2, 3, 2.8, 4]]
  25. }, {
  26. low: 0,
  27. showArea: true,
  28. showPoint: false,
  29. showLine: false,
  30. fullWidth: true,
  31. chartPadding: {
  32. top: 0,
  33. right: 0,
  34. bottom: 0,
  35. left: 0
  36. },
  37. axisX: {
  38. showLabel: false,
  39. showGrid: false,
  40. offset: 0
  41. },
  42. axisY: {
  43. showLabel: false,
  44. showGrid: false,
  45. offset: 0
  46. }
  47. });
  48. })(); // Chart line Pie
  49. // --------------------------
  50. (function () {
  51. new Chartist.Line("#chartLinePie .chart-line", {
  52. labels: ['1', '2', '3', '4', '5', '6', '7', '8'],
  53. series: [[4, 5, 3, 6, 7, 5.5, 5.8, 4.6]]
  54. }, {
  55. low: 0,
  56. showArea: false,
  57. showPoint: true,
  58. showLine: true,
  59. fullWidth: true,
  60. lineSmooth: false,
  61. chartPadding: {
  62. top: 4,
  63. right: 4,
  64. bottom: -20,
  65. left: 4
  66. },
  67. axisX: {
  68. showLabel: false,
  69. showGrid: false,
  70. offset: 0
  71. },
  72. axisY: {
  73. showLabel: false,
  74. showGrid: false,
  75. offset: 0
  76. }
  77. });
  78. new Chartist.Pie('#chartLinePie .chart-pie', {
  79. series: [35, 65]
  80. }, {
  81. donut: true,
  82. donutWidth: 10,
  83. startAngle: 0,
  84. showLabel: false
  85. });
  86. })(); // Chart Bar Pie
  87. // ----------------------
  88. (function () {
  89. new Chartist.Bar("#chartBarPie .chart-bar", {
  90. labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L'],
  91. series: [[50, 90, 100, 90, 110, 100, 120, 130, 115, 95, 80, 85]]
  92. }, {
  93. low: 0,
  94. fullWidth: true,
  95. chartPadding: {
  96. top: 0,
  97. right: 0,
  98. bottom: 0,
  99. left: 0
  100. },
  101. axisX: {
  102. showLabel: false,
  103. showGrid: false,
  104. offset: 0
  105. },
  106. axisY: {
  107. showLabel: false,
  108. showGrid: false,
  109. offset: 0
  110. }
  111. });
  112. new Chartist.Pie('#chartBarPie .chart-pie', {
  113. series: [70, 30]
  114. }, {
  115. donut: true,
  116. donutWidth: 10,
  117. startAngle: 0,
  118. showLabel: false
  119. });
  120. })(); // Chart Bar Stacked
  121. // -----------------------
  122. (function () {
  123. var stacked_bar = new Chartist.Bar('#chartBarStacked .ct-chart', {
  124. labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M'],
  125. series: [[11, 19, 17, 13, 2, 11, 26, 20, 27, 5, 22, 4], [6, 18, 7, 9, 26, 24, 3, 18, 28, 21, 19, 12], [9, 10, 22, 14, 23, 19, 15, 25, 28, 21, 17, 17]]
  126. }, {
  127. stackBars: true,
  128. fullWidth: true,
  129. seriesBarDistance: 0,
  130. chartPadding: {
  131. top: -10,
  132. right: 0,
  133. bottom: 0,
  134. left: 0
  135. },
  136. axisX: {
  137. showLabel: true,
  138. showGrid: false,
  139. offset: 30
  140. },
  141. axisY: {
  142. showLabel: true,
  143. showGrid: true,
  144. offset: 30
  145. }
  146. });
  147. })(); // Chart Pie
  148. // -------------------
  149. (function () {
  150. new Chartist.Pie('#chartPie .ct-chart', {
  151. series: [35, 20, 45]
  152. }, {
  153. donut: true,
  154. donutWidth: 10,
  155. startAngle: 0,
  156. showLabel: false
  157. });
  158. })(); // Chart Bar Simple
  159. // -----------------------
  160. (function () {
  161. new Chartist.Bar("#chartBarSimple .ct-chart", {
  162. labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T'],
  163. series: [[6, 3, 2, 5, 4, 7, 5, 9, 4, 5, 4, 9, 8, 3, 6, 4, 8, 6, 8, 6, 4]]
  164. }, {
  165. low: 0,
  166. fullWidth: true,
  167. chartPadding: {
  168. top: 0,
  169. right: 0,
  170. bottom: 0,
  171. left: 0
  172. },
  173. axisX: {
  174. showLabel: false,
  175. showGrid: false,
  176. offset: 0
  177. },
  178. axisY: {
  179. showLabel: false,
  180. showGrid: false,
  181. offset: 0
  182. }
  183. });
  184. })(); // Chart Linearea Simple
  185. // --------------------------
  186. (function () {
  187. new Chartist.Line('#chartLineareaSimple .ct-chart', {
  188. labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T'],
  189. series: [[1, 6, 4, 9, 1, 6, 4, 9, 8, 6, 5, 1, 4, 6, 4, 9, 1, 3, 1, 9]]
  190. }, {
  191. low: 0,
  192. showArea: true,
  193. showPoint: false,
  194. showLine: true,
  195. fullWidth: true,
  196. lineSmooth: false,
  197. chartPadding: {
  198. top: 0,
  199. right: 0,
  200. bottom: 0,
  201. left: 0
  202. },
  203. axisX: {
  204. showLabel: false,
  205. showGrid: false,
  206. offset: 0
  207. },
  208. axisY: {
  209. showLabel: false,
  210. showGrid: false,
  211. offset: 0
  212. }
  213. });
  214. })(); // Chart Linearea Withfooter
  215. // ----------------------------
  216. (function () {
  217. new Chartist.Line('#chartLineareaWithfooter .ct-chart', {
  218. labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
  219. series: [[1, 6, 4, 9, 1, 6, 4, 9]]
  220. }, {
  221. low: 0,
  222. showArea: true,
  223. showPoint: false,
  224. showLine: true,
  225. fullWidth: true,
  226. lineSmooth: false,
  227. chartPadding: {
  228. top: 0,
  229. right: 0,
  230. bottom: 0,
  231. left: 0
  232. },
  233. axisX: {
  234. showLabel: false,
  235. showGrid: false,
  236. offset: 0
  237. },
  238. axisY: {
  239. showLabel: false,
  240. showGrid: false,
  241. offset: 0
  242. }
  243. });
  244. })(); // Chart Bar Withfooter
  245. // ------------------------
  246. (function () {
  247. new Chartist.Bar('#chartBarWithfooter .ct-chart', {
  248. labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O'],
  249. series: [[160, 200, 150, 400, 460, 440, 240, 250, 50, 200, 360, 150, 380, 240, 460], [600 - 160, 600 - 200, 600 - 150, 600 - 400, 600 - 460, 600 - 440, 600 - 240, 600 - 250, 600 - 50, 600 - 200, 600 - 360, 600 - 150, 600 - 380, 600 - 240, 600 - 460]]
  250. }, {
  251. stackBars: true,
  252. fullWidth: true,
  253. seriesBarDistance: 0,
  254. axisX: {
  255. showLabel: false,
  256. showGrid: false,
  257. offset: 0
  258. },
  259. axisY: {
  260. showLabel: false,
  261. showGrid: false,
  262. offset: 0
  263. }
  264. });
  265. })(); // Chart Linebar Large
  266. // ----------------------
  267. (function () {
  268. new Chartist.Line("#chartLinebarLarge .chart-line", {
  269. labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  270. series: [[20, 50, 70, 110, 100, 200, 230, 50, 80, 140, 130, 150]]
  271. }, {
  272. low: 0,
  273. showArea: false,
  274. showPoint: false,
  275. showLine: true,
  276. lineSmooth: false,
  277. fullWidth: true,
  278. chartPadding: {
  279. top: 0,
  280. right: 10,
  281. bottom: 0,
  282. left: 10
  283. },
  284. axisX: {
  285. showLabel: true,
  286. showGrid: false,
  287. offset: 30
  288. },
  289. axisY: {
  290. showLabel: true,
  291. showGrid: true,
  292. offset: 30
  293. }
  294. });
  295. new Chartist.Bar('#chartLinebarLarge .chart-bar', {
  296. labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X'],
  297. series: [[6, 3, 2, 5, 4, 7, 5, 9, 4, 5, 4, 9, 8, 3, 6, 4, 8, 6, 8, 6, 4, 3, 6, 4]]
  298. }, {
  299. stackBars: true,
  300. fullWidth: true,
  301. seriesBarDistance: 0,
  302. axisX: {
  303. showLabel: false,
  304. showGrid: false,
  305. offset: 0
  306. },
  307. axisY: {
  308. showLabel: false,
  309. showGrid: false,
  310. offset: 0
  311. }
  312. });
  313. })(); // Chart Line Time
  314. // -----------------------
  315. (function () {
  316. var line_time_labels = [];
  317. var line_time_data = [];
  318. var line_time_totalPoints = 100;
  319. var line_time_updateInterval = 1000;
  320. var line_time_now = new Date().getTime();
  321. function line_time_getData() {
  322. line_time_labels.shift();
  323. line_time_data.shift();
  324. while (line_time_data.length < line_time_totalPoints) {
  325. var x = Math.random() * 100;
  326. line_time_labels.push(line_time_now += line_time_updateInterval);
  327. line_time_data.push(x);
  328. }
  329. }
  330. var lineTime = {
  331. labels: line_time_labels,
  332. series: [line_time_data]
  333. };
  334. var lineTimeOptions = {
  335. low: 0,
  336. showArea: false,
  337. showPoint: false,
  338. showLine: true,
  339. lineSmooth: false,
  340. fullWidth: true,
  341. chartPadding: {
  342. top: 0,
  343. right: 0,
  344. bottom: 0,
  345. left: 0
  346. },
  347. axisX: {
  348. showLabel: false,
  349. showGrid: false,
  350. offset: 0
  351. },
  352. axisY: {
  353. showLabel: false,
  354. showGrid: false,
  355. offset: 0
  356. }
  357. };
  358. new Chartist.Line("#chartLineTime .chart-line", lineTime, lineTimeOptions);
  359. function line_time_update() {
  360. line_time_getData();
  361. new Chartist.Line("#chartLineTime .chart-line", lineTime, lineTimeOptions);
  362. setTimeout(line_time_update, line_time_updateInterval);
  363. }
  364. line_time_update();
  365. new Chartist.Pie('#chartLineTime .chart-pie-left', {
  366. series: [50, 50]
  367. }, {
  368. donut: true,
  369. donutWidth: 10,
  370. startAngle: 0,
  371. showLabel: false
  372. });
  373. new Chartist.Pie('#chartLineTime .chart-pie-right', {
  374. series: [80, 20]
  375. }, {
  376. donut: true,
  377. donutWidth: 10,
  378. startAngle: 0,
  379. showLabel: false
  380. });
  381. })(); // Chart Barline Mix
  382. // -----------------------
  383. (function () {
  384. var mix_data = {
  385. labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O'],
  386. series: [[50, 90, 100, 90, 110, 100, 120, 130, 115, 95, 80, 85, 60, 100, 90]]
  387. };
  388. new Chartist.Bar("#chartBarlineMix .chart-bar", mix_data, {
  389. low: 0,
  390. fullWidth: true,
  391. chartPadding: {
  392. top: 0,
  393. right: -7,
  394. bottom: 0,
  395. left: -7
  396. },
  397. axisX: {
  398. showLabel: false,
  399. showGrid: false,
  400. offset: 0
  401. },
  402. axisY: {
  403. showLabel: false,
  404. showGrid: false,
  405. offset: 0
  406. }
  407. });
  408. new Chartist.Line("#chartBarlineMix .chart-line", mix_data, {
  409. low: 0,
  410. showArea: false,
  411. showPoint: false,
  412. showLine: true,
  413. lineSmooth: false,
  414. fullWidth: true,
  415. chartPadding: {
  416. top: 50,
  417. right: 4,
  418. bottom: 0,
  419. left: 4
  420. },
  421. axisX: {
  422. showLabel: false,
  423. showGrid: false,
  424. offset: 0
  425. },
  426. axisY: {
  427. showLabel: false,
  428. showGrid: false,
  429. offset: 0
  430. }
  431. });
  432. })(); // Chart Barline Mix Two
  433. // ---------------------------
  434. (function () {
  435. new Chartist.Bar("#chartBarlineMixTwo .small-bar-one", {
  436. labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'],
  437. series: [[50, 90, 100, 90, 110, 100, 120, 130]]
  438. }, {
  439. low: 0,
  440. fullWidth: true,
  441. chartPadding: {
  442. top: -10,
  443. right: 0,
  444. bottom: 0,
  445. left: 20
  446. },
  447. axisX: {
  448. showLabel: false,
  449. showGrid: false,
  450. offset: 0
  451. },
  452. axisY: {
  453. showLabel: false,
  454. showGrid: false,
  455. offset: 0
  456. }
  457. });
  458. new Chartist.Bar("#chartBarlineMixTwo .small-bar-two", {
  459. labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'],
  460. series: [[50, 90, 100, 90, 110, 100, 120, 120]]
  461. }, {
  462. low: 0,
  463. fullWidth: true,
  464. chartPadding: {
  465. top: -10,
  466. right: 0,
  467. bottom: 0,
  468. left: 20
  469. },
  470. axisX: {
  471. showLabel: false,
  472. showGrid: false,
  473. offset: 0
  474. },
  475. axisY: {
  476. showLabel: false,
  477. showGrid: false,
  478. offset: 0
  479. }
  480. });
  481. new Chartist.Line("#chartBarlineMixTwo .line-chart", {
  482. labels: ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'],
  483. series: [[20, 50, 70, 110, 100, 200, 230], [50, 80, 140, 130, 150, 110, 160]]
  484. }, {
  485. low: 0,
  486. showArea: false,
  487. showPoint: false,
  488. showLine: true,
  489. lineSmooth: false,
  490. fullWidth: true,
  491. chartPadding: {
  492. top: 0,
  493. right: 10,
  494. bottom: 0,
  495. left: 10
  496. },
  497. axisX: {
  498. showLabel: true,
  499. showGrid: false,
  500. offset: 30
  501. },
  502. axisY: {
  503. showLabel: true,
  504. showGrid: true,
  505. offset: 30
  506. }
  507. });
  508. })(); // Chart Linearea Two
  509. // --------------------------
  510. (function () {
  511. new Chartist.Line('#charLineareaTwo .ct-chart', {
  512. labels: ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'],
  513. series: [[0, 2.5, 2, 2.8, 2.6, 3.8, 0], [0, 1.4, 0.5, 2, 1.2, 0.9, 0]]
  514. }, {
  515. low: 0,
  516. showArea: true,
  517. showPoint: false,
  518. showLine: false,
  519. fullWidth: true,
  520. chartPadding: {
  521. top: 0,
  522. right: 10,
  523. bottom: 0,
  524. left: 0
  525. },
  526. axisX: {
  527. showGrid: false,
  528. labelOffset: {
  529. x: -14,
  530. y: 0
  531. }
  532. },
  533. axisY: {
  534. labelOffset: {
  535. x: -10,
  536. y: 0
  537. },
  538. labelInterpolationFnc: function labelInterpolationFnc(num) {
  539. return num % 1 === 0 ? num : false;
  540. }
  541. }
  542. });
  543. })(); // Chart Linepoint
  544. // ---------------------
  545. (function () {
  546. new Chartist.Line("#chartLinepoint .ct-chart", {
  547. labels: ['1', '2', '3', '4', '5', '6'],
  548. series: [[1, 1.5, 0.5, 2, 2.5, 1.5]]
  549. }, {
  550. low: 0,
  551. showArea: false,
  552. showPoint: true,
  553. showLine: true,
  554. fullWidth: true,
  555. lineSmooth: false,
  556. chartPadding: {
  557. top: 10,
  558. right: -4,
  559. bottom: 10,
  560. left: -4
  561. },
  562. axisX: {
  563. showLabel: false,
  564. showGrid: false,
  565. offset: 0
  566. },
  567. axisY: {
  568. showLabel: false,
  569. showGrid: false,
  570. offset: 0
  571. }
  572. });
  573. })(); // Chart Timeline Two
  574. // -----------------------------
  575. (function () {
  576. var timeline_labels = [];
  577. var timeline_data1 = [];
  578. var timeline_data2 = [];
  579. var totalPoints = 20;
  580. var updateInterval = 1000;
  581. var now = new Date().getTime();
  582. function getData() {
  583. timeline_labels.shift();
  584. timeline_data1.shift();
  585. timeline_data2.shift();
  586. while (timeline_data1.length < totalPoints) {
  587. var x = Math.random() * 100 + 800;
  588. var y = Math.random() * 100 + 400;
  589. timeline_labels.push(now += updateInterval);
  590. timeline_data1.push(x);
  591. timeline_data2.push(y);
  592. }
  593. }
  594. var timlelineData = {
  595. labels: timeline_labels,
  596. series: [timeline_data1, timeline_data2]
  597. };
  598. var timelineOptions = {
  599. low: 0,
  600. showArea: true,
  601. showPoint: false,
  602. showLine: false,
  603. fullWidth: true,
  604. chartPadding: {
  605. top: 0,
  606. right: 0,
  607. bottom: 0,
  608. left: 0
  609. },
  610. axisX: {
  611. showLabel: false,
  612. showGrid: false,
  613. offset: 0
  614. },
  615. axisY: {
  616. showLabel: false,
  617. showGrid: false,
  618. offset: 0
  619. }
  620. };
  621. new Chartist.Line("#chartTimelineTwo .ct-chart", timlelineData, timelineOptions);
  622. function update() {
  623. getData();
  624. new Chartist.Line("#chartTimelineTwo .ct-chart", timlelineData, timelineOptions);
  625. setTimeout(update, updateInterval);
  626. }
  627. update();
  628. })(); // Chart Stacked Bar
  629. // ----------------------
  630. (function () {
  631. new Chartist.Bar('#chartStackedBar .ct-chart', {
  632. labels: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
  633. series: [[50, 90, 100, 90, 110, 100, 120, 130, 115, 95, 80, 85, 100, 140, 130, 120, 135, 110, 120, 105, 100, 105, 90, 110, 100, 60], [150, 190, 200, 190, 210, 200, 220, 230, 215, 195, 180, 185, 200, 240, 230, 220, 235, 210, 220, 205, 200, 205, 190, 210, 200, 160]]
  634. }, {
  635. stackBars: true,
  636. fullWidth: true,
  637. seriesBarDistance: 0,
  638. chartPadding: {
  639. top: 0,
  640. right: 30,
  641. bottom: 30,
  642. left: 20
  643. },
  644. axisX: {
  645. showLabel: false,
  646. showGrid: false,
  647. offset: 0
  648. },
  649. axisY: {
  650. showLabel: false,
  651. showGrid: false,
  652. offset: 0
  653. }
  654. });
  655. })();
  656. });