axis-extrema.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. <!DOCTYPE>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <script src="esl.js"></script>
  6. <script src="config.js"></script>
  7. <script src="lib/jquery.min.js"></script>
  8. <script src="lib/facePrint.js"></script>
  9. <meta name="viewport" content="width=device-width, initial-scale=1" />
  10. <link rel="stylesheet" href="reset.css">
  11. </head>
  12. <body>
  13. <style>
  14. body {
  15. }
  16. .chart {
  17. position: relative;
  18. height: 300px;
  19. }
  20. h2 {
  21. text-align: center;
  22. font-size: 16px;
  23. line-height: 30px;
  24. font-weight: normal;
  25. background: #A3AEFF;
  26. }
  27. </style>
  28. <h2>cartesian category axis | xAxis: {min: 'dataMin', max: 'dataMax'}</h2>
  29. <div class="chart" id="main1"></div>
  30. <h2>cartesian category axis | xAxis: {min: undefined, max: undefined}</h2>
  31. <div class="chart" id="main1.1"></div>
  32. <h2>cartesian category axis | xAxis.data is empty</h2>
  33. <div class="chart" id="main1.2"></div>
  34. <h2>cartesian category axis | xAxis: {min: -10, max: '类目3'}</h2>
  35. <div class="chart" id="main2"></div>
  36. <h2>cartesian value axis | xAxis: {min: 'dataMin', max: 'dataMax'}</h2>
  37. <div class="chart" id="main3"></div>
  38. <h2>cartesian value axis | xAxis: {min: -10, max: 10}</h2>
  39. <div class="chart" id="main4"></div>
  40. <h2>cartesian time axis | xAxis: {min: 'dataMin', max: 'dataMax'}</h2>
  41. <div class="chart" id="main5"></div>
  42. <h2>cartesian time axis | xAxis: {min: '2012-08-12', max: '2012-10-01'}</h2>
  43. <div class="chart" id="main6"></div>
  44. <h2>polar category axis | radiuAxis: {min: 'dataMin', max: 'dataMax'}</h2>
  45. <div class="chart" id="main90.1"></div>
  46. <h2>parallel category axis | parallelAxis: {min: undefined, max: undefined}</h2>
  47. <div class="chart" id="main91.1"></div>
  48. <h2>single category axis | singleAxis: {min: 'dataMin', max: 'dataMax'}</h2>
  49. <div class="chart" id="main92.1"></div>
  50. <script>
  51. function makeChart(id, option, noDataZoom) {
  52. require([
  53. 'echarts',
  54. 'echarts/chart/line',
  55. 'echarts/chart/scatter',
  56. 'echarts/chart/parallel',
  57. 'echarts/component/polar',
  58. 'echarts/component/grid',
  59. 'echarts/component/legend',
  60. 'echarts/component/singleAxis',
  61. 'echarts/component/tooltip',
  62. 'echarts/component/dataZoom'
  63. ], function (echarts) {
  64. var main = document.getElementById(id);
  65. if (main) {
  66. var chartMain = document.createElement('div');
  67. chartMain.style.cssText = 'height:100%';
  68. main.appendChild(chartMain);
  69. var chart = echarts.init(chartMain);
  70. chart.setOption(option);
  71. if (!noDataZoom) {
  72. var controller = document.createElement('div');
  73. controller.style.cssText = 'position: absolute; right: 10px; top: 10px;';
  74. main.appendChild(controller);
  75. controller.innerHTML = [
  76. '<button>Add DataZoom</button>',
  77. '<button>Remove DataZoom</button>'
  78. ].join('');
  79. var btns = $(controller).children();
  80. $(btns[0]).on('click', function () {
  81. option.dataZoom = [{type: 'inside'}, {type: 'slider'}];
  82. chart.setOption(option, true);
  83. });
  84. $(btns[1]).on('click', function () {
  85. delete option.dataZoom;
  86. chart.setOption(option, true);
  87. });
  88. }
  89. }
  90. });
  91. }
  92. </script>
  93. <script>
  94. makeChart('main1', {
  95. legend: {
  96. data: ['no point', 'one point', 'two points'],
  97. selectedMode: 'single'
  98. },
  99. tooltip: {
  100. trigger: 'axis',
  101. axisPointer: {
  102. type: 'line'
  103. }
  104. },
  105. xAxis: {
  106. data: ['类目1', '类目2', '类目3', '类目4', '类目5'],
  107. min: 'dataMin',
  108. max: 'dataMax'
  109. },
  110. yAxis: {},
  111. series: [{
  112. name: 'no point',
  113. type: 'line',
  114. data: []
  115. }, {
  116. name: 'one point',
  117. type: 'line',
  118. data: [43]
  119. }, {
  120. name: 'two points',
  121. type: 'line',
  122. data: [43, 99]
  123. }]
  124. });
  125. </script>
  126. <script>
  127. makeChart('main1.1', {
  128. legend: {
  129. data: ['no point', 'one point', 'two points'],
  130. selectedMode: 'single'
  131. },
  132. tooltip: {
  133. trigger: 'axis',
  134. axisPointer: {
  135. type: 'line'
  136. }
  137. },
  138. xAxis: {
  139. data: ['类目1', '类目2', '类目3', '类目4', '类目5']
  140. },
  141. yAxis: {},
  142. series: [{
  143. name: 'no point',
  144. type: 'line',
  145. data: []
  146. }, {
  147. name: 'one point',
  148. type: 'line',
  149. data: [43]
  150. }, {
  151. name: 'two points',
  152. type: 'line',
  153. data: [43, 99]
  154. }]
  155. });
  156. </script>
  157. <script>
  158. makeChart('main1.2', {
  159. legend: {
  160. data: ['no point', 'one point', 'two points'],
  161. selectedMode: 'single'
  162. },
  163. tooltip: {
  164. trigger: 'axis',
  165. axisPointer: {
  166. type: 'line'
  167. }
  168. },
  169. xAxis: {
  170. data: []
  171. },
  172. yAxis: {},
  173. series: [{
  174. name: 'no point',
  175. type: 'line',
  176. data: []
  177. }, {
  178. name: 'one point',
  179. type: 'line',
  180. data: [43]
  181. }, {
  182. name: 'two points',
  183. type: 'line',
  184. data: [43, 99]
  185. }]
  186. });
  187. </script>
  188. <script>
  189. makeChart('main2', {
  190. legend: {
  191. data: ['no point', 'one point', 'two points'],
  192. selectedMode: 'single'
  193. },
  194. tooltip: {
  195. trigger: 'axis',
  196. axisPointer: {
  197. type: 'line'
  198. }
  199. },
  200. grid: {
  201. containLabel: true
  202. },
  203. xAxis: {
  204. data: ['类目1', '类目2', '类目3', '类目4', '类目5'],
  205. min: -10,
  206. max: '类目3',
  207. axisTick: {
  208. interval: 0
  209. },
  210. axisLabel: {
  211. interval: 0
  212. }
  213. },
  214. yAxis: {},
  215. series: [{
  216. name: 'no point',
  217. type: 'line',
  218. data: []
  219. }, {
  220. name: 'one point',
  221. type: 'line',
  222. data: [43]
  223. }, {
  224. name: 'two points',
  225. type: 'line',
  226. data: [43, 99]
  227. }]
  228. });
  229. </script>
  230. <script>
  231. makeChart('main3', {
  232. legend: {
  233. data: ['no point', 'one point', 'two points'],
  234. selectedMode: 'single'
  235. },
  236. tooltip: {
  237. trigger: 'axis',
  238. axisPointer: {
  239. type: 'line'
  240. }
  241. },
  242. xAxis: {},
  243. yAxis: {},
  244. series: [{
  245. name: 'no point',
  246. type: 'line',
  247. data: []
  248. }, {
  249. name: 'one point',
  250. type: 'line',
  251. data: [[2, 43]]
  252. }, {
  253. name: 'two points',
  254. type: 'line',
  255. data: [[2, 43], [4, 99]]
  256. }]
  257. });
  258. </script>
  259. <script>
  260. makeChart('main4', {
  261. legend: {
  262. data: ['no point', 'one point', 'two points'],
  263. selectedMode: 'single'
  264. },
  265. tooltip: {
  266. trigger: 'axis',
  267. axisPointer: {
  268. type: 'line'
  269. }
  270. },
  271. xAxis: {min: -10, max: 10},
  272. yAxis: {},
  273. series: [{
  274. name: 'no point',
  275. type: 'line',
  276. data: []
  277. }, {
  278. name: 'one point',
  279. type: 'line',
  280. data: [[2, 43]]
  281. }, {
  282. name: 'two points',
  283. type: 'line',
  284. data: [[2, 43], [4, 99]]
  285. }]
  286. });
  287. </script>
  288. <script>
  289. makeChart('main5', {
  290. legend: {
  291. data: ['no point', 'one point', 'two points'],
  292. selectedMode: 'single'
  293. },
  294. tooltip: {
  295. trigger: 'axis',
  296. axisPointer: {
  297. type: 'line'
  298. }
  299. },
  300. xAxis: {type: 'time'},
  301. yAxis: {},
  302. series: [{
  303. name: 'one point',
  304. type: 'line',
  305. data: [
  306. [new Date('2011-11-11'), 2112]
  307. ]
  308. }, {
  309. name: 'two points',
  310. type: 'line',
  311. data: [
  312. [new Date('2011-11-11'), 2112],
  313. [new Date('2012-11-12'), 122]
  314. ]
  315. }, {
  316. name: 'no point',
  317. type: 'line',
  318. data: []
  319. }]
  320. });
  321. </script>
  322. <script>
  323. makeChart('main6', {
  324. legend: {
  325. data: ['no point', 'one point', 'two points'],
  326. selectedMode: 'single'
  327. },
  328. tooltip: {
  329. trigger: 'axis',
  330. axisPointer: {
  331. type: 'line'
  332. }
  333. },
  334. xAxis: {
  335. type: 'time',
  336. min: '2012-8-12',
  337. max: '2012-10-01'
  338. },
  339. yAxis: {},
  340. series: [{
  341. name: 'one point',
  342. type: 'line',
  343. data: [
  344. [new Date('2012-9-12'), 11]
  345. ]
  346. }, {
  347. name: 'two points',
  348. type: 'line',
  349. data: [
  350. ['2012-9-12', 11],
  351. ['2012-9-18', 14]
  352. ]
  353. }, {
  354. name: 'no point',
  355. type: 'line',
  356. data: []
  357. }]
  358. });
  359. </script>
  360. <script>
  361. makeChart('main90.1', {
  362. legend: {
  363. data: ['no point', 'one point', 'two points'],
  364. selectedMode: 'single'
  365. },
  366. tooltip: {
  367. trigger: 'axis'
  368. },
  369. polar: {},
  370. radiusAxis: {
  371. min: 'dataMin',
  372. max: 'dataMax',
  373. data: ['类目1', '类目2', '类目3', '类目4', '类目5']
  374. },
  375. angleAxis: {},
  376. series: [{
  377. coordinateSystem: 'polar',
  378. name: 'no point',
  379. type: 'line',
  380. data: []
  381. }, {
  382. coordinateSystem: 'polar',
  383. name: 'one point',
  384. type: 'line',
  385. data: [43]
  386. }, {
  387. coordinateSystem: 'polar',
  388. name: 'two points',
  389. type: 'line',
  390. data: [43, 99]
  391. }]
  392. });
  393. </script>
  394. <script>
  395. makeChart('main91.1', {
  396. legend: {
  397. data: ['no point', 'one point', 'two points'],
  398. selectedMode: 'single'
  399. },
  400. parallelAxis: [{
  401. type: 'value',
  402. dim: 0
  403. }, {
  404. dim: 1,
  405. type: 'category',
  406. data: ['优', '良', '轻度污染', '中度污染', '重度污染', '严重污染']
  407. }],
  408. parallel: {
  409. },
  410. series: [{
  411. name: 'no point',
  412. type: 'parallel',
  413. data: []
  414. }, {
  415. name: 'one point',
  416. type: 'parallel',
  417. data: [[43, '良']]
  418. }, {
  419. name: 'two points',
  420. type: 'parallel',
  421. data: [[43, '良'], [99, '重度污染']]
  422. }]
  423. }, true);
  424. </script>
  425. <script>
  426. makeChart('main92.1', {
  427. legend: {
  428. data: ['no point', 'one point', 'two points'],
  429. selectedMode: 'single'
  430. },
  431. tooltip: {
  432. trigger: 'axis'
  433. },
  434. singleAxis: {
  435. type: 'category',
  436. min: 'dataMin',
  437. max: 'dataMax',
  438. data: ['类目1', '类目2', '类目3', '类目4', '类目5']
  439. },
  440. series: [{
  441. coordinateSystem: 'singleAxis',
  442. name: 'no point',
  443. type: 'scatter',
  444. symbolSize: 20,
  445. data: []
  446. }, {
  447. coordinateSystem: 'singleAxis',
  448. name: 'one point',
  449. type: 'scatter',
  450. symbolSize: 20,
  451. data: [[2]]
  452. }, {
  453. coordinateSystem: 'singleAxis',
  454. name: 'two points',
  455. type: 'scatter',
  456. symbolSize: 20,
  457. data: [[2], [4]]
  458. }]
  459. }, true);
  460. </script>
  461. </body>
  462. </html>