graph-grid.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. </head>
  8. <body>
  9. <style>
  10. html, body, #main {
  11. width: 100%;
  12. height: 100%;
  13. margin: 0;
  14. }
  15. </style>
  16. <div id="main"></div>
  17. <script>
  18. require([
  19. 'echarts',
  20. // 'echarts/component/grid',
  21. // 'echarts/chart/graph',
  22. // 'echarts/component/title',
  23. // 'echarts/component/legend',
  24. // 'echarts/component/tooltip',
  25. // 'echarts/component/toolbox',
  26. // 'echarts/component/dataZoomInside',
  27. // 'zrender/vml/vml',
  28. 'theme/vintage'
  29. ], function (echarts) {
  30. var chart = echarts.init(document.getElementById('main'), 'vintage');
  31. var axisData = ['周一','周二','周三','很长很长的周四','应为系列色边框(auto)的周五','周六','周日'];
  32. var data = axisData.map(function (item, i) {
  33. var val = Math.round(Math.random() * 1000 * (i + 1))
  34. return i !== 4
  35. ? val
  36. : {
  37. value: val,
  38. label: {
  39. normal: {
  40. borderColor: 'auto',
  41. borderWidth: 1,
  42. padding: 5,
  43. position: 'top'
  44. }
  45. }
  46. };
  47. });
  48. var links = data.map(function (item, i) {
  49. return {
  50. source: i,
  51. target: i + 1
  52. };
  53. });
  54. links.pop();
  55. var option = {
  56. tooltip: {},
  57. xAxis: {
  58. type : 'category',
  59. boundaryGap : false,
  60. data : axisData
  61. },
  62. yAxis: {
  63. type : 'value'
  64. },
  65. toolbox: {
  66. feature: {
  67. dataZoom: {
  68. yAxisIndex: false
  69. }
  70. }
  71. },
  72. dataZoom: {
  73. type: 'inside'
  74. },
  75. series: [
  76. {
  77. type: 'graph',
  78. layout: 'none',
  79. coordinateSystem: 'cartesian2d',
  80. symbolSize: 40,
  81. label: {
  82. normal: {
  83. show: true
  84. }
  85. },
  86. edgeSymbol: ['circle', 'arrow'],
  87. edgeSymbolSize: [4, 10],
  88. data: data,
  89. links: links
  90. }
  91. ]
  92. };
  93. chart.setOption(option);
  94. });
  95. </script>
  96. </body>
  97. </html>