问题
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
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.
回答1:
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.
Edit: fiddle example
来源:https://stackoverflow.com/questions/21711784/how-to-render-fx-1-x-with-flot-js