array( array( 1, 5 ), array( 3, 8 ), array( 10, 2 ) ), 'Second Label' => array( array( 1, 7 ), array( 4, 5 ), array( 12, 8 ) ) ); $graph = new EDD_Graph( $data ); $graph->display(); */ /** * Data to graph * * @var array * @since 1.9 */ private $data; /** * Unique ID for the graph * * @var string * @since 1.9 */ private $id = ''; /** * Graph options * * @var array * @since 1.9 */ private $options = array(); /** * Get things started * * @since 1.9 */ public function __construct( $_data ) { $this->data = $_data; // Generate unique ID $this->id = 'a' . md5( rand() ); // Setup default options; $this->options = array( 'y_mode' => null, 'x_mode' => null, 'y_decimals' => 0, 'x_decimals' => 0, 'y_position' => 'right', 'time_format' => '%d/%b', 'ticksize_unit' => 'day', 'ticksize_num' => 1, 'multiple_y_axes' => false, 'bgcolor' => '#f9f9f9', 'bordercolor' => '#ccc', 'color' => '#bbb', 'borderwidth' => 2, 'bars' => false, 'lines' => true, 'points' => true, 'additional_options' => '', ); } /** * Set an option * * @param $key The option key to set * @param $value The value to assign to the key * @since 1.9 */ 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 ); } /** * Load the graphing library script * * @since 1.9 */ public function load_scripts() { wp_enqueue_script( 'edd-jquery-flot', EDD_PLUGIN_URL . 'assets/js/vendor/jquery.flot.min.js' ); wp_enqueue_script( 'edd-jquery-flot-time', EDD_PLUGIN_URL . 'assets/js/vendor/jquery.flot.time.min.js' ); /** * Fires immediately after the legacy Flot JS graphing framework is enqueued. * * @since 1.9 */ do_action( 'edd_graph_load_scripts' ); } /** * Build the graph and return it as a string * * @var array * @since 1.9 * @return string */ public function build_graph() { $yaxis_count = 1; $this->load_scripts(); ob_start(); ?>
build_graph(); do_action( 'edd_after_graph', $this ); } }