area-github-style.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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>Area - Github style</title>
  8. <link href="../../assets/styles.css" rel="stylesheet" />
  9. <style>
  10. #wrapper {
  11. padding-top: 20px;
  12. padding-left: 10px;
  13. padding-right: 10px;
  14. background: #fff;
  15. border: 1px solid #ddd;
  16. box-shadow: 0 22px 35px -16px rgba(0, 0, 0, 0.1);
  17. max-width: 650px;
  18. margin: 35px auto;
  19. }
  20. .github-style {
  21. clear: both;
  22. font-weight: 400;
  23. height: 40px;
  24. margin-left: 6px;
  25. }
  26. .github-style a {
  27. color: #0366d6;
  28. font-size: 18px;
  29. }
  30. .github-style .cmeta {
  31. display: block;
  32. color: #777;
  33. font-weight: 400;
  34. }
  35. .github-style .userimg {
  36. float: left;
  37. display: block;
  38. border-radius: 3px;
  39. }
  40. .github-style .userdetails {
  41. float: left;
  42. margin-left: 10px;
  43. }
  44. </style>
  45. <script>
  46. window.Promise ||
  47. document.write(
  48. '<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"><\/script>'
  49. )
  50. window.Promise ||
  51. document.write(
  52. '<script src="https://cdn.jsdelivr.net/npm/eligrey-classlist-js-polyfill@1.2.20171210/classList.min.js"><\/script>'
  53. )
  54. window.Promise ||
  55. document.write(
  56. '<script src="https://cdn.jsdelivr.net/npm/findindex_polyfill_mdn"><\/script>'
  57. )
  58. </script>
  59. <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
  60. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  61. <script src="https://cdn.jsdelivr.net/npm/vue-apexcharts"></script>
  62. <script src="../../assets/github-data.js"></script>
  63. </head>
  64. <body>
  65. <div id="app">
  66. <div id="wrapper">
  67. <div id="chart-months">
  68. <apexchart type="area" height="160" :options="chartOptions" :series="series"></apexchart>
  69. </div>
  70. <h5 class="github-style">
  71. <img class="userimg" src="https://picsum.photos/200/200/?image=1031" data-hovercard-user-id="634573" alt="" width="38" height="38" />
  72. <div class="userdetails">
  73. <a class="username">coder</a>
  74. <span class="cmeta">
  75. <span class="commits"></span> commits
  76. </span>
  77. </div>
  78. </h5>
  79. <div id="chart-years">
  80. <apexchart type="area" height="200" :options="chartOptionsYears" :series="seriesYears"></apexchart>
  81. </div>
  82. </div>
  83. </div>
  84. <!-- Below element is just for displaying source code. it is not required. DO NOT USE -->
  85. <div id="html">
  86. &lt;div id=&quot;wrapper&quot;&gt;
  87. &lt;div id=&quot;chart-months&quot;&gt;
  88. &lt;apexchart type=&quot;area&quot; height=&quot;160&quot; :options=&quot;chartOptions&quot; :series=&quot;series&quot;&gt;&lt;/apexchart&gt;
  89. &lt;/div&gt;
  90. &lt;h5 class=&quot;github-style&quot;&gt;
  91. &lt;img class=&quot;userimg&quot; src=&quot;https://picsum.photos/200/200/?image=1031&quot; data-hovercard-user-id=&quot;634573&quot; alt=&quot;&quot; width=&quot;38&quot; height=&quot;38&quot; /&gt;
  92. &lt;div class=&quot;userdetails&quot;&gt;
  93. &lt;a class=&quot;username&quot;&gt;coder&lt;/a&gt;
  94. &lt;span class=&quot;cmeta&quot;&gt;
  95. &lt;span class=&quot;commits&quot;&gt;&lt;/span&gt; commits
  96. &lt;/span&gt;
  97. &lt;/div&gt;
  98. &lt;/h5&gt;
  99. &lt;div id=&quot;chart-years&quot;&gt;
  100. &lt;apexchart type=&quot;area&quot; height=&quot;200&quot; :options=&quot;chartOptionsYears&quot; :series=&quot;seriesYears&quot;&gt;&lt;/apexchart&gt;
  101. &lt;/div&gt;
  102. &lt;/div&gt;
  103. </div>
  104. <script>
  105. new Vue({
  106. el: '#app',
  107. components: {
  108. apexchart: VueApexCharts,
  109. },
  110. data: {
  111. series: [{
  112. name: 'commits',
  113. data: githubdata.series
  114. }],
  115. chartOptions: {
  116. chart: {
  117. id: 'chartyear',
  118. type: 'area',
  119. height: 160,
  120. background: '#F6F8FA',
  121. toolbar: {
  122. show: false,
  123. autoSelected: 'pan'
  124. },
  125. events: {
  126. mounted: function (chart) {
  127. var commitsEl = document.querySelector('.cmeta span.commits');
  128. var commits = chart.getSeriesTotalXRange(chart.w.globals.minX, chart.w.globals.maxX)
  129. commitsEl.innerHTML = commits
  130. },
  131. updated: function (chart) {
  132. var commitsEl = document.querySelector('.cmeta span.commits');
  133. var commits = chart.getSeriesTotalXRange(chart.w.globals.minX, chart.w.globals.maxX)
  134. commitsEl.innerHTML = commits
  135. }
  136. }
  137. },
  138. colors: ['#FF7F00'],
  139. stroke: {
  140. width: 0,
  141. curve: 'smooth'
  142. },
  143. dataLabels: {
  144. enabled: false
  145. },
  146. fill: {
  147. opacity: 1,
  148. type: 'solid'
  149. },
  150. yaxis: {
  151. show: false,
  152. tickAmount: 3,
  153. },
  154. xaxis: {
  155. type: 'datetime',
  156. }
  157. },
  158. seriesYears: [{
  159. name: 'commits',
  160. data: githubdata.series
  161. }],
  162. chartOptionsYears: {
  163. chart: {
  164. height: 200,
  165. type: 'area',
  166. background: '#F6F8FA',
  167. toolbar: {
  168. autoSelected: 'selection',
  169. },
  170. brush: {
  171. enabled: true,
  172. target: 'chartyear'
  173. },
  174. selection: {
  175. enabled: true,
  176. xaxis: {
  177. min: new Date('26 Jan 2014').getTime(),
  178. max: new Date('29 Mar 2015').getTime()
  179. }
  180. },
  181. },
  182. colors: ['#7BD39A'],
  183. dataLabels: {
  184. enabled: false
  185. },
  186. stroke: {
  187. width: 0,
  188. curve: 'smooth'
  189. },
  190. fill: {
  191. opacity: 1,
  192. type: 'solid'
  193. },
  194. legend: {
  195. position: 'top',
  196. horizontalAlign: 'left'
  197. },
  198. xaxis: {
  199. type: 'datetime'
  200. },
  201. },
  202. },
  203. })
  204. </script>
  205. </body>
  206. </html>