sparklines.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  7. <title>Sparklines</title>
  8. <link href="../../assets/styles.css" rel="stylesheet" />
  9. <style>
  10. .row {
  11. overflow: hidden;
  12. max-width: 890px;
  13. margin: 30px auto;
  14. display: flex;
  15. }
  16. .col-md-4 {
  17. width: 33.33%;
  18. padding: 0 25px;
  19. }
  20. table {
  21. width: 100%;
  22. }
  23. tbody tr {
  24. border-top: 1px solid #e7e7e7;
  25. }
  26. th {
  27. font-weight: bold;
  28. font-family: Helvetica;
  29. padding-bottom: 20px;
  30. }
  31. td, th {
  32. width: 25%;
  33. text-align: center;
  34. height: 65px;
  35. }
  36. td div {
  37. margin: 0 auto;
  38. }
  39. .left {
  40. float: left;
  41. }
  42. .right {
  43. float: right;
  44. }
  45. @media only screen and (max-width: 480px) {
  46. th:first-child, td:first-child {
  47. display: none;
  48. }
  49. .row {
  50. display: block;
  51. }
  52. .col-md-4 {
  53. padding: 0;
  54. width: 100%;
  55. }
  56. }
  57. </style>
  58. <script>
  59. window.Promise ||
  60. document.write(
  61. '<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"><\/script>'
  62. )
  63. window.Promise ||
  64. document.write(
  65. '<script src="https://cdn.jsdelivr.net/npm/eligrey-classlist-js-polyfill@1.2.20171210/classList.min.js"><\/script>'
  66. )
  67. window.Promise ||
  68. document.write(
  69. '<script src="https://cdn.jsdelivr.net/npm/findindex_polyfill_mdn"><\/script>'
  70. )
  71. </script>
  72. <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
  73. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  74. <script src="https://cdn.jsdelivr.net/npm/vue-apexcharts"></script>
  75. <script>
  76. window.Apex = {
  77. stroke: {
  78. width: 3
  79. },
  80. markers: {
  81. size: 0
  82. },
  83. tooltip: {
  84. fixed: {
  85. enabled: true,
  86. }
  87. }
  88. };
  89. var randomizeArray = function (arg) {
  90. var array = arg.slice();
  91. var currentIndex = array.length,
  92. temporaryValue, randomIndex;
  93. while (0 !== currentIndex) {
  94. randomIndex = Math.floor(Math.random() * currentIndex);
  95. currentIndex -= 1;
  96. temporaryValue = array[currentIndex];
  97. array[currentIndex] = array[randomIndex];
  98. array[randomIndex] = temporaryValue;
  99. }
  100. return array;
  101. }
  102. // data for the sparklines that appear below header area
  103. var sparklineData = [47, 45, 54, 38, 56, 24, 65, 31, 37, 39, 62, 51, 35, 41, 35, 27, 93, 53, 61, 27, 54, 43, 19, 46];
  104. </script>
  105. </head>
  106. <body>
  107. <div id="app">
  108. <div>
  109. <div class="row">
  110. <div class="col-md-4">
  111. <div id="chart-spark1">
  112. <apexchart type="area" height="160" :options="chartOptions" :series="series"></apexchart>
  113. </div>
  114. </div>
  115. <div class="col-md-4">
  116. <div id="chart-spark2">
  117. <apexchart type="area" height="160" :options="chartOptionsSpark2" :series="seriesSpark2"></apexchart>
  118. </div>
  119. </div>
  120. <div class="col-md-4">
  121. <div id="chart-spark3">
  122. <apexchart type="area" height="160" :options="chartOptionsSpark3" :series="seriesSpark3"></apexchart>
  123. </div>
  124. </div>
  125. </div>
  126. <div class="row">
  127. <table>
  128. <thead>
  129. <th>Total Value</th>
  130. <th>Percentage of Portfolio</th>
  131. <th>Last 10 days</th>
  132. <th>Volume</th>
  133. </thead>
  134. <tbody>
  135. <tr>
  136. <td>$32,554</td>
  137. <td>15%</td>
  138. <td>
  139. <div id="chart-1">
  140. <apexchart type="line" height="35" width="100" :options="chartOptions1" :series="series1"></apexchart>
  141. </div>
  142. </td>
  143. <td>
  144. <div id="chart-5">
  145. <apexchart type="bar" height="35" width="100" :options="chartOptions5" :series="series5"></apexchart>
  146. </div>
  147. </td>
  148. </tr>
  149. <tr>
  150. <td>$23,533</td>
  151. <td>7%</td>
  152. <td>
  153. <div id="chart-2">
  154. <apexchart type="line" height="35" width="100" :options="chartOptions2" :series="series2"></apexchart>
  155. </div>
  156. </td>
  157. <td>
  158. <div id="chart-6">
  159. <apexchart type="bar" height="35" width="100" :options="chartOptions6" :series="series6"></apexchart>
  160. </div>
  161. </td>
  162. </tr>
  163. <tr>
  164. <td>$54,276</td>
  165. <td>9%</td>
  166. <td>
  167. <div id="chart-3">
  168. <apexchart type="pie" height="40" width="40" :options="chartOptions3" :series="series3"></apexchart>
  169. </div>
  170. </td>
  171. <td>
  172. <div id="chart-7">
  173. <apexchart type="radialBar" height="50" width="50" :options="chartOptions7" :series="series7"></apexchart>
  174. </div>
  175. </td>
  176. </tr>
  177. <tr>
  178. <td>$11,533</td>
  179. <td>2%</td>
  180. <td>
  181. <div id="chart-4">
  182. <apexchart type="donut" height="40" width="40" :options="chartOptions4" :series="series4"></apexchart>
  183. </div>
  184. </td>
  185. <td>
  186. <div id="chart-8">
  187. <apexchart type="radialBar" height="40" width="40" :options="chartOptions8" :series="series8"></apexchart>
  188. </div>
  189. </td>
  190. </tr>
  191. </tbody>
  192. </table>
  193. </div>
  194. </div>
  195. </div>
  196. <!-- Below element is just for displaying source code. it is not required. DO NOT USE -->
  197. <div id="html">
  198. &lt;div&gt;
  199. &lt;div class=&quot;row&quot;&gt;
  200. &lt;div class=&quot;col-md-4&quot;&gt;
  201. &lt;div id=&quot;chart-spark1&quot;&gt;
  202. &lt;apexchart type=&quot;area&quot; height=&quot;160&quot; :options=&quot;chartOptions&quot; :series=&quot;series&quot;&gt;&lt;/apexchart&gt;
  203. &lt;/div&gt;
  204. &lt;/div&gt;
  205. &lt;div class=&quot;col-md-4&quot;&gt;
  206. &lt;div id=&quot;chart-spark2&quot;&gt;
  207. &lt;apexchart type=&quot;area&quot; height=&quot;160&quot; :options=&quot;chartOptionsSpark2&quot; :series=&quot;seriesSpark2&quot;&gt;&lt;/apexchart&gt;
  208. &lt;/div&gt;
  209. &lt;/div&gt;
  210. &lt;div class=&quot;col-md-4&quot;&gt;
  211. &lt;div id=&quot;chart-spark3&quot;&gt;
  212. &lt;apexchart type=&quot;area&quot; height=&quot;160&quot; :options=&quot;chartOptionsSpark3&quot; :series=&quot;seriesSpark3&quot;&gt;&lt;/apexchart&gt;
  213. &lt;/div&gt;
  214. &lt;/div&gt;
  215. &lt;/div&gt;
  216. &lt;div class=&quot;row&quot;&gt;
  217. &lt;table&gt;
  218. &lt;thead&gt;
  219. &lt;th&gt;Total Value&lt;/th&gt;
  220. &lt;th&gt;Percentage of Portfolio&lt;/th&gt;
  221. &lt;th&gt;Last 10 days&lt;/th&gt;
  222. &lt;th&gt;Volume&lt;/th&gt;
  223. &lt;/thead&gt;
  224. &lt;tbody&gt;
  225. &lt;tr&gt;
  226. &lt;td&gt;$32,554&lt;/td&gt;
  227. &lt;td&gt;15%&lt;/td&gt;
  228. &lt;td&gt;
  229. &lt;div id=&quot;chart-1&quot;&gt;
  230. &lt;apexchart type=&quot;line&quot; height=&quot;35&quot; width=&quot;100&quot; :options=&quot;chartOptions1&quot; :series=&quot;series1&quot;&gt;&lt;/apexchart&gt;
  231. &lt;/div&gt;
  232. &lt;/td&gt;
  233. &lt;td&gt;
  234. &lt;div id=&quot;chart-5&quot;&gt;
  235. &lt;apexchart type=&quot;bar&quot; height=&quot;35&quot; width=&quot;100&quot; :options=&quot;chartOptions5&quot; :series=&quot;series5&quot;&gt;&lt;/apexchart&gt;
  236. &lt;/div&gt;
  237. &lt;/td&gt;
  238. &lt;/tr&gt;
  239. &lt;tr&gt;
  240. &lt;td&gt;$23,533&lt;/td&gt;
  241. &lt;td&gt;7%&lt;/td&gt;
  242. &lt;td&gt;
  243. &lt;div id=&quot;chart-2&quot;&gt;
  244. &lt;apexchart type=&quot;line&quot; height=&quot;35&quot; width=&quot;100&quot; :options=&quot;chartOptions2&quot; :series=&quot;series2&quot;&gt;&lt;/apexchart&gt;
  245. &lt;/div&gt;
  246. &lt;/td&gt;
  247. &lt;td&gt;
  248. &lt;div id=&quot;chart-6&quot;&gt;
  249. &lt;apexchart type=&quot;bar&quot; height=&quot;35&quot; width=&quot;100&quot; :options=&quot;chartOptions6&quot; :series=&quot;series6&quot;&gt;&lt;/apexchart&gt;
  250. &lt;/div&gt;
  251. &lt;/td&gt;
  252. &lt;/tr&gt;
  253. &lt;tr&gt;
  254. &lt;td&gt;$54,276&lt;/td&gt;
  255. &lt;td&gt;9%&lt;/td&gt;
  256. &lt;td&gt;
  257. &lt;div id=&quot;chart-3&quot;&gt;
  258. &lt;apexchart type=&quot;pie&quot; height=&quot;40&quot; width=&quot;40&quot; :options=&quot;chartOptions3&quot; :series=&quot;series3&quot;&gt;&lt;/apexchart&gt;
  259. &lt;/div&gt;
  260. &lt;/td&gt;
  261. &lt;td&gt;
  262. &lt;div id=&quot;chart-7&quot;&gt;
  263. &lt;apexchart type=&quot;radialBar&quot; height=&quot;50&quot; width=&quot;50&quot; :options=&quot;chartOptions7&quot; :series=&quot;series7&quot;&gt;&lt;/apexchart&gt;
  264. &lt;/div&gt;
  265. &lt;/td&gt;
  266. &lt;/tr&gt;
  267. &lt;tr&gt;
  268. &lt;td&gt;$11,533&lt;/td&gt;
  269. &lt;td&gt;2%&lt;/td&gt;
  270. &lt;td&gt;
  271. &lt;div id=&quot;chart-4&quot;&gt;
  272. &lt;apexchart type=&quot;donut&quot; height=&quot;40&quot; width=&quot;40&quot; :options=&quot;chartOptions4&quot; :series=&quot;series4&quot;&gt;&lt;/apexchart&gt;
  273. &lt;/div&gt;
  274. &lt;/td&gt;
  275. &lt;td&gt;
  276. &lt;div id=&quot;chart-8&quot;&gt;
  277. &lt;apexchart type=&quot;radialBar&quot; height=&quot;40&quot; width=&quot;40&quot; :options=&quot;chartOptions8&quot; :series=&quot;series8&quot;&gt;&lt;/apexchart&gt;
  278. &lt;/div&gt;
  279. &lt;/td&gt;
  280. &lt;/tr&gt;
  281. &lt;/tbody&gt;
  282. &lt;/table&gt;
  283. &lt;/div&gt;
  284. &lt;/div&gt;
  285. </div>
  286. <script>
  287. new Vue({
  288. el: '#app',
  289. components: {
  290. apexchart: VueApexCharts,
  291. },
  292. data: {
  293. series: [{
  294. data: randomizeArray(sparklineData)
  295. }],
  296. chartOptions: {
  297. chart: {
  298. type: 'area',
  299. height: 160,
  300. sparkline: {
  301. enabled: true
  302. },
  303. },
  304. stroke: {
  305. curve: 'straight'
  306. },
  307. fill: {
  308. opacity: 0.3,
  309. },
  310. yaxis: {
  311. min: 0
  312. },
  313. colors: ['#DCE6EC'],
  314. title: {
  315. text: '$424,652',
  316. offsetX: 0,
  317. style: {
  318. fontSize: '24px',
  319. }
  320. },
  321. subtitle: {
  322. text: 'Sales',
  323. offsetX: 0,
  324. style: {
  325. fontSize: '14px',
  326. }
  327. }
  328. },
  329. seriesSpark2: [{
  330. data: randomizeArray(sparklineData)
  331. }],
  332. chartOptionsSpark2: {
  333. chart: {
  334. type: 'area',
  335. height: 160,
  336. sparkline: {
  337. enabled: true
  338. },
  339. },
  340. stroke: {
  341. curve: 'straight'
  342. },
  343. fill: {
  344. opacity: 0.3,
  345. },
  346. yaxis: {
  347. min: 0
  348. },
  349. colors: ['#DCE6EC'],
  350. title: {
  351. text: '$235,312',
  352. offsetX: 0,
  353. style: {
  354. fontSize: '24px',
  355. }
  356. },
  357. subtitle: {
  358. text: 'Expenses',
  359. offsetX: 0,
  360. style: {
  361. fontSize: '14px',
  362. }
  363. }
  364. },
  365. seriesSpark3: [{
  366. data: randomizeArray(sparklineData)
  367. }],
  368. chartOptionsSpark3: {
  369. chart: {
  370. type: 'area',
  371. height: 160,
  372. sparkline: {
  373. enabled: true
  374. },
  375. },
  376. stroke: {
  377. curve: 'straight'
  378. },
  379. fill: {
  380. opacity: 0.3
  381. },
  382. xaxis: {
  383. crosshairs: {
  384. width: 1
  385. },
  386. },
  387. yaxis: {
  388. min: 0
  389. },
  390. title: {
  391. text: '$135,965',
  392. offsetX: 0,
  393. style: {
  394. fontSize: '24px',
  395. }
  396. },
  397. subtitle: {
  398. text: 'Profits',
  399. offsetX: 0,
  400. style: {
  401. fontSize: '14px',
  402. }
  403. }
  404. },
  405. series1: [{
  406. data: [25, 66, 41, 89, 63, 25, 44, 12, 36, 9, 54]
  407. }],
  408. chartOptions1: {
  409. chart: {
  410. type: 'line',
  411. width: 100,
  412. height: 35,
  413. sparkline: {
  414. enabled: true
  415. }
  416. },
  417. tooltip: {
  418. fixed: {
  419. enabled: false
  420. },
  421. x: {
  422. show: false
  423. },
  424. y: {
  425. title: {
  426. formatter: function (seriesName) {
  427. return ''
  428. }
  429. }
  430. },
  431. marker: {
  432. show: false
  433. }
  434. }
  435. },
  436. series2: [{
  437. data: [12, 14, 2, 47, 42, 15, 47, 75, 65, 19, 14]
  438. }],
  439. chartOptions2: {
  440. chart: {
  441. type: 'line',
  442. width: 100,
  443. height: 35,
  444. sparkline: {
  445. enabled: true
  446. }
  447. },
  448. tooltip: {
  449. fixed: {
  450. enabled: false
  451. },
  452. x: {
  453. show: false
  454. },
  455. y: {
  456. title: {
  457. formatter: function (seriesName) {
  458. return ''
  459. }
  460. }
  461. },
  462. marker: {
  463. show: false
  464. }
  465. }
  466. },
  467. series3: [43, 32, 12, 9],
  468. chartOptions3: {
  469. chart: {
  470. type: 'pie',
  471. width: 40,
  472. height: 40,
  473. sparkline: {
  474. enabled: true
  475. }
  476. },
  477. stroke: {
  478. width: 1
  479. },
  480. tooltip: {
  481. fixed: {
  482. enabled: false
  483. },
  484. }
  485. },
  486. series4: [43, 32, 12, 9],
  487. chartOptions4: {
  488. chart: {
  489. type: 'donut',
  490. width: 40,
  491. height: 40,
  492. sparkline: {
  493. enabled: true
  494. }
  495. },
  496. stroke: {
  497. width: 1
  498. },
  499. tooltip: {
  500. fixed: {
  501. enabled: false
  502. },
  503. }
  504. },
  505. series5: [{
  506. data: [25, 66, 41, 89, 63, 25, 44, 12, 36, 9, 54]
  507. }],
  508. chartOptions5: {
  509. chart: {
  510. type: 'bar',
  511. width: 100,
  512. height: 35,
  513. sparkline: {
  514. enabled: true
  515. }
  516. },
  517. plotOptions: {
  518. bar: {
  519. columnWidth: '80%'
  520. }
  521. },
  522. labels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
  523. xaxis: {
  524. crosshairs: {
  525. width: 1
  526. },
  527. },
  528. tooltip: {
  529. fixed: {
  530. enabled: false
  531. },
  532. x: {
  533. show: false
  534. },
  535. y: {
  536. title: {
  537. formatter: function (seriesName) {
  538. return ''
  539. }
  540. }
  541. },
  542. marker: {
  543. show: false
  544. }
  545. }
  546. },
  547. series6: [{
  548. data: [12, 14, 2, 47, 42, 15, 47, 75, 65, 19, 14]
  549. }],
  550. chartOptions6: {
  551. chart: {
  552. type: 'bar',
  553. width: 100,
  554. height: 35,
  555. sparkline: {
  556. enabled: true
  557. }
  558. },
  559. plotOptions: {
  560. bar: {
  561. columnWidth: '80%'
  562. }
  563. },
  564. labels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
  565. xaxis: {
  566. crosshairs: {
  567. width: 1
  568. },
  569. },
  570. tooltip: {
  571. fixed: {
  572. enabled: false
  573. },
  574. x: {
  575. show: false
  576. },
  577. y: {
  578. title: {
  579. formatter: function (seriesName) {
  580. return ''
  581. }
  582. }
  583. },
  584. marker: {
  585. show: false
  586. }
  587. }
  588. },
  589. series7: [45],
  590. chartOptions7: {
  591. chart: {
  592. type: 'radialBar',
  593. width: 50,
  594. height: 50,
  595. sparkline: {
  596. enabled: true
  597. }
  598. },
  599. dataLabels: {
  600. enabled: false
  601. },
  602. plotOptions: {
  603. radialBar: {
  604. hollow: {
  605. margin: 0,
  606. size: '50%'
  607. },
  608. track: {
  609. margin: 0
  610. },
  611. dataLabels: {
  612. show: false
  613. }
  614. }
  615. }
  616. },
  617. series8: [53, 67],
  618. chartOptions8: {
  619. chart: {
  620. type: 'radialBar',
  621. width: 40,
  622. height: 40,
  623. sparkline: {
  624. enabled: true
  625. }
  626. },
  627. dataLabels: {
  628. enabled: false
  629. },
  630. plotOptions: {
  631. radialBar: {
  632. hollow: {
  633. margin: 0,
  634. size: '50%'
  635. },
  636. track: {
  637. margin: 1
  638. },
  639. dataLabels: {
  640. show: false
  641. }
  642. }
  643. }
  644. },
  645. },
  646. })
  647. </script>
  648. </body>
  649. </html>