report.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>ECharts</title>
  6. <!-- 引入 echarts.js -->
  7. <script src="/jc_data/static/lib/echarts.min.js" type="text/javascript"></script>
  8. <style>
  9. .clearfix{zoom:1} /*zooom 属性:IE 浏览器的专用属性。这一句是专门针对老版本的IE浏览器所写的,为了兼容*/
  10. .clearfix:after{ /* :after伪对象选择符---在这个对象被浏览器渲染后添加一定的内容*/
  11. content:"."; /*content属性:添加的内容即为这个属性的值。这个属性是专门与伪对象搭配使用的*/
  12. display: block; /*将添加进去的内容转换为块状元素*/
  13. visibility: hidden; /*visibility:可视化属性,控制元素是否可见,但无论是否隐藏都保留物理空间。{与display:none的比较}*/
  14. height: 0;/*将添加进去的内容高度设置为0,消除其占位*/
  15. clear: both;/*将添加进去的内容作为清除浮动的对象,实现外围容器中有内容存在,因此可以自动判定高度,解决塌陷*/
  16. }
  17. .label-link{
  18. color: blue;
  19. cursor: pointer;
  20. text-decoration: underline;
  21. }
  22. .label-link-select{
  23. color: red;
  24. cursor: pointer;
  25. text-decoration: underline;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
  31. <div class="wrap clearfix">
  32. <div style="float: left;">
  33. <div>
  34. {% for item in data.labels %}
  35. {% if item.id==data.selectedID1 %}
  36. <text class="label-link-select" onclick="click_label(1,{{item.id}})">{{item.name}}</text>
  37. {% else %}
  38. <text class="label-link" onclick="click_label(1,{{item.id}})">{{item.name}}</text>
  39. {% endif %}
  40. {% endfor %}
  41. </div>
  42. <div>
  43. {% if data.show2 %}
  44. {% for item in data.labels2 %}
  45. {% if item.id==data.selectedID2 %}
  46. <text class="label-link-select" onclick="click_label(2,{{item.id}})">{{item.name}}</text>
  47. {% else %}
  48. <text class="label-link" onclick="click_label(2,{{item.id}})">{{item.name}}</text>
  49. {% endif %}
  50. {% endfor %}
  51. {% endif %}
  52. </div>
  53. <div>
  54. {% if data.show3 %}
  55. {% for item in data.labels3 %}
  56. {% if item.id==data.selectedID3 %}
  57. <text class="label-link-select" onclick="click_label(3,{{item.id}})">{{item.name}}</text>
  58. {% else %}
  59. <text class="label-link" onclick="click_label(3,{{item.id}})">{{item.name}}</text>
  60. {% endif %}
  61. {% endfor %}
  62. {% endif %}
  63. </div>
  64. </div>
  65. <div style="float: right;">
  66. <div style="float: left;">日期:</div>
  67. <div style="float: right;">
  68. <input type="date" id="date-start" value="{{data.date_start}}"/>~<input type="date" id="date-end" value="{{data.date_end}}"/>
  69. </div>
  70. </div>
  71. </div>
  72. <div id="main" style="width: 600px;height:400px;"></div>
  73. <script type="text/javascript">
  74. // 基于准备好的dom,初始化echarts实例
  75. var myChart = echarts.init(document.getElementById('main'));
  76. var data_table = {{data_table|safe}};
  77. if(data_table){
  78. var data_table = (new Function("return " + data_table))();
  79. // 使用刚指定的配置项和数据显示图表。
  80. myChart.setOption(data_table);
  81. }
  82. function click_label(level, data_id) {
  83. let start = document.getElementById('date-start').value;
  84. let end = document.getElementById('date-end').value;
  85. let url = "";
  86. if (level === 1){
  87. url = "/report/data/" + data_id + "?s=" + start + "&e=" + end;
  88. }
  89. if (level === 2){
  90. url = "/report/data/{{data.selectedID1}}/" + data_id + "?s=" + start + "&e=" + end;
  91. }
  92. if (level === 3){
  93. url = "/report/data/{{data.selectedID1}}/{{data.selectedID2}}/" + data_id + "?s=" + start + "&e=" + end;
  94. }
  95. window.location.href = url;
  96. }
  97. </script>
  98. </body>
  99. </html>