Vue.js 如何使用Vue';使用Python';烧瓶
我对Vue和Python都是新手。我一直在搜索Vue提供的一些图表。其中之一是FunnelGraph.js。然而,我不太确定如何将它们整合在一起 我试着按照文档Vue.js 如何使用Vue';使用Python';烧瓶,vue.js,flask,Vue.js,Flask,我对Vue和Python都是新手。我一直在搜索Vue提供的一些图表。其中之一是FunnelGraph.js。然而,我不太确定如何将它们整合在一起 我试着按照文档https://github.com/greghub/funnel-graph-js#usage但我不太确定在哪里使用图形变量。我选择使用它的CDN 在python的Flask的app.py中 from flask import Flask, render_template app = Flask(__name__) @app.rout
https://github.com/greghub/funnel-graph-js#usage
但我不太确定在哪里使用图形
变量。我选择使用它的CDN
在python的Flask的app.py
中
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/about')
def about():
return render_template('about.html')
if __name__ == "__main__":
app.run(debug=True)
在about.html
中,我有
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/funnel-graph-js@1.3.9/dist/css/main.min.css">
<link rel="stylesheet" type="text/css" href="https://unpkg.com/funnel-graph-js@1.3.9/dist/css/theme.min.css">
<title></title>
</head>
<body>
<div id="graph">
<h1>graph</h1>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/funnel-graph-js@1.3.9/dist/js/funnel-graph.min.js"></script>
<script>
var graph = new FunnelGraph({
container: '.funnel',
gradientDirection: 'horizontal',
data: [12000, 5700, 360],
displayPercent: true,
direction: 'horizontal'
});
graph.draw();
</script>
</body>
</html>
看起来漏斗图有问题:当您将
数据
定义为数组时,它似乎会抛出此错误,尽管他们的文档中有此示例。要解决此问题,请将数据定义为对象:
var graph = new FunnelGraph({
container: '#graph',
gradientDirection: 'horizontal',
displayPercent: true,
direction: 'horizontal',
data: {
values: [12000, 5700, 360]
},
});
graph.draw();
我还必须将您的容器选择器调整为
#graph
,因为这是标记中的内容。这是与vue.js
相同的插件,它是否对您有效,以便您可以看到整个漏斗图?我似乎只能看到几行和几个百分比。但您的解决方案肯定修复了inspector错误。
var graph = new FunnelGraph({
container: '#graph',
gradientDirection: 'horizontal',
displayPercent: true,
direction: 'horizontal',
data: {
values: [12000, 5700, 360]
},
});
graph.draw();