Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

charts-chartjs.js 27KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  1. /**
  2. * Charts ChartsJS
  3. */
  4. 'use strict';
  5. document.addEventListener('DOMContentLoaded', function (e) {
  6. // Color Variables
  7. const purpleColor = '#836AF9',
  8. yellowColor = '#ffe800',
  9. cyanColor = '#28dac6',
  10. orangeColor = '#FF8132',
  11. orangeLightColor = '#FDAC34',
  12. oceanBlueColor = '#299AFF',
  13. greyColor = '#4F5D70',
  14. greyLightColor = '#EDF1F4',
  15. blueColor = '#2B9AFF',
  16. blueLightColor = '#84D0FF',
  17. blueDarkColor = '#1D9FF2';
  18. // overriding color variables for chartjs
  19. let cardColor, headingColor, labelColor, borderColor, legendColor, info, danger, primary;
  20. if (isDarkStyle) {
  21. cardColor = window.Helpers.getCssVar('paper-bg', true);
  22. headingColor = window.Helpers.getCssVar('heading-color', true);
  23. labelColor = window.Helpers.getCssVar('secondary-color', true);
  24. legendColor = window.Helpers.getCssVar('body-color', true);
  25. borderColor = window.Helpers.getCssVar('border-color', true);
  26. primary = window.Helpers.getCssVar('primary', true);
  27. info = window.Helpers.getCssVar('info', true);
  28. danger = window.Helpers.getCssVar('danger', true);
  29. } else {
  30. cardColor = window.Helpers.getCssVar('paper-bg', true);
  31. headingColor = window.Helpers.getCssVar('heading-color', true);
  32. labelColor = window.Helpers.getCssVar('secondary-color', true);
  33. legendColor = window.Helpers.getCssVar('body-color', true);
  34. borderColor = window.Helpers.getCssVar('border-color', true);
  35. primary = window.Helpers.getCssVar('primary', true);
  36. info = window.Helpers.getCssVar('info', true);
  37. danger = window.Helpers.getCssVar('danger', true);
  38. }
  39. // Set height according to their data-height
  40. // --------------------------------------------------------------------
  41. const chartList = document.querySelectorAll('.chartjs');
  42. chartList.forEach(function (chartListItem) {
  43. chartListItem.height = chartListItem.dataset.height;
  44. });
  45. // Bar Chart
  46. // --------------------------------------------------------------------
  47. const barChart = document.getElementById('barChart');
  48. if (barChart) {
  49. const barChartVar = new Chart(barChart, {
  50. type: 'bar',
  51. data: {
  52. labels: [
  53. '7/12',
  54. '8/12',
  55. '9/12',
  56. '10/12',
  57. '11/12',
  58. '12/12',
  59. '13/12',
  60. '14/12',
  61. '15/12',
  62. '16/12',
  63. '17/12',
  64. '18/12',
  65. '19/12'
  66. ],
  67. datasets: [
  68. {
  69. data: [275, 90, 190, 205, 125, 85, 55, 87, 127, 150, 230, 280, 190],
  70. backgroundColor: cyanColor,
  71. borderColor: 'transparent',
  72. maxBarThickness: 15,
  73. borderRadius: {
  74. topRight: 15,
  75. topLeft: 15
  76. }
  77. }
  78. ]
  79. },
  80. options: {
  81. responsive: true,
  82. maintainAspectRatio: false,
  83. animation: {
  84. duration: 500
  85. },
  86. plugins: {
  87. tooltip: {
  88. rtl: isRtl,
  89. backgroundColor: cardColor,
  90. titleColor: headingColor,
  91. bodyColor: legendColor,
  92. borderWidth: 1,
  93. borderColor: borderColor
  94. },
  95. legend: {
  96. display: false
  97. }
  98. },
  99. scales: {
  100. x: {
  101. grid: {
  102. color: borderColor,
  103. drawBorder: false,
  104. borderColor: borderColor
  105. },
  106. ticks: {
  107. color: labelColor
  108. }
  109. },
  110. y: {
  111. min: 0,
  112. max: 400,
  113. grid: {
  114. color: borderColor,
  115. drawBorder: false,
  116. borderColor: borderColor
  117. },
  118. ticks: {
  119. stepSize: 100,
  120. color: labelColor
  121. }
  122. }
  123. }
  124. }
  125. });
  126. }
  127. // Horizontal Bar Chart
  128. // --------------------------------------------------------------------
  129. const horizontalBarChart = document.getElementById('horizontalBarChart');
  130. if (horizontalBarChart) {
  131. const horizontalBarChartVar = new Chart(horizontalBarChart, {
  132. type: 'bar',
  133. data: {
  134. labels: ['MON', 'TUE', 'WED ', 'THU', 'FRI', 'SAT', 'SUN'],
  135. datasets: [
  136. {
  137. data: [710, 350, 470, 580, 230, 460, 120],
  138. backgroundColor: info,
  139. borderColor: 'transparent',
  140. maxBarThickness: 15
  141. }
  142. ]
  143. },
  144. options: {
  145. indexAxis: 'y',
  146. responsive: true,
  147. maintainAspectRatio: false,
  148. animation: {
  149. duration: 500
  150. },
  151. elements: {
  152. bar: {
  153. borderRadius: {
  154. topRight: 15,
  155. bottomRight: 15
  156. }
  157. }
  158. },
  159. plugins: {
  160. tooltip: {
  161. rtl: isRtl,
  162. backgroundColor: cardColor,
  163. titleColor: headingColor,
  164. bodyColor: legendColor,
  165. borderWidth: 1,
  166. borderColor: borderColor
  167. },
  168. legend: {
  169. display: false
  170. }
  171. },
  172. scales: {
  173. x: {
  174. min: 0,
  175. grid: {
  176. color: borderColor,
  177. borderColor: borderColor
  178. },
  179. ticks: {
  180. color: labelColor
  181. }
  182. },
  183. y: {
  184. grid: {
  185. borderColor: borderColor,
  186. display: false,
  187. drawBorder: false
  188. },
  189. ticks: {
  190. color: labelColor
  191. }
  192. }
  193. }
  194. }
  195. });
  196. }
  197. // Line Chart
  198. // --------------------------------------------------------------------
  199. const lineChart = document.getElementById('lineChart');
  200. if (lineChart) {
  201. const lineChartVar = new Chart(lineChart, {
  202. type: 'line',
  203. data: {
  204. labels: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],
  205. datasets: [
  206. {
  207. data: [80, 150, 180, 270, 210, 160, 160, 202, 265, 210, 270, 255, 290, 360, 375],
  208. label: 'Europe',
  209. borderColor: danger,
  210. tension: 0.5,
  211. pointStyle: 'circle',
  212. backgroundColor: danger,
  213. fill: false,
  214. pointRadius: 1,
  215. pointHoverRadius: 5,
  216. pointHoverBorderWidth: 5,
  217. pointBorderColor: 'transparent',
  218. pointHoverBorderColor: cardColor,
  219. pointHoverBackgroundColor: danger
  220. },
  221. {
  222. data: [80, 125, 105, 130, 215, 195, 140, 160, 230, 300, 220, 170, 210, 200, 280],
  223. label: 'Asia',
  224. borderColor: primary,
  225. tension: 0.5,
  226. pointStyle: 'circle',
  227. backgroundColor: primary,
  228. fill: false,
  229. pointRadius: 1,
  230. pointHoverRadius: 5,
  231. pointHoverBorderWidth: 5,
  232. pointBorderColor: 'transparent',
  233. pointHoverBorderColor: cardColor,
  234. pointHoverBackgroundColor: primary
  235. },
  236. {
  237. data: [80, 99, 82, 90, 115, 115, 74, 75, 130, 155, 125, 90, 140, 130, 180],
  238. label: 'Africa',
  239. borderColor: yellowColor,
  240. tension: 0.5,
  241. pointStyle: 'circle',
  242. backgroundColor: yellowColor,
  243. fill: false,
  244. pointRadius: 1,
  245. pointHoverRadius: 5,
  246. pointHoverBorderWidth: 5,
  247. pointBorderColor: 'transparent',
  248. pointHoverBorderColor: cardColor,
  249. pointHoverBackgroundColor: yellowColor
  250. }
  251. ]
  252. },
  253. options: {
  254. responsive: true,
  255. maintainAspectRatio: false,
  256. scales: {
  257. x: {
  258. grid: {
  259. color: borderColor,
  260. drawBorder: false,
  261. borderColor: borderColor
  262. },
  263. ticks: {
  264. color: labelColor
  265. }
  266. },
  267. y: {
  268. scaleLabel: {
  269. display: true
  270. },
  271. min: 0,
  272. max: 400,
  273. ticks: {
  274. color: labelColor,
  275. stepSize: 100
  276. },
  277. grid: {
  278. color: borderColor,
  279. drawBorder: false,
  280. borderColor: borderColor
  281. }
  282. }
  283. },
  284. plugins: {
  285. tooltip: {
  286. // Updated default tooltip UI
  287. rtl: isRtl,
  288. backgroundColor: cardColor,
  289. titleColor: headingColor,
  290. bodyColor: legendColor,
  291. borderWidth: 1,
  292. borderColor: borderColor
  293. },
  294. htmlLegend: {
  295. containerID: 'legendContainer'
  296. },
  297. legend: {
  298. display: false
  299. }
  300. }
  301. },
  302. plugins: [LegendUtils.htmlLegendPlugin]
  303. });
  304. }
  305. // Radar Chart
  306. // --------------------------------------------------------------------
  307. const radarChart = document.getElementById('radarChart');
  308. if (radarChart) {
  309. // For radar gradient color
  310. const gradientBlue = radarChart.getContext('2d').createLinearGradient(0, 0, 0, 150);
  311. gradientBlue.addColorStop(0, 'rgba(85, 85, 255, 0.9)');
  312. gradientBlue.addColorStop(1, 'rgba(151, 135, 255, 0.8)');
  313. const gradientRed = radarChart.getContext('2d').createLinearGradient(0, 0, 0, 150);
  314. gradientRed.addColorStop(0, 'rgba(255, 85, 184, 0.9)');
  315. gradientRed.addColorStop(1, 'rgba(255, 135, 135, 0.8)');
  316. const radarChartVar = new Chart(radarChart, {
  317. type: 'radar',
  318. data: {
  319. labels: ['STA', 'STR', 'AGI', 'VIT', 'CHA', 'INT'],
  320. datasets: [
  321. {
  322. label: 'Donté Panlin',
  323. data: [25, 59, 90, 81, 60, 82],
  324. fill: true,
  325. pointStyle: 'dash',
  326. backgroundColor: gradientRed,
  327. borderColor: 'transparent',
  328. pointBorderColor: 'transparent'
  329. },
  330. {
  331. label: 'Mireska Sunbreeze',
  332. data: [40, 100, 40, 90, 40, 90],
  333. fill: true,
  334. pointStyle: 'dash',
  335. backgroundColor: gradientBlue,
  336. borderColor: 'transparent',
  337. pointBorderColor: 'transparent'
  338. }
  339. ]
  340. },
  341. options: {
  342. responsive: true,
  343. maintainAspectRatio: false,
  344. animation: {
  345. duration: 500
  346. },
  347. scales: {
  348. r: {
  349. ticks: {
  350. maxTicksLimit: 1,
  351. display: false,
  352. color: labelColor
  353. },
  354. grid: {
  355. color: borderColor
  356. },
  357. angleLines: { color: borderColor },
  358. pointLabels: {
  359. color: labelColor
  360. }
  361. }
  362. },
  363. plugins: {
  364. legend: {
  365. rtl: isRtl,
  366. position: 'top',
  367. labels: {
  368. padding: 25,
  369. color: legendColor
  370. }
  371. },
  372. tooltip: {
  373. // Updated default tooltip UI
  374. rtl: isRtl,
  375. backgroundColor: cardColor,
  376. titleColor: headingColor,
  377. bodyColor: legendColor,
  378. borderWidth: 1,
  379. borderColor: borderColor
  380. }
  381. }
  382. }
  383. });
  384. }
  385. // Polar Chart
  386. // --------------------------------------------------------------------
  387. const polarChart = document.getElementById('polarChart');
  388. if (polarChart) {
  389. const polarChartVar = new Chart(polarChart, {
  390. type: 'polarArea',
  391. data: {
  392. labels: ['Africa', 'Asia', 'Europe', 'America', 'Antarctica', 'Australia'],
  393. datasets: [
  394. {
  395. label: 'Population (millions)',
  396. backgroundColor: [purpleColor, yellowColor, orangeColor, oceanBlueColor, greyColor, cyanColor],
  397. data: [19, 17.5, 15, 13.5, 11, 9],
  398. borderWidth: 0
  399. }
  400. ]
  401. },
  402. options: {
  403. responsive: true,
  404. maintainAspectRatio: false,
  405. animation: {
  406. duration: 500
  407. },
  408. scales: {
  409. r: {
  410. ticks: {
  411. display: false,
  412. color: labelColor
  413. },
  414. grid: {
  415. display: false
  416. }
  417. }
  418. },
  419. plugins: {
  420. tooltip: {
  421. // Updated default tooltip UI
  422. rtl: isRtl,
  423. backgroundColor: cardColor,
  424. titleColor: headingColor,
  425. bodyColor: legendColor,
  426. borderWidth: 1,
  427. borderColor: borderColor
  428. },
  429. legend: {
  430. rtl: isRtl,
  431. position: 'bottom',
  432. labels: {
  433. usePointStyle: true,
  434. padding: 25,
  435. boxWidth: 8,
  436. boxHeight: 8,
  437. color: legendColor
  438. }
  439. }
  440. }
  441. }
  442. });
  443. }
  444. // Bubble Chart
  445. // --------------------------------------------------------------------
  446. const bubbleChart = document.getElementById('bubbleChart');
  447. if (bubbleChart) {
  448. const bubbleChartVar = new Chart(bubbleChart, {
  449. type: 'bubble',
  450. data: {
  451. animation: {
  452. duration: 10000
  453. },
  454. datasets: [
  455. {
  456. label: 'Dataset 1',
  457. backgroundColor: purpleColor,
  458. borderColor: purpleColor,
  459. data: [
  460. {
  461. x: 20,
  462. y: 74,
  463. r: 10
  464. },
  465. {
  466. x: 10,
  467. y: 110,
  468. r: 5
  469. },
  470. {
  471. x: 30,
  472. y: 165,
  473. r: 7
  474. },
  475. {
  476. x: 40,
  477. y: 200,
  478. r: 20
  479. },
  480. {
  481. x: 90,
  482. y: 185,
  483. r: 7
  484. },
  485. {
  486. x: 50,
  487. y: 240,
  488. r: 7
  489. },
  490. {
  491. x: 60,
  492. y: 275,
  493. r: 10
  494. },
  495. {
  496. x: 70,
  497. y: 305,
  498. r: 5
  499. },
  500. {
  501. x: 80,
  502. y: 325,
  503. r: 4
  504. },
  505. {
  506. x: 100,
  507. y: 310,
  508. r: 5
  509. },
  510. {
  511. x: 110,
  512. y: 240,
  513. r: 5
  514. },
  515. {
  516. x: 120,
  517. y: 270,
  518. r: 7
  519. },
  520. {
  521. x: 130,
  522. y: 300,
  523. r: 6
  524. }
  525. ]
  526. },
  527. {
  528. label: 'Dataset 2',
  529. backgroundColor: yellowColor,
  530. borderColor: yellowColor,
  531. data: [
  532. {
  533. x: 30,
  534. y: 72,
  535. r: 5
  536. },
  537. {
  538. x: 40,
  539. y: 110,
  540. r: 7
  541. },
  542. {
  543. x: 20,
  544. y: 135,
  545. r: 6
  546. },
  547. {
  548. x: 10,
  549. y: 160,
  550. r: 12
  551. },
  552. {
  553. x: 50,
  554. y: 285,
  555. r: 5
  556. },
  557. {
  558. x: 60,
  559. y: 235,
  560. r: 5
  561. },
  562. {
  563. x: 70,
  564. y: 275,
  565. r: 7
  566. },
  567. {
  568. x: 80,
  569. y: 290,
  570. r: 4
  571. },
  572. {
  573. x: 90,
  574. y: 250,
  575. r: 10
  576. },
  577. {
  578. x: 100,
  579. y: 220,
  580. r: 7
  581. },
  582. {
  583. x: 120,
  584. y: 230,
  585. r: 4
  586. },
  587. {
  588. x: 110,
  589. y: 320,
  590. r: 15
  591. },
  592. {
  593. x: 130,
  594. y: 330,
  595. r: 7
  596. }
  597. ]
  598. }
  599. ]
  600. },
  601. options: {
  602. responsive: true,
  603. maintainAspectRatio: false,
  604. scales: {
  605. x: {
  606. min: 0,
  607. max: 140,
  608. grid: {
  609. color: borderColor,
  610. drawBorder: false,
  611. borderColor: borderColor
  612. },
  613. ticks: {
  614. stepSize: 10,
  615. color: labelColor
  616. }
  617. },
  618. y: {
  619. min: 0,
  620. max: 400,
  621. grid: {
  622. color: borderColor,
  623. drawBorder: false,
  624. borderColor: borderColor
  625. },
  626. ticks: {
  627. stepSize: 100,
  628. color: labelColor
  629. }
  630. }
  631. },
  632. plugins: {
  633. legend: {
  634. display: false
  635. },
  636. tooltip: {
  637. // Updated default tooltip UI
  638. rtl: isRtl,
  639. backgroundColor: cardColor,
  640. titleColor: headingColor,
  641. bodyColor: legendColor,
  642. borderWidth: 1,
  643. borderColor: borderColor
  644. }
  645. }
  646. }
  647. });
  648. }
  649. // LineArea Chart
  650. // --------------------------------------------------------------------
  651. const lineAreaChart = document.getElementById('lineAreaChart');
  652. if (lineAreaChart) {
  653. const lineAreaChartVar = new Chart(lineAreaChart, {
  654. type: 'line',
  655. data: {
  656. labels: [
  657. '7/12',
  658. '8/12',
  659. '9/12',
  660. '10/12',
  661. '11/12',
  662. '12/12',
  663. '13/12',
  664. '14/12',
  665. '15/12',
  666. '16/12',
  667. '17/12',
  668. '18/12',
  669. '19/12',
  670. '20/12',
  671. ''
  672. ],
  673. datasets: [
  674. {
  675. label: 'Africa',
  676. data: [40, 55, 45, 75, 65, 55, 70, 60, 100, 98, 90, 120, 125, 140, 155],
  677. tension: 0,
  678. fill: true,
  679. backgroundColor: blueColor,
  680. pointStyle: 'circle',
  681. borderColor: 'transparent',
  682. pointRadius: 0.5,
  683. pointHoverRadius: 5,
  684. pointHoverBorderWidth: 5,
  685. pointBorderColor: 'transparent',
  686. pointHoverBackgroundColor: blueColor,
  687. pointHoverBorderColor: cardColor
  688. },
  689. {
  690. label: 'Asia',
  691. data: [70, 85, 75, 150, 100, 140, 110, 105, 160, 150, 125, 190, 200, 240, 275],
  692. tension: 0,
  693. fill: true,
  694. backgroundColor: blueLightColor,
  695. pointStyle: 'circle',
  696. borderColor: 'transparent',
  697. pointRadius: 0.5,
  698. pointHoverRadius: 5,
  699. pointHoverBorderWidth: 5,
  700. pointBorderColor: 'transparent',
  701. pointHoverBackgroundColor: blueLightColor,
  702. pointHoverBorderColor: cardColor
  703. },
  704. {
  705. label: 'Europe',
  706. data: [240, 195, 160, 215, 185, 215, 185, 200, 250, 210, 195, 250, 235, 300, 315],
  707. tension: 0,
  708. fill: true,
  709. backgroundColor: greyLightColor,
  710. pointStyle: 'circle',
  711. borderColor: 'transparent',
  712. pointRadius: 0.5,
  713. pointHoverRadius: 5,
  714. pointHoverBorderWidth: 5,
  715. pointBorderColor: 'transparent',
  716. pointHoverBackgroundColor: greyLightColor,
  717. pointHoverBorderColor: cardColor
  718. }
  719. ]
  720. },
  721. options: {
  722. responsive: true,
  723. maintainAspectRatio: false,
  724. plugins: {
  725. htmlLegend: {
  726. containerID: 'legendContainer1'
  727. },
  728. legend: {
  729. display: false
  730. },
  731. tooltip: {
  732. // Updated default tooltip UI
  733. rtl: isRtl,
  734. backgroundColor: cardColor,
  735. titleColor: headingColor,
  736. bodyColor: legendColor,
  737. borderWidth: 1,
  738. borderColor: borderColor
  739. }
  740. },
  741. scales: {
  742. x: {
  743. grid: {
  744. color: 'transparent',
  745. borderColor: borderColor
  746. },
  747. ticks: {
  748. color: labelColor
  749. }
  750. },
  751. y: {
  752. min: 0,
  753. max: 400,
  754. grid: {
  755. color: 'transparent',
  756. borderColor: borderColor
  757. },
  758. ticks: {
  759. stepSize: 100,
  760. color: labelColor
  761. }
  762. }
  763. }
  764. },
  765. plugins: [LegendUtils.htmlLegendPlugin]
  766. });
  767. }
  768. // Doughnut Chart
  769. // --------------------------------------------------------------------
  770. const doughnutChart = document.getElementById('doughnutChart');
  771. if (doughnutChart) {
  772. const doughnutChartVar = new Chart(doughnutChart, {
  773. type: 'doughnut',
  774. data: {
  775. labels: ['Tablet', 'Mobile', 'Desktop'],
  776. datasets: [
  777. {
  778. data: [10, 10, 80],
  779. backgroundColor: [cyanColor, orangeLightColor, primary],
  780. borderWidth: 0,
  781. pointStyle: 'rectRounded'
  782. }
  783. ]
  784. },
  785. options: {
  786. responsive: true,
  787. animation: {
  788. duration: 500
  789. },
  790. cutout: '68%',
  791. plugins: {
  792. legend: {
  793. display: false
  794. },
  795. tooltip: {
  796. callbacks: {
  797. label: function (context) {
  798. const label = context.labels || '',
  799. value = context.parsed;
  800. const output = ' ' + label + ' : ' + value + ' %';
  801. return output;
  802. }
  803. },
  804. // Updated default tooltip UI
  805. rtl: isRtl,
  806. backgroundColor: cardColor,
  807. titleColor: headingColor,
  808. bodyColor: legendColor,
  809. borderWidth: 1,
  810. borderColor: borderColor
  811. }
  812. }
  813. }
  814. });
  815. }
  816. // Scatter Chart
  817. // --------------------------------------------------------------------
  818. const scatterChart = document.getElementById('scatterChart');
  819. if (scatterChart) {
  820. const scatterChartVar = new Chart(scatterChart, {
  821. type: 'scatter',
  822. data: {
  823. datasets: [
  824. {
  825. label: 'iPhone',
  826. data: [
  827. {
  828. x: 72,
  829. y: 225
  830. },
  831. {
  832. x: 81,
  833. y: 270
  834. },
  835. {
  836. x: 90,
  837. y: 230
  838. },
  839. {
  840. x: 103,
  841. y: 305
  842. },
  843. {
  844. x: 103,
  845. y: 245
  846. },
  847. {
  848. x: 108,
  849. y: 275
  850. },
  851. {
  852. x: 110,
  853. y: 290
  854. },
  855. {
  856. x: 111,
  857. y: 315
  858. },
  859. {
  860. x: 109,
  861. y: 350
  862. },
  863. {
  864. x: 116,
  865. y: 340
  866. },
  867. {
  868. x: 113,
  869. y: 260
  870. },
  871. {
  872. x: 117,
  873. y: 275
  874. },
  875. {
  876. x: 117,
  877. y: 295
  878. },
  879. {
  880. x: 126,
  881. y: 280
  882. },
  883. {
  884. x: 127,
  885. y: 340
  886. },
  887. {
  888. x: 133,
  889. y: 330
  890. }
  891. ],
  892. backgroundColor: primary,
  893. borderColor: 'transparent',
  894. pointBorderWidth: 2,
  895. pointHoverBorderWidth: 2,
  896. pointRadius: 5
  897. },
  898. {
  899. label: 'Samsung Note',
  900. data: [
  901. {
  902. x: 13,
  903. y: 95
  904. },
  905. {
  906. x: 22,
  907. y: 105
  908. },
  909. {
  910. x: 17,
  911. y: 115
  912. },
  913. {
  914. x: 19,
  915. y: 130
  916. },
  917. {
  918. x: 21,
  919. y: 125
  920. },
  921. {
  922. x: 35,
  923. y: 125
  924. },
  925. {
  926. x: 13,
  927. y: 155
  928. },
  929. {
  930. x: 21,
  931. y: 165
  932. },
  933. {
  934. x: 25,
  935. y: 155
  936. },
  937. {
  938. x: 18,
  939. y: 190
  940. },
  941. {
  942. x: 26,
  943. y: 180
  944. },
  945. {
  946. x: 43,
  947. y: 180
  948. },
  949. {
  950. x: 53,
  951. y: 202
  952. },
  953. {
  954. x: 61,
  955. y: 165
  956. },
  957. {
  958. x: 67,
  959. y: 225
  960. }
  961. ],
  962. backgroundColor: yellowColor,
  963. borderColor: 'transparent',
  964. pointRadius: 5
  965. },
  966. {
  967. label: 'OnePlus',
  968. data: [
  969. {
  970. x: 70,
  971. y: 195
  972. },
  973. {
  974. x: 72,
  975. y: 270
  976. },
  977. {
  978. x: 98,
  979. y: 255
  980. },
  981. {
  982. x: 100,
  983. y: 215
  984. },
  985. {
  986. x: 87,
  987. y: 240
  988. },
  989. {
  990. x: 94,
  991. y: 280
  992. },
  993. {
  994. x: 99,
  995. y: 300
  996. },
  997. {
  998. x: 102,
  999. y: 290
  1000. },
  1001. {
  1002. x: 110,
  1003. y: 275
  1004. },
  1005. {
  1006. x: 111,
  1007. y: 250
  1008. },
  1009. {
  1010. x: 94,
  1011. y: 280
  1012. },
  1013. {
  1014. x: 92,
  1015. y: 340
  1016. },
  1017. {
  1018. x: 100,
  1019. y: 335
  1020. },
  1021. {
  1022. x: 108,
  1023. y: 330
  1024. }
  1025. ],
  1026. backgroundColor: cyanColor,
  1027. borderColor: 'transparent',
  1028. pointBorderWidth: 2,
  1029. pointHoverBorderWidth: 2,
  1030. pointRadius: 5
  1031. }
  1032. ]
  1033. },
  1034. options: {
  1035. responsive: true,
  1036. maintainAspectRatio: false,
  1037. animation: {
  1038. duration: 800
  1039. },
  1040. plugins: {
  1041. legend: {
  1042. display: false
  1043. },
  1044. htmlLegend: {
  1045. containerID: 'legendContainer2'
  1046. },
  1047. tooltip: {
  1048. // Updated default tooltip UI
  1049. rtl: isRtl,
  1050. backgroundColor: cardColor,
  1051. titleColor: headingColor,
  1052. bodyColor: legendColor,
  1053. borderWidth: 1,
  1054. borderColor: borderColor
  1055. }
  1056. },
  1057. scales: {
  1058. x: {
  1059. min: 0,
  1060. max: 140,
  1061. grid: {
  1062. color: borderColor,
  1063. drawTicks: false,
  1064. drawBorder: false,
  1065. borderColor: borderColor
  1066. },
  1067. ticks: {
  1068. stepSize: 10,
  1069. color: labelColor
  1070. }
  1071. },
  1072. y: {
  1073. min: 0,
  1074. max: 400,
  1075. grid: {
  1076. color: borderColor,
  1077. drawTicks: false,
  1078. drawBorder: false,
  1079. borderColor: borderColor
  1080. },
  1081. ticks: {
  1082. stepSize: 100,
  1083. color: labelColor
  1084. }
  1085. }
  1086. }
  1087. },
  1088. plugins: [LegendUtils.htmlLegendPlugin]
  1089. });
  1090. }
  1091. });