array( array( 1, 5 ), array( 3, 8 ), array( 10, 2 ) ), 'Second Label' => array( array( 1, 7 ), array( 4, 5 ), array( 12, 8 ) ) ); $graph = new Give_Graph( $data ); $graph->display(); */ /** * Data to graph * * @var array * @since 1.0 */ private $data; /** * Unique ID for the graph * * @var string * @since 1.0 */ private $id = ''; /** * Graph options * * @var array * @since 1.0 */ private $options = array(); /** * Get things started * * @since 1.0 * * @param array $_data * @param array $options */ public function __construct( $_data, $options = array() ) { $this->data = $_data; // Generate unique ID $this->id = md5( rand() ); // Setup default options; $this->options = apply_filters( 'give_graph_args', 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' => '#eee', 'color' => '#bbb', 'borderwidth' => 1, 'bars' => true, 'lines' => false, 'points' => true, 'dataType' => array() ) ); $this->options = wp_parse_args( $options, $this->options ); } /** * Set an option * * @param $key The option key to set * @param $value The value to assign to the key * * @since 1.0 */ public function set( $key, $value ) { $this->options[ $key ] = $value; } /** * Get an option * * @param $key The option key to get * * @since 1.0 */ public function get( $key ) { return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false; } /** * Get graph data * * @since 1.0 */ public function get_data() { return apply_filters( 'give_get_graph_data', $this->data, $this ); } /** * Load the graphing library script * * @since 1.0 */ public function load_scripts() { // Use minified libraries if SCRIPT_DEBUG is turned off $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); wp_enqueue_script( 'jquery-flot-orderbars' ); wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.time' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); wp_enqueue_script( 'jquery-flot-time' ); wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); wp_enqueue_script( 'jquery-flot-resize' ); wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION ); wp_enqueue_script( 'jquery-flot' ); } /** * Build the graph and return it as a string * * @var array * @since 1.0 * @return string */ public function build_graph() { $yaxis_count = 1; ob_start(); ?>
build_graph(); /** * Fires after displaying the final graph. * * @since 1.0 * * @param Give_Graph $this Graph object. */ do_action( 'give_after_graph', $this ); } }