rabin 7 years ago
parent
commit
3f5ad49c82
1 changed files with 26 additions and 20 deletions
  1. 26 20
      web/templates/mobile/origin/env.html

+ 26 - 20
web/templates/mobile/origin/env.html

@@ -22,9 +22,10 @@
 <script type="text/javascript" src="{{static_url('js/echarts.common.min.js')}}"></script>
 <script>
 {% for v in data['list'] %}
-var myChart = echarts.init(document.getElementById('main_{{v['id']}}'));
 var date = {% for key,value in enumerate(v['stat']) %}{% if key == 0 %}{% raw value['data']['time'] %}{% end %}{% end %};
-var series = [
+if (date) {
+    var myChart = echarts.init(document.getElementById('main_{{v['id']}}'));
+    var series = [
         {% for key,value in enumerate(v['stat']) %}
         {% if key > 0 %},{% end %}
         {
@@ -46,24 +47,29 @@ var series = [
         {% end %}
         ];
 
-// 指定图表的配置项和数据
-var option = {
-    tooltip: {
-        trigger: 'axis'
-    },
-    xAxis: {
-        type: 'category',
-        data: date
-    },
-    yAxis: {
-        type: 'value',
-        axisLabel: {
-            formatter: '{value} {{v['type']['unit']}}'
-        }
-    },
-    series: series
-};
-myChart.setOption(option, true);
+    // 指定图表的配置项和数据
+    var option = {
+        tooltip: {
+            trigger: 'axis'
+        },
+        xAxis: {
+            type: 'category',
+            data: date
+        },
+        yAxis: {
+            type: 'value',
+            axisLabel: {
+                formatter: '{value} {{v['type']['unit']}}'
+            }
+        },
+        series: series
+    };
+    myChart.setOption(option, true);
+} else {
+    var myChart = $('#main_{{v['id']}}');
+    myChart.html('您要查询的时间段暂无数据');
+}
+
 {% end %}
 </script>
 </body>