chart.html 690 B

123456789101112131415
  1. {% macro get_chart(data,chart_id,table_height,table_width) %}
  2. <div id="chart_zone_{{chart_id}}" style="overflow: auto;height: {{table_height}};width:{{table_width}};float: left;">
  3. </div>
  4. <script type="text/javascript">
  5. // 基于准备好的dom,初始化echarts实例
  6. var _chart_{{chart_id}} = echarts.init(document.getElementById('chart_zone_{{chart_id}}'));
  7. var data_chart_{{chart_id}} = {{data|safe}};
  8. if(data_chart_{{chart_id}}){
  9. var data_chart_{{chart_id}} = (new Function("return " + data_chart_{{chart_id}}))();
  10. // 使用刚指定的配置项和数据显示图表。
  11. _chart_{{chart_id}}.setOption(data_chart_{{chart_id}});
  12. }
  13. </script>
  14. {% endmacro %}