area-github-style.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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/react@16.12/umd/react.production.min.js"></script>
  60. <script src="https://cdn.jsdelivr.net/npm/react-dom@16.12/umd/react-dom.production.min.js"></script>
  61. <script src="https://cdn.jsdelivr.net/npm/prop-types@15.7.2/prop-types.min.js"></script>
  62. <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
  63. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  64. <script src="https://cdn.jsdelivr.net/npm/react-apexcharts@1.3.6/dist/react-apexcharts.iife.min.js"></script>
  65. <script src="../../assets/github-data.js"></script>
  66. </head>
  67. <body>
  68. <div id="app"></div>
  69. <div id="html">
  70. &lt;div id=&quot;wrapper&quot;&gt;
  71. &lt;div id=&quot;chart-months&quot;&gt;
  72. &lt;ReactApexChart options={this.state.options} series={this.state.series} type=&quot;area&quot; height={160} /&gt;
  73. &lt;/div&gt;
  74. &lt;h5 class=&quot;github-style&quot;&gt;
  75. &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;
  76. &lt;div class=&quot;userdetails&quot;&gt;
  77. &lt;a class=&quot;username&quot;&gt;coder&lt;/a&gt;
  78. &lt;span class=&quot;cmeta&quot;&gt;
  79. &lt;span class=&quot;commits&quot;&gt;&lt;/span&gt; commits
  80. &lt;/span&gt;
  81. &lt;/div&gt;
  82. &lt;/h5&gt;
  83. &lt;div id=&quot;chart-years&quot;&gt;
  84. &lt;ReactApexChart options={this.state.optionsYears} series={this.state.seriesYears} type=&quot;area&quot; height={200} /&gt;
  85. &lt;/div&gt;
  86. &lt;/div&gt;
  87. </div>
  88. <script type="text/babel">
  89. class ApexChart extends React.Component {
  90. constructor(props) {
  91. super(props);
  92. this.state = {
  93. series: [{
  94. name: 'commits',
  95. data: githubdata.series
  96. }],
  97. options: {
  98. chart: {
  99. id: 'chartyear',
  100. type: 'area',
  101. height: 160,
  102. background: '#F6F8FA',
  103. toolbar: {
  104. show: false,
  105. autoSelected: 'pan'
  106. },
  107. events: {
  108. mounted: function (chart) {
  109. var commitsEl = document.querySelector('.cmeta span.commits');
  110. var commits = chart.getSeriesTotalXRange(chart.w.globals.minX, chart.w.globals.maxX)
  111. commitsEl.innerHTML = commits
  112. },
  113. updated: function (chart) {
  114. var commitsEl = document.querySelector('.cmeta span.commits');
  115. var commits = chart.getSeriesTotalXRange(chart.w.globals.minX, chart.w.globals.maxX)
  116. commitsEl.innerHTML = commits
  117. }
  118. }
  119. },
  120. colors: ['#FF7F00'],
  121. stroke: {
  122. width: 0,
  123. curve: 'smooth'
  124. },
  125. dataLabels: {
  126. enabled: false
  127. },
  128. fill: {
  129. opacity: 1,
  130. type: 'solid'
  131. },
  132. yaxis: {
  133. show: false,
  134. tickAmount: 3,
  135. },
  136. xaxis: {
  137. type: 'datetime',
  138. }
  139. },
  140. seriesYears: [{
  141. name: 'commits',
  142. data: githubdata.series
  143. }],
  144. optionsYears: {
  145. chart: {
  146. height: 200,
  147. type: 'area',
  148. background: '#F6F8FA',
  149. toolbar: {
  150. autoSelected: 'selection',
  151. },
  152. brush: {
  153. enabled: true,
  154. target: 'chartyear'
  155. },
  156. selection: {
  157. enabled: true,
  158. xaxis: {
  159. min: new Date('26 Jan 2014').getTime(),
  160. max: new Date('29 Mar 2015').getTime()
  161. }
  162. },
  163. },
  164. colors: ['#7BD39A'],
  165. dataLabels: {
  166. enabled: false
  167. },
  168. stroke: {
  169. width: 0,
  170. curve: 'smooth'
  171. },
  172. fill: {
  173. opacity: 1,
  174. type: 'solid'
  175. },
  176. legend: {
  177. position: 'top',
  178. horizontalAlign: 'left'
  179. },
  180. xaxis: {
  181. type: 'datetime'
  182. },
  183. },
  184. };
  185. }
  186. render() {
  187. return (
  188. <div>
  189. <div id="wrapper">
  190. <div id="chart-months">
  191. <ReactApexChart options={this.state.options} series={this.state.series} type="area" height={160} />
  192. </div>
  193. <h5 class="github-style">
  194. <img class="userimg" src="https://picsum.photos/200/200/?image=1031" data-hovercard-user-id="634573" alt="" width="38" height="38" />
  195. <div class="userdetails">
  196. <a class="username">coder</a>
  197. <span class="cmeta">
  198. <span class="commits"></span> commits
  199. </span>
  200. </div>
  201. </h5>
  202. <div id="chart-years">
  203. <ReactApexChart options={this.state.optionsYears} series={this.state.seriesYears} type="area" height={200} />
  204. </div>
  205. </div>
  206. <div id="html-dist"></div>
  207. </div>
  208. );
  209. }
  210. }
  211. const domContainer = document.querySelector('#app');
  212. ReactDOM.render(React.createElement(ApexChart), domContainer);
  213. </script>
  214. </body>
  215. </html>