<html>
<script src="/lib/graphics/plotly.js"></script>
<body>
<div id="myPlot" style="width:100%;max-width:700px"></div>
<script>
var exp = "x + 17";
// 生成值
var xValues = [];
var yValues = [];
for (var x = 0; x <= 10; x += 1) {
xValues.push(x);
yValues.push(eval(exp));
}
// 定义数据
var data = [{
x: xValues,
y: yValues,
mode:"lines"
}];
// 定义布局
var layout = {title: "y = " + exp};
// 使用 Plotly 来显示
Plotly.newPlot("myPlot", data, layout);
</script>
</body>
</html>