# -*- coding: UTF-8 -*-
# @Time :2021-09-10 21:37
# @File :app.py
# @Author : Poleung
from flask import Flask
from flask import render_template
app = Flask(__name__)#,template_folder='./templates',默认在templates目录
@app.route("/")
def index():
data_name = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
data_list = [150, 230, 224, 218, 135, 147, 260]
return render_template('aaa.html', data_name=data_name, data_list=data_list)
if __name__ == '__main__':
app.run("0.0.0.0", "680", debug=True)#127.0.0.1这个外网不能访问,用0.0.0.0可以?
------------------------
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Python Flask Echarts折线图的实现方法</title>
<!--静态文件引入-->
<link rel="stylesheet" href="static/css/common.css">
<script src="static/js/echarts.min.js"></script>
</head>
<body>
<div id="container"></div>
<script>
//调用数据;
dataName={{ data_name | safe}};
dataList={{ data_list }};
drawLine(dataName, dataList);
//封装折线图;
function drawLine(dataName, dataList) {
let myChart = echarts.init(document.getElementById("container"));
let option = {
xAxis: {
type: 'category',
data: dataName
},
yAxis: {
type: 'value'
},
series: [{
data: dataList,
type: 'line'
}]
};
//自适应浏览器;
myChart.setOption(option);
window.addEventListener("resize", function () {
myChart.resize();
});
}
</script>
试试我的文字有没有出来</br>
</body>
</html>
我没发现问题 在哪呢