index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <link href="https://fonts.googleapis.com/css?family=Lobster+Two:700i" rel="stylesheet">
  5. <script src='https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js'></script>
  6. <script src='../dist/echarts-liquidfill.js'></script>
  7. </head>
  8. <body>
  9. <style>
  10. html, body {
  11. width: 100%;
  12. height: 100%;
  13. margin: 0;
  14. background: #F1F7FF;
  15. }
  16. #main {
  17. padding: 20px;
  18. }
  19. #main:after {
  20. display: block;
  21. content: ' ';
  22. clear: both;
  23. }
  24. h1 {
  25. margin: 20px;
  26. font-size: 20px;
  27. font-weight: bold;
  28. text-align: center;
  29. color: #D94854;
  30. }
  31. .chart {
  32. width: 25%;
  33. height: 300px;
  34. float: left;
  35. }
  36. @media (max-width: 980px) {
  37. .chart {
  38. height: 200px;
  39. }
  40. }
  41. @media (max-width: 750px) {
  42. .chart {
  43. width: 33.333333%;
  44. }
  45. }
  46. @media (max-width: 500px) {
  47. .chart {
  48. width: 50%;
  49. height: 180px;
  50. }
  51. }
  52. .main-chart {
  53. width: 100%;
  54. height: 400px;
  55. float: none;
  56. margin: -50px 0;
  57. }
  58. .nav {
  59. text-align: center;
  60. margin: 10px;
  61. }
  62. a {
  63. text-decoration: none;
  64. background-color: #294D99;
  65. transition: 0.5s;
  66. color: white;
  67. padding: 6px 18px;
  68. border-radius: 20px;
  69. margin: 0 4px;
  70. }
  71. a:hover {
  72. background-color: #1598ED;
  73. }
  74. #view-more {
  75. text-align: center;
  76. margin: 20px 0 80px 0;
  77. }
  78. </style>
  79. <div id='main'>
  80. <div class="chart main-chart"></div>
  81. <h1>Liquid Fill Chart (ECharts Extension)</h1>
  82. <div class="nav">
  83. <a href="https://github.com/ecomfe/echarts-liquidfill">GitHub (Doc & API)</a>
  84. <a href="http://gallery.echartsjs.com/explore.html?u=bd-4013131402&type=work#tags=liquidFill">More Examples</a>
  85. <a href="http://echarts.baidu.com">ECharts</a>
  86. </div>
  87. <div class="chart"></div>
  88. <div class="chart"></div>
  89. <div class="chart"></div>
  90. <div class="chart"></div>
  91. <div class="chart"></div>
  92. <div class="chart"></div>
  93. <div class="chart"></div>
  94. <div class="chart"></div>
  95. <div class="chart"></div>
  96. <div class="chart"></div>
  97. <div class="chart"></div>
  98. <div class="chart"></div>
  99. </div>
  100. <script>
  101. var _hmt = _hmt || [];
  102. (function() {
  103. var hm = document.createElement('script');
  104. hm.src = '//hm.baidu.com/hm.js?4bad1df23f079e0d12bdbef5e65b072f';
  105. var s = document.getElementsByTagName('script')[0];
  106. s.parentNode.insertBefore(hm, s);
  107. })();
  108. var bgColor = '#E3F7FF';
  109. var containers = document.getElementsByClassName('chart');
  110. var options = [{
  111. series: [{
  112. type: 'liquidFill',
  113. data: [0.6, 0.55, 0.4, 0.25],
  114. radius: '70%',
  115. outline: {
  116. show: false
  117. },
  118. backgroundStyle: {
  119. borderColor: '#156ACF',
  120. borderWidth: 1,
  121. color: bgColor,
  122. shadowColor: 'rgba(0, 0, 0, 0.4)',
  123. shadowBlur: 20
  124. },
  125. shape: 'path://M367.855,428.202c-3.674-1.385-7.452-1.966-11.146-1.794c0.659-2.922,0.844-5.85,0.58-8.719 c-0.937-10.407-7.663-19.864-18.063-23.834c-10.697-4.043-22.298-1.168-29.902,6.403c3.015,0.026,6.074,0.594,9.035,1.728 c13.626,5.151,20.465,20.379,15.32,34.004c-1.905,5.02-5.177,9.115-9.22,12.05c-6.951,4.992-16.19,6.536-24.777,3.271 c-13.625-5.137-20.471-20.371-15.32-34.004c0.673-1.768,1.523-3.423,2.526-4.992h-0.014c0,0,0,0,0,0.014 c4.386-6.853,8.145-14.279,11.146-22.187c23.294-61.505-7.689-130.278-69.215-153.579c-61.532-23.293-130.279,7.69-153.579,69.202 c-6.371,16.785-8.679,34.097-7.426,50.901c0.026,0.554,0.079,1.121,0.132,1.688c4.973,57.107,41.767,109.148,98.945,130.793 c58.162,22.008,121.303,6.529,162.839-34.465c7.103-6.893,17.826-9.444,27.679-5.719c11.858,4.491,18.565,16.6,16.719,28.643 c4.438-3.126,8.033-7.564,10.117-13.045C389.751,449.992,382.411,433.709,367.855,428.202z',
  126. label: {
  127. position: ['38%', '40%'],
  128. formatter: function () {
  129. return 'ECharts\nLiquid Fill';
  130. },
  131. fontSize: 40,
  132. fontFamily: 'Lobster Two',
  133. color: '#D94854',
  134. insideColor: bgColor
  135. }
  136. }]
  137. }, {
  138. series: [{
  139. type: 'liquidFill',
  140. data: [0.6, 0.5, 0.4, 0.3],
  141. radius: '70%',
  142. outline: {
  143. show: false
  144. }
  145. }]
  146. }, {
  147. series: [{
  148. type: 'liquidFill',
  149. data: [0.6, 0.5, 0.4, 0.3],
  150. radius: '70%',
  151. phase: 0,
  152. period: 5000,
  153. outline: {
  154. show: false
  155. }
  156. }]
  157. }, {
  158. series: [{
  159. type: 'liquidFill',
  160. data: [0.6, {
  161. value: 0.5,
  162. direction: 'left'
  163. }, 0.4, {
  164. value: 0.3,
  165. direction: 'left'
  166. }],
  167. radius: '70%',
  168. outline: {
  169. show: false
  170. }
  171. }]
  172. }, {
  173. series: [{
  174. type: 'liquidFill',
  175. data: [0.6, 0.5, {
  176. value: 0.4,
  177. amplitude: 15
  178. }, {
  179. value: 0.3,
  180. amplitude: 20,
  181. waveLength: 100
  182. }],
  183. radius: '70%',
  184. amplitude: 10,
  185. outline: {
  186. show: false
  187. }
  188. }]
  189. }, {
  190. series: [{
  191. type: 'liquidFill',
  192. data: [0.6],
  193. radius: '70%'
  194. }]
  195. }, {
  196. series: [{
  197. type: 'liquidFill',
  198. data: [0.6],
  199. radius: '70%',
  200. amplitude: 0,
  201. waveAnimation: false,
  202. silent: true
  203. }]
  204. }, {
  205. series: [{
  206. type: 'liquidFill',
  207. data: [1, 0.9, 0.8, 0.7],
  208. radius: '70%',
  209. label: {
  210. formatter: 'I\'m full.',
  211. textStyle: {
  212. fontSize: 35,
  213. fontFamily: 'Lobster Two'
  214. }
  215. }
  216. }]
  217. }, {
  218. series: [{
  219. type: 'liquidFill',
  220. data: [0, 0, 0, 0],
  221. radius: '70%',
  222. label: {
  223. formatter: 'I\'m empty.',
  224. fontSize: 25,
  225. fontFamily: 'Lobster Two',
  226. baseline: 'bottom',
  227. position: ['50%', '86%']
  228. }
  229. }]
  230. }, {
  231. series: [{
  232. type: 'liquidFill',
  233. data: [0.6, 0.5, 0.4, 0.3],
  234. waveAnimation: false,
  235. radius: '70%',
  236. backgroundStyle: {
  237. borderWidth: 2,
  238. borderColor: '#156ACF'
  239. },
  240. outline: {
  241. show: false
  242. },
  243. shape: 'diamond'
  244. }]
  245. }, {
  246. series: [{
  247. type: 'liquidFill',
  248. data: [0.6, 0.5, 0.4, 0.3],
  249. radius: '70%',
  250. amplitude: 0,
  251. waveAnimation: false,
  252. backgroundStyle: {
  253. borderWidth: 2,
  254. borderColor: '#156ACF'
  255. },
  256. outline: {
  257. show: false
  258. },
  259. shape: 'triangle',
  260. label: {
  261. position: ['50%', '65%']
  262. }
  263. }]
  264. }, {
  265. series: [{
  266. type: 'liquidFill',
  267. data: [0.6, 0.5, 0.4, 0.3],
  268. radius: '90%',
  269. itemStyle: {
  270. shadowBlur: 0
  271. },
  272. backgroundStyle: {
  273. borderWidth: 2,
  274. borderColor: '#156ACF'
  275. },
  276. outline: {
  277. show: false
  278. },
  279. label: {
  280. shadowBlur: 0,
  281. position: ['50%', '45%']
  282. },
  283. shape: 'pin',
  284. center: ['50%', '40%']
  285. }]
  286. }, {
  287. series: [{
  288. type: 'liquidFill',
  289. data: [0.6, 0.5, 0.4, 0.3],
  290. radius: '70%',
  291. backgroundStyle: {
  292. borderWidth: 2,
  293. borderColor: '#156ACF'
  294. },
  295. outline: {
  296. show: false
  297. },
  298. shape: 'rect'
  299. }]
  300. }];
  301. var charts = [];
  302. for (var i = 0; i < options.length; ++i) {
  303. var chart = echarts.init(containers[i]);
  304. if (i > 0) {
  305. options[i].series[0].silent = true;
  306. }
  307. chart.setOption(options[i]);
  308. chart.setOption({
  309. baseOption: options[i],
  310. media: [{
  311. query: {
  312. maxWidth: 300
  313. },
  314. option: {
  315. series: [{
  316. label: {
  317. fontSize: 26
  318. }
  319. }]
  320. }
  321. }]
  322. });
  323. charts.push(chart);
  324. }
  325. window.onresize = function () {
  326. for (var i = 0; i < charts.length; ++i) {
  327. charts[i].resize();
  328. }
  329. };
  330. setInterval(update, 3000);
  331. function update() {
  332. var data = [];
  333. var last = 1;
  334. for (var i = 0; i < 4; ++i) {
  335. last = Math.floor(last * (Math.random() * 0.5 + 0.5)
  336. * 100) / 100;
  337. data.push(last);
  338. }
  339. charts[1].setOption({
  340. series: [{
  341. data: data
  342. }]
  343. });
  344. }
  345. </script>
  346. </body>
  347. </html>