label-position.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <!DOCTYPE>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <script src="lib/esl.js"></script>
  7. <script src="lib/config.js"></script>
  8. <script src="lib/jquery.min.js"></script>
  9. <script src="lib/facePrint.js"></script>
  10. <script src="lib/testHelper.js"></script>
  11. <script src="lib/dat.gui.min.js"></script>
  12. <link rel="stylesheet" href="lib/reset.css">
  13. </head>
  14. <body>
  15. <style>
  16. h1 {
  17. line-height: 60px;
  18. height: 60px;
  19. background: #146402;
  20. text-align: center;
  21. font-weight: bold;
  22. color: #eee;
  23. font-size: 14px;
  24. }
  25. .chart {
  26. height: 500px;
  27. }
  28. </style>
  29. <div class="chart" id="main"></div>
  30. <script>
  31. var echarts;
  32. var chart;
  33. var myChart;
  34. var groupCategories = [];
  35. var groupColors = [];
  36. require([
  37. 'echarts'
  38. // 'echarts/chart/line',
  39. // 'echarts/chart/bar',
  40. // 'echarts/chart/pie',
  41. // 'echarts/chart/scatter',
  42. // 'echarts/chart/map',
  43. // 'echarts/chart/parallel',
  44. // 'echarts/chart/radar',
  45. // 'echarts/component/grid',
  46. // 'echarts/component/polar',
  47. // 'echarts/component/geo',
  48. // 'echarts/component/singleAxis',
  49. // 'echarts/component/legend',
  50. // 'echarts/component/tooltip',
  51. // 'echarts/component/toolbox',
  52. // 'echarts/component/visualMap',
  53. // 'echarts/component/dataZoom'
  54. ], function (ec) {
  55. echarts = ec;
  56. var posList = [
  57. 'left', 'right', 'top', 'bottom',
  58. 'inside',
  59. 'insideTop', 'insideLeft', 'insideRight', 'insideBottom',
  60. 'insideTopLeft', 'insideTopRight', 'insideBottomLeft', 'insideBottomRight'
  61. ];
  62. var config = {
  63. position: 'top',
  64. distance: 20
  65. };
  66. function update() {
  67. chart.setOption({
  68. series: {
  69. type: 'scatter',
  70. label: {
  71. normal: {
  72. position: config.position,
  73. distance: config.distance
  74. }
  75. }
  76. }
  77. });
  78. }
  79. var gui = new dat.GUI();
  80. gui.add(config, 'position', posList)
  81. .onChange(update);
  82. gui.add(config, 'distance', 0, 100)
  83. .onChange(update);
  84. option = {
  85. series: [
  86. {
  87. type: 'scatter',
  88. symbolSize: 160,
  89. symbol: 'roundRect',
  90. data: [[1, 1]],
  91. label: {
  92. normal: {
  93. position: config.position,
  94. distance: config.distance,
  95. show: true,
  96. formatter: [
  97. 'Label Text',
  98. ].join('\n'),
  99. backgroundColor: '#eee',
  100. borderColor: '#555',
  101. borderWidth: 2,
  102. borderRadius: 5,
  103. padding: 10,
  104. fontSize: 18,
  105. shadowBlur: 3,
  106. shadowColor: '#888',
  107. shadowOffsetX: 0,
  108. shadowOffsetY: 3,
  109. textBorderColor: '#000',
  110. textBorderWidth: 3,
  111. color: '#fff'
  112. }
  113. }
  114. }
  115. ],
  116. xAxis: {
  117. max: 2
  118. },
  119. yAxis: {
  120. max: 2
  121. }
  122. };
  123. var chart = testHelper.createChart(echarts, 'main', option);
  124. });
  125. </script>
  126. </body>
  127. </html>