How to make f (x) = 1 / x with flot.js?

I am considering using flot.js to display the function f (x) = 1 / x for three cases:

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

I would like the student to be able to change n to see what happens, so I will need to update the schedule as well.

I do not know how to display this function.

0
source share
1 answer

You must fill the array, for example. 100, and then use this array to plot. Something like that:

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 additional questions.

Edit: sample script

+1
source

Source: https://habr.com/ru/post/1526211/


All Articles