New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce EDD_Graph class #1424
Comments
Punting to 1.9. I'm really not yet sure how to go about this one. |
Might look at http://www.chartjs.org/ |
FYI "I'm currently working on a big refactor of the library into a more object oriented structure." on the Github's readme for that project. Looks like he's almost done with it, so if we want to use this we should keep in mind we should prob wait for the finish of the refactor. |
I think to start I will use Flot, just so it stays the same as what we have, then when Charts.js is finished with the rewrite, we can migrate. |
Flot API for reference https://github.com/flot/flot/blob/master/API.md |
Todo:
|
if( class_exists( 'EDD_Graph' ) ) { |
👍 can't wait |
Further todo:
|
This is ready for testing! Quick and dirty example: // Single line example
$data = array(
'Line Label' => array(
array( 1, 5 ),
array( 3, 8 ),
array( 10, 2 )
)
);
$graph = new EDD_Graph( $data );
$graph->display();
// Multi line example
$data = array(
'Line Label' => array(
array( 1, 5 ),
array( 3, 8 ),
array( 10, 2 )
),
'Second Line Label' => array(
array( 1, 7 ),
array( 4, 5 ),
array( 12, 8 )
)
);
$graph = new EDD_Graph( $data );
$graph->display();
// Example with options set to other than default:
$data = array(
'Line Label' => array(
array( 1, 5 ),
array( 3, 8 ),
array( 10, 2 )
),
'Second Line Label' => array(
array( 1, 7 ),
array( 4, 5 ),
array( 12, 8 )
)
);
$graph = new EDD_Graph( $data );
$graph->set( 'bgcolor' => '#000' );
$graph->set( 'color' => '#fff' );
$graph->display(); |
Note on the data format. 'Line Label' => array(
array( 1, 5 ),
array( 3, 8 ),
array( 10, 2 )
) Each inner array represents a data point on the graph. Each inner array should be structured as |
@pippinsplugins I believe your last example above is incorrect. Should be:
Throws an unexpected double arrow error otherwise |
Oops! You're right, thanks! |
With scripts loaded in |
Merged into |
We need to write a new class for handling the creation and display of graphs.
The class should allow us to pass an array of data and set arguments such as tick size then generate the graph.
This will be extremely useful for add-ons, such as Commissions, that want to generate their own graphs.
Related: #1376
The text was updated successfully, but these errors were encountered: