123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <script type="text/javascript" src="{{static_url('pc/js/echarts.common.min.js')}}"></script>
- <script>
- // 基于准备好的dom,初始化echarts实例
- var myChart = echarts.init(document.getElementById('main'));
- var date = {% for key,value in enumerate(data['statList']) %}{% if key == 0 %}{% raw value['data']['time'] %}{% end %}{% end %};
- if (date == "") {
- $("#main").hide();
- } else {
- var series = [
- {% for key,value in enumerate(data['statList']) %}
- {% if key > 0 %},{% end %}
- {
- name:'{{value['name']}}',
- type:'line',
- data:{% raw value['data']['value'] %},
- markPoint: {
- data: [
- {type: 'max', name: '最大值'},
- {type: 'min', name: '最小值'}
- ]
- },
- markLine: {
- data: [
- {type: 'average', name: '平均值'}
- ]
- }
- }
- {% end %}
- ];
- // 指定图表的配置项和数据
- var option = {
- title: {
- text: '{{data['deviceInfo']['name']}}',
- subtext: '数据来自{{data['setting']['farmInfo']['name']}}'
- },
- tooltip: {
- trigger: 'axis'
- },
- legend: {
- data:[{% for key,value in enumerate(data['statList']) %}{% if key > 0 %},{% end %}'{{value['name']}}'{% end %}]
- },
- toolbox: {
- show: true,
- feature: {
- dataZoom: {
- yAxisIndex: 'none'
- },
- dataView: {readOnly: false},
- magicType: {type: ['line', 'bar']},
- restore: {},
- saveAsImage: {}
- }
- },
- xAxis: {
- type: 'category',
- boundaryGap: false,
- data: date
- },
- yAxis: {
- type: 'value',
- axisLabel: {
- formatter: '{value} {{data['type']['unit']}}'
- }
- },
- series: series
- };
- //myChart.showLoading();
- // 使用刚指定的配置项和数据显示图表。
- //myChart.hideLoading();
- myChart.setOption(option, true);
- $("#main").show();
- }
- </script>
|