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.

1169 lines
27 KiB

2 years ago
  1. /*
  2. Project Name : Business
  3. Author Company : SpecThemes
  4. Project Date: 5 Feb, 2017
  5. Template Developer: vsafaryan50@gmail.com
  6. */
  7. /*
  8. ==============================================
  9. TABLE OF CONTENT
  10. ==============================================
  11. 1. Owl Carousels
  12. 2. CountUp
  13. 3. Slider
  14. 4. Hover Drop Down
  15. 5. Youtube Video Section
  16. 6. Video Modal
  17. 7. Preloader
  18. 8. Scroll To Top
  19. 9. Isotop
  20. 10. WOW
  21. 11. Serach
  22. 12. Input Number, Shopping Cart
  23. 13. Tabs
  24. 14. Pie Chart
  25. 15. Charts.js
  26. ==============================================
  27. [END] TABLE OF CONTENT
  28. ==============================================
  29. */
  30. "use strict";
  31. $('#preloader').fadeOut('normall', function () {
  32. $(this).remove();
  33. });
  34. $(document).ready(function () {
  35. /*------------------------------------
  36. 1. Owl Carousel
  37. --------------------------------------*/
  38. /*---------------------
  39. Testmonials carousel
  40. -----------------------*/
  41. $('#testmonials-carousel').owlCarousel({
  42. loop: false,
  43. smartSpeed: 850,
  44. responsiveClass: true,
  45. nav: true,
  46. navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],
  47. responsive: {
  48. 0: {
  49. items: 1,
  50. nav: false,
  51. dots: true,
  52. margin: 10,
  53. },
  54. 600: {
  55. items: 1,
  56. nav: false,
  57. dots: true,
  58. margin: 15,
  59. },
  60. 1000: {
  61. items: 1,
  62. dots: false,
  63. margin: 40,
  64. }
  65. }
  66. })
  67. /*---------------------
  68. Testmonials carousel 2
  69. -----------------------*/
  70. $('#testmonials-carousel-2').owlCarousel({
  71. loop: false,
  72. smartSpeed: 850,
  73. responsiveClass: true,
  74. nav: true,
  75. navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],
  76. responsive: {
  77. 0: {
  78. items: 1,
  79. nav: false,
  80. dots: true,
  81. margin: 30,
  82. },
  83. 600: {
  84. items: 2,
  85. nav: false,
  86. dots: true,
  87. margin: 0,
  88. },
  89. 1000: {
  90. items: 3,
  91. dots: false,
  92. margin: 0,
  93. }
  94. }
  95. })
  96. /*---------------------
  97. Testmonials carousel 3
  98. -----------------------*/
  99. $('#testmonial-item').owlCarousel({
  100. loop: true,
  101. nav: false,
  102. responsiveClass: true,
  103. startPosition: 0,
  104. smartSpeed: 850,
  105. center: true,
  106. autoplay: true,
  107. autoplayTimeout: 3000,
  108. autoplayHoverPause: true,
  109. responsive: {
  110. 0: {
  111. items: 1,
  112. margin: 15,
  113. dots: false,
  114. },
  115. 600: {
  116. items: 1,
  117. margin: 20,
  118. dots: false,
  119. },
  120. 1000: {
  121. items: 3,
  122. margin: 30,
  123. dots: false,
  124. }
  125. }
  126. });
  127. /*---------------------
  128. Testmonials box 4
  129. -----------------------*/
  130. $('#testmonials-box-4').owlCarousel({
  131. loop: false,
  132. smartSpeed: 850,
  133. responsiveClass: true,
  134. nav: true,
  135. dots: false,
  136. responsive: {
  137. 0: {
  138. items: 1,
  139. nav: false,
  140. dots: true,
  141. margin: 30,
  142. },
  143. 600: {
  144. items: 1,
  145. nav: false,
  146. dots: true,
  147. margin: 15,
  148. },
  149. 1000: {
  150. items: 2,
  151. nav: false,
  152. dots: true,
  153. margin: 45,
  154. }
  155. }
  156. })
  157. /*---------------------
  158. Services carousel
  159. -----------------------*/
  160. $('#services-carousel').owlCarousel({
  161. loop: false,
  162. smartSpeed: 850,
  163. responsiveClass: true,
  164. dots: false,
  165. nav: true,
  166. navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],
  167. responsive: {
  168. 0: {
  169. items: 1,
  170. margin: 15,
  171. },
  172. 600: {
  173. items: 2,
  174. margin: 30,
  175. },
  176. 1000: {
  177. items: 3,
  178. margin: 0,
  179. }
  180. }
  181. })
  182. /*---------------------
  183. Services carousel 2
  184. -----------------------*/
  185. $('#services-carousel-2').owlCarousel({
  186. loop: false,
  187. responsiveClass: true,
  188. dots: false,
  189. nav: true,
  190. smartSpeed: 850,
  191. navText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"],
  192. responsive: {
  193. 0: {
  194. items: 1,
  195. margin: 15,
  196. },
  197. 767: {
  198. items: 2,
  199. margin: 30,
  200. },
  201. 991: {
  202. items: 3,
  203. margin: 30,
  204. },
  205. 1200: {
  206. items: 4,
  207. margin: 0,
  208. }
  209. }
  210. })
  211. /*---------------------
  212. Blog Grid carousel
  213. -----------------------*/
  214. $('#blog-grid').owlCarousel({
  215. loop: false,
  216. dots: true,
  217. nav: false,
  218. smartSpeed: 850,
  219. autoplay: true,
  220. autoplayTimeout: 2500,
  221. responsiveClass: true,
  222. autoplayHoverPause: false,
  223. responsive: {
  224. 0: {
  225. items: 1,
  226. margin: 0,
  227. },
  228. 600: {
  229. items: 2,
  230. margin: 0,
  231. },
  232. 1000: {
  233. items: 3,
  234. margin: 0,
  235. }
  236. }
  237. })
  238. /*---------------------
  239. Clients carousel
  240. -----------------------*/
  241. $('#clients').owlCarousel({
  242. loop: true,
  243. nav: false,
  244. dots: false,
  245. smartSpeed: 850,
  246. autoplay: true,
  247. autoplayTimeout: 3000,
  248. responsiveClass: true,
  249. autoplayHoverPause: false,
  250. responsive: {
  251. 0: {
  252. items: 2,
  253. margin: 50,
  254. },
  255. 600: {
  256. items: 3,
  257. margin: 30,
  258. },
  259. 1000: {
  260. items: 6,
  261. margin: 40,
  262. }
  263. }
  264. })
  265. /*---------------------
  266. Project Single carousel
  267. -----------------------*/
  268. $('#project-single').owlCarousel({
  269. loop: false,
  270. nav: false,
  271. smartSpeed: 850,
  272. responsiveClass: true,
  273. dots: false,
  274. responsive: {
  275. 0: {
  276. items: 1,
  277. margin: 15,
  278. },
  279. 600: {
  280. items: 2,
  281. margin: 15,
  282. },
  283. 1000: {
  284. items: 3,
  285. margin: 15
  286. }
  287. }
  288. })
  289. /*------------------------------------
  290. 2. CountUp
  291. --------------------------------------*/
  292. $('.countup').counterUp({
  293. delay: 25,
  294. time: 2000
  295. });
  296. /*------------------------------------
  297. 3. Slider
  298. --------------------------------------*/
  299. /*---------------------
  300. Main Slider
  301. -----------------------*/
  302. if ($(".swiper-main-slider").length !== 0) {
  303. //Slider Animated Caption
  304. var swiper = new Swiper('.swiper-container', {
  305. navigation: {
  306. nextEl: '.swiper-button-next',
  307. prevEl: '.swiper-button-prev',
  308. },
  309. pagination: {
  310. el: '.swiper-pagination',
  311. dynamicBullets: true,
  312. },
  313. pagination: '.swiper-pagination',
  314. paginationClickable: true,
  315. nextButton: '.swiper-button-next',
  316. prevButton: '.swiper-button-prev',
  317. spaceBetween: 0,
  318. loop: true,
  319. simulateTouch: true,
  320. autoplay: 5000,
  321. speed: 1000,
  322. onSlideChangeEnd: function (swiper) {
  323. $('.swiper-slide').each(function () {
  324. if ($(this).index() === swiper.activeIndex) {
  325. // Fadein in active slide
  326. $(this).find('.slider-content').fadeIn(300);
  327. } else {
  328. // Fadeout in inactive slides
  329. $(this).find('.slider-content').fadeOut(300);
  330. }
  331. });
  332. }
  333. });
  334. }
  335. /*---------------------
  336. Main Slider Fade Effect
  337. -----------------------*/
  338. if ($(".swiper-main-slider-fade").length !== 0) {
  339. //Slider Animated Caption
  340. var swiper = new Swiper('.swiper-container', {
  341. effect: 'fade',
  342. navigation: {
  343. nextEl: '.swiper-button-next',
  344. prevEl: '.swiper-button-prev',
  345. },
  346. pagination: {
  347. el: '.swiper-pagination',
  348. dynamicBullets: true,
  349. },
  350. pagination: '.swiper-pagination',
  351. paginationClickable: true,
  352. nextButton: '.swiper-button-next',
  353. prevButton: '.swiper-button-prev',
  354. spaceBetween: 0,
  355. loop: true,
  356. simulateTouch: true,
  357. autoplay: 5000,
  358. speed: 1000,
  359. onSlideChangeEnd: function (swiper) {
  360. $('.swiper-slide').each(function () {
  361. if ($(this).index() === swiper.activeIndex) {
  362. // Fadein in active slide
  363. $(this).find('.slider-content').fadeIn(300);
  364. } else {
  365. // Fadeout in inactive slides
  366. $(this).find('.slider-content').fadeOut(300);
  367. }
  368. });
  369. }
  370. });
  371. }
  372. /*---------------------
  373. Parallax Slider
  374. -----------------------*/
  375. if ($("#swiper-parallax").length !== 0) {
  376. var swiper = new Swiper('.swiper-container', {
  377. parallax: true,
  378. navigation: {
  379. nextEl: '.swiper-button-next',
  380. prevEl: '.swiper-button-prev',
  381. },
  382. pagination: {
  383. el: '.swiper-pagination',
  384. dynamicBullets: true,
  385. },
  386. pagination: '.swiper-pagination',
  387. paginationClickable: true,
  388. nextButton: '.swiper-button-next',
  389. prevButton: '.swiper-button-prev',
  390. spaceBetween: 0,
  391. loop: false,
  392. simulateTouch: true,
  393. autoplay: false,
  394. speed: 1000,
  395. });
  396. }
  397. /*---------------------
  398. Revolution Slider
  399. -----------------------*/
  400. if ($("#rev_slider_24_1").length !== 0) {
  401. var tpj = jQuery;
  402. var revapi24;
  403. tpj(document).ready(function () {
  404. if (tpj("#rev_slider_24_1").revolution == undefined) {
  405. revslider_showDoubleJqueryError("#rev_slider_24_1");
  406. } else {
  407. revapi24 = tpj("#rev_slider_24_1").show().revolution({
  408. sliderType: "standard",
  409. jsFileLocation: "revolution/js/",
  410. sliderLayout: "fullscreen",
  411. dottedOverlay: "none",
  412. delay: 9000,
  413. navigation: {
  414. keyboardNavigation: "off",
  415. keyboard_direction: "horizontal",
  416. mouseScrollNavigation: "off",
  417. mouseScrollReverse: "default",
  418. onHoverStop: "off",
  419. bullets: {
  420. enable: true,
  421. hide_onmobile: false,
  422. style: "bullet-bar",
  423. hide_onleave: false,
  424. direction: "horizontal",
  425. h_align: "center",
  426. v_align: "bottom",
  427. h_offset: 0,
  428. v_offset: 50,
  429. space: 5,
  430. tmp: ''
  431. }
  432. },
  433. responsiveLevels: [1240, 1024, 778, 480],
  434. visibilityLevels: [1240, 1024, 778, 480],
  435. gridwidth: [1240, 1024, 778, 480],
  436. gridheight: [868, 768, 960, 720],
  437. lazyType: "none",
  438. shadow: 0,
  439. spinner: "off",
  440. stopLoop: "off",
  441. stopAfterLoops: -1,
  442. stopAtSlide: -1,
  443. shuffle: "off",
  444. autoHeight: "off",
  445. fullScreenAutoWidth: "off",
  446. fullScreenAlignForce: "off",
  447. fullScreenOffsetContainer: "",
  448. fullScreenOffset: "60px",
  449. hideThumbsOnMobile: "off",
  450. hideSliderAtLimit: 0,
  451. hideCaptionAtLimit: 0,
  452. hideAllCaptionAtLilmit: 0,
  453. debugMode: false,
  454. fallbacks: {
  455. simplifyAll: "off",
  456. nextSlideOnWindowFocus: "off",
  457. disableFocusListener: false,
  458. }
  459. });
  460. }
  461. if (revapi24) revapi24.revSliderSlicey();
  462. }); /*ready*/
  463. }
  464. if (typeof $.fn.revolution !== 'undefined') {
  465. $("#rev_slider").revolution({
  466. sliderType: "standard",
  467. sliderLayout: "fullscreen",
  468. dottedOverlay: "none",
  469. delay: 7000,
  470. navigation: {
  471. keyboardNavigation: "off",
  472. keyboard_direction: "horizontal",
  473. onHoverStop: "off",
  474. touch: {
  475. touchenabled: "on",
  476. swipe_threshold: 75,
  477. swipe_min_touches: 1,
  478. swipe_direction: "horizontal",
  479. drag_block_vertical: false
  480. }
  481. },
  482. viewPort: {
  483. enable: true,
  484. outof: "pause",
  485. visible_area: "80%"
  486. },
  487. navigation: {
  488. arrows: {
  489. enable: false,
  490. style: 'hesperiden',
  491. tmp: '',
  492. rtl: false,
  493. hide_onleave: false,
  494. hide_onmobile: true,
  495. hide_under: 0,
  496. hide_over: 9999,
  497. hide_delay: 200,
  498. hide_delay_mobile: 1200,
  499. left: {
  500. container: 'slider',
  501. h_align: 'left',
  502. v_align: 'center',
  503. h_offset: 20,
  504. v_offset: 0
  505. },
  506. right: {
  507. container: 'slider',
  508. h_align: 'right',
  509. v_align: 'center',
  510. h_offset: 20,
  511. v_offset: 0
  512. }
  513. }
  514. },
  515. responsiveLevels: [2048, 1750, 1192],
  516. gridwidth: [1180, 1180, 980],
  517. gridheight: [550],
  518. lazyType: "none",
  519. shadow: 0,
  520. spinner: "off",
  521. stopLoop: "on",
  522. stopAfterLoops: 0,
  523. shuffle: "off",
  524. autoHeight: "on",
  525. fullScreenAlignForce: "off",
  526. fullScreenOffsetContainer: "",
  527. fullScreenOffset: "",
  528. disableProgressBar: "on",
  529. hideThumbsOnMobile: "off",
  530. hideSliderAtLimit: 0,
  531. hideCaptionAtLimit: 0,
  532. hideAllCaptionAtLilmit: 0,
  533. debugMode: false,
  534. fallbacks: {
  535. simplifyAll: "off",
  536. nextSlideOnWindowFocus: "off",
  537. disableFocusListener: false,
  538. }
  539. });
  540. }
  541. /*------------------------------------
  542. 4. Navbar
  543. --------------------------------------*/
  544. /*---------------------
  545. Fixed Nav
  546. -----------------------*/
  547. $("#navigation1").navigation();
  548. $("#navigation1").fixed();
  549. /*---------------------
  550. Transparent Nav Options
  551. -----------------------*/
  552. if ($("#nav-transparent").length !== 0) {
  553. if ($(window).width() > 991) {
  554. $("#nav-transparent #main_logo").css("display", "none");
  555. } else {
  556. $("#nav-transparent #light_logo").css("display", "none");
  557. }
  558. $(window).scroll(function () {
  559. var scroll = $(window).scrollTop();
  560. if ($(window).width() > 991) {
  561. if (scroll > 30) {
  562. $(".navigation-fixed-wrapper").addClass("nav-white-bg");
  563. $("#nav-transparent #main_logo").css("display", "inline-block");
  564. $("#nav-transparent #light_logo").css("display", "none");
  565. } else {
  566. $(".navigation-fixed-wrapper").removeClass("nav-white-bg");
  567. $("#nav-transparent #light_logo").css("display", "inline-block");
  568. $("#nav-transparent #main_logo").css("display", "none");
  569. }
  570. }
  571. })
  572. }
  573. /*---------------------
  574. Nav Slide Effect
  575. -----------------------*/
  576. $("#navigation2").navigation({
  577. effect: "slide"
  578. });
  579. /*---------------------
  580. Nav Zoom Effect
  581. -----------------------*/
  582. $("#navigation3").navigation({
  583. animationOnShow: "zoom-in",
  584. animationOnHide: "zoom-out"
  585. });
  586. /*---------------------
  587. Overlay Nav
  588. -----------------------*/
  589. $("#navigation4").navigation({
  590. offset: 20,
  591. overlayColor: "rgba(0,0,0,0.6)",
  592. effect: "slide"
  593. });
  594. /*---------------------
  595. Affix Nav
  596. -----------------------*/
  597. $("#navigation4").fixed({
  598. offset: 20
  599. });
  600. /*---------------------
  601. Hidden Nav
  602. -----------------------*/
  603. $("#navigation5").navigation({
  604. hidden: true
  605. });
  606. if ($("#navigation-push").length !== 0) {
  607. if ($(window).width() > 991) {
  608. $("#navigation-push").find($(".nav-menus-wrapper").addClass("nav-menus-wrapper-open"));
  609. $("#navigation-push").find($(".nav-menus-wrapper-close-button").hide());
  610. $("#navigation-push").find($(".small-size-header").hide());
  611. } else {
  612. $("#navigation5 #main_logo").clone().appendTo(".small-size-header-logo");
  613. $("#main_logo").css("display", "none");
  614. $("#navigation-push").find($(".nav-menus-wrapper").removeClass("nav-menus-wrapper-open"));
  615. }
  616. }
  617. /*---------------------
  618. Button Nav
  619. -----------------------*/
  620. $(".btn-show").on('click', function () {
  621. $("#navigation5").data("navigation").toggleOffcanvas();
  622. });
  623. $("#navigation6").navigation({
  624. offCanvasSide: "right"
  625. });
  626. /*---------------------
  627. Simple Nav
  628. -----------------------*/
  629. $("#navigation7").navigation();
  630. /*------------------------------------
  631. 5. Youtube Video Section
  632. --------------------------------------*/
  633. if ($(".video-section").length !== 0) {
  634. $('.player').mb_YTPlayer();
  635. }
  636. if ($(".main-video-section").length !== 0) {
  637. $('#main-video-play').mb_YTPlayer();
  638. }
  639. /*------------------------------------
  640. 6. Video Modal
  641. --------------------------------------*/
  642. $('.modal').on('hidden.bs.modal', function () {
  643. var $this = $(this).find('iframe'),
  644. tempSrc = $this.attr('src');
  645. $this.attr('src', "");
  646. $this.attr('src', tempSrc);
  647. });
  648. /*------------------------------------
  649. 7. Preloader
  650. --------------------------------------*/
  651. /*------------------------------------
  652. 8. Scroll To Top
  653. --------------------------------------*/
  654. $(window).scroll(function () {
  655. if ($(this).scrollTop() > 500) {
  656. $(".scroll-to-top").fadeIn(400);
  657. } else {
  658. $(".scroll-to-top").fadeOut(400);
  659. }
  660. });
  661. $(".scroll-to-top").on('click', function (event) {
  662. event.preventDefault();
  663. $("html, body").animate({scrollTop: 0}, 600);
  664. });
  665. /*------------------------------------
  666. 9. Isotop
  667. --------------------------------------*/
  668. // external js: isotope.pkgd.js
  669. // init Isotope
  670. var $grid = $('.isotope-grid').isotope({
  671. itemSelector: '.isotope-item',
  672. layoutMode: 'fitRows',
  673. getSortData: {
  674. name: '.name',
  675. symbol: '.symbol',
  676. number: '.number parseInt',
  677. category: '[data-category]',
  678. weight: function (itemElem) {
  679. var weight = $(itemElem).find('.weight').text();
  680. return parseFloat(weight.replace(/[\(\)]/g, ''));
  681. }
  682. }
  683. });
  684. // filter functions
  685. var filterFns = {
  686. // show if name ends with -ium
  687. ium: function () {
  688. var name = $(this).find('.name').text();
  689. return name.match(/ium$/);
  690. }
  691. };
  692. // bind filter button click
  693. $('#filters').on('click', 'button', function () {
  694. var filterValue = $(this).attr('data-filter');
  695. // use filterFn if matches value
  696. filterValue = filterFns[filterValue] || filterValue;
  697. $grid.isotope({filter: filterValue});
  698. });
  699. // change is-checked class on buttons
  700. $('.parent-isotope').each(function (i, buttonGroup) {
  701. var $buttonGroup = $(buttonGroup);
  702. $buttonGroup.on('click', 'button', function () {
  703. $buttonGroup.find('.is-checked').removeClass('is-checked');
  704. $(this).addClass('is-checked');
  705. });
  706. });
  707. /*------------------------------------
  708. 10. WOW
  709. --------------------------------------*/
  710. new WOW().init();
  711. });
  712. /*------------------------------------
  713. 11. Seacrh
  714. --------------------------------------*/
  715. function openNav() {
  716. document.getElementById("search_nav").style.width = "100%";
  717. }
  718. function closeNav() {
  719. document.getElementById("search_nav").style.width = "0%";
  720. }
  721. /*------------------------------------
  722. 12. Input Number, Shopping Cart
  723. --------------------------------------*/
  724. /*---------------------
  725. Input Number
  726. -----------------------*/
  727. jQuery('<div class="quantity-nav"><div class="quantity-button quantity-up">+</div><div class="quantity-button quantity-down">-</div></div>').insertAfter('.quantity input');
  728. jQuery('.quantity').each(function () {
  729. var spinner = jQuery(this),
  730. input = spinner.find('input[type="number"]'),
  731. btnUp = spinner.find('.quantity-up'),
  732. btnDown = spinner.find('.quantity-down'),
  733. min = input.attr('min'),
  734. max = input.attr('max');
  735. btnUp.on("click", function () {
  736. var oldValue = parseFloat(input.val());
  737. if (oldValue >= max) {
  738. var newVal = oldValue;
  739. } else {
  740. var newVal = oldValue + 1;
  741. }
  742. spinner.find("input").val(newVal);
  743. spinner.find("input").trigger("change");
  744. });
  745. btnDown.on("click", function () {
  746. var oldValue = parseFloat(input.val());
  747. if (oldValue <= min) {
  748. var newVal = oldValue;
  749. } else {
  750. var newVal = oldValue - 1;
  751. }
  752. spinner.find("input").val(newVal);
  753. spinner.find("input").trigger("change");
  754. });
  755. });
  756. /*---------------------
  757. Shopping Cart
  758. -----------------------*/
  759. $('.close-box').on("click", function () {
  760. $(this).parentsUntil('.row').slideToggle();
  761. return false;
  762. });
  763. /*------------------------------------
  764. 13. Tabs
  765. --------------------------------------*/
  766. $('.tabs_animate').tabslet({
  767. mouseevent: 'click',
  768. attribute: 'href',
  769. animation: true
  770. });
  771. /*------------------------------------
  772. 14. Pie Chart
  773. --------------------------------------*/
  774. /*------------------------------------
  775. 9. Pie Chart
  776. --------------------------------------*/
  777. if ($('.chart').length > 0) {
  778. var $pieChart = $('.chart');
  779. $pieChart.each(function () {
  780. var $elem = $(this),
  781. pieChartSize = $elem.attr('data-size') || "120",
  782. pieChartAnimate = $elem.attr('data-animate') || "2100",
  783. pieChartWidth = $elem.attr('data-width') || "6",
  784. pieChartColor = $elem.attr('data-color') || "#2e52c2",
  785. pieChartTrackColor = $elem.attr('data-trackcolor') || "rgba(0,0,0,0.1)";
  786. $elem.find('span, i').css({
  787. 'width': pieChartSize + 'px',
  788. 'height': pieChartSize + 'px',
  789. 'line-height': pieChartSize + 'px'
  790. });
  791. $elem.appear(function () {
  792. $elem.easyPieChart({
  793. size: Number(pieChartSize),
  794. animate: Number(pieChartAnimate),
  795. trackColor: pieChartTrackColor,
  796. lineWidth: Number(pieChartWidth),
  797. barColor: pieChartColor,
  798. scaleColor: false,
  799. lineCap: 'round',
  800. onStep: function (from, to, percent) {
  801. $elem.find('span.percent').text(Math.round(percent));
  802. }
  803. });
  804. });
  805. });
  806. }
  807. ;
  808. if ($(".chartjs-render-monitor").length !== 0) {
  809. var randomScalingFactor = function () {
  810. return Math.round(Math.random() * 100);
  811. };
  812. var config = {
  813. type: 'pie',
  814. data: {
  815. datasets: [{
  816. data: [
  817. randomScalingFactor(),
  818. randomScalingFactor(),
  819. randomScalingFactor(),
  820. randomScalingFactor(),
  821. ],
  822. backgroundColor: [
  823. window.chartColors.red,
  824. window.chartColors.orange,
  825. window.chartColors.green,
  826. window.chartColors.blue,
  827. ],
  828. label: 'Dataset 1'
  829. }],
  830. labels: [
  831. "Red",
  832. "Orange",
  833. "Green",
  834. "Blue"
  835. ]
  836. },
  837. options: {
  838. responsive: true
  839. }
  840. };
  841. window.onload = function () {
  842. var ctx = document.getElementById("chart-area").getContext("2d");
  843. window.myPie = new Chart(ctx, config);
  844. };
  845. document.getElementById('randomizeData').addEventListener('click', function () {
  846. config.data.datasets.forEach(function (dataset) {
  847. dataset.data = dataset.data.map(function () {
  848. return randomScalingFactor();
  849. });
  850. });
  851. window.myPie.update();
  852. });
  853. var colorNames = Object.keys(window.chartColors);
  854. document.getElementById('addDataset').addEventListener('click', function () {
  855. var newDataset = {
  856. backgroundColor: [],
  857. data: [],
  858. label: 'New dataset ' + config.data.datasets.length,
  859. };
  860. for (var index = 0; index < config.data.labels.length; ++index) {
  861. newDataset.data.push(randomScalingFactor());
  862. var colorName = colorNames[index % colorNames.length];
  863. ;
  864. var newColor = window.chartColors[colorName];
  865. newDataset.backgroundColor.push(newColor);
  866. }
  867. config.data.datasets.push(newDataset);
  868. window.myPie.update();
  869. });
  870. document.getElementById('removeDataset').addEventListener('click', function () {
  871. config.data.datasets.splice(0, 1);
  872. window.myPie.update();
  873. });
  874. }
  875. /*------------------------------------
  876. 15. Charts.js
  877. --------------------------------------*/
  878. if ($(".chartjs").length !== 0) {
  879. /*----------------
  880. Chart style 1
  881. ------------------*/
  882. var presets = window.chartColors;
  883. var utils = Samples.utils;
  884. var inputs = {
  885. min: -100,
  886. max: 100,
  887. count: 8,
  888. decimals: 2,
  889. continuity: 1
  890. };
  891. function generateData(config) {
  892. return utils.numbers(Chart.helpers.merge(inputs, config || {}));
  893. }
  894. function generateLabels(config) {
  895. return utils.months(Chart.helpers.merge({
  896. count: inputs.count,
  897. section: 3
  898. }, config || {}));
  899. }
  900. var options = {
  901. maintainAspectRatio: false,
  902. spanGaps: false,
  903. elements: {
  904. line: {
  905. tension: 0.000001
  906. }
  907. },
  908. plugins: {
  909. filler: {
  910. propagate: false
  911. }
  912. },
  913. scales: {
  914. xAxes: [{
  915. ticks: {
  916. autoSkip: false,
  917. maxRotation: 0
  918. }
  919. }]
  920. }
  921. };
  922. [false, 'origin', 'start', 'end'].forEach(function (boundary, index) {
  923. // reset the random seed to generate the same data for all charts
  924. utils.srand(8);
  925. new Chart('chart-' + index, {
  926. type: 'line',
  927. data: {
  928. labels: generateLabels(),
  929. datasets: [{
  930. backgroundColor: utils.transparentize(presets.red),
  931. borderColor: presets.red,
  932. data: generateData(),
  933. label: 'Dataset',
  934. fill: boundary
  935. }]
  936. },
  937. options: Chart.helpers.merge(options, {
  938. title: {
  939. text: 'fill: ' + boundary,
  940. display: false
  941. }
  942. })
  943. });
  944. });
  945. // eslint-disable-next-line no-unused-vars
  946. function toggleSmooth(btn) {
  947. var value = btn.classList.toggle('btn-on');
  948. Chart.helpers.each(Chart.instances, function (chart) {
  949. chart.options.elements.line.tension = value ? 0.4 : 0.000001;
  950. chart.update();
  951. });
  952. }
  953. // eslint-disable-next-line no-unused-vars
  954. function randomize() {
  955. var seed = utils.rand();
  956. Chart.helpers.each(Chart.instances, function (chart) {
  957. utils.srand(seed);
  958. chart.data.datasets.forEach(function (dataset) {
  959. dataset.data = generateData();
  960. });
  961. chart.update();
  962. });
  963. }
  964. /*----------------
  965. Chart style 2
  966. ------------------*/
  967. var config = {
  968. type: 'line',
  969. data: {
  970. labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
  971. datasets: [{
  972. label: 'My First dataset',
  973. borderColor: window.chartColors.red,
  974. backgroundColor: window.chartColors.red,
  975. data: [
  976. randomScalingFactor(),
  977. randomScalingFactor(),
  978. randomScalingFactor(),
  979. randomScalingFactor(),
  980. randomScalingFactor(),
  981. randomScalingFactor(),
  982. randomScalingFactor()
  983. ],
  984. fill: false,
  985. }, {
  986. label: 'My Second dataset',
  987. borderColor: window.chartColors.black,
  988. backgroundColor: window.chartColors.black,
  989. data: [
  990. randomScalingFactor(),
  991. randomScalingFactor(),
  992. randomScalingFactor(),
  993. randomScalingFactor(),
  994. randomScalingFactor(),
  995. randomScalingFactor(),
  996. randomScalingFactor()
  997. ],
  998. fill: false,
  999. }]
  1000. },
  1001. options: {
  1002. responsive: true,
  1003. title: {
  1004. display: false,
  1005. text: 'Chart.js Line Chart - Custom Information in Tooltip'
  1006. },
  1007. tooltips: {
  1008. mode: 'index',
  1009. callbacks: {
  1010. // Use the footer callback to display the sum of the items showing in the tooltip
  1011. footer: function (tooltipItems, data) {
  1012. var sum = 0;
  1013. tooltipItems.forEach(function (tooltipItem) {
  1014. sum += data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
  1015. });
  1016. return 'Sum: ' + sum;
  1017. },
  1018. },
  1019. footerFontStyle: 'normal'
  1020. },
  1021. hover: {
  1022. mode: 'index',
  1023. intersect: true
  1024. },
  1025. scales: {
  1026. xAxes: [{
  1027. display: true,
  1028. scaleLabel: {
  1029. show: true,
  1030. labelString: 'Month'
  1031. }
  1032. }],
  1033. yAxes: [{
  1034. display: true,
  1035. scaleLabel: {
  1036. show: true,
  1037. labelString: 'Value'
  1038. }
  1039. }]
  1040. }
  1041. }
  1042. };
  1043. window.onload = function () {
  1044. var ctx = document.getElementById('canvas').getContext('2d');
  1045. window.myLine = new Chart(ctx, config);
  1046. };
  1047. }