# EDD_Graph

 The EDD\_Graph class, introduced in EDD version 1.9, is used for easily building graphs of data. For example, the earnings / sales reports graphs seen in Downloads → Reports are created using EDD\_Graph. The class can be used by extensions to quickly graph any data set.

 
 A simple example looks like this:

```
$data = array(
	&#039;Your Graph Label Here&#039; =&gt; array(
		array( 1, 5 ),
		array( 3, 8 ),
		array( 10, 2 )
	),
	&#039;Second Label Here&#039; =&gt; array(
		array( 1, 7 ),
		array( 4, 5 ),
		array( 12, 8 )
	)
);
$graph = new EDD_Graph( $data );
$graph-&gt;display();&lt;br&gt;&lt;/br&gt;
```

 Each inner array represents a data point on the graph and should be structured like this:

```
array( &#039;value on x axis&#039;, &#039;value on y axis&#039; )
```

 Graphs can contain one one or more lines. To add multiple lines, simply add additional inner arrays, as shown in the example above.

 Along with the data points, EDD\_Grap allows you to control various options of the graph by using the *set()* method. For example:

```
// Example with options set to other than default:
$data = array(
    &#039;Line Label&#039; =&gt; array(
        array( 1, 5 ),
        array( 3, 8 ),
        array( 10, 2 )
    ),
    &#039;Second Line Label&#039; =&gt; array(
        array( 1, 7 ),
        array( 4, 5 ),
        array( 12, 8 )
    )
);
$graph = new EDD_Graph( $data );
$graph-&gt;set( &#039;bgcolor&#039;, &#039;#000&#039; );
$graph-&gt;set( &#039;color&#039;, &#039;#fff&#039; );
$graph-&gt;display();&lt;br&gt;&lt;/br&gt;
```

 The available options are:

- y\_mode
- x\_mode
- y\_decimals
- x\_decimals
- y\_position
- time\_format
- ticksize\_unit
- ticksize\_num
- multiple\_y\_axes
- bgcolor
- bordercolor
- color
- borderwidth
- bars
- lines
- points

 See the [Flot API reference](https://github.com/flot/flot/blob/master/API.md) for the possible values each of these can receive.

 Note, if you want to display a graph on the front end, you will need to include *includes/admin/reporting/class-edd-graph.php* first.