I'm looking to declare a function that can generate a series of ordered pairs of values within an array, such as can be plotted on a graph. I have two variables:
var xAxis = 1;
var yFunction = 4*(xAxis^xAxis) + 12(xAxis) + 20;
so, basically this would use Flot for JQuery to plot a quadratic equation on a graph, but I want to be able to use, say, a while loop to increment the xAxis
variable by one on every iteration, and then compute the yFunction
value for xAxis
on that iteration. I'm not sure how to keep yFunction
pegged to the present value of xAxis
.
Also, the function has to generate each value of xAxis
and yFunction for every iteration and then store these values into an array of the format:
var graphArray = [[1, 2], [2, 4], [3, 6], [4, 8]];
And from there, I can plot the graph.
If anyone has any idea how I would go about doing this, I'd be grateful. I've looked around forms and can see no obvious solution to my very specific problem.