sankey.html 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. chart.setOption({
  37. tooltip: {
  38. trigger: 'item',
  39. triggerOn: 'mousemove'
  40. },
  41. series: [
  42. {
  43. type: 'sankey',
  44. layout:'none',
  45. data: data.nodes,
  46. links: data.links,
  47. lineStyle: {
  48. normal: {
  49. curveness: 0.5
  50. }
  51. }
  52. }
  53. ]
  54. });
  55. });
  56. });
  57. </script>
  58. </body>
  59. </html>