dataset-pivot.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <script src="lib/esl.js"></script>
  6. <script src="lib/config.js"></script>
  7. <script src="lib/testHelper.js"></script>
  8. <script src="lib/jquery.min.js"></script>
  9. <meta name="viewport" content="width=device-width, initial-scale=1" />
  10. <link rel="stylesheet" href="lib/reset.css" />
  11. </head>
  12. <body>
  13. <style>
  14. .test-title {
  15. background: rgb(0, 112, 6);
  16. color: #fff;
  17. }
  18. </style>
  19. <div id="layout0"></div>
  20. <script>
  21. var arrayRows0 = [
  22. ['product', '2015', '2016', '2017'],
  23. ['Matcha Latte', 43.3, 85.8, 93.7],
  24. ['Milk Tea', 83.1, 73.4, 55.1],
  25. ['Cheese Cocoa', 86.4, 65.2, 82.5],
  26. ['Walnut Brownie', 72.4, 53.9, 39.1]
  27. ];
  28. var arrayRows1 = [
  29. ['product', '2012', '2013', '2014', '2015', '2016', '2017'],
  30. ['Matcha Latte', 41.1, 30.4, 65.1, 53.3, 83.8, 98.7],
  31. ['Milk Tea', 86.5, 92.1, 85.7, 83.1, 73.4, 55.1],
  32. ['Cheese Cocoa', 24.1, 67.2, 79.5, 86.4, 65.2, 82.5],
  33. ['Walnut Brownie', 55.2, 67.1, 69.2, 72.4, 53.9, 39.1]
  34. ];
  35. function loadLifeData(cb) {
  36. $.getJSON('data/life-expectancy-table.json', function (data) {
  37. cb(data);
  38. })
  39. }
  40. </script>
  41. <script>
  42. require(['echarts'], function (echarts) {
  43. loadLifeData(function (data) {
  44. var sizeValue = '57%';
  45. var option = {
  46. legend: {},
  47. tooltip: {},
  48. toolbox: {
  49. feature: {
  50. dataZoom: {}
  51. }
  52. },
  53. grid: [
  54. {right: sizeValue, bottom: sizeValue},
  55. {left: sizeValue, bottom: sizeValue},
  56. {right: sizeValue, top: sizeValue},
  57. {left: sizeValue, top: sizeValue}
  58. ],
  59. xAxis: [
  60. {type: 'value', gridIndex: 0, name: 'Income'},
  61. {type: 'category', gridIndex: 1, name: 'Country', boundaryGap: false, axisLabel: {rotate: 50, interval: 0}},
  62. {type: 'category', gridIndex: 2, name: 'Year', boundaryGap: false},
  63. {type: 'category', gridIndex: 3, name: 'Country', boundaryGap: false, axisLabel: {rotate: 50, interval: 0}}
  64. ],
  65. yAxis: [
  66. {type: 'value', gridIndex: 0, name: 'Life Expectency'},
  67. {type: 'value', gridIndex: 1, name: 'Income'},
  68. {type: 'value', gridIndex: 2, name: 'Population'},
  69. {type: 'category', gridIndex: 3, name: 'Year', boundaryGap: false}
  70. ],
  71. dataset: {
  72. source: data
  73. },
  74. series: [
  75. {
  76. type: 'scatter',
  77. symbolSize: 3,
  78. xAxisIndex: 0,
  79. yAxisIndex: 0,
  80. encode: {
  81. x: 'Income',
  82. y: 'Life Expectency'
  83. }
  84. },
  85. {
  86. type: 'scatter',
  87. symbolSize: 3,
  88. xAxisIndex: 1,
  89. yAxisIndex: 1,
  90. encode: {
  91. x: 'Country',
  92. y: 'Income'
  93. }
  94. },
  95. {
  96. type: 'scatter',
  97. symbolSize: 3,
  98. xAxisIndex: 2,
  99. yAxisIndex: 2,
  100. encode: {
  101. x: 'Year',
  102. y: 'Population'
  103. }
  104. },
  105. {
  106. type: 'scatter',
  107. symbolSize: 3,
  108. xAxisIndex: 3,
  109. yAxisIndex: 3,
  110. encode: {
  111. x: 'Country',
  112. y: 'Year'
  113. }
  114. }
  115. ]
  116. };
  117. testHelper.create(echarts, 'layout0', {
  118. option: option,
  119. height: 700,
  120. dataTable: data
  121. });
  122. });
  123. });
  124. </script>
  125. </body>
  126. </html>