### 1. Getting started

#### 1.1. Installation

For Eclipse user, copy the org.csstudio.swt.xygraph.jar into ../eclipse/plugins directory. Restart Eclipse and include the plug-in org.csstudio.swt.xygraph and org.eclipse.draw2d in your plug-in dependencies list or add the jar files into your build path. Now you are ready to use SWT XYGraph!

#### 1.2. Create your first XY Graph

Just few simple steps, you can create your first XYGraph with a trace added.
See SimpleExample.java

Step 1. Establish the bridge between Draw2D and SWT.

The XY Graph is a Draw2D figure, so if you want to display an XY Graph as an SWT widget, you have to create the bridge between Draw2D and SWT:

    final LightweightSystem lws = new LightweightSystem(shell);

The shell can also be replaced with an SWT Canvas.

Step 2. Create a new XYGraph.

    XYGraph xyGraph = new XYGraph();
    xyGraph.setTitle("Simple Example");

Step 3. Set it as the content of LightwightSystem.

    lws.setContents(xyGraph);

Step 4. Create a trace data provider, which will provide the data to the trace. Here we use CircularBufferDataProvider which is a default provided data provider in XY Graph package. You can also create your own data provider by implementing the interface `IDataProvider` .

    CircularBufferDataProvider traceDataProvider = new CircularBufferDataProvider(false);
    traceDataProvider.setBufferSize(100);
    traceDataProvider.setCurrentXDataArray(new double[]{10, 23, 34, 45, 56, 78, 88, 99});
    traceDataProvider.setCurrentYDataArray(new double[]{11, 44, 55, 45, 88, 98, 52, 23});

Step 5. Create a trace and set its properties.

    Trace trace = new Trace("Trace1-XY Plot",
    	xyGraph.primaryXAxis, xyGraph.primaryYAxis, traceDataProvider);
    trace.setPointStyle(PointStyle.XCROSS);

Step 6. Add the trace to xyGraph.

    xyGraph.addTrace(trace);

Congratulations! You just created your first XYGraph which has the basic elements: title, axes, trace and legend.