'value' ), array( 'Label 2' => 'value 2' ), ); $graph = new EDD_Pie_Graph( $data ); $graph->display(); */ /** * Data to graph * * @var array * @since 2.4 */ private $data; /** * Unique ID for the graph * * @var string * @since 2.4 */ private $id = ''; /** * Graph options * * @var array * @since 2.4 */ private $options = array(); /** * Get things started * * @since 2.4 */ public function __construct( $_data, $options = array() ) { $this->data = $_data; // Set this so filters recieving $this can quickly know if it's a graph they want to modify $this->type = 'pie'; // Generate unique ID, add 'a' since md5 can leave a numerical first character $this->id = 'a' . md5( rand() ); // Setup default options; $this->options = wp_parse_args( $options, array( 'radius' => 1, 'legend' => true, 'legend_formatter' => false, 'legend_columns' => 3, 'legend_position' => 's', 'show_labels' => false, 'label_threshold' => 0.01, 'label_formatter' => 'eddLabelFormatter', 'label_bg_opacity' => 0.75, 'label_radius' => 1, 'height' => '300', 'hoverable' => true, 'clickable' => false, 'threshold' => false, ) ); add_action( 'edd_graph_load_scripts', array( $this, 'load_additional_scripts' ) ); } /** * Load the graphing library script * * @since 2.4 */ public function load_additional_scripts() { wp_enqueue_script( 'edd-jquery-flot-pie', EDD_PLUGIN_URL . 'assets/js/vendor/jquery.flot.pie.min.js' ); } /** * Build the graph and return it as a string * * @var array * @since 2.4 * @return string */ public function build_graph() { if ( count( $this->data ) ) { $this->load_scripts(); ob_start(); ?>
id, $this->data, $this->options ); } }