Home > plot > plot

plot() function#

Create a plot from regular JavaScript data.

Signature:
export declare function plot(input: PlotInput, plotDef?: IPlotConfig, axisMap?: IAxisMap): IPlotAPI;

Parameters#

ParameterTypeDescription
inputPlotInputThe data to plot. Can be an array of numbers or an array objects where the fields in the objects specify the data series.
plotDefIPlotConfigOptional configuration to control the plot.
axisMapIAxisMapOptional configuration that maps data series to axis'.
Returns:

IPlotAPI

A plot API object that is used to further configure the plot, serialize it or render it to an image.

Example 1#

const data = [10, 30, 15, 45]; // Array of numbers.
plot(data)
.renderImage("./myplot.png"); // Need @plotex/render-image installed for this.

Example 2#

const data = [ // Array of JS objects to specify multiple data series.
{ A: 10, B: 50 },
{ A: 30, B: 45, },
{ A: 15, B: 60 },
{ A: 45, B: 65 }
];
plot(data)
.renderImage("./myplot.png"); // Need @plotex/render-image installed for this.

Example 3#

const data = {
A: [10, 30, 15, 45],
B: [50, 45, 60, 65]
};
plot(data)
.renderImage("./myplot.png"); // Need @plotex/render-image installed for this.