test.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf8">
  6. <style type="text/css">
  7. html,body{height:100%;margin:0px;padding:0px;font-family:"微软雅黑";font-size:14px;}
  8. #allmap{height:100%;width:100%; margin:0 auto;}
  9. .optionpanel{margin: 10px auto;}
  10. #r-result{ margin:0 auto; width:500px; position: absolute; top:0px;}
  11. .anchorBL {display:none;}
  12. img
  13. {
  14. opacity:0.85;
  15. }
  16. </style>
  17. <title>个性底图设置模板Demo页</title>
  18. <script src="echarts.min.js"></script>
  19. <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
  20. </head>
  21. <body>
  22. <div id="main" style="width: 600px;height:400px;"></div>
  23. </body>
  24. </html>
  25. <script type="text/javascript">
  26. // 基于准备好的dom,初始化echarts实例
  27. var myChart = echarts.init(document.getElementById('main'));
  28. // 指定图表的配置项和数据
  29. $.get('data-1469156830975-S1PyA-yO.json', function (data) {
  30. myChart.setOption(option = {
  31. title: {
  32. text: 'Beijing AQI'
  33. },
  34. tooltip: {
  35. trigger: 'axis'
  36. },
  37. xAxis: {
  38. data: data.map(function (item) {
  39. return item[0];
  40. })
  41. },
  42. yAxis: {
  43. splitLine: {
  44. show: false
  45. }
  46. },
  47. toolbox: {
  48. left: 'center',
  49. feature: {
  50. dataZoom: {
  51. yAxisIndex: 'none'
  52. },
  53. restore: {},
  54. saveAsImage: {}
  55. }
  56. },
  57. dataZoom: [{
  58. startValue: '2014-06-01'
  59. }, {
  60. type: 'inside'
  61. }],
  62. visualMap: {
  63. top: 10,
  64. right: 10,
  65. pieces: [{
  66. gt: 0,
  67. lte: 50,
  68. color: '#096'
  69. }, {
  70. gt: 50,
  71. lte: 100,
  72. color: '#ffde33'
  73. }, {
  74. gt: 100,
  75. lte: 150,
  76. color: '#ff9933'
  77. }, {
  78. gt: 150,
  79. lte: 200,
  80. color: '#cc0033'
  81. }, {
  82. gt: 200,
  83. lte: 300,
  84. color: '#660099'
  85. }, {
  86. gt: 300,
  87. color: '#7e0023'
  88. }],
  89. outOfRange: {
  90. color: '#999'
  91. }
  92. },
  93. series: {
  94. name: 'Beijing AQI',
  95. type: 'line',
  96. data: data.map(function (item) {
  97. return item[1];
  98. }),
  99. markLine: {
  100. silent: true,
  101. data: [{
  102. yAxis: 50
  103. }, {
  104. yAxis: 100
  105. }, {
  106. yAxis: 150
  107. }, {
  108. yAxis: 200
  109. }, {
  110. yAxis: 300
  111. }]
  112. }
  113. }
  114. });
  115. });
  116. </script>