pictorial-repeat.html 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  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. <script src="data/symbols.js"></script>
  10. <meta name="viewport" content="width=device-width, initial-scale=1" />
  11. <link rel="stylesheet" href="reset.css">
  12. </head>
  13. <body>
  14. <style>
  15. body {
  16. }
  17. .chart {
  18. position: relative;
  19. height: 500px;
  20. max-width: 1000px;
  21. margin: 0 auto;
  22. }
  23. h2 {
  24. text-align: center;
  25. font-size: 16px;
  26. line-height: 30px;
  27. font-weight: normal;
  28. background: #dde;
  29. }
  30. </style>
  31. <h2>vertical | no clip | symbol w/h ratio and margin '40%!'</h2>
  32. <div class="chart" id="main1"></div>
  33. <h2>vertical | no clip | symbol w/h ratio and margin '40%' (notice 0 value)</h2>
  34. <div class="chart" id="main1.x"></div>
  35. <h2>vertical | clip | fixed repeatTimes</h2>
  36. <div class="chart" id="main1.1"></div>
  37. <h2>dataURI | symbolSize responsive (<strong>TRY RESIZE</strong>)</h2>
  38. <div class="chart" id="symbolSize"></div>
  39. <h2>horizontal | clip | positive | rotate</h2>
  40. <div class="chart" id="main2"></div>
  41. <h2>horizontal | clip | negative | no animation</h2>
  42. <div class="chart" id="main3"></div>
  43. <h2>negative symbolMargin | symbolPosition (check whether overflow)</h2>
  44. <div class="chart" id="main4"></div>
  45. <h2>repeat strategy | dynamic data</h2>
  46. <div class="chart" id="dynamic-data"></div>
  47. <script>
  48. function makeChart(id, option, cb) {
  49. require([
  50. 'echarts',
  51. 'echarts/chart/pictorialBar',
  52. 'echarts/chart/bar',
  53. 'echarts/chart/scatter',
  54. 'echarts/component/grid',
  55. 'echarts/component/markLine',
  56. 'echarts/component/legend',
  57. 'echarts/component/tooltip',
  58. 'echarts/component/dataZoom'
  59. ], function (echarts) {
  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. window.addEventListener('resize', chart.resize);
  68. cb && cb(echarts, chart);
  69. }
  70. });
  71. }
  72. </script>
  73. <script>
  74. makeChart('main1', {
  75. legend: {
  76. data: ['data', 'data2', 'bg', 'original bar', 'original bg'],
  77. selected: {
  78. 'original bar': false,
  79. 'original bg': false
  80. }
  81. },
  82. tooltip: {
  83. },
  84. yAxis: {
  85. data: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
  86. axisTick: {show: false}
  87. },
  88. xAxis: {
  89. splitLine: {show: false}
  90. },
  91. // animationDuration: 2000,
  92. // animationDurationUpdate: 2000,
  93. series: [{
  94. name: 'data',
  95. type: 'pictorialBar',
  96. label: {
  97. normal: {
  98. show: true,
  99. position: 'outside',
  100. offset: [40, 0]
  101. }
  102. },
  103. symbol: pathSymbols.plane,
  104. symbolRepeat: true,
  105. symbolMargin: '40%!',
  106. symbolSize: ['100%', '80%'],
  107. z: 10,
  108. data: [12, 60, 54, '-', 23, -16, 0, 25]
  109. }, {
  110. name: 'data2',
  111. type: 'pictorialBar',
  112. symbol: pathSymbols.plane,
  113. barGap: '20%',
  114. symbolRepeat: true,
  115. symbolMargin: '40%!',
  116. symbolSize: ['100%', '80%'],
  117. z: 10,
  118. data: [33, 1, 41, -18, 23, -56, 0, 15]
  119. }, {
  120. name: 'original bar',
  121. type: 'bar',
  122. color: ['rgba(0,0,0,0.5)'],
  123. data: [12, 60, 54, '-', 23, -16, 0, 25]
  124. }, {
  125. name: 'original bg',
  126. type: 'bar',
  127. color: ['rgba(0,0,0,0.5)'],
  128. data: [60, 60, 60, '-', 60, -30, 60, 60]
  129. }]
  130. });
  131. </script>
  132. <script>
  133. makeChart('main1.x', {
  134. legend: {
  135. data: ['data', 'data2', 'bg', 'original bar', 'original bg'],
  136. selected: {
  137. 'original bar': false,
  138. 'original bg': false
  139. }
  140. },
  141. tooltip: {
  142. },
  143. yAxis: {
  144. data: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
  145. axisTick: {show: false}
  146. },
  147. xAxis: {
  148. splitLine: {show: false}
  149. },
  150. // animationDuration: 2000,
  151. // animationDurationUpdate: 2000,
  152. series: [{
  153. name: 'data',
  154. type: 'pictorialBar',
  155. label: {
  156. normal: {
  157. show: true,
  158. position: 'outside',
  159. offset: [40, 0]
  160. }
  161. },
  162. symbol: pathSymbols.plane,
  163. symbolRepeat: true,
  164. symbolMargin: '40%',
  165. symbolSize: ['100%', '80%'],
  166. z: 10,
  167. data: [12, 60, 54, '-', 23, -16, 0, 25]
  168. }, {
  169. name: 'data2',
  170. type: 'pictorialBar',
  171. symbol: pathSymbols.plane,
  172. barGap: '20%',
  173. symbolRepeat: true,
  174. symbolMargin: '40%',
  175. symbolSize: ['100%', '80%'],
  176. z: 10,
  177. data: [33, 1, 41, -18, 23, -56, 0, 15]
  178. }, {
  179. name: 'original bar',
  180. type: 'bar',
  181. color: ['rgba(0,0,0,0.5)'],
  182. data: [12, 60, 54, '-', 23, -16, 0, 25]
  183. }, {
  184. name: 'original bg',
  185. type: 'bar',
  186. color: ['rgba(0,0,0,0.5)'],
  187. data: [60, 60, 60, '-', 60, -30, 60, 60]
  188. }]
  189. });
  190. </script>
  191. <script>
  192. makeChart('main1.1', {
  193. legend: {
  194. data: ['data'],
  195. selected: {
  196. 'original bar': false,
  197. 'original bg': false
  198. }
  199. },
  200. tooltip: {
  201. },
  202. yAxis: {
  203. data: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
  204. axisTick: {show: false},
  205. axisLine: {show: false}
  206. },
  207. xAxis: {
  208. splitLine: {show: false},
  209. axisTick: {show: false},
  210. axisLabel: {show: false},
  211. axisLine: {show: false}
  212. },
  213. // animationDuration: 2000,
  214. // animationDurationUpdate: 2000,
  215. series: [{
  216. name: 'data',
  217. type: 'pictorialBar',
  218. symbol: pathSymbols.pentagram,
  219. symbolRepeat: 5,
  220. itemStyle: {
  221. normal: {
  222. color: '#ddd'
  223. }
  224. },
  225. animation: false,
  226. silent: true,
  227. data: [12, 60, 54, 25, 23, 16, 1, 25],
  228. z: -1
  229. }, {
  230. name: 'data',
  231. type: 'pictorialBar',
  232. symbol: pathSymbols.pentagram,
  233. symbolRepeat: 5,
  234. symbolClip: true,
  235. z: 10,
  236. data: [12, 60, 54, 25, 23, 16, 1, 25]
  237. }]
  238. });
  239. </script>
  240. <script>
  241. makeChart('symbolSize', {
  242. color: ['#e54035'],
  243. xAxis: {
  244. splitLine: {show: false},
  245. axisTick: {show: false},
  246. axisLine: {show: false},
  247. axisLabel: {show: false}
  248. },
  249. yAxis: {
  250. data: ['a', 'b', 'c'],
  251. axisTick: {show: false},
  252. axisLine: {show: false},
  253. axisLabel: {show: false}
  254. },
  255. grid: {
  256. height: 80
  257. },
  258. series: [{
  259. name: 'glyph',
  260. type: 'pictorialBar',
  261. symbol: imageSymbols.spirit,
  262. symbolRepeat: 10,
  263. symbolSize: [20, 20],
  264. data: [100, 100, 100]
  265. }, {
  266. name: 'glyph',
  267. type: 'pictorialBar',
  268. symbol: 'rect',
  269. symbolSize: ['20%', 24],
  270. symbolPosition: 'center',
  271. itemStyle: {
  272. normal: {
  273. color: '#e54035'
  274. }
  275. },
  276. label: {
  277. normal: {
  278. show: true,
  279. formatter: '16 亿',
  280. textStyle: {
  281. color: '#fff',
  282. fontSize: 18,
  283. fontFamily: 'Arial',
  284. fontWeight: 'bold'
  285. }
  286. }
  287. },
  288. data: ['-', 100, '-'],
  289. z: 100
  290. }]
  291. });
  292. </script>
  293. <script>
  294. makeChart('main2', {
  295. legend: {
  296. data: ['data', 'original bar', 'original bg'],
  297. selected: {
  298. 'original bar': false,
  299. 'original bg': false
  300. }
  301. },
  302. tooltip: {
  303. // trigger: 'axis',
  304. // axisPointer: {
  305. // type: 'line'
  306. // }
  307. },
  308. xAxis: {
  309. data: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
  310. axisTick: {show: false}
  311. },
  312. yAxis: {
  313. splitLine: {show: false}
  314. },
  315. series: [{
  316. name: 'data',
  317. type: 'pictorialBar',
  318. symbol: pathSymbols.pumpkin,
  319. symbolRotate: 30,
  320. itemStyle: {
  321. normal: {
  322. color: '#ddd'
  323. }
  324. },
  325. label: {
  326. normal: {
  327. show: true,
  328. position: 'outside',
  329. textStyle: {
  330. color: '#c23531',
  331. fontSize: 20
  332. }
  333. }
  334. },
  335. silent: true,
  336. symbolRepeat: 'fixed',
  337. animation: false,
  338. symbolBoundingData: 60,
  339. data: [12, 60, 54, '-', 23, 2, 0, 25]
  340. }, {
  341. name: 'data',
  342. type: 'pictorialBar',
  343. symbol: pathSymbols.pumpkin,
  344. symbolRotate: 30,
  345. symbolRepeat: true,
  346. symbolClip: true,
  347. symbolBoundingData: 60,
  348. z: 10,
  349. data: [12, 60, 54, '-', 23, -2, 0, 25]
  350. }, {
  351. name: 'original bar',
  352. type: 'bar',
  353. color: ['rgba(0,0,0,0.5)'],
  354. data: [12, 60, 54, '-', 23, -2, 0, 25]
  355. }, {
  356. name: 'original bg',
  357. type: 'bar',
  358. color: ['rgba(0,0,0,0.5)'],
  359. data: [60, 60, 60, '-', 60, 60, 60, 60]
  360. }]
  361. });
  362. </script>
  363. <script>
  364. makeChart('main3', {
  365. animation: false,
  366. legend: {
  367. data: ['data', 'bg', 'original bar', 'original bg'],
  368. selected: {
  369. 'original bar': false,
  370. 'original bg': false
  371. }
  372. },
  373. tooltip: {
  374. // trigger: 'axis',
  375. // axisPointer: {
  376. // type: 'line'
  377. // }
  378. },
  379. xAxis: {
  380. data: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
  381. axisTick: {show: false},
  382. position: 'top'
  383. },
  384. yAxis: {
  385. splitLine: {show: false}
  386. },
  387. series: [{
  388. name: 'bg',
  389. type: 'pictorialBar',
  390. symbol: pathSymbols.pumpkin,
  391. itemStyle: {
  392. normal: {
  393. color: '#ddd'
  394. }
  395. },
  396. label: {
  397. normal: {
  398. show: true,
  399. position: 'outside',
  400. textStyle: {
  401. color: '#c23531',
  402. fontSize: 20
  403. }
  404. }
  405. },
  406. silent: true,
  407. symbolRepeat: 'fixed',
  408. symbolClip: false,
  409. symbolBoundingData: -60,
  410. symbolRotate: 30,
  411. z: -1,
  412. data: [-12, -60, -54, '-', -23, -2, 0, -25]
  413. }, {
  414. name: 'data',
  415. type: 'pictorialBar',
  416. itemStyle: {
  417. emphasis: {
  418. color: 'blue'
  419. }
  420. },
  421. symbol: pathSymbols.pumpkin,
  422. symbolRepeat: true,
  423. symbolClip: true,
  424. symbolRotate: 30,
  425. symbolBoundingData: -60,
  426. data: [-12, -60, -54, '-', -23, -2, 0, -25]
  427. }, {
  428. name: 'original bar',
  429. type: 'bar',
  430. color: ['rgba(0,0,0,0.5)'],
  431. data: [-12, -60, -54, '-', -23, -2, 0, -25]
  432. }, {
  433. name: 'original bg',
  434. type: 'bar',
  435. color: ['rgba(0,0,0,0.5)'],
  436. data: [-60, -60, -60, '-', -60, -60, -60, -60]
  437. }]
  438. });
  439. </script>
  440. <script>
  441. makeChart('main4', {
  442. color: ['#bb0004', 'orange'],
  443. xAxis: {
  444. data: [],
  445. axisTick: {show: false},
  446. axisLabel: {show: false}
  447. },
  448. yAxis: {
  449. splitLine: {show: false},
  450. axisTick: {show: false},
  451. axisLine: {show: false},
  452. axisLabel: {show: false}
  453. },
  454. grid: {
  455. bottom: 100
  456. },
  457. animationEasing: 'elasticOut',
  458. series: [{
  459. name: 'all',
  460. type: 'pictorialBar',
  461. barCategoryGap: '40%',
  462. label: {
  463. normal: {
  464. show: true,
  465. position: 'outside'
  466. }
  467. },
  468. itemStyle: {
  469. normal: {
  470. borderColor: 'rgba(0,0,0,0.5)',
  471. borderWidth: 6
  472. }
  473. },
  474. symbol: 'circle',
  475. data: [{
  476. value: 29000,
  477. symbolBoundingData: 29000,
  478. symbolRepeat: true,
  479. label: {normal: {formatter: 'start'}}
  480. }, {
  481. value: 29000,
  482. symbolBoundingData: 29000,
  483. symbolRepeat: true,
  484. symbolSize: ['80%', '20%'],
  485. label: {normal: {formatter: 'start'}}
  486. }, {
  487. value: 29000,
  488. symbolBoundingData: 29000,
  489. symbolRepeat: true,
  490. symbolMargin: 10,
  491. label: {normal: {formatter: 'start'}}
  492. }, {
  493. value: 29000,
  494. symbolBoundingData: 29000,
  495. symbolRepeat: true,
  496. symbolMargin: 30,
  497. symbolSize: ['100%', 160],
  498. label: {normal: {formatter: 'start'}}
  499. }, {
  500. value: 29000,
  501. symbolBoundingData: 29000,
  502. symbolRepeat: true,
  503. symbolMargin: 30,
  504. symbolSize: ['100%', 160],
  505. symbolPosition: 'center',
  506. label: {normal: {formatter: 'center'}}
  507. }, {
  508. value: 29000,
  509. symbolBoundingData: 29000,
  510. symbolRepeat: true,
  511. symbolMargin: 30,
  512. symbolSize: ['100%', 160],
  513. symbolPosition: 'end',
  514. label: {normal: {formatter: 'end'}}
  515. }, {
  516. value: 29000,
  517. symbolBoundingData: 29000,
  518. symbolRepeat: true,
  519. symbolSize: ['80%', '120%'],
  520. symbolMargin: '-30%',
  521. label: {normal: {formatter: 'start'}}
  522. }, {
  523. value: 29000,
  524. symbolBoundingData: 29000,
  525. symbolRepeat: true,
  526. symbolSize: ['80%', '120%'],
  527. symbolMargin: '-30%',
  528. symbolPosition: 'center',
  529. label: {normal: {formatter: 'center'}}
  530. }, {
  531. value: 29000,
  532. symbolBoundingData: 29000,
  533. symbolRepeat: true,
  534. symbolRotate: 80,
  535. symbolSize: ['80%', '120%'],
  536. symbolMargin: '-30%',
  537. symbolPosition: 'end',
  538. label: {normal: {formatter: 'end'}}
  539. }, {
  540. value: 19000,
  541. symbolPosition: 'start',
  542. label: {normal: {formatter: 'start'}}
  543. }, {
  544. value: 19000,
  545. symbolSize: ['60%', '20%'],
  546. symbolPosition: 'start',
  547. label: {normal: {formatter: 'start'}}
  548. }, {
  549. value: 19000,
  550. symbolSize: ['60%', '20%'],
  551. symbolPosition: 'center',
  552. label: {normal: {formatter: 'center'}}
  553. }, {
  554. value: 19000,
  555. symbolSize: ['60%', '20%'],
  556. symbolPosition: 'end',
  557. label: {normal: {formatter: 'end'}}
  558. }, {
  559. value: 19000,
  560. symbolSize: ['60%', '150%'],
  561. symbolPosition: 'start',
  562. label: {normal: {formatter: 'start'}}
  563. }, {
  564. value: 19000,
  565. symbolSize: ['60%', '150%'],
  566. symbolPosition: 'center',
  567. label: {normal: {formatter: 'center'}}
  568. }, {
  569. value: 19000,
  570. symbolSize: ['60%', '150%'],
  571. symbolPosition: 'end',
  572. label: {normal: {formatter: 'end'}}
  573. }, {
  574. value: 190,
  575. symbolPosition: 'end',
  576. label: {normal: {formatter: 'min'}}
  577. }],
  578. z: 10
  579. }, {
  580. name: 'shadow2',
  581. type: 'bar',
  582. data: [29000, 29000, 29000, 29000, 29000, 29000, 29000, 29000, 29000, 19000, 19000, 19000, 19000, 19000, 19000, 19000, 19]
  583. }]
  584. });
  585. </script>
  586. <script>
  587. var startData = 13000;
  588. var maxData = 18000;
  589. var minData = 5000;
  590. makeChart('dynamic-data', {
  591. backgroundColor: '#0f375f',
  592. tooltip: {},
  593. legend: {
  594. data: ['all'],
  595. textStyle: {color: '#ddd'}
  596. },
  597. grid: {
  598. bottom: 100
  599. },
  600. xAxis: [{
  601. data: [
  602. 'standard',
  603. 'fix symbol margin\n(not accurate)\n(but more comparable)',
  604. 'use symbolBoundingData\nauto repeat times\n(accurate)\n(but symbolMargin not fixed)',
  605. 'use symbolBoundingData\nfix repeat times\n(accurate)\n(but less responsive)'
  606. ],
  607. axisTick: {show: false},
  608. axisLine: {
  609. lineStyle: {
  610. color: '#ddd'
  611. }
  612. },
  613. axisLabel: {
  614. margin: 20,
  615. interval: 0,
  616. textStyle: {
  617. color: '#ddd',
  618. fontSize: 14
  619. }
  620. }
  621. }],
  622. yAxis: {
  623. splitLine: {show: false},
  624. axisTick: {
  625. lineStyle: {
  626. color: '#ddd'
  627. }
  628. },
  629. axisLine: {
  630. lineStyle: {
  631. color: '#ddd'
  632. }
  633. },
  634. axisLabel: {
  635. textStyle: {
  636. color: '#ddd'
  637. }
  638. }
  639. },
  640. animationEasing: 'cubicOut',
  641. animationDuration: 100,
  642. animationDurationUpdate: 2000,
  643. series: [{
  644. type: 'pictorialBar',
  645. name: 'all',
  646. id: 'paper',
  647. hoverAnimation: true,
  648. label: {
  649. normal: {
  650. show: true,
  651. position: 'top',
  652. formatter: '{c} km',
  653. textStyle: {
  654. fontSize: 16,
  655. color: '#e54035'
  656. }
  657. }
  658. },
  659. symbol: imageSymbols.paper,
  660. symbolSize: ['70%', 50],
  661. symbolMargin: '-25%',
  662. data: [{
  663. value: maxData,
  664. symbolRepeat: true
  665. }, {
  666. value: startData,
  667. symbolRepeat: true
  668. }, {
  669. value: startData,
  670. symbolBoundingData: startData,
  671. symbolRepeat: true
  672. }, {
  673. value: startData,
  674. symbolBoundingData: startData,
  675. symbolRepeat: 20
  676. }],
  677. markLine: {
  678. symbol: ['none', 'none'],
  679. label: {
  680. normal: {show: false}
  681. },
  682. lineStyle: {
  683. normal: {
  684. color: '#e54035'
  685. }
  686. },
  687. data: [{
  688. yAxis: startData
  689. }]
  690. }
  691. }, {
  692. name: 'all',
  693. type: 'pictorialBar',
  694. symbol: 'circle',
  695. itemStyle: {
  696. normal: {
  697. color: '#185491'
  698. }
  699. },
  700. silent: true,
  701. symbolSize: ['150%', 50],
  702. symbolOffset: [0, 20],
  703. z: -10,
  704. data: [1, 1, 1, 1]
  705. }]
  706. }, function (echarts, chart) {
  707. setInterval(function () {
  708. var dynamicData = Math.round(Math.random() * (maxData - minData) + minData);
  709. chart.setOption({
  710. series: [{
  711. id: 'paper',
  712. data: [{
  713. value: maxData,
  714. symbolRepeat: true
  715. }, {
  716. value: dynamicData,
  717. symbolRepeat: true
  718. }, {
  719. value: dynamicData,
  720. symbolBoundingData: dynamicData,
  721. symbolRepeat: true
  722. }, {
  723. value: dynamicData,
  724. symbolBoundingData: dynamicData,
  725. symbolRepeat: 20
  726. }],
  727. markLine: {
  728. data: [{
  729. yAxis: dynamicData
  730. }]
  731. }
  732. }]
  733. });
  734. }, 3000);
  735. });
  736. </script>
  737. </body>
  738. </html>