sankey.html 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1" />
  5. <script src="esl.js"></script>
  6. <script src="config.js"></script>
  7. <script src="config.js"></script>
  8. <script src="lib/jquery.min.js"></script>
  9. </head>
  10. <body>
  11. <style>
  12. html, body, #main {
  13. width: 100%;
  14. height: 90%;
  15. /*border: 1px solid #000;*/
  16. }
  17. </style>
  18. <div id="main"><div>
  19. <script>
  20. require([
  21. 'echarts',
  22. 'echarts/chart/sankey',
  23. 'echarts/component/tooltip'
  24. ], function (echarts) {
  25. var chart = echarts.init(document.getElementById('main'), null, {
  26. renderer: 'canvas'
  27. });
  28. window.onresize = function () {
  29. chart.resize();
  30. };
  31. chart.on('click', function (params) {
  32. console.log(params, params.data);
  33. });
  34. $.getJSON('./data/energy.json')
  35. .done(function(data) {
  36. data.nodes[0].itemStyle = {
  37. normal: {
  38. color: 'red'
  39. }
  40. };
  41. chart.setOption({
  42. tooltip: {
  43. trigger: 'item',
  44. triggerOn: 'mousemove'
  45. },
  46. animation: false,
  47. series: [
  48. {
  49. type: 'sankey',
  50. layout:'none',
  51. data: data.nodes,
  52. links: data.links,
  53. lineStyle: {
  54. normal: {
  55. color: 'source',
  56. curveness: 0.5
  57. }
  58. }
  59. }
  60. ]
  61. });
  62. });
  63. });
  64. </script>
  65. </body>
  66. </html>