sunburst-visualMap.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="lib/esl.js"></script>
  5. <script src="lib/config.js"></script>
  6. </head>
  7. <body>
  8. <style>
  9. html, body, #main {
  10. width: 100%;
  11. height: 100%;
  12. /* background-image: url(old_mathematics.png); */
  13. /* background-repeat: repeat; */
  14. }
  15. </style>
  16. <div id="main"></div>
  17. <script>
  18. var chart;
  19. require([
  20. 'echarts'
  21. ], function (echarts) {
  22. chart = echarts.init(document.getElementById('main'), null, {
  23. // renderer: 'svg'
  24. });
  25. var data = [{
  26. name: 'Grandpa',
  27. children: [{
  28. name: 'Uncle Leo',
  29. value: 15,
  30. children: [{
  31. name: 'Cousin Jack',
  32. value: 2
  33. }, {
  34. name: 'Cousin Mary',
  35. value: 5,
  36. children: [{
  37. name: 'Jackson',
  38. value: 2
  39. }]
  40. }, {
  41. name: 'Cousin Ben',
  42. value: 4
  43. }]
  44. }, {
  45. name: 'Aunt Jane',
  46. children: [{
  47. name: 'Cousin Kate',
  48. value: 4
  49. }]
  50. }, {
  51. name: 'Father',
  52. value: 10,
  53. children: [{
  54. name: 'Me',
  55. value: 5,
  56. itemStyle: {
  57. color: 'red'
  58. }
  59. }, {
  60. name: 'Brother Peter',
  61. value: 1
  62. }]
  63. }]
  64. }, {
  65. name: 'Mike',
  66. children: [{
  67. name: 'Uncle Dan',
  68. children: [{
  69. name: 'Cousin Lucy',
  70. value: 3
  71. }, {
  72. name: 'Cousin Luck',
  73. value: 4,
  74. children: [{
  75. name: 'Nephew',
  76. value: 2
  77. }]
  78. }]
  79. }]
  80. }, {
  81. name: 'Nancy',
  82. children: [{
  83. name: 'Uncle Nike',
  84. children: [{
  85. name: 'Cousin Betty',
  86. value: 1
  87. }, {
  88. name: 'Cousin Jenny',
  89. value: 2
  90. }]
  91. }]
  92. }];
  93. chart.setOption({
  94. visualMap: {
  95. type: 'continuous',
  96. min: 0,
  97. max: 10,
  98. inRange: {
  99. color: ['#2D5F73', '#538EA6', '#F2D1B3', '#F2B8A2', '#F28C8C']
  100. }
  101. },
  102. series: {
  103. type: 'sunburst',
  104. data: data,
  105. radius: [0, '90%'],
  106. label: {
  107. rotate: 'radial'
  108. }
  109. }
  110. });
  111. setTimeout(function () {
  112. chart.dispatchAction({
  113. type: 'sunburstHighlight',
  114. targetNodeId: 'Cousin Jenny'
  115. });
  116. }, 3000);
  117. setTimeout(function () {
  118. chart.dispatchAction({
  119. type: 'sunburstUnhighlight'
  120. });
  121. }, 5000);
  122. });
  123. </script>
  124. </body>
  125. </html>