axis-extrema.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. <!DOCTYPE>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <script src="../dist/echarts.js"></script>
  6. <script src="lib/jquery.min.js"></script>
  7. <script src="lib/facePrint.js"></script>
  8. <meta name="viewport" content="width=device-width, initial-scale=1" />
  9. <link rel="stylesheet" href="lib/reset.css">
  10. </head>
  11. <body>
  12. <style>
  13. body {
  14. }
  15. .chart {
  16. position: relative;
  17. height: 300px;
  18. }
  19. h2 {
  20. text-align: center;
  21. font-size: 16px;
  22. line-height: 30px;
  23. font-weight: normal;
  24. background: #A3AEFF;
  25. }
  26. </style>
  27. <div class="chart" id="main1"></div>
  28. <h2>cartesian category axis | xAxis: {min: undefined, max: undefined}</h2>
  29. <div class="chart" id="main1.1"></div>
  30. <h2>cartesian category axis | xAxis.data is empty</h2>
  31. <div class="chart" id="main1.2"></div>
  32. <h2>cartesian category axis | xAxis: {min: -10, max: '类目3'}</h2>
  33. <div class="chart" id="main2"></div>
  34. <h2>cartesian category axis | xAxis: {min: function, max: function}</h2>
  35. <div class="chart" id="main2.1"></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 value axis | xAxis: {min: function, max: function}</h2>
  41. <div class="chart" id="main4.1"></div>
  42. <h2>cartesian time axis | xAxis: {min: 'dataMin', max: 'dataMax'}</h2>
  43. <div class="chart" id="main5"></div>
  44. <h2>cartesian time axis | xAxis: {min: '2012-08-12', max: '2012-10-01'}</h2>
  45. <div class="chart" id="main6"></div>
  46. <h2>cartesian time axis | xAxis: {min: function, max: function}</h2>
  47. <div class="chart" id="main6.1"></div>
  48. <h2>polar category axis | radiuAxis: {min: 'dataMin', max: 'dataMax'}</h2>
  49. <div class="chart" id="main90.1"></div>
  50. <h2>polar category axis | radiuAxis: {min: function, max: function}</h2>
  51. <div class="chart" id="main90.2"></div>
  52. <h2>parallel category axis | parallelAxis: {min: undefined, max: undefined}</h2>
  53. <div class="chart" id="main91.1"></div>
  54. <h2>single category axis | singleAxis: {min: 'dataMin', max: 'dataMax'}</h2>
  55. <div class="chart" id="main92.1"></div>
  56. <h2>single category axis | singleAxis: {min: function, max: function}</h2>
  57. <div class="chart" id="main92.2"></div>
  58. <script>
  59. function makeChart(id, option, noDataZoom) {
  60. var main = document.getElementById(id);
  61. if (main) {
  62. var chartMain = document.createElement('div');
  63. chartMain.style.cssText = 'height:100%';
  64. main.appendChild(chartMain);
  65. var chart = echarts.init(chartMain);
  66. chart.setOption(option);
  67. if (!noDataZoom) {
  68. var controller = document.createElement('div');
  69. controller.style.cssText = 'position: absolute; right: 10px; top: 10px;';
  70. main.appendChild(controller);
  71. controller.innerHTML = [
  72. '<button>Add DataZoom</button>',
  73. '<button>Remove DataZoom</button>'
  74. ].join('');
  75. var btns = $(controller).children();
  76. $(btns[0]).on('click', function () {
  77. option.dataZoom = [{type: 'inside'}, {type: 'slider'}];
  78. chart.setOption(option, true);
  79. });
  80. $(btns[1]).on('click', function () {
  81. delete option.dataZoom;
  82. chart.setOption(option, true);
  83. });
  84. }
  85. }
  86. }
  87. </script>
  88. <script>
  89. makeChart('main1', {
  90. legend: {
  91. data: ['no point', 'one point', 'two points'],
  92. selectedMode: 'single'
  93. },
  94. tooltip: {
  95. trigger: 'axis',
  96. axisPointer: {
  97. type: 'line'
  98. }
  99. },
  100. xAxis: {
  101. data: ['类目1', '类目2', '类目3', '类目4', '类目5'],
  102. min: 'dataMin',
  103. max: 'dataMax'
  104. },
  105. yAxis: {},
  106. series: [{
  107. name: 'no point',
  108. type: 'line',
  109. data: []
  110. }, {
  111. name: 'one point',
  112. type: 'line',
  113. data: [43]
  114. }, {
  115. name: 'two points',
  116. type: 'line',
  117. data: [43, 99]
  118. }]
  119. });
  120. </script>
  121. <script>
  122. makeChart('main1.1', {
  123. legend: {
  124. data: ['no point', 'one point', 'two points'],
  125. selectedMode: 'single'
  126. },
  127. tooltip: {
  128. trigger: 'axis',
  129. axisPointer: {
  130. type: 'line'
  131. }
  132. },
  133. xAxis: {
  134. data: ['类目1', '类目2', '类目3', '类目4', '类目5']
  135. },
  136. yAxis: {},
  137. series: [{
  138. name: 'no point',
  139. type: 'line',
  140. data: []
  141. }, {
  142. name: 'one point',
  143. type: 'line',
  144. data: [43]
  145. }, {
  146. name: 'two points',
  147. type: 'line',
  148. data: [43, 99]
  149. }]
  150. });
  151. </script>
  152. <script>
  153. makeChart('main1.2', {
  154. legend: {
  155. data: ['no point', 'one point', 'two points'],
  156. selectedMode: 'single'
  157. },
  158. tooltip: {
  159. trigger: 'axis',
  160. axisPointer: {
  161. type: 'line'
  162. }
  163. },
  164. xAxis: {
  165. data: []
  166. },
  167. yAxis: {},
  168. series: [{
  169. name: 'no point',
  170. type: 'line',
  171. data: []
  172. }, {
  173. name: 'one point',
  174. type: 'line',
  175. data: [43]
  176. }, {
  177. name: 'two points',
  178. type: 'line',
  179. data: [43, 99]
  180. }]
  181. });
  182. </script>
  183. <script>
  184. makeChart('main2', {
  185. legend: {
  186. data: ['no point', 'one point', 'two points'],
  187. selectedMode: 'single'
  188. },
  189. tooltip: {
  190. trigger: 'axis',
  191. axisPointer: {
  192. type: 'line'
  193. }
  194. },
  195. grid: {
  196. containLabel: true
  197. },
  198. xAxis: {
  199. data: ['类目1', '类目2', '类目3', '类目4', '类目5'],
  200. min: -10,
  201. max: '类目3',
  202. axisTick: {
  203. interval: 0
  204. },
  205. axisLabel: {
  206. interval: 0
  207. }
  208. },
  209. yAxis: {},
  210. series: [{
  211. name: 'no point',
  212. type: 'line',
  213. data: []
  214. }, {
  215. name: 'one point',
  216. type: 'line',
  217. data: [43]
  218. }, {
  219. name: 'two points',
  220. type: 'line',
  221. data: [43, 99]
  222. }]
  223. });
  224. </script>
  225. <script>
  226. makeChart('main2.1', {
  227. legend: {
  228. data: ['no point', 'one point', 'two points'],
  229. selectedMode: 'single'
  230. },
  231. tooltip: {
  232. trigger: 'axis',
  233. axisPointer: {
  234. type: 'line'
  235. }
  236. },
  237. grid: {
  238. containLabel: true
  239. },
  240. xAxis: {
  241. data: ['类目1', '类目2', '类目3', '类目4', '类目5'],
  242. min: function (value) {
  243. return value + 20;
  244. },
  245. max: function (value) {
  246. return value + 20;
  247. },
  248. axisTick: {
  249. interval: 0
  250. },
  251. axisLabel: {
  252. interval: 0
  253. }
  254. },
  255. yAxis: {},
  256. series: [{
  257. name: 'no point',
  258. type: 'line',
  259. data: []
  260. }, {
  261. name: 'one point',
  262. type: 'line',
  263. data: [43]
  264. }, {
  265. name: 'two points',
  266. type: 'line',
  267. data: [43, 99]
  268. }]
  269. });
  270. </script>
  271. <script>
  272. makeChart('main3', {
  273. legend: {
  274. data: ['no point', 'one point', 'two points'],
  275. selectedMode: 'single'
  276. },
  277. tooltip: {
  278. trigger: 'axis',
  279. axisPointer: {
  280. type: 'line'
  281. }
  282. },
  283. xAxis: {},
  284. yAxis: {},
  285. series: [{
  286. name: 'no point',
  287. type: 'line',
  288. data: []
  289. }, {
  290. name: 'one point',
  291. type: 'line',
  292. data: [[2, 43]]
  293. }, {
  294. name: 'two points',
  295. type: 'line',
  296. data: [[2, 43], [4, 99]]
  297. }]
  298. });
  299. </script>
  300. <script>
  301. makeChart('main4', {
  302. legend: {
  303. data: ['no point', 'one point', 'two points'],
  304. selectedMode: 'single'
  305. },
  306. tooltip: {
  307. trigger: 'axis',
  308. axisPointer: {
  309. type: 'line'
  310. }
  311. },
  312. xAxis: {min: -10, max: 10},
  313. yAxis: {},
  314. series: [{
  315. name: 'no point',
  316. type: 'line',
  317. data: []
  318. }, {
  319. name: 'one point',
  320. type: 'line',
  321. data: [[2, 43]]
  322. }, {
  323. name: 'two points',
  324. type: 'line',
  325. data: [[2, 43], [4, 99]]
  326. }]
  327. });
  328. </script>
  329. <script>
  330. makeChart('main4.1', {
  331. legend: {
  332. data: ['no point', 'one point', 'two points'],
  333. selectedMode: 'single'
  334. },
  335. tooltip: {
  336. trigger: 'axis',
  337. axisPointer: {
  338. type: 'line'
  339. }
  340. },
  341. xAxis: {
  342. min: function (value) {
  343. return value + 20;
  344. },
  345. max: function (value) {
  346. return value + 20;
  347. }
  348. },
  349. yAxis: {},
  350. series: [{
  351. name: 'no point',
  352. type: 'line',
  353. data: []
  354. }, {
  355. name: 'one point',
  356. type: 'line',
  357. data: [[2, 43]]
  358. }, {
  359. name: 'two points',
  360. type: 'line',
  361. data: [[2, 43], [4, 99]]
  362. }]
  363. });
  364. </script>
  365. <script>
  366. makeChart('main5', {
  367. legend: {
  368. data: ['no point', 'one point', 'two points'],
  369. selectedMode: 'single'
  370. },
  371. tooltip: {
  372. trigger: 'axis',
  373. axisPointer: {
  374. type: 'line'
  375. }
  376. },
  377. xAxis: {type: 'time'},
  378. yAxis: {},
  379. series: [{
  380. name: 'one point',
  381. type: 'line',
  382. data: [
  383. [new Date('2011-11-11'), 2112]
  384. ]
  385. }, {
  386. name: 'two points',
  387. type: 'line',
  388. data: [
  389. [new Date('2011-11-11'), 2112],
  390. [new Date('2012-11-12'), 122]
  391. ]
  392. }, {
  393. name: 'no point',
  394. type: 'line',
  395. data: []
  396. }]
  397. });
  398. </script>
  399. <script>
  400. makeChart('main6', {
  401. legend: {
  402. data: ['no point', 'one point', 'two points'],
  403. selectedMode: 'single'
  404. },
  405. tooltip: {
  406. trigger: 'axis',
  407. axisPointer: {
  408. type: 'line'
  409. }
  410. },
  411. xAxis: {
  412. type: 'time',
  413. min: '2012-8-12',
  414. max: '2012-10-01'
  415. },
  416. yAxis: {},
  417. series: [{
  418. name: 'one point',
  419. type: 'line',
  420. data: [
  421. [new Date('2012-9-12'), 11]
  422. ]
  423. }, {
  424. name: 'two points',
  425. type: 'line',
  426. data: [
  427. ['2012-9-12', 11],
  428. ['2012-9-18', 14]
  429. ]
  430. }, {
  431. name: 'no point',
  432. type: 'line',
  433. data: []
  434. }]
  435. });
  436. </script>
  437. <script>
  438. makeChart('main6.1', {
  439. legend: {
  440. data: ['no point', 'one point', 'two points'],
  441. selectedMode: 'single'
  442. },
  443. tooltip: {
  444. trigger: 'axis',
  445. axisPointer: {
  446. type: 'line'
  447. }
  448. },
  449. xAxis: {
  450. type: 'time',
  451. min: function (value) {
  452. return value + 20;
  453. },
  454. max: function (value) {
  455. return value + 20;
  456. }
  457. },
  458. yAxis: {},
  459. series: [{
  460. name: 'one point',
  461. type: 'line',
  462. data: [
  463. [new Date('2012-9-12'), 11]
  464. ]
  465. }, {
  466. name: 'two points',
  467. type: 'line',
  468. data: [
  469. ['2012-9-12', 11],
  470. ['2012-9-18', 14]
  471. ]
  472. }, {
  473. name: 'no point',
  474. type: 'line',
  475. data: []
  476. }]
  477. });
  478. </script>
  479. <script>
  480. makeChart('main90.1', {
  481. legend: {
  482. data: ['no point', 'one point', 'two points'],
  483. selectedMode: 'single'
  484. },
  485. tooltip: {
  486. trigger: 'axis'
  487. },
  488. polar: {},
  489. radiusAxis: {
  490. min: 'dataMin',
  491. max: 'dataMax',
  492. data: ['类目1', '类目2', '类目3', '类目4', '类目5']
  493. },
  494. angleAxis: {},
  495. series: [{
  496. coordinateSystem: 'polar',
  497. name: 'no point',
  498. type: 'line',
  499. data: []
  500. }, {
  501. coordinateSystem: 'polar',
  502. name: 'one point',
  503. type: 'line',
  504. data: [43]
  505. }, {
  506. coordinateSystem: 'polar',
  507. name: 'two points',
  508. type: 'line',
  509. data: [43, 99]
  510. }]
  511. });
  512. </script>
  513. <script>
  514. makeChart('main90.2', {
  515. legend: {
  516. data: ['no point', 'one point', 'two points'],
  517. selectedMode: 'single'
  518. },
  519. tooltip: {
  520. trigger: 'axis'
  521. },
  522. polar: {},
  523. radiusAxis: {
  524. min: function (value) {
  525. return value + 20;
  526. },
  527. max: function (value) {
  528. return value + 20;
  529. },
  530. data: ['类目1', '类目2', '类目3', '类目4', '类目5']
  531. },
  532. angleAxis: {},
  533. series: [{
  534. coordinateSystem: 'polar',
  535. name: 'no point',
  536. type: 'line',
  537. data: []
  538. }, {
  539. coordinateSystem: 'polar',
  540. name: 'one point',
  541. type: 'line',
  542. data: [43]
  543. }, {
  544. coordinateSystem: 'polar',
  545. name: 'two points',
  546. type: 'line',
  547. data: [43, 99]
  548. }]
  549. });
  550. </script>
  551. <script>
  552. makeChart('main91.1', {
  553. legend: {
  554. data: ['no point', 'one point', 'two points'],
  555. selectedMode: 'single'
  556. },
  557. parallelAxis: [{
  558. type: 'value',
  559. dim: 0
  560. }, {
  561. dim: 1,
  562. type: 'category',
  563. data: ['优', '良', '轻度污染', '中度污染', '重度污染', '严重污染']
  564. }],
  565. parallel: {
  566. },
  567. series: [{
  568. name: 'no point',
  569. type: 'parallel',
  570. data: []
  571. }, {
  572. name: 'one point',
  573. type: 'parallel',
  574. data: [[43, '良']]
  575. }, {
  576. name: 'two points',
  577. type: 'parallel',
  578. data: [[43, '良'], [99, '重度污染']]
  579. }]
  580. }, true);
  581. </script>
  582. <script>
  583. makeChart('main92.1', {
  584. legend: {
  585. data: ['no point', 'one point', 'two points'],
  586. selectedMode: 'single'
  587. },
  588. tooltip: {
  589. trigger: 'axis'
  590. },
  591. singleAxis: {
  592. type: 'category',
  593. min: 'dataMin',
  594. max: 'dataMax',
  595. data: ['类目1', '类目2', '类目3', '类目4', '类目5']
  596. },
  597. series: [{
  598. coordinateSystem: 'singleAxis',
  599. name: 'no point',
  600. type: 'scatter',
  601. symbolSize: 20,
  602. data: []
  603. }, {
  604. coordinateSystem: 'singleAxis',
  605. name: 'one point',
  606. type: 'scatter',
  607. symbolSize: 20,
  608. data: [[2]]
  609. }, {
  610. coordinateSystem: 'singleAxis',
  611. name: 'two points',
  612. type: 'scatter',
  613. symbolSize: 20,
  614. data: [[2], [4]]
  615. }]
  616. }, true);
  617. </script>
  618. <script>
  619. makeChart('main92.2', {
  620. legend: {
  621. data: ['no point', 'one point', 'two points'],
  622. selectedMode: 'single'
  623. },
  624. tooltip: {
  625. trigger: 'axis'
  626. },
  627. singleAxis: {
  628. type: 'category',
  629. min: function (value) {
  630. return value + 20;
  631. },
  632. max: function (value) {
  633. return value + 20;
  634. },
  635. data: ['类目1', '类目2', '类目3', '类目4', '类目5']
  636. },
  637. series: [{
  638. coordinateSystem: 'singleAxis',
  639. name: 'no point',
  640. type: 'scatter',
  641. symbolSize: 20,
  642. data: []
  643. }, {
  644. coordinateSystem: 'singleAxis',
  645. name: 'one point',
  646. type: 'scatter',
  647. symbolSize: 20,
  648. data: [[2]]
  649. }, {
  650. coordinateSystem: 'singleAxis',
  651. name: 'two points',
  652. type: 'scatter',
  653. symbolSize: 20,
  654. data: [[2], [4]]
  655. }]
  656. }, true);
  657. </script>
  658. </body>
  659. </html>