Skip to content

Commit

Permalink
Add get() and get_data() methods. #1424
Browse files Browse the repository at this point in the history
  • Loading branch information
pippinsplugins committed Dec 9, 2013
1 parent a911187 commit 1182cbc
Showing 1 changed file with 21 additions and 39 deletions.
60 changes: 21 additions & 39 deletions includes/admin/reporting/class-edd-graph.php
Expand Up @@ -119,6 +119,25 @@ public function set( $key, $value ) {
$this->options[ $key ] = $value;
}

/**
* Get an option
*
* @param $key The option key to get
* @since 1.9
*/
public function get( $key ) {
return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false;
}

/**
* Get graph data
*
* @since 1.9
*/
public function get_data() {
return apply_filters( 'edd_get_graph_data', $this->data, $this );
}

/**
* Build the graph and return it as a string
*
Expand All @@ -136,7 +155,7 @@ public function build_graph() {
$.plot(
$("#edd-graph-<?php echo $this->id; ?>"),
[
<?php foreach( $this->data as $label => $data ) : ?>
<?php foreach( $this->get_data() as $label => $data ) : ?>
{
label: "<?php echo esc_attr( $label ); ?>",
id: "<?php echo sanitize_key( $label ); ?>",
Expand Down Expand Up @@ -252,41 +271,4 @@ public function display() {
}


}

// Just for simple testing

function edd_test_graph_class() {

$data = array(

// Line one
'Foo' => array(
array( 1386048624, 3 ),
array( 1386307825, 5 ),
array( 1386394224, 8 ),
array( 1386480624, 2 )
),

// Line 2
'Bar' => array(
array( 1386048624, 1 ),
array( 1386307825, 2 ),
array( 1386394224, 10 ),
array( 1386480624, 3 )
),

// Line 3
'Puppy' => array(
array( 1386048624, 10 ),
array( 1386307825, 12 ),
array( 1386394224, 2 ),
array( 1386480624, 4 )
)
);

$graph = new EDD_Graph( $data );
$graph->set( 'x_mode', 'time' );
$graph->display();
}
//add_action( 'edd_reports_view_earnings', 'edd_test_graph_class', -1 );
}

0 comments on commit 1182cbc

Please sign in to comment.