You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

352 lines
13 KiB

  1. var myChart = echarts.init(document.getElementById('main'));
  2. function mapTooltipClick(name) {
  3. alert(name)
  4. }
  5. function tooltipCharts() {
  6. console.log(arguments[0]);
  7. var myChart = echarts.init(document.getElementById('tooltipBarId'));
  8. var option = {
  9. tooltip: {},
  10. dataset: {
  11. source: [
  12. ['xAxis', '201701', '201702', '201703', '201704', '201705', '201706', '201707', '201708', '201709', '20170', '201710', '20170', '201801'],
  13. ['amount', 41.1, 30.4, 65.1, 53.3, 83.8, 98.7, 65.1, 53.3, 41.1, 30.4, 53.3, 41.1, 53.3, 83.8]
  14. ]
  15. },
  16. xAxis: {
  17. type: 'category',
  18. interval: true,
  19. axisLabel: {
  20. rotate: 45
  21. },
  22. axisTick: {
  23. show: false
  24. }
  25. },
  26. yAxis: {},
  27. color: ['#4FA8F9', '#F5A623'],
  28. grid: {
  29. show: true,
  30. backgroundColor: '#FAFAFA',
  31. left: 30,
  32. right: 20,
  33. top: 20
  34. },
  35. series: [{
  36. type: 'bar',
  37. smooth: true,
  38. seriesLayoutBy: 'row',
  39. barWidth: 10
  40. }]
  41. };
  42. myChart.setOption(option);
  43. }
  44. option = {
  45. visualMap: {
  46. min: 0,
  47. max: 1000,
  48. left: 'left',
  49. top: 'bottom',
  50. text: ['高', '低'],
  51. calculable: false,
  52. orient: 'horizontal',
  53. inRange: {
  54. color: ['#e0ffff', '#006edd'],
  55. symbolSize: [30, 100]
  56. }
  57. },
  58. tooltip: {
  59. padding: 0,
  60. enterable: true,
  61. transitionDuration: 1,
  62. textStyle: {
  63. color: '#000',
  64. decoration: 'none',
  65. },
  66. // position: function (point, params, dom, rect, size) {
  67. // return [point[0], point[1]];
  68. // },
  69. formatter: function(params) {
  70. // console.log(params)
  71. var tipHtml = '';
  72. tipHtml = '<div style="height:360px;width:400px;border-radius:5px;background:#fff;box-shadow:0 0 10px 5px #aaa">' +
  73. ' <div style="height:50px;width:100%;border-radius:5px;background:#F8F9F9;border-bottom:1px solid #F0F0F0">' +
  74. ' <span style="line-height:50px;margin-left:18px">' + params.name + '</span>' +
  75. ' <span style="float:right;line-height:50px;margin-right:18px;color:#5396E3;cursor:pointer" onclick="mapTooltipClick(this);">点击查看详情</span>' +
  76. ' </div>' +
  77. ' <div style="height:110px;width:100%;background:#fff">' +
  78. ' <div style="padding-left:18px;padding-top:22px">' +
  79. ' <span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:rgba(92,169,235,1)"></span> ' +
  80. ' <span>上传表格数量</span>' +
  81. ' <span style="float:right;margin-right:18px">' + params.data.tipData[0] + '万</span>' +
  82. ' </div>' +
  83. ' <div style="padding-left:18px;padding-top:14px">' +
  84. ' <span style="display:inline-block;margin-right:5px;width:10px;height:10px;background-color:rgba(92,169,235,1)"></span> ' +
  85. ' <span>上传数据条数</span>' +
  86. ' <span style="float:right;margin-right:18px">' + params.data.tipData[1] + '条</span>' +
  87. ' </div>' +
  88. ' </div>' +
  89. ' <div id="tooltipBarId" style="height:200px;width:100%;border-radius:0 0 5px 0;background:#fff"></div>' +
  90. '</div>';
  91. setTimeout(function() {
  92. tooltipCharts(params.name);
  93. }, 10);
  94. return tipHtml;
  95. }
  96. },
  97. series: [{
  98. name: 'iphone4',
  99. type: 'map',
  100. mapType: 'china',
  101. itemStyle: {
  102. normal: {
  103. label: {
  104. show: true
  105. }
  106. },
  107. emphasis: {
  108. label: {
  109. show: true
  110. }
  111. }
  112. },
  113. data: [{
  114. name: '北京',
  115. value: Math.round(Math.random() * 1000),
  116. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  117. },
  118. {
  119. name: '天津',
  120. value: Math.round(Math.random() * 1000),
  121. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  122. },
  123. {
  124. name: '上海',
  125. value: Math.round(Math.random() * 1000),
  126. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  127. },
  128. {
  129. name: '重庆',
  130. value: Math.round(Math.random() * 1000),
  131. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  132. },
  133. {
  134. name: '河北',
  135. value: Math.round(Math.random() * 1000),
  136. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  137. },
  138. {
  139. name: '河南',
  140. value: Math.round(Math.random() * 1000),
  141. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  142. },
  143. {
  144. name: '云南',
  145. value: Math.round(Math.random() * 1000),
  146. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  147. },
  148. {
  149. name: '辽宁',
  150. value: Math.round(Math.random() * 1000),
  151. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  152. },
  153. {
  154. name: '黑龙江',
  155. value: Math.round(Math.random() * 1000),
  156. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  157. },
  158. {
  159. name: '湖南',
  160. value: Math.round(Math.random() * 1000),
  161. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  162. },
  163. {
  164. name: '安徽',
  165. value: Math.round(Math.random() * 1000),
  166. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  167. },
  168. {
  169. name: '山东',
  170. value: Math.round(Math.random() * 1000),
  171. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  172. },
  173. {
  174. name: '新疆',
  175. value: Math.round(Math.random() * 1000),
  176. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  177. },
  178. {
  179. name: '江苏',
  180. value: Math.round(Math.random() * 1000),
  181. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  182. },
  183. {
  184. name: '浙江',
  185. value: Math.round(Math.random() * 1000),
  186. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  187. },
  188. {
  189. name: '江西',
  190. value: Math.round(Math.random() * 1000),
  191. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  192. },
  193. {
  194. name: '湖北',
  195. value: Math.round(Math.random() * 1000),
  196. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  197. },
  198. {
  199. name: '广西',
  200. value: Math.round(Math.random() * 1000),
  201. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  202. },
  203. {
  204. name: '甘肃',
  205. value: Math.round(Math.random() * 1000),
  206. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  207. },
  208. {
  209. name: '山西',
  210. value: Math.round(Math.random() * 1000),
  211. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  212. },
  213. {
  214. name: '内蒙古',
  215. value: Math.round(Math.random() * 1000),
  216. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  217. },
  218. {
  219. name: '陕西',
  220. value: Math.round(Math.random() * 1000),
  221. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  222. },
  223. {
  224. name: '吉林',
  225. value: Math.round(Math.random() * 1000),
  226. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  227. },
  228. {
  229. name: '福建',
  230. value: Math.round(Math.random() * 1000),
  231. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  232. },
  233. {
  234. name: '贵州',
  235. value: Math.round(Math.random() * 1000),
  236. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  237. },
  238. {
  239. name: '广东',
  240. value: Math.round(Math.random() * 1000),
  241. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  242. },
  243. {
  244. name: '青海',
  245. value: Math.round(Math.random() * 1000),
  246. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  247. },
  248. {
  249. name: '西藏',
  250. value: Math.round(Math.random() * 1000),
  251. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  252. },
  253. {
  254. name: '四川',
  255. value: Math.round(Math.random() * 1000),
  256. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  257. },
  258. {
  259. name: '宁夏',
  260. value: Math.round(Math.random() * 1000),
  261. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  262. },
  263. {
  264. name: '海南',
  265. value: Math.round(Math.random() * 1000),
  266. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  267. },
  268. {
  269. name: '台湾',
  270. value: Math.round(Math.random() * 1000),
  271. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  272. },
  273. {
  274. name: '香港',
  275. value: Math.round(Math.random() * 1000),
  276. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  277. },
  278. {
  279. name: '澳门',
  280. value: Math.round(Math.random() * 1000),
  281. tipData: [Math.round(Math.random() * 1000), Math.round(Math.random() * 1000)]
  282. },
  283. ]
  284. }, ]
  285. }
  286. //var count = 0;
  287. //var timeTicket = null;
  288. //var dataLength = option.series[0].data.length;
  289. //timeTicket && clearInterval(timeTicket);
  290. //timeTicket = setInterval(function() {
  291. // myChart.dispatchAction({
  292. // type: 'downplay',
  293. // seriesIndex: 0,
  294. // });
  295. // myChart.dispatchAction({
  296. // type: 'highlight',
  297. // seriesIndex: 0,
  298. // dataIndex: (count) % dataLength
  299. // });
  300. // myChart.dispatchAction({
  301. // type: 'showTip',
  302. // seriesIndex: 0,
  303. // dataIndex: (count) % dataLength
  304. // });
  305. // count++;
  306. //}, 1000);
  307. //
  308. //myChart.on('mouseover', function(params) {
  309. // console.log(params)
  310. // clearInterval(timeTicket);
  311. // myChart.dispatchAction({
  312. // type: 'downplay',
  313. // seriesIndex: 0
  314. // });
  315. // myChart.dispatchAction({
  316. // type: 'highlight',
  317. // seriesIndex: 0,
  318. // dataIndex: params.dataIndex
  319. // });
  320. // myChart.dispatchAction({
  321. // type: 'showTip',
  322. // seriesIndex: 0,
  323. // dataIndex: params.dataIndex,
  324. // });
  325. //});
  326. //myChart.on('mouseout', function(params) {
  327. // timeTicket && clearInterval(timeTicket);
  328. // timeTicket = setInterval(function() {
  329. // myChart.dispatchAction({
  330. // type: 'downplay',
  331. // seriesIndex: 0,
  332. // });
  333. // myChart.dispatchAction({
  334. // type: 'highlight',
  335. // seriesIndex: 0,
  336. // dataIndex: (count) % dataLength
  337. // });
  338. // myChart.dispatchAction({
  339. // type: 'showTip',
  340. // seriesIndex: 0,
  341. // dataIndex: (count) % dataLength
  342. // });
  343. // count++;
  344. // }, 1000);
  345. //});
  346. // 使用刚指定的配置项和数据显示图表。
  347. myChart.setOption(option);