visualMap-layout.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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. <style>
  8. #main {
  9. position: relative;
  10. min-width: 1080px;
  11. }
  12. .block {
  13. text-align: center;
  14. display: inline-block;
  15. *display: inline;
  16. *zoom: 1;
  17. position: relative;
  18. height: 400px;
  19. margin: 20px;
  20. }
  21. .block .ec {
  22. float: left;
  23. width: 600px;
  24. height: 100%;
  25. border: 3px solid #777;
  26. }
  27. .block label {
  28. margin-left: 500px;
  29. display: block;
  30. width: 400px;
  31. height: 100%;
  32. background: #777;
  33. color: #fff;
  34. font-size: 12px;
  35. line-height: 18px;
  36. border: 3px solid #777;
  37. text-align: left;
  38. overflow: auto;
  39. }
  40. </style>
  41. </head>
  42. <body>
  43. <div id="main"></div>
  44. <script>
  45. require([
  46. 'echarts',
  47. 'zrender/core/util',
  48. 'echarts/chart/scatter',
  49. 'echarts/component/grid',
  50. 'echarts/component/visualMap'
  51. ], function (echarts, zrUtil) {
  52. makeChart({
  53. show: true,
  54. splitNumber: 7,
  55. backgroundColor: '#eee',
  56. padding: [10, 30, 5, 40],
  57. visualSelected: {
  58. data: ['red', 'pink']
  59. }
  60. });
  61. makeChart({
  62. show: true,
  63. pieces: [
  64. {min: 10, max: 15, color: 'green'},
  65. {min: 15, max: 25, visualValue: 'blue'},
  66. {min: 25, max: 35},
  67. {min: 35, max: 55},
  68. {min: 55}
  69. ],
  70. left: 200,
  71. backgroundColor: '#eee',
  72. visualSelected: {
  73. data: ['red', 'pink']
  74. }
  75. });
  76. makeChart({
  77. splitNumber: 5,
  78. right: 0,
  79. dimension: 3,
  80. backgroundColor: '#eee',
  81. visualSelected: {
  82. type: 'symbol',
  83. data: ['roundRect', 'rect', 'diamond', 'line', 'circle']
  84. }
  85. });
  86. makeChart({
  87. splitNumber: 6,
  88. top: 0,
  89. left: 0,
  90. orient: 'horizontal',
  91. dimension: 3,
  92. backgroundColor: '#eee',
  93. visualSelected: {
  94. type: 'colorSaturation'
  95. }
  96. });
  97. makeChart({
  98. splitNumber: 5,
  99. top: 20,
  100. right: 0,
  101. orient: 'horizontal',
  102. dimension: 3,
  103. backgroundColor: '#eee',
  104. visualSelected: {
  105. type: 'colorLightness'
  106. }
  107. });
  108. makeChart({
  109. splitNumber: 6,
  110. top: 40,
  111. orient: 'horizontal',
  112. align: 'right',
  113. dimension: 3,
  114. backgroundColor: '#eee',
  115. visualSelected: {
  116. type: 'colorAlpha'
  117. }
  118. });
  119. // -------------------------------------------
  120. makeChart({
  121. show: true,
  122. splitNumber: 7,
  123. text: ['高1', '低'],
  124. inverse: true,
  125. backgroundColor: '#eee',
  126. padding: [10, 30, 5, 40],
  127. visualSelected: {
  128. data: ['red', 'pink']
  129. }
  130. });
  131. makeChart({
  132. show: true,
  133. pieces: [
  134. {min: 10, max: 15, color: 'green'},
  135. {min: 15, max: 25, visualValue: 'blue'},
  136. {min: 25, max: 35},
  137. {min: 35, max: 55},
  138. {min: 55}
  139. ],
  140. left: 200,
  141. text: ['高', '低'],
  142. backgroundColor: '#eee',
  143. visualSelected: {
  144. data: ['red', 'pink']
  145. }
  146. });
  147. makeChart({
  148. splitNumber: 5,
  149. right: 0,
  150. dimension: 3,
  151. text: ['高', '低'],
  152. backgroundColor: '#eee',
  153. visualSelected: {
  154. type: 'symbol',
  155. data: ['roundRect', 'rect', 'diamond', 'line', 'circle']
  156. }
  157. });
  158. makeChart({
  159. splitNumber: 6,
  160. top: 0,
  161. left: 0,
  162. orient: 'horizontal',
  163. dimension: 3,
  164. text: ['高', '低'],
  165. backgroundColor: '#eee',
  166. visualSelected: {
  167. type: 'colorSaturation'
  168. }
  169. });
  170. makeChart({
  171. splitNumber: 5,
  172. top: 20,
  173. right: 0,
  174. orient: 'horizontal',
  175. dimension: 3,
  176. text: ['高', '低'],
  177. backgroundColor: '#eee',
  178. visualSelected: {
  179. type: 'colorLightness'
  180. }
  181. });
  182. makeChart({
  183. splitNumber: 6,
  184. top: 40,
  185. orient: 'horizontal',
  186. dimension: 3,
  187. text: ['高', '低'],
  188. backgroundColor: '#eee',
  189. visualSelected: {
  190. type: 'colorAlpha'
  191. }
  192. });
  193. // -------------------------------------------
  194. makeChart({
  195. show: true,
  196. splitNumber: 0,
  197. backgroundColor: '#eee',
  198. padding: [10, 30, 5, 40],
  199. calculable: true,
  200. inRange: {
  201. color: ['red', 'pink']
  202. }
  203. });
  204. makeChart({
  205. left: 200,
  206. show: true,
  207. pieces: [
  208. {min: 10, max: 15, color: 'green'},
  209. {min: 15, max: 25, visualValue: 'blue'},
  210. {min: 25, max: 35},
  211. {min: 35, max: 55},
  212. {min: 55}
  213. ],
  214. inverse: true,
  215. calculable: true,
  216. backgroundColor: '#eee',
  217. inRange: {
  218. color: ['red', 'pink']
  219. }
  220. });
  221. makeChart({
  222. right: 0,
  223. splitNumber: 5,
  224. calculable: true,
  225. dimension: 3,
  226. backgroundColor: '#eee',
  227. inRange: {
  228. color: ['red', 'pink']
  229. }
  230. });
  231. makeChart({
  232. left: 0,
  233. top: 0,
  234. orient: 'horizontal',
  235. splitNumber: 6,
  236. calculable: true,
  237. inverse: true,
  238. dimension: 3,
  239. backgroundColor: '#eee',
  240. inRange: 'colorSaturation'
  241. });
  242. makeChart({
  243. right: 0,
  244. top: 20,
  245. orient: 'horizontal',
  246. splitNumber: 5,
  247. calculable: true,
  248. dimension: 3,
  249. backgroundColor: '#eee',
  250. inRange: 'colorLightness'
  251. });
  252. makeChart({
  253. top: 40,
  254. splitNumber: 6,
  255. orient: 'horizontal',
  256. calculable: true,
  257. dimension: 3,
  258. backgroundColor: '#eee',
  259. inRange: 'colorAlpha'
  260. });
  261. makeChart({
  262. left: 'center',
  263. top: 'bottom',
  264. orient: 'horizontal',
  265. splitNumber: 6,
  266. calculable: true,
  267. dimension: 3,
  268. backgroundColor: '#eee',
  269. inRange: 'colorAlpha'
  270. });
  271. // -------------------------------------------
  272. makeChart({
  273. show: true,
  274. splitNumber: 7,
  275. text: ['高2', '低'],
  276. backgroundColor: '#eee',
  277. inverse: true,
  278. padding: [10, 30, 5, 40],
  279. calculable: true,
  280. inRange: {
  281. color: ['red', 'pink']
  282. }
  283. });
  284. makeChart({
  285. left: 200,
  286. show: true,
  287. pieces: [
  288. {min: 10, max: 15, color: 'green'},
  289. {min: 15, max: 25, visualValue: 'blue'},
  290. {min: 25, max: 35},
  291. {min: 35, max: 55},
  292. {min: 55}
  293. ],
  294. inverse: true,
  295. text: ['高', '低'],
  296. calculable: true,
  297. backgroundColor: '#eee',
  298. inRange: {
  299. color: ['red', 'pink']
  300. }
  301. });
  302. makeChart({
  303. right: 0,
  304. splitNumber: 5,
  305. text: ['高', '低'],
  306. calculable: true,
  307. dimension: 3,
  308. backgroundColor: '#eee',
  309. inRange: {
  310. color: ['red', 'pink']
  311. }
  312. });
  313. makeChart({
  314. left: 0,
  315. top: 0,
  316. orient: 'horizontal',
  317. text: ['高', '低'],
  318. splitNumber: 6,
  319. calculable: true,
  320. inverse: true,
  321. dimension: 3,
  322. backgroundColor: '#eee',
  323. inRange: 'colorSaturation'
  324. });
  325. makeChart({
  326. right: 0,
  327. top: 20,
  328. orient: 'horizontal',
  329. text: ['高', '低'],
  330. splitNumber: 5,
  331. align: 'bottom',
  332. calculable: true,
  333. dimension: 3,
  334. backgroundColor: '#eee',
  335. inRange: 'colorLightness'
  336. });
  337. makeChart({
  338. top: 40,
  339. splitNumber: 6,
  340. orient: 'horizontal',
  341. text: ['高', '低'],
  342. calculable: true,
  343. dimension: 3,
  344. backgroundColor: '#eee',
  345. inRange: 'colorAlpha'
  346. });
  347. makeChart({
  348. left: 'center',
  349. bottom: 0,
  350. orient: 'horizontal',
  351. splitNumber: 6,
  352. text: ['高', '低'],
  353. calculable: true,
  354. dimension: 3,
  355. backgroundColor: '#eee',
  356. inRange: 'colorAlpha'
  357. });
  358. function makeChart(opt) {
  359. var label = JSON.stringify(opt, null, 4);
  360. opt = {visualMap: opt || {}};
  361. var containerEl = document.getElementById('main');
  362. var el = document.createElement('div');
  363. el.className = 'block';
  364. el.innerHTML = '<div class="ec"></div><label><pre>' + encodeHTML(label) + '</pre></label>';
  365. containerEl.appendChild(el);
  366. var chart = echarts.init(el.firstChild, null, {renderer: 'canvas'});
  367. chart.setOption(zrUtil.merge(opt, getOption()));
  368. }
  369. function encodeHTML(source) {
  370. return source == null
  371. ? ''
  372. : String(source)
  373. .replace(/&/g, '&amp;')
  374. .replace(/</g, '&lt;')
  375. .replace(/>/g, '&gt;')
  376. .replace(/"/g, '&quot;')
  377. .replace(/'/g, '&#39;');
  378. };
  379. function getOption() {
  380. return {
  381. grid: {top: 'center', left: 'center', width: 50, height: 50},
  382. xAxis: {type: 'value', splitLine: {show: false}},
  383. yAxis: {type: 'value', splitLine: {show: false}},
  384. series: [
  385. {
  386. name: 'scatter',
  387. type: 'scatter',
  388. itemStyle: {
  389. normal: {
  390. opacity: 0.8,
  391. shadowBlur: 10,
  392. shadowOffsetX: 0,
  393. shadowOffsetY: 0,
  394. shadowColor: 'rgba(0, 0, 0, 0.5)'
  395. }
  396. },
  397. symbolSize: 20,
  398. data: [[50, 50, 50, 50, 50]]
  399. }
  400. ]
  401. };
  402. }
  403. });
  404. </script>
  405. </body>
  406. </html>