plotLine.js
Live Editor
Enter your JS-Code below and click 'Run the Code' to execute it.
quickPlot([[0,1.5],[1.5,2.1],[2,0.5],[2.5,2.8],[3,2],[4,3.5]]); quickFunc('3*Math.sin(x)', -3.14, 3.14);
Run the Code
(see you result here)
Usage:
quickPlot(data, arg={}) to plot data inline like [[0,2],[2,2]] quickFunc(func, min=0, max=10, arg={}) to plot a function like 'Math.sin(x)' pl = plotLine(arg = {}) to create a plotline-object 'pl' where arg is an object with (optional): - 'id' = id of the parent block (default: random Id) - 'height' / 'width' = size of the svg (default '600px' / '450px') - 'grid' = _'main'_ / 'small' / 'both' / 'none' to show grid - 'x_axis' / 'y_axis' = _true_ / false to show or hide x / y axis - 'x_label' / 'y_label' = _true_ / false to show or hide x / y labels pl.addGraph('name', arg={}) to add a graph 'name' to 'pl' where arg is an object with (optional): - 'color = css-color (default: 'green') - 'line' = _'line'_ / 'dashed' / 'none' to choose line type - 'drawpoints' = true / false to draw points (plot: _true_, func: _false_) - 'smooth' = true / _false_ to use splines to smoothen the graph - 'fill' = true / _false_ to fill below the graph or not - 'samples' = _100_ to set samples for function-plots pl.addPoints('name', [[0,2],[2,2]]) to add points to the graph 'name' or pl.addFunc('name', 'func', min=0, max=10) to add a function pl.draw() to draw it