visualMap-continuous.html 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="esl.js"></script>
  5. <script src="config.js"></script>
  6. <link rel="stylesheet" href="reset.css" />
  7. </head>
  8. <body>
  9. <style>
  10. .split {
  11. line-height: 60px;
  12. height: 60px;
  13. background: #ddd;
  14. text-align: center;
  15. font-weight: bold;
  16. font-size: 20px;
  17. }
  18. .main {
  19. height: 80%;
  20. }
  21. </style>
  22. <div class="split">Color Hue</div>
  23. <div id="main1" class="main"></div>
  24. <div class="split">Color List</div>
  25. <div id="main2" class="main"></div>
  26. <div class="split">Map</div>
  27. <div id="main3" class="main"></div>
  28. <div class="split">Stacked Bar (and inversed)</div>
  29. <div id="main4" class="main"></div>
  30. <script type="text/javascript">
  31. require([
  32. 'echarts',
  33. 'echarts/chart/bar',
  34. 'echarts/component/grid',
  35. 'echarts/component/visualMapContinuous'
  36. ], function (echarts) {
  37. var main = document.getElementById('main1');
  38. if (!main) {
  39. return;
  40. }
  41. var chart = echarts.init(main);
  42. var data0 = [];
  43. var MAX_DIM1 = 100;
  44. var itemStyle = {
  45. normal: {
  46. opacity: 0.8,
  47. shadowBlur: 10,
  48. shadowOffsetX: 0,
  49. shadowOffsetY: 0,
  50. shadowColor: 'rgba(0, 0, 0, 0.3)'
  51. }
  52. };
  53. var last = 60;
  54. var lastDelta = 20;
  55. for (var i = 0; i < MAX_DIM1; i++) {
  56. lastDelta += (Math.random() - 0.5) * 15;
  57. data0.push([
  58. i,
  59. last += lastDelta
  60. ]);
  61. }
  62. chart.setOption({
  63. grid: {
  64. top: 100,
  65. bottom: 100
  66. },
  67. xAxis: {
  68. type: 'value',
  69. splitLine: {
  70. show: false
  71. }
  72. },
  73. yAxis: {
  74. type: 'value',
  75. splitLine: {
  76. show: false
  77. }
  78. },
  79. visualMap: [
  80. {
  81. show: true,
  82. left: 'center',
  83. bottom: 20,
  84. orient: 'horizontal',
  85. itemWidth: 20,
  86. itemHeight: 200,
  87. min: 0,
  88. max: MAX_DIM1,
  89. calculable: true,
  90. range: [5, 95],
  91. dimension: 0,
  92. inRange: {
  93. colorHue: [0, 300],
  94. colorLightness: 0.35,
  95. colorSaturation: 1
  96. },
  97. outOfRange: {
  98. color: '#eee'
  99. }
  100. }
  101. ],
  102. series: [
  103. {
  104. name: 'bar',
  105. type: 'bar',
  106. barMaxWidth: 10,
  107. itemStyle: itemStyle,
  108. data: data0
  109. }
  110. ]
  111. });
  112. })
  113. </script>
  114. <script type="text/javascript">
  115. require([
  116. 'echarts',
  117. 'echarts/chart/scatter',
  118. 'echarts/component/legend',
  119. 'echarts/component/grid',
  120. 'echarts/component/visualMapContinuous'
  121. ], function (echarts) {
  122. var main = document.getElementById('main2');
  123. if (!main) {
  124. return;
  125. }
  126. var chart = echarts.init(main);
  127. var data0 = [];
  128. var data1 = [];
  129. var MAX_DIM2 = 300;
  130. var MAX_DIM3 = 20000;
  131. var itemStyle = {
  132. normal: {
  133. opacity: 0.8,
  134. shadowBlur: 10,
  135. shadowOffsetX: 0,
  136. shadowOffsetY: 0,
  137. shadowColor: 'rgba(0, 0, 0, 0.5)'
  138. }
  139. };
  140. for (var i = 0; i < 60; i++) {
  141. data0.push(genDataItem());
  142. data1.push(genDataItem());
  143. }
  144. function genDataItem() {
  145. return [
  146. Math.random() * 5,
  147. Math.random() * 4,
  148. Math.random() * MAX_DIM2,
  149. Math.random() * MAX_DIM3
  150. ];
  151. }
  152. chart.setOption({
  153. color: ['#555', '#555'],
  154. legend: {
  155. top: 20,
  156. data: ['scatter0', 'scatter1']
  157. },
  158. grid: {
  159. top: 100,
  160. bottom: 60,
  161. left: 150
  162. },
  163. xAxis: {
  164. type: 'value',
  165. splitLine: {
  166. show: false
  167. }
  168. },
  169. yAxis: {
  170. type: 'value',
  171. splitLine: {
  172. show: false
  173. }
  174. },
  175. visualMap: [
  176. {
  177. show: true,
  178. top: 'center',
  179. left: 30,
  180. itemHeight: 400,
  181. min: 0,
  182. max: MAX_DIM2,
  183. calculable: true,
  184. dimension: 2,
  185. range: [15, 278],
  186. inRange: {
  187. color: ['blue', 'orange', 'yellow']
  188. },
  189. outOfRange: {
  190. color: '#ddd'
  191. }
  192. },
  193. {
  194. show: false,
  195. min: 0,
  196. max: MAX_DIM3,
  197. dimension: 3,
  198. inRange: {
  199. symbolSize: [3, 40]
  200. },
  201. outOfRange: {
  202. symbolSize: [3, 40]
  203. }
  204. }
  205. ],
  206. series: [
  207. {
  208. name: 'scatter0',
  209. type: 'scatter',
  210. symbol: 'circle',
  211. itemStyle: itemStyle,
  212. data: data0
  213. },
  214. {
  215. name: 'scatter1',
  216. type: 'scatter',
  217. symbol: 'diamond',
  218. itemStyle: itemStyle,
  219. data: data1
  220. }
  221. ]
  222. });
  223. })
  224. </script>
  225. <script type="text/javascript">
  226. require([
  227. 'echarts',
  228. 'echarts/chart/map',
  229. 'echarts/component/legend',
  230. 'echarts/component/visualMapContinuous',
  231. ], function (echarts) {
  232. require(['map/js/world'], function () {
  233. renderWorldMap(echarts);
  234. });
  235. });
  236. function renderWorldMap(echarts) {
  237. var main = document.getElementById('main3');
  238. if (!main) {
  239. return;
  240. }
  241. var chart = echarts.init(main);
  242. option = {
  243. title: {
  244. text: 'World Population (2010)',
  245. subtext: 'from United Nations, Total population, both sexes combined, as of 1 July (thousands)',
  246. sublink: 'http://esa.un.org/wpp/Excel-Data/population.htm',
  247. left: 'center',
  248. top: 'top'
  249. },
  250. tooltip: {
  251. trigger: 'item',
  252. formatter: function (params) {
  253. var value = (params.value + '').split('.');
  254. value = value[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g, '$1,')
  255. + '.' + value[1];
  256. return params.seriesName + '<br/>' + params.name + ' : ' + value;
  257. }
  258. },
  259. toolbox: {
  260. show: true,
  261. orient: 'vertical',
  262. left: 'right',
  263. top: 'center',
  264. feature: {
  265. dataView: {readOnly: false},
  266. restore: {},
  267. saveAsImage: {}
  268. }
  269. },
  270. visualMap: {
  271. min: 0,
  272. max: 1000000,
  273. left: 10,
  274. bottom: 70,
  275. itemHeight: 200,
  276. text: ['High', 'Low'],
  277. realtime: false,
  278. calculable: true,
  279. color: ['orangered', 'yellow', 'lightskyblue']
  280. },
  281. series: [
  282. {
  283. name: 'World Population (2010)',
  284. type: 'map',
  285. mapType: 'world',
  286. roam: true,
  287. itemStyle:{
  288. emphasis:{label:{show:true}}
  289. },
  290. data:[
  291. {name: 'Afghanistan', value: 28397.812},
  292. {name: 'Angola', value: 19549.124},
  293. {name: 'Albania', value: 3150.143},
  294. {name: 'United Arab Emirates', value: 8441.537},
  295. {name: 'Argentina', value: 40374.224},
  296. {name: 'Armenia', value: 2963.496},
  297. {name: 'French Southern and Antarctic Lands', value: 268.065},
  298. {name: 'Australia', value: 22404.488},
  299. {name: 'Austria', value: 8401.924},
  300. {name: 'Azerbaijan', value: 9094.718},
  301. {name: 'Burundi', value: 9232.753},
  302. {name: 'Belgium', value: 10941.288},
  303. {name: 'Benin', value: 9509.798},
  304. {name: 'Burkina Faso', value: 15540.284},
  305. {name: 'Bangladesh', value: 151125.475},
  306. {name: 'Bulgaria', value: 7389.175},
  307. {name: 'The Bahamas', value: 66402.316},
  308. {name: 'Bosnia and Herzegovina', value: 3845.929},
  309. {name: 'Belarus', value: 9491.07},
  310. {name: 'Belize', value: 308.595},
  311. {name: 'Bermuda', value: 64.951},
  312. {name: 'Bolivia', value: 716.939},
  313. {name: 'Brazil', value: 195210.154},
  314. {name: 'Brunei', value: 27.223},
  315. {name: 'Bhutan', value: 716.939},
  316. {name: 'Botswana', value: 1969.341},
  317. {name: 'Central African Republic', value: 4349.921},
  318. {name: 'Canada', value: 34126.24},
  319. {name: 'Switzerland', value: 7830.534},
  320. {name: 'Chile', value: 17150.76},
  321. {name: 'China', value: 1359821.465},
  322. {name: 'Ivory Coast', value: 60508.978},
  323. {name: 'Cameroon', value: 20624.343},
  324. {name: 'Democratic Republic of the Congo', value: 62191.161},
  325. {name: 'Republic of the Congo', value: 3573.024},
  326. {name: 'Colombia', value: 46444.798},
  327. {name: 'Costa Rica', value: 4669.685},
  328. {name: 'Cuba', value: 11281.768},
  329. {name: 'Northern Cyprus', value: 1.468},
  330. {name: 'Cyprus', value: 1103.685},
  331. {name: 'Czech Republic', value: 10553.701},
  332. {name: 'Germany', value: 83017.404},
  333. {name: 'Djibouti', value: 834.036},
  334. {name: 'Denmark', value: 5550.959},
  335. {name: 'Dominican Republic', value: 10016.797},
  336. {name: 'Algeria', value: 37062.82},
  337. {name: 'Ecuador', value: 15001.072},
  338. {name: 'Egypt', value: 78075.705},
  339. {name: 'Eritrea', value: 5741.159},
  340. {name: 'Spain', value: 46182.038},
  341. {name: 'Estonia', value: 1298.533},
  342. {name: 'Ethiopia', value: 87095.281},
  343. {name: 'Finland', value: 5367.693},
  344. {name: 'Fiji', value: 860.559},
  345. {name: 'Falkland Islands', value: 49.581},
  346. {name: 'France', value: 63230.866},
  347. {name: 'Gabon', value: 1556.222},
  348. {name: 'United Kingdom', value: 62066.35},
  349. {name: 'Georgia', value: 4388.674},
  350. {name: 'Ghana', value: 24262.901},
  351. {name: 'Guinea', value: 10876.033},
  352. {name: 'Gambia', value: 1680.64},
  353. {name: 'Guinea Bissau', value: 10876.033},
  354. {name: 'Equatorial Guinea', value: 696.167},
  355. {name: 'Greece', value: 11109.999},
  356. {name: 'Greenland', value: 56.546},
  357. {name: 'Guatemala', value: 14341.576},
  358. {name: 'French Guiana', value: 231.169},
  359. {name: 'Guyana', value: 786.126},
  360. {name: 'Honduras', value: 7621.204},
  361. {name: 'Croatia', value: 4338.027},
  362. {name: 'Haiti', value: 9896.4},
  363. {name: 'Hungary', value: 10014.633},
  364. {name: 'Indonesia', value: 240676.485},
  365. {name: 'India', value: 1205624.648},
  366. {name: 'Ireland', value: 4467.561},
  367. {name: 'Iran', value: 240676.485},
  368. {name: 'Iraq', value: 30962.38},
  369. {name: 'Iceland', value: 318.042},
  370. {name: 'Israel', value: 7420.368},
  371. {name: 'Italy', value: 60508.978},
  372. {name: 'Jamaica', value: 2741.485},
  373. {name: 'Jordan', value: 6454.554},
  374. {name: 'Japan', value: 127352.833},
  375. {name: 'Kazakhstan', value: 15921.127},
  376. {name: 'Kenya', value: 40909.194},
  377. {name: 'Kyrgyzstan', value: 5334.223},
  378. {name: 'Cambodia', value: 14364.931},
  379. {name: 'South Korea', value: 51452.352},
  380. {name: 'Kosovo', value: 97.743},
  381. {name: 'Kuwait', value: 2991.58},
  382. {name: 'Laos', value: 6395.713},
  383. {name: 'Lebanon', value: 4341.092},
  384. {name: 'Liberia', value: 3957.99},
  385. {name: 'Libya', value: 6040.612},
  386. {name: 'Sri Lanka', value: 20758.779},
  387. {name: 'Lesotho', value: 2008.921},
  388. {name: 'Lithuania', value: 3068.457},
  389. {name: 'Luxembourg', value: 507.885},
  390. {name: 'Latvia', value: 2090.519},
  391. {name: 'Morocco', value: 31642.36},
  392. {name: 'Moldova', value: 103.619},
  393. {name: 'Madagascar', value: 21079.532},
  394. {name: 'Mexico', value: 117886.404},
  395. {name: 'Macedonia', value: 507.885},
  396. {name: 'Mali', value: 13985.961},
  397. {name: 'Myanmar', value: 51931.231},
  398. {name: 'Montenegro', value: 620.078},
  399. {name: 'Mongolia', value: 2712.738},
  400. {name: 'Mozambique', value: 23967.265},
  401. {name: 'Mauritania', value: 3609.42},
  402. {name: 'Malawi', value: 15013.694},
  403. {name: 'Malaysia', value: 28275.835},
  404. {name: 'Namibia', value: 2178.967},
  405. {name: 'New Caledonia', value: 246.379},
  406. {name: 'Niger', value: 15893.746},
  407. {name: 'Nigeria', value: 159707.78},
  408. {name: 'Nicaragua', value: 5822.209},
  409. {name: 'Netherlands', value: 16615.243},
  410. {name: 'Norway', value: 4891.251},
  411. {name: 'Nepal', value: 26846.016},
  412. {name: 'New Zealand', value: 4368.136},
  413. {name: 'Oman', value: 2802.768},
  414. {name: 'Pakistan', value: 173149.306},
  415. {name: 'Panama', value: 3678.128},
  416. {name: 'Peru', value: 29262.83},
  417. {name: 'Philippines', value: 93444.322},
  418. {name: 'Papua New Guinea', value: 6858.945},
  419. {name: 'Poland', value: 38198.754},
  420. {name: 'Puerto Rico', value: 3709.671},
  421. {name: 'North Korea', value: 1.468},
  422. {name: 'Portugal', value: 10589.792},
  423. {name: 'Paraguay', value: 6459.721},
  424. {name: 'Qatar', value: 1749.713},
  425. {name: 'Romania', value: 21861.476},
  426. {name: 'Russia', value: 21861.476},
  427. {name: 'Rwanda', value: 10836.732},
  428. {name: 'Western Sahara', value: 514.648},
  429. {name: 'Saudi Arabia', value: 27258.387},
  430. {name: 'Sudan', value: 35652.002},
  431. {name: 'South Sudan', value: 9940.929},
  432. {name: 'Senegal', value: 12950.564},
  433. {name: 'Solomon Islands', value: 526.447},
  434. {name: 'Sierra Leone', value: 5751.976},
  435. {name: 'El Salvador', value: 6218.195},
  436. {name: 'Somaliland', value: 9636.173},
  437. {name: 'Somalia', value: 9636.173},
  438. {name: 'Republic of Serbia', value: 3573.024},
  439. {name: 'Suriname', value: 524.96},
  440. {name: 'Slovakia', value: 5433.437},
  441. {name: 'Slovenia', value: 2054.232},
  442. {name: 'Sweden', value: 9382.297},
  443. {name: 'Swaziland', value: 1193.148},
  444. {name: 'Syria', value: 7830.534},
  445. {name: 'Chad', value: 11720.781},
  446. {name: 'Togo', value: 6306.014},
  447. {name: 'Thailand', value: 66402.316},
  448. {name: 'Tajikistan', value: 7627.326},
  449. {name: 'Turkmenistan', value: 5041.995},
  450. {name: 'East Timor', value: 10016.797},
  451. {name: 'Trinidad and Tobago', value: 1328.095},
  452. {name: 'Tunisia', value: 10631.83},
  453. {name: 'Turkey', value: 72137.546},
  454. {name: 'United Republic of Tanzania', value: 44973.33},
  455. {name: 'Uganda', value: 33987.213},
  456. {name: 'Ukraine', value: 46050.22},
  457. {name: 'Uruguay', value: 3371.982},
  458. {name: 'United States of America', value: 312247.116},
  459. {name: 'Uzbekistan', value: 27769.27},
  460. {name: 'Venezuela', value: 236.299},
  461. {name: 'Vietnam', value: 89047.397},
  462. {name: 'Vanuatu', value: 236.299},
  463. {name: 'West Bank', value: 13.565},
  464. {name: 'Yemen', value: 22763.008},
  465. {name: 'South Africa', value: 51452.352},
  466. {name: 'Zambia', value: 13216.985},
  467. {name: 'Zimbabwe', value: 13076.978}
  468. ]
  469. }
  470. ]
  471. };
  472. chart.setOption(option);
  473. }
  474. </script>
  475. <script type="text/javascript">
  476. require([
  477. 'echarts',
  478. 'echarts/chart/bar',
  479. 'echarts/chart/line',
  480. 'echarts/component/legend',
  481. 'echarts/component/grid',
  482. 'echarts/component/tooltip',
  483. 'echarts/component/toolbox',
  484. 'zrender/vml/vml'
  485. ], function (echarts) {
  486. var main = document.getElementById('main4');
  487. if (!main) {
  488. return;
  489. }
  490. var chart = echarts.init(main);
  491. var xAxisData = [];
  492. var data1 = [];
  493. var data2 = [];
  494. var data3 = [];
  495. var data4 = [];
  496. for (var i = 0; i < 10; i++) {
  497. xAxisData.push('Class' + i);
  498. data1.push((Math.random() * 2).toFixed(2));
  499. data2.push(-Math.random().toFixed(2));
  500. data3.push((Math.random() * 5).toFixed(2));
  501. data4.push((Math.random() + 0.3).toFixed(2));
  502. }
  503. var itemStyle = {
  504. normal: {
  505. label: {
  506. show: true,
  507. position: 'outside'
  508. }
  509. },
  510. emphasis: {
  511. label: {
  512. position: 'outside'
  513. },
  514. barBorderWidth: 1,
  515. shadowBlur: 10,
  516. shadowOffsetX: 0,
  517. shadowOffsetY: 0,
  518. shadowColor: 'rgba(0,0,0,0.5)'
  519. }
  520. };
  521. chart.setOption({
  522. backgroundColor: '#eee',
  523. legend: {
  524. data: ['bar', 'bar2', 'bar3', 'bar4'],
  525. align: 'left'
  526. },
  527. toolbox: {
  528. feature: {
  529. magicType: {
  530. type: ['line', 'bar', 'stack', 'tiled']
  531. },
  532. dataView: {}
  533. }
  534. },
  535. tooltip: {},
  536. xAxis: {
  537. data: xAxisData,
  538. name: 'X Axis',
  539. silent: false,
  540. axisLine: {onZero: true},
  541. splitLine: {show: false},
  542. splitArea: {show: false}
  543. },
  544. yAxis: {
  545. inverse: true,
  546. splitArea: {show: false}
  547. },
  548. grid: {
  549. left: 100
  550. },
  551. visualMap: {
  552. type: 'continuous',
  553. dimension: 1,
  554. text: ['High', 'Low'],
  555. inverse: true,
  556. itemHeight: 200,
  557. calculable: true,
  558. min: -2,
  559. max: 6,
  560. top: 60,
  561. left: 10
  562. },
  563. series: [
  564. {
  565. name: 'bar',
  566. type: 'bar',
  567. stack: 'one',
  568. itemStyle: itemStyle,
  569. data: data1
  570. },
  571. {
  572. name: 'bar2',
  573. type: 'bar',
  574. stack: 'one',
  575. itemStyle: itemStyle,
  576. data: data2
  577. },
  578. {
  579. name: 'bar3',
  580. type: 'bar',
  581. stack: 'two',
  582. itemStyle: itemStyle,
  583. data: data3
  584. },
  585. {
  586. name: 'bar4',
  587. type: 'bar',
  588. stack: 'two',
  589. itemStyle: itemStyle,
  590. data: data4
  591. }
  592. ]
  593. });
  594. });
  595. </script>
  596. </body>
  597. </html>