1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <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 %};
- 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 = {
- tooltip: {
- trigger: 'axis'
- },
- legend: {
- data:[{% for key,value in enumerate(data['statList']) %}{% if key > 0 %},{% end %}'{{value['name']}}'{% end %}]
- },
- 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);
- </script>
|