singleAxisScales.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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/jquery.min.js"></script>
  7. <meta name="viewport" content="width=device-width, initial-scale=1" />
  8. <link rel="stylesheet" href="lib/reset.css">
  9. </head>
  10. <body>
  11. <style>
  12. </style>
  13. <div id="main"></div>
  14. <script>
  15. var echarts;
  16. var colorTool;
  17. var chart;
  18. var myChart;
  19. var groupCategories = [];
  20. var groupColors = [];
  21. require([
  22. 'echarts'
  23. // 'zrender/tool/color',
  24. // 'echarts/chart/scatter',
  25. // 'echarts/chart/graph',
  26. // 'echarts/component/singleAxis',
  27. // 'echarts/component/tooltip',
  28. // 'echarts/component/toolbox',
  29. // 'echarts/component/dataZoom',
  30. // 'echarts/component/visualMap'
  31. ], function (ec) {
  32. echarts = ec;
  33. colorTool = echarts.color;
  34. var myChart = echarts.init(document.getElementById('main'));
  35. var xAxisData = [
  36. 'Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo', 'Libra',
  37. 'Scorpio', 'Sagittarius', 'Capricornus', 'Aquarius', 'Pisces'
  38. ];
  39. var data0 = [];
  40. var data1 = [];
  41. var data2 = [];
  42. var data3 = [];
  43. for (var i = 0; i < xAxisData.length; i++) {
  44. data0.push([Math.random() * 100, Math.random() * 30]);
  45. data1.push(Math.random() * 30);
  46. data2.push([Math.random() * (i % 2 === 0 ? 100 : 1000000), Math.random() * 30]);
  47. data3.push([+new Date() + Math.round(Math.random() * 3600 * 24 * 30), Math.random() * 30]);
  48. }
  49. var height = '18%';
  50. myChart.setOption({
  51. backgroundColor: '#fff',
  52. tooltip: {
  53. trigger: 'axis'
  54. },
  55. dataZoom: [{
  56. type: 'inside',
  57. singleAxisIndex: [0]
  58. }, {
  59. type: 'inside',
  60. singleAxisIndex: [1]
  61. }, {
  62. type: 'inside',
  63. singleAxisIndex: [2]
  64. }, {
  65. type: 'inside',
  66. singleAxisIndex: [3]
  67. }],
  68. singleAxis: [{
  69. type: 'value',
  70. id: 'a',
  71. height: height
  72. }, {
  73. type: 'category',
  74. id: 'b',
  75. data: xAxisData,
  76. height: height,
  77. axisPointer: {
  78. type: 'shadow'
  79. },
  80. top: '27%'
  81. }, {
  82. type: 'log',
  83. id: 'c',
  84. height: height,
  85. axisPointer: {
  86. snap: false,
  87. label: {
  88. show: true
  89. }
  90. },
  91. top: '55%'
  92. }, {
  93. type: 'time',
  94. id: 'd',
  95. height: height,
  96. top: '77%'
  97. }],
  98. series: [{
  99. type: 'scatter',
  100. coordinateSystem: 'singleAxis',
  101. singleAxisId: 'a',
  102. symbolSize: function (val) {
  103. return val[1];
  104. },
  105. data: data0
  106. }, {
  107. type: 'scatter',
  108. coordinateSystem: 'singleAxis',
  109. singleAxisId: 'b',
  110. symbolSize: function (val) {
  111. return val;
  112. },
  113. data: data1
  114. }, {
  115. type: 'scatter',
  116. coordinateSystem: 'singleAxis',
  117. singleAxisId: 'c',
  118. symbolSize: function (val) {
  119. return val[1];
  120. },
  121. data: data2
  122. }, {
  123. type: 'scatter',
  124. coordinateSystem: 'singleAxis',
  125. singleAxisId: 'd',
  126. symbolSize: function (val) {
  127. return val[1];
  128. },
  129. data: data3
  130. }]
  131. });
  132. });
  133. </script>
  134. </body>
  135. </html>