simple.html 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. {% if 'statList' in data %}
  2. <script type="text/javascript" src="{{static_url('pc/js/echarts.common.min.js')}}"></script>
  3. <script>
  4. // 基于准备好的dom,初始化echarts实例
  5. var myChart = echarts.init(document.getElementById('main'));
  6. var date = {% for key,value in enumerate(data['statList']) %}{% if key == 0 %}{% raw value['data']['time'] %}{% end %}{% end %};
  7. if (date == "") {
  8. $("#chart").hide();
  9. //$(".crumbs .statMenu").hide();
  10. } else {
  11. var series = [
  12. {% for key,value in enumerate(data['statList']) %}
  13. {% if key > 0 %},{% end %}
  14. {
  15. name:'{{value['name']}}',
  16. type:'line',
  17. data:{% raw value['data']['value'] %},
  18. markPoint: {
  19. data: [
  20. {type: 'max', name: '最大值'},
  21. {type: 'min', name: '最小值'}
  22. ]
  23. },
  24. markLine: {
  25. data: [
  26. {type: 'average', name: '平均值'}
  27. ]
  28. }
  29. }
  30. {% end %}
  31. ];
  32. // 指定图表的配置项和数据
  33. var option = {
  34. tooltip: {
  35. trigger: 'axis'
  36. },
  37. xAxis: {
  38. type: 'category',
  39. data: date
  40. },
  41. yAxis: {
  42. type: 'value',
  43. axisLabel: {
  44. formatter: '{value} {{data['type']['unit']}}'
  45. }
  46. },
  47. series: series
  48. };
  49. myChart.setOption(option, true);
  50. $("#chart").show();
  51. //$(".crumbs .statMenu").show();
  52. }
  53. </script>
  54. {% end %}