stat.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. {% extends "../theme/stat.html" %}
  2. {% block search %}
  3. {% for index,key in enumerate(data['common']['search'][0]) %}
  4. {%set value = data['common']['search'][1][index] %}
  5. {%set param = key.split('-') %}
  6. {% if 'label' in key %}
  7. <label class="layui-form-label">{{value}}</label>
  8. {% elif param[1] == 'input' %}
  9. <div class="layui-input-inline" style="width:auto" >
  10. <input type="text" name="search_{{key}}"id="search_{{key}}" placeholder="{{value}}" autocomplete="off" class="layui-input" value="{% if data['search'] and key in data['search'] %}{{data['search'][key]}}{% end %}">
  11. </div>
  12. {% elif param[1] == 'time' %}
  13. <div class="layui-input-inline" style="width:auto">
  14. <input type="text" name="search_{{key}}" id="search_{{key}}" placeholder="{{value}}" autocomplete="off" class="layui-input time" value="{% if data['search'] and key in data['search'] %}{{data['search'][key]}}{% end %}">
  15. </div>
  16. {% elif param[1] == 'select' %}
  17. <label class="layui-form-label">{{value}}</label>
  18. <div class="layui-input-inline" style="width:auto">
  19. {%set option = 'search_' + key %}
  20. {% if option in data['common'] %}
  21. {%set select = data['common'][option] %}
  22. <select name="search_{{key}}" id="search_{{key}}" lay-verify="" lay-search>
  23. <option value="">请选择一项</option>
  24. {% for v in select %}
  25. <option value="{{v['id']}}" {% if data['search'] and key in data['search'] and data['search'][key] == str(v['id']) %}selected{% end %}>{{v['name']}}</option>
  26. {% end %}
  27. </select>
  28. {% end %}
  29. </div>
  30. {% end %}
  31. {% end %}
  32. {% end %}
  33. {% block script %}
  34. <script src="{{static_url('js/echarts.common.min.js')}}" charset="utf-8"></script>
  35. <script type="text/javascript">
  36. // 基于准备好的dom,初始化echarts实例
  37. var myChart = echarts.init(document.getElementById('main'));
  38. // 指定图表的配置项和数据
  39. var option = {
  40. title: {
  41. text: '{{data['info']['name']}}',
  42. subtext: '数据来自{{data['farm']['name']}}'
  43. },
  44. tooltip: {
  45. trigger: 'axis'
  46. },
  47. legend: {
  48. data:[{% for key,value in enumerate(data['list']) %}{% if key > 0 %},{% end %}'{{value['name']}}'{% end %}]
  49. },
  50. grid: {
  51. left: '3%',
  52. right: '4%',
  53. bottom: '3%',
  54. containLabel: true
  55. },
  56. toolbox: {
  57. show: true,
  58. feature: {
  59. dataZoom: {
  60. yAxisIndex: 'none'
  61. },
  62. dataView: {readOnly: false},
  63. magicType: {type: ['line', 'bar']},
  64. restore: {},
  65. saveAsImage: {}
  66. }
  67. },
  68. xAxis: {
  69. type: 'category',
  70. boundaryGap: false,
  71. data: {% for key,value in enumerate(data['list']) %}{% if key == 0 %}{% raw value['data']['time'] %}{% end %}{% end %}
  72. },
  73. yAxis: {
  74. type: 'value',
  75. axisLabel: {
  76. formatter: '{value} {{data['type']['unit']}}'
  77. }
  78. },
  79. series: [
  80. {% for key,value in enumerate(data['list']) %}
  81. {% if key > 0 %},{% end %}
  82. {
  83. name:'{{value['name']}}',
  84. type:'line',
  85. data:{% raw value['data']['value'] %},
  86. markPoint: {
  87. data: [
  88. {type: 'max', name: '最大值'},
  89. {type: 'min', name: '最小值'}
  90. ]
  91. },
  92. markLine: {
  93. data: [
  94. {type: 'average', name: '平均值'}
  95. ]
  96. }
  97. }
  98. {% end %}
  99. ]
  100. };
  101. // 使用刚指定的配置项和数据显示图表。
  102. myChart.setOption(option);
  103. </script>
  104. {% end %}