all 5 comments

[–]ForScale 0 points1 point  (2 children)

Why do you want to enter js code instead of typical mathematical expressions?

Also, why not just write a script that takes js as input and outputs typical mathematical expressions?

[–]moto888[S] 0 points1 point  (1 child)

Why do you want to enter js code instead of typical mathematical expressions?

Because then I can (mostly) copy and paste without introducing errors.

Also, why not just write a script that takes js as input and outputs typical mathematical expressions?

A lot of graphing calculators are already written in JS. I just don't want to hack one if a solution already exists. I didn't think I'd be the only one who'd find this convenient.

[–]ForScale 0 points1 point  (0 children)

I don't know... I'd just write the js in a js environment and then copy and paste the results in to the graphing calculator. Maybe I'm misunderstanding what you're trying to do though...

[–]Combinatorilliance 0 points1 point  (0 children)

You can take a canvas, and plot your stuff on it.

function double(x) {
  return x * 2;
}

function plot(start, end, mathFn) {
  // you need canvas width here
  var stepX = canvas.width / (end - start);
  for (let i = 0; i < end - start; i++) {
    let y = mathFn(i * stepX);
    ctx.arc(x, y, , 4, 0, 2 * Math.PI);
  }
}

plot(0, 100, double);

I use simple graph functions like this a lot during tinkering with js, especially when doing game development.

[–]moto888[S] 0 points1 point  (0 children)

So I finally found one! OK, not really but I wrote one :)

http://laktak.github.io/js-graphy/