Skip to content

ASCIIGraph | Getting Started

Mitch Talmadge edited this page Feb 22, 2018 · 6 revisions

Graphs are simply large Strings. Use the ASCIIGraph class to configure the graph, and plot() to convert it to a String.

When using ASCIIGraph, ensure that your data is in the form of a double array. The index of the array corresponds to the value on the x axis, and the value at the index corresponds to the value on the y axis. For example, data[10] = 15.0 would correspond to the coordinates (10, 15.0).

Usage

To use the ASCIIGraph class, first call the static method ASCIIGraph#fromSeries(double[]). This creates an ASCIIGraph instance which you can configure in-line. Once configured, simply call the ASCIIGraph#plot() method, which returns the graph as a String.

The most simple example might be:

ASCIIGraph.fromSeries(new double[] { 1.0, 2.0, 3.0 }).plot();

Output

As you can see, there's not much to show on the graph. Try adding more data!