tooltip-touch.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="lib/esl.js"></script>
  5. <script src="lib/config.js"></script>
  6. <script src="lib/facePrint.js"></script>
  7. <meta name="viewport" content="width=device-width, initial-scale=1" />
  8. <link rel="stylesheet" href="lib/reset.css" />
  9. <script src="lib/testHelper.js"></script>
  10. <script src="tooltipTestHelper.js"></script>
  11. </head>
  12. <body>
  13. <style>
  14. h1 {
  15. line-height: 60px;
  16. background: #360;
  17. text-align: center;
  18. font-weight: bold;
  19. color: #eee;
  20. font-size: 14px;
  21. margin: 0;
  22. }
  23. .chart {
  24. height: 350px;
  25. }
  26. </style>
  27. <h1>handle | time axis | x snap | init value: '2017-04-12' | tooltip not show | inside data zoom | animation auto | check blank</h1>
  28. <div class="chart" id="handle-time-init"></div>
  29. <h1>handle | category | check resize | should trigger hightlight | should link </h1>
  30. <h1>press button: show tip, release button: hide tip</h1>
  31. <div class="chart" id="handle-category"></div>
  32. <h1>handle | value axis | x snap, y not-snap | has init handle value | tooltip.alwaysShowContent | y handle tooltip position should not overflow axispointer line | image icon</h1>
  33. <div class="chart" id="handle-value-init"></div>
  34. <h1>single coordinate system handle | tooltip time label should be consistent with axisPinter.label.formatter</h1>
  35. <div class="chart" id="themeRiver"></div>
  36. <h1>setOption in not merge mode: (1) drag handle (2) click the eye. Check: handle should be normal</h1>
  37. <div class="chart" id="setOption-merge"></div>
  38. <script>
  39. require([
  40. 'echarts'
  41. // 'echarts/chart/scatter',
  42. // 'echarts/chart/line',
  43. // 'echarts/component/legend',
  44. // 'echarts/component/grid',
  45. // 'echarts/component/tooltip',
  46. // 'echarts/component/dataZoom',
  47. // 'zrender/vml/vml'
  48. ], function (echarts) {
  49. var option = {
  50. dataZoom: {
  51. type: 'inside',
  52. start: 20,
  53. end: 50
  54. },
  55. axisPointer: {
  56. triggerOn: 'none'
  57. }
  58. };
  59. var baseTop = 90;
  60. var height = 250;
  61. var gap = 50;
  62. makeTimeGrid(option, {
  63. grid: {left: 100, top: baseTop, height: height},
  64. xAxis: {
  65. axisPointer: {
  66. show: true,
  67. snap: true,
  68. handle: {
  69. show: true,
  70. margin: 60
  71. },
  72. value: '2017-04-12', // init value
  73. }
  74. }
  75. });
  76. baseTop += height + gap;
  77. createChart('handle-time-init', echarts, option, baseTop + 100);
  78. })
  79. </script>
  80. <script>
  81. require([
  82. 'echarts'
  83. // 'echarts/chart/line',
  84. // 'echarts/component/legend',
  85. // 'echarts/component/grid',
  86. // 'echarts/component/tooltip',
  87. // 'zrender/vml/vml'
  88. ], function (echarts) {
  89. var option = {
  90. tooltip: {
  91. triggerOn: 'none'
  92. },
  93. axisPointer: {
  94. link: {xAxisIndex: 'all'}
  95. }
  96. };
  97. var baseTop = 90;
  98. var height = 150;
  99. var gap = 100;
  100. makeCategoryGrid(option, {
  101. grid: {top: baseTop, height: height},
  102. xAxis: {
  103. axisPointer: {
  104. handle: {show: true}
  105. }
  106. },
  107. yAxis: {name: 'no init handle value'}
  108. });
  109. baseTop += height + gap;
  110. makeCategoryGrid(option, {
  111. grid: {top: baseTop, height: height, left: '30%', width: '50%'},
  112. xAxis: {
  113. axisPointer: {
  114. handle: {show: true},
  115. value: 'category3'
  116. }
  117. },
  118. yAxis: {name: 'init handle value: "category3"'}
  119. });
  120. baseTop += height + gap;
  121. createChart('handle-category', echarts, option, baseTop + 100);
  122. });
  123. </script>
  124. <script>
  125. require([
  126. 'echarts'
  127. // 'echarts/chart/scatter',
  128. // 'echarts/component/legend',
  129. // 'echarts/component/grid',
  130. // 'echarts/component/tooltip',
  131. // 'zrender/vml/vml'
  132. ], function (echarts) {
  133. var option = {
  134. tooltip: {
  135. alwaysShowContent: true
  136. }
  137. };
  138. var baseTop = 90;
  139. var height = 150;
  140. var gap = 160;
  141. makeValueGrid(option, {
  142. grid: {left: 100, top: baseTop, height: height, left: 120, right: 120},
  143. xAxis: {
  144. axisPointer: {
  145. handle: {show: true},
  146. snap: true,
  147. value: 600 // init value
  148. }
  149. },
  150. yAxis: {
  151. axisPointer: {
  152. handle: {
  153. show: true,
  154. margin: 70
  155. }
  156. }
  157. }
  158. });
  159. baseTop += height + gap;
  160. makeValueGrid(option, {
  161. grid: {left: 100, top: baseTop, height: height, left: 120, right: 120},
  162. xAxis: {
  163. position: 'top',
  164. axisPointer: {
  165. handle: {
  166. show: true,
  167. icon: 'image://http://echarts.baidu.com/images/favicon.png'
  168. },
  169. snap: true,
  170. value: 600 // init value
  171. }
  172. },
  173. yAxis: {
  174. inverse: true,
  175. position: 'right',
  176. axisLine: {
  177. onZero: false
  178. },
  179. axisPointer: {
  180. handle: {
  181. show: true,
  182. icon: 'image://http://echarts.baidu.com/images/favicon.png',
  183. margin: 70
  184. }
  185. }
  186. }
  187. });
  188. baseTop += height + gap;
  189. createChart('handle-value-init', echarts, option, baseTop + 100);
  190. })
  191. </script>
  192. <script>
  193. require([
  194. 'echarts'
  195. // 'echarts/chart/themeRiver',
  196. // 'echarts/component/legend',
  197. // 'echarts/component/singleAxis',
  198. // 'echarts/component/tooltip',
  199. ], function (echarts) {
  200. var chart = echarts.init(document.getElementById('themeRiver'));
  201. var option = {
  202. tooltip: {
  203. triggerOn: 'none'
  204. },
  205. legend: {
  206. data: ['DQ', 'TY', 'SS', 'QG', 'SY', 'DD']
  207. },
  208. singleAxis: {
  209. axisTick: {},
  210. axisLabel: {},
  211. top: 100,
  212. bottom: 100,
  213. // position: 'top',
  214. type: 'time',
  215. axisPointer: {
  216. handle: {show: true},
  217. label: {
  218. // formatter: '|{value}|',
  219. formatter: function (params) {
  220. return echarts.format.formatTime('yyyy-MM-dd', params.value);
  221. }
  222. }
  223. },
  224. splitLine: {
  225. show: true,
  226. lineStyle: {
  227. type: 'dashed',
  228. opacity: 0.2
  229. }
  230. }
  231. },
  232. series: [
  233. {
  234. type: 'themeRiver',
  235. itemStyle: {
  236. emphasis: {
  237. shadowBlur: 20,
  238. shadowColor: 'rgba(0, 0, 0, 0.8)'
  239. }
  240. },
  241. data: [['2015/11/08',10,'DQ'],['2015/11/09',15,'DQ'],['2015/11/10',35,'DQ'],
  242. // ['2015/11/11',38,'DQ'],['2015/11/12',22,'DQ'],['2015/11/13',16,'DQ'],
  243. ['2015/11/14',7,'DQ'],['2015/11/15',2,'DQ'],['2015/11/16',17,'DQ'],
  244. ['2015/11/17',33,'DQ'],['2015/11/18',40,'DQ'],['2015/11/19',32,'DQ'],
  245. ['2015/11/20',26,'DQ'],['2015/11/21',35,'DQ'],['2015/11/22',40,'DQ'],
  246. ['2015/11/23',32,'DQ'],['2015/11/24',26,'DQ'],['2015/11/25',22,'DQ'],
  247. // ['2015/11/26',16,'DQ'],['2015/11/27',22,'DQ'],['2015/11/28',10,'DQ'],
  248. ['2015/11/08',35,'TY'],['2015/11/09',36,'TY'],['2015/11/10',37,'TY'],
  249. ['2015/11/11',22,'TY'],['2015/11/12',24,'TY'],['2015/11/13',26,'TY'],
  250. ['2015/11/14',34,'TY'],['2015/11/15',21,'TY'],['2015/11/16',18,'TY'],
  251. ['2015/11/17',45,'TY'],['2015/11/18',32,'TY'],['2015/11/19',35,'TY'],
  252. ['2015/11/20',30,'TY'],['2015/11/21',28,'TY'],['2015/11/22',27,'TY'],
  253. ['2015/11/23',26,'TY'],['2015/11/24',15,'TY'],['2015/11/25',30,'TY'],
  254. ['2015/11/26',35,'TY'],['2015/11/27',42,'TY'],['2015/11/28',42,'TY'],
  255. ['2015/11/08',21,'SS'],['2015/11/09',25,'SS'],['2015/11/10',27,'SS'],
  256. ['2015/11/11',23,'SS'],['2015/11/12',24,'SS'],['2015/11/13',21,'SS'],
  257. ['2015/11/14',35,'SS'],['2015/11/15',39,'SS'],['2015/11/16',40,'SS'],
  258. ['2015/11/17',36,'SS'],['2015/11/18',33,'SS'],['2015/11/19',43,'SS'],
  259. ['2015/11/20',40,'SS'],['2015/11/21',34,'SS'],['2015/11/22',28,'SS'],
  260. // ['2015/11/23',26,'SS'],['2015/11/24',37,'SS'],['2015/11/25',41,'SS'],
  261. // ['2015/11/26',46,'SS'],['2015/11/27',47,'SS'],['2015/11/28',41,'SS'],
  262. // ['2015/11/08',10,'QG'],['2015/11/09',15,'QG'],['2015/11/10',35,'QG'],
  263. // ['2015/11/11',38,'QG'],['2015/11/12',22,'QG'],['2015/11/13',16,'QG'],
  264. ['2015/11/14',7,'QG'],['2015/11/15',2,'QG'],['2015/11/16',17,'QG'],
  265. ['2015/11/17',33,'QG'],['2015/11/18',40,'QG'],['2015/11/19',32,'QG'],
  266. ['2015/11/20',26,'QG'],['2015/11/21',35,'QG'],['2015/11/22',40,'QG'],
  267. ['2015/11/23',32,'QG'],['2015/11/24',26,'QG'],['2015/11/25',22,'QG'],
  268. ['2015/11/26',16,'QG'],['2015/11/27',22,'QG'],['2015/11/28',10,'QG'],
  269. ['2015/11/08',10,'SY'],['2015/11/09',15,'SY'],['2015/11/10',35,'SY'],
  270. ['2015/11/11',38,'SY'],['2015/11/12',22,'SY'],['2015/11/13',16,'SY'],
  271. ['2015/11/14',7,'SY'],['2015/11/15',2,'SY'],['2015/11/16',17,'SY'],
  272. ['2015/11/17',33,'SY'],['2015/11/18',40,'SY'],['2015/11/19',32,'SY'],
  273. ['2015/11/20',26,'SY'],['2015/11/21',35,'SY'],['2015/11/22',4,'SY'],
  274. ['2015/11/23',32,'SY'],['2015/11/24',26,'SY'],['2015/11/25',22,'SY'],
  275. ['2015/11/26',16,'SY'],['2015/11/27',22,'SY'],['2015/11/28',10,'SY'],
  276. ['2015/11/08',10,'DD'],['2015/11/09',15,'DD'],['2015/11/10',35,'DD'],
  277. ['2015/11/11',38,'DD'],['2015/11/12',22,'DD'],['2015/11/13',16,'DD'],
  278. ['2015/11/14',7,'DD'],['2015/11/15',2,'DD'],['2015/11/16',17,'DD'],
  279. ['2015/11/17',33,'DD'],['2015/11/18',4,'DD'],['2015/11/19',32,'DD'],
  280. ['2015/11/20',26,'DD'],['2015/11/21',35,'DD'],['2015/11/22',40,'DD'],
  281. ['2015/11/23',32,'DD'],['2015/11/24',26,'DD'],['2015/11/25',22,'DD'],
  282. ['2015/11/26',16,'DD'],['2015/11/27',22,'DD'],['2015/11/28',10,'DD']]
  283. }
  284. ]
  285. };
  286. createChart('themeRiver', echarts, option, 500);
  287. });
  288. </script>
  289. <script>
  290. require([
  291. 'echarts'
  292. // 'echarts/chart/line',
  293. // 'echarts/component/legend',
  294. // 'echarts/component/grid',
  295. // 'echarts/component/tooltip',
  296. // 'echarts/component/dataZoom',
  297. // 'echarts/component/toolbox',
  298. // 'zrender/vml/vml'
  299. ], function (echarts) {
  300. var base = +new Date(1968, 9, 3);
  301. var oneDay = 24 * 3600 * 1000;
  302. var date = [];
  303. var data = [Math.random() * 300];
  304. for (var i = 1; i < 200; i++) {
  305. var now = new Date(base += oneDay);
  306. date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'));
  307. data.push(Math.round((Math.random() - 0.5) * 20 + data[i - 1]));
  308. }
  309. option = {
  310. animation: false,
  311. title: {
  312. left: 'center',
  313. text: '触屏 tooltip 和 dataZoom 示例',
  314. subtext: '"tootip" and "dataZoom" on mobile device',
  315. },
  316. legend: {
  317. top: 'bottom',
  318. data:['意向']
  319. },
  320. tooltip: {
  321. triggerOn: 'none',
  322. position: function (pt) {
  323. return [pt[0], 100];
  324. }
  325. },
  326. toolbox: {
  327. left: 'center',
  328. top: 10,
  329. itemSize: 40,
  330. feature: {
  331. myMerge: {
  332. show: true,
  333. title: 'setOption in NOT merge mode',
  334. icon: 'path://M432.45,595.444c0,2.177-4.661,6.82-11.305,6.82c-6.475,0-11.306-4.567-11.306-6.82s4.852-6.812,11.306-6.812C427.841,588.632,432.452,593.191,432.45,595.444L432.45,595.444z M421.155,589.876c-3.009,0-5.448,2.495-5.448,5.572s2.439,5.572,5.448,5.572c3.01,0,5.449-2.495,5.449-5.572C426.604,592.371,424.165,589.876,421.155,589.876L421.155,589.876z M421.146,591.891c-1.916,0-3.47,1.589-3.47,3.549c0,1.959,1.554,3.548,3.47,3.548s3.469-1.589,3.469-3.548C424.614,593.479,423.062,591.891,421.146,591.891L421.146,591.891zM421.146,591.891',
  335. onclick: function () {
  336. chart.setOption(option, true);
  337. }
  338. }
  339. }
  340. },
  341. xAxis: {
  342. type: 'category',
  343. boundaryGap: false,
  344. axisPointer: {
  345. lineStyle: {
  346. color: '#215F5A',
  347. width: 2
  348. },
  349. label: {
  350. show: true
  351. },
  352. handle: {
  353. show: true
  354. }
  355. },
  356. data: date
  357. },
  358. yAxis: {
  359. type: 'value',
  360. boundaryGap: [0, '100%']
  361. },
  362. grid: {
  363. top: 70,
  364. left: 20,
  365. right: 30,
  366. containLabel: true,
  367. height: 150
  368. },
  369. dataZoom: [{
  370. type: 'inside',
  371. start: 0,
  372. end: 10
  373. }],
  374. series: [
  375. {
  376. name:'模拟数据',
  377. type:'line',
  378. smooth:true,
  379. symbol: 'none',
  380. sampling: 'average',
  381. itemStyle: {
  382. normal: {
  383. color: '#8ec6ad'
  384. }
  385. },
  386. areaStyle: {
  387. normal: {
  388. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  389. offset: 0,
  390. color: '#8ec6ad'
  391. }, {
  392. offset: 1,
  393. color: '#ffe'
  394. }])
  395. }
  396. },
  397. data: data
  398. }
  399. ]
  400. };
  401. var chart = createChart('setOption-merge', echarts, option, 400);
  402. });
  403. </script>
  404. </body>
  405. </html>