如何使用flot.js渲染f(x)= 1 / x? [英] How to render f(x) = 1/x with flot.js?

查看:109
本文介绍了如何使用flot.js渲染f(x)= 1 / x?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑使用flot.js来为三种情况渲染函数f(x)= 1 / x:

I am considering use flot.js to render the function f(x) = 1/x for 3 cases:

f(x) = 1/n  , 
f(x) = n/x , and 
f(x) = 1/x +n 

我希望学生能够更改n以查看会发生什么,因此我需要刷新图表。

I would like to have the student able to change n to see what happens so I will need to refresh the graph as well.

我不知道如何渲染函数本身。

I have no clue how to render the function itself.

推荐答案

您必须用例如100个值,然后使用该数组绘制图形。像这样:

You have to fill an array with e.g. 100 values and then use that array to plot the graph. Something like this:

var f1array = [];
for (var i = 1; i <= 100; i++) {
    f1array.push([0.1 * i, 1 / (0.1 * i)]);
}
$.plot('#placeholderdiv', [f1array]);

以此为起点,如果您还有其他问题,请返回。

Use this as a starting point and come back if you have further questions.

编辑:

fiddle example

这篇关于如何使用flot.js渲染f(x)= 1 / x?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆