Skip to content

Latest commit

 

History

History
57 lines (43 loc) · 1.11 KB

README.md

File metadata and controls

57 lines (43 loc) · 1.11 KB

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();