map-labels.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!DOCTYPE>
  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/jquery.min.js"></script>
  8. <script src="lib/facePrint.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. body {
  15. }
  16. #main {
  17. height: 600px;
  18. }
  19. </style>
  20. <div id="main"></div>
  21. <script>
  22. var echarts;
  23. var colorTool;
  24. var chart;
  25. var myChart;
  26. var groupCategories = [];
  27. var groupColors = [];
  28. require([
  29. 'echarts'
  30. // 'zrender/tool/color',
  31. // 'echarts/chart/line',
  32. // 'echarts/chart/map',
  33. // 'echarts/component/title',
  34. // 'echarts/component/geo',
  35. // 'echarts/component/legend',
  36. // 'echarts/component/tooltip',
  37. // 'echarts/component/toolbox',
  38. // 'echarts/component/visualMap'
  39. ], function (ec, ct) {
  40. echarts = ec;
  41. colorTool = echarts.color;
  42. chart = myChart = echarts.init(document.getElementById('main'));
  43. $.get('../map/json/world.json', function (worldJson) {
  44. echarts.registerMap('world', worldJson);
  45. option = {
  46. title: {
  47. text: 'Test hover link\nCheck highlights and label positions',
  48. subtext: 'Each colony is a region.\nLabel should not be in the ocean.'
  49. },
  50. visualMap: {
  51. type: 'piecewise',
  52. dimension: 1,
  53. orient: 'vertical',
  54. top: 120,
  55. left: 0,
  56. categories: [
  57. 'China', 'France', 'United Kingdom',
  58. 'Netherlands', 'Denmark', 'Portugal', 'Spain'
  59. ],
  60. inRange: {
  61. color: {
  62. 'China': '#943382',
  63. 'France': '#2196f3',
  64. 'United Kingdom': '#e91e63',
  65. 'Netherlands': '#341290',
  66. 'Denmark': '#e1648f',
  67. 'Portugal': '#498121',
  68. 'Spain': '#a41933'
  69. }
  70. }
  71. },
  72. series: [
  73. {
  74. map: 'world',
  75. name: 'France',
  76. type: 'map',
  77. roam: true,
  78. left: 130,
  79. data: [
  80. {
  81. name: 'China',
  82. value: [6, 'China']
  83. },
  84. {
  85. name: 'France',
  86. value: [6, 'France']
  87. },
  88. {
  89. name: 'United Kingdom',
  90. value: [5, 'United Kingdom']
  91. },
  92. {
  93. name: 'Netherlands',
  94. value: [5, 'Netherlands']
  95. },
  96. {
  97. name: 'Denmark',
  98. value: [5, 'Denmark']
  99. },
  100. {
  101. name: 'Portugal',
  102. value: [5, 'Portugal']
  103. },
  104. {
  105. name: 'Spain',
  106. value: [5, 'Spain']
  107. }
  108. ]
  109. }
  110. ]
  111. }
  112. chart.setOption(option);
  113. });
  114. });
  115. </script>
  116. </body>
  117. </html>