Skip to content

Javascript library that lets you plot points and lines based on the Cartesian system with a very simple api, on an html5 canvas.

License

Notifications You must be signed in to change notification settings

phenax/graph-plotting

Repository files navigation

Graph

Build Status

Javascript library that lets you plot points and lines based on the Cartesian system with a very simple api, on an html5 canvas.

Preview

API

  • Create the graph
  const ctx= canvas.getContext('2d');

  const graph= new Graph({
    context: ctx,
    labels: {
      x: 'foo',
      y: 'bar'
    },
    dimens: {
      width: $canvas.width,
      height: $canvas.height,
    }
  });
  • Set the axes for the graph(This will also determine the scale for the graph)
  graph
    .setAxisX([-100, 100])
    .setAxisY([-100, 100]);
  • Plot a point on the graph
  graph.plot(x, y);
  • Plot a line

    • Standard form

        graph.plotLine({ 'standard': { m: 1, c: 20 }});
    • 2 Point form

        graph.plotLine({ '2 points': [ [ 0, 0 ], [ 2, 1 ] ]});
  • Show the graph

  graph.show();

About

Javascript library that lets you plot points and lines based on the Cartesian system with a very simple api, on an html5 canvas.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published