ajax.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. {% if 'deviceInfo' in data and data['deviceInfo'] %}
  2. <script>
  3. $("#chart .name").html('{{data['deviceInfo']['name']}}');
  4. var date = {% for key,value in enumerate(data['statList']) %}{% if key == 0 %}{% raw value['data']['time'] %}{% end %}{% end %};
  5. if (date == "") {
  6. $("#chart").hide();
  7. //$(".crumbs .statMenu").hide();
  8. } else {
  9. var series = [
  10. {% for key,value in enumerate(data['statList']) %}
  11. {% if key > 0 %},{% end %}
  12. {
  13. name:'{{value['name']}}',
  14. type:'line',
  15. data:{% raw value['data']['value'] %},
  16. markPoint: {
  17. data: [
  18. {type: 'max', name: '最大值'},
  19. {type: 'min', name: '最小值'}
  20. ]
  21. },
  22. markLine: {
  23. data: [
  24. {type: 'average', name: '平均值'}
  25. ]
  26. }
  27. }
  28. {% end %}
  29. ];
  30. myChart.setOption({
  31. xAxis: {
  32. data: date
  33. },
  34. yAxis: {
  35. type: 'value',
  36. axisLabel: {
  37. formatter: '{value} {{data['type']['unit']}}'
  38. }
  39. },
  40. series: series
  41. });
  42. $("#chart").show();
  43. //$(".crumbs .statMenu").show();
  44. }
  45. </script>
  46. {% end %}