Monthly Archives: February 2015

You are here: Home . Archive

This stormy walk

In my head, Christianity is this nice, cushy place where you chill with the Lord Jesus, safe from all life’s randomness. Brokeness, brokenness, debt, indecision, loss, waves, crazy storms that toss you, lift you and carry you off and when they finally set you down (as you breathe a sigh of relief), you realise you’ve been dropped in a den of lions. That have been fasting. That stuff, those things, in my head, are for those who don’t know our Lord. That was one of my expectations getting into this.

Come with your poverty, Lord Jesus will make you rich. Come. Just come. Yes, you there at your computer, writing code. Come. The message of striking a gold mine, of all problems going away, sounds pretty attractive. On Sunday though, the message we received had this as the take-out:

The life of the godly is not a straight line to glory, but God sees that they get there.

Wait? What? *murmurs in my head*

The message re-affirms what I’ve been learning on this walk. It isn’t a straight line. *face drops.* Now that I’m here, what do I do with all these expectations? What do I do with this list of things I’d come with for Lord Jesus to give me?

One of the most widely known passage from the Bible was written by giant-slaying David. Psalms 23.

The Lord is my Shepherd,

I shall not want

That’s it David. That’s exactly what I want – not to want. Hence my list….

He maketh me to lie down in green pastures: he leadeth me beside the still waters.

He restoreth my soul: he leadeth me in the paths of righteousness for his name’s sake.

All on my list. Still waters, peace, calm. If those still waters are in Hawaii, or Brazil, or Seychelles, I’m totally in for that too. You, David, are a man who knows my list. Lying down in green pastures, especially in a lush field, with some mellow music playing, a lovely breeze blowing and my wife next to me, I’m sold. Lord Jesus, I’m in.

Yea, though I walk through the valley of the shadow of death,

Wait, what?! There must be a mistake here. Lord, if you truly are my Shepherd (as I confidently pronounced, remember), why is there even a remote possibility of me walking through the valley of the shadow of death? If I need to go to a valley, take me to Silicon Valley, that’s what good shepherds do no?

But David continues, unfazed…

I will fear no evil: for thou art with me; thy rod and thy staff they comfort me.

And that’s what I’m learning. In Jesus’s words:

24 “Therefore everyone who hears these words of mine and puts them into practice is like a wise man who built his house on the rock. 25 The rain came down, the streams rose, and the winds blew and beat against that house; yet it did not fall, because it had its foundation on the rock. 26 But everyone who hears these words of mine and does not put them into practice is like a foolish man who built his house on sand. 27 The rain came down, the streams rose, and the winds blew and beat against that house, and it fell with a great crash.”                                                                                                     Matthew 7:24-27

I’m learning exactly that; that with or without Jesus, storms come, so do the valleys (of the shadow of death and of Silicon, I’m still waiting Lord!). I’m learning though to recognize God’s rod and staff in the storms. A rod, from what I know, is for discipline (spare the rod, spoil the child). Staffs are for guidance (Shepherds use them to herd). I’m learning, rather slowly, to look for his comfort, his grounding through everything.

When MPs blow it

Do you read some stories in the news and immediately think that all that’s lacking is some good actors, a great soundtrack and a deep-voiced narrator to turn the story into a blockbuster movie? You do? I do too. Last week, well after I’d submitted an article for publishing, one such story came up. One so interesting, it walked in and demanded that ‘By The Way’ be about it. See, it was reported that two Members of Parliament got into a fist fight. Two female MPs, it is alleged, took the phrase ‘the power is in your hands’ literally by swinging that power at each other. I can’t give a blow by blow account (heavy pause) but here’s an account of the events, adapted for a movie.

The setting: The ruling party’s MPs are at a week-long retreat in Kyankwanzi, resplendent in yellow, discussing important national matters, only taking time off to breathe. The sun’s shining, a gentle breeze is blowing, lulling some to sleep, but only for a few minutes at a time.

Characters: Ms Ann Nankabirwa, the Kyankwanzi District MP aka AnDistracable and Ms Florence Nebanda ,Butaleja Woman MP aka Flo

Conflict: Both AnDistracable and Flo are peace-loving, patriotic citizens, diligently serving the country. But something in their food, some experimental drug dropped in by an evil NRM scientist that can’t be named here lest the newspaper be shut down, changed all that.

Flo, tired from the day’s activities, heads back to the dormitory to turn in. Her bed though has been given away to someone else by AnDistracable. Flo investigates and discovers what happened. She confronts AnDistracable about it. Then the drug kicks in and the events that follow aren’t suitable for the family section of the newspaper like this. Suffice to say they did not shake hands and have a civil conversation about it, one punctuated with laughter and a few sips of tea.

The MP's debate

The MP’s debate

For the sake of the movie, while the above ‘discussions’ take place, a crowd mills around the discussants, cheering them on and placing bets on who’ll win. An ambulance also rushes to the scene, ready to whisk away any by-stander injured by any stray word used by the discussants. The evil scientist behind all this stands by, grinning at his success.

Moral: Don’t just give out people’s beds

Here’s to true hardworking Ugandans

It’s been said by a number of detractors that Ugandans are not very hardworking people. The same haters have said that we only love to party; that we only go to work to finance the partying. They are quick to bring out pictures of politicians in various states of slumber in the middle of meetings. If these haters of progress knew anything, they’d know that a politician only sleeps in proceedings because he’s been working hard elsewhere – a late trip to and from their constituency, or a long night discussing critical matters with his constituents. I’ll share more details in another article but for now, suffice to say, the haters don’t believe we work hard. To finally put them to rest, here are some solid reasons that arose this week showing, undeniably, that we are very hardworking.

First, I have the International Consortium of Investigative Journalists (ICIJ), a team of journalists from 45 countries, to thank. They showed, in something dubbed “the Swiss Leaks data project”, that 57 people associated with Uganda have $89.3m (about Shs. 256b) in a bank in Switzerland. 57 hardworking Ugandans have amassed that colossal sum and being patriots, they didn’t want to cause inflation so they put it outside countries. One of the 57 individuals is a special star, holding a tidy sum of $8.8m (about Shs. 25b). These are true Ugandans; they are stars we need to celebrate come Heroes’ day. They’ve toiled without tiring, run without giving up and above everything, have taken time to care for their community by not letting their earnings spoil the economy. In fact, if they so chose, they could finance a healthy portion of our National budget (as local donors so that we kick-out foreign aid). They are a great representation of the hardworking Ugandan.

ant_working_hard

Working hard for ungrateful citizens

Second, last week our beloved leader went out to personally investigate the murder of two prominent persons in Mayuge and Namayingo districts. I can only imagine how full his plate is but to still be able to make time and take on investigative work (which movies have shown me is very hard work) says, rather loudly, how hardworking our leader is (and by extension, how hardworking we are). It should come as no surprise then that we have that much money stashed away abroad; finally the naysayers have been silenced. We burn the midnight oil, we work like the very air we breathe depended on how much work we do…we also party a lot but that’s only after working hard. For God and our country.

For a happier back-to-school season

The back-to-school season did this thing it usually does of sounding a war cry that simultaneously empties parents’ bank accounts and also draws traffic from all parts of the world and deposits it on our ailing roads. Over the years, with the help of school administrators around the country, the war cry has become very effective at migrating more and more out of accounts. That’s unless your account is at Crane Bank and it has 10 billion Shillings on it-in such cases, back-to-school’s best war cry will seem like bank charges. You’d actually be able to pay for an alternative road to the school to be used by only you and whoever you or your children chose. Over family bonding time, you’d all decide who gets to use your road. Even the school headmaster would need your permission to use it.

The traffic jam that back-to-school unleashes on all of us is as severe as the January sunshine. Here’s why; at the end of every single day in January, the sun cheerily tells its friends, jam and fees, how it enjoyed its day. It tells of all the places it shone and how happy it was to be alive. By early February, the friends, tired of hearing that story, are all raring to go. Back-to-school’s war cry finds them stretching at the door, shoelaces tied and ready to bring their A-game. We are the (unlucky) players on the other team. Germany vs. Uganda. That’s us without 10 billion on an account in Crane Bank. For those who do, it’s Germany vs. a team that has paid the referee and the opponent’s goal keeper.

The January sun rocking ray burns (did you see it? You did?)

The January sun rocking ray burns (Did you see that?)

Here’s an appeal to government to help us even the score at least against traffic jam. It might be hard for us to vote wisely after spending that much time in traffic. You could help us by organising concerts that take place in the slowest moving traffic. Chameleone, Navio and Goodlyfe can do mobile shows for us as we wait for the traffic to move. If that’s hard, we can get stand-up comedians to give us a good laugh as Afande makes up his mind which lane should be released. If that’s hard, maybe some politicians can do it – we know that their jokes pack a punch and they’d charge Government less since they are all for serving the country in any and every way.

Google reCAPTCHA client-side validation

Released less than two months ago, Google reCAPTCHA is the pretty new on the block. And she’s clad in skimpy clothes. That’s another way of saying that the documentation is still scanty but the first imagery seemed more appropriate for an audience of solid developers like you.

The need for client-side validation arose when users of a WordPress plugin I developed were being confused by a server-side response being returned. Thing is, if one submitted a form before Google reCAPTCHA completed the validation process (say while the loading dialog was still showing), there’d be a problem. The best way to address this was to stop users from submitting till Google reCAPTCHA completed the validation. Finding a way to do client-side validation wasn’t straightforward but here’s what I used in my submit handler:

 if (!grecaptcha.getResponse()){
           console.log("Google reCAPTCHA not complete");//Display error here e.g. jQuery('#targetID').html("Please check the 'I'm not a robot' checkbox!")
            return;//End the processing
        }

 

WordPress admin Pointers with navigation

WordPress admin pointers are generally used to give an introductory tour to where different features are in WordPress. They are mainly used by WordPress in the admin section to show you, especially after upgrades, where different (new) functionality is.

wordpress_admin_pointers

In plugin development, they make it easy for you, the developer, to show off some features pretty easily. If your plugin has a number of sections, chances are one pointer won’t do. You’ll probably require a series of pointers, one leading to another (with a ‘Next’ and ‘Previous’ button). To achieve this for the introductory tour in Kanzu Support Desk(KSD), I used the following code. The explanation is inline

WordPress Admin Pointer in KSD

KSD admin pointer in intro tour

The PHP Code

In your plugin file, use this:


if ( ! class_exists( 'My_Custom_Plugin' ) ) :

class My_Custom_Plugin{

              public function __construct() {
               //Define plugin constants if you haven't already. I recommend calling  a function, $this->define_constants and doing the definitions there
               $this->define_constants();
              // Load admin JavaScript. Do an is_admin() check before calling My_Custom_Plugin
               add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
             //Used to disable tour mode
            add_action( 'wp_ajax_my_plugin_disable_tour_mode', array( $this, 'my_plugin_disable_tour_mode' ));              

          }
      /**
       * Define plugin constants
       */
      private function define_constants(){
             if ( ! defined( 'MY_PLUGIN_VERSION' ) ) {                
        define( 'MY_PLUGIN_VERSION', '1.x.x' );
             }
            if ( ! defined( 'MY_PLUGIN_SLUG' ) ) {                
                define( 'MY_PLUGIN_SLUG', 'my-custom-plugin' );           
            }                
                
            if ( ! defined( 'MY_PLUGIN_PLUGIN_URL' ) ) {
                define( 'MY_PLUGIN_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
             }
     }

        public function enqueue_admin_scripts() {
                wp_enqueue_script( MY_PLUGIN_SLUG . '-admin-js', MY_PLUGIN_URL.'/assets/js/my-plugin-admin.js', array( 'jquery' ), MY_PLUGIN_VERSION );
                $tour_pointer_messages['my_plugin_intro_tour'] =  $this->load_intro_tour();
                 //Localization allows us to send variables to the JS script. In this case, we are sending the pointers array
                wp_localize_script( MY_PLUGIN_SLUG . '-admin-js',
                                    'my_plugin_admin',
                                    array(  'ajax_url'              =>  admin_url( 'admin-ajax.php'),
                                            'my_plugin_admin_nonce' =>  wp_create_nonce( 'my-plugin-admin-nonce' ),//Not used in this example but important
                                            'my_plugin_tour_pointers'     =>  $tour_pointer_messages
                                        )
                                    );
                                    }

           /**
          * Give the user an introductory tour to your plugin
          * @return Array $pointers Returns an array of pointers or false
          */
         private function load_intro_tour(){
            // Don't run on WP < 3.3. Admin pointers were only introduced in WP 3.3
            if ( get_bloginfo( 'version' ) < '3.3' ){
                return false;                
            }
            //Do a check to see whether your user wants to take the tour. You can check
            //a custom plugin setting here like this:
           if ( "no" === get_option('my_plugin_enable_tour') || !get_option('my_plugin_enable_tour') ){
                return false;
            }//This implies that you need to use update_option('my_plugin_enable_tour') to trigger the tour
            
            //Generate the tour messages
            $pointers = $this->generate_tour_content();
            
            // No pointers? Then we stop.
            if ( ! $pointers || ! is_array( $pointers ) ){
                return false;
            }
            wp_enqueue_style( 'wp-pointer' );//Needed to style the pointers.
            wp_enqueue_script( 'wp-pointer' );//Has the actual pointer logic
            
            return $pointers;
         }

         /**
          * The tour content for the different screens
          */

       private function generate_tour_content(){
             //The content is entered into the array based on when it should display since
             //it'll be displayed sequentially i.e. content at $p[0] will come first, then $p[n+1]
             $p[] = array(
                "target" => "#my-id",//Target ID or class
                "screen"  => 0, //Which screen to show the pointer on. This is useful if you have multiple screens to navigate between
                "options" => array(
                    "content" => sprintf( "<span><h3> %s </h3> <p> %s </p><p> %s </p></span>",
                    __( "Title one" ,"my-custom-plugin"),
                    __( "First paragraph of the first item","my-custom-plugin"),
                    __( "More information","my-custom-plugin")
                    ),                    
                    "position" => array( 'edge' => 'right', 'align' => 'top' )//Edge and alignment gotten using 'Better Admin Pointers' plugin
                    )                
            );
            $p[] = array(
                "target" => ".my-class",//Target ID or class
                "screen"  => 1, //Which screen to show the pointer on. This is useful if you have multiple screens to navigate between
                "options" => array(
                    "content" => sprintf( "<span><h3> %s </h3> <p> %s </p></span>",
                    __( "Title two" ,"my-custom-plugin"),
                    __( "This is short and sweet. One paragraph only","my-custom-plugin")
                    ),                    
                    "position" => array( 'edge' => 'right', 'align' => 'top' )//Edge and alignment gotten using 'Better Admin Pointers' plugin
                    )                
            );
            return $p;
         }
         /**
          * Disable tour mode
          */
         public function my_plugin_disable_tour_mode(){
            update_option("my_plugin_enable_tour","no");
            echo json_encode( 1 );
            die();            
         }
         }

endif;

return new My_Custom_Plugin();

That covers the PHP end of the logic. Note that finding the best positions for your pointers is pretty tricky; to do it faster, download and install the Better Admin Pointers plugin and create dummy pointers. Use the values you get from testing in your code.

The JavaScript

Now for the JavaScript that does the manipulation:


var pointerContentIndex = 0;
if( my_plugin_admin.my_plugin_tour_pointers.my_plugin_intro_tour ){//If pointers are set, show them off
var pointer = my_plugin_admin.my_plugin_tour_pointers.my_plugin_intro_tour;

/**
* Create a pointer using content defined at pointer[pointerContentIndex]
* and display it on a particular screen. The screen to display
* the pointer on is defined at pointer[pointerContentIndex].screen
* @param int pointerContentIndex
*/
generatePointer = function( pointerContentIndex ){
//Change the active screen
//Add your custom (jQuery) logic to change the plugin screen to the one corresponding to the content at pointerContentIndex
////Remember, you specified the screen at pointer[pointerContentIndex].screen
//In my case, using jQuery tabs, I used this to switch to the correct tab:
// jQuery( "#tabs" ).tabs( "option", "active", pointer[pointerContentIndex].screen );

//Generate the pointer options
options = jQuery.extend( pointer[pointerContentIndex].options, {
close: function() {
/* jQuery.post( my_plugin_admin.ajax_url, {
pointer: 'my_plugin_intro_tour',
action: 'dismiss-wp-pointer'
});//Ordinarily, we'd use this to send an AJAX call to WordPress to disable our pointer
//However, we are manually handling the display ourselves so we don't use this*/
//Disable tour mode
jQuery.post( my_plugin_admin.ajax_url, {
action: 'my_plugin_disable_tour_mode' //In the PHP,there's an action to handle this AJAX callback and
//change the setting you are using to start/stop the tour
});
}
});
//Open the pointer
jQuery( pointer[pointerContentIndex].target ).pointer( options ).pointer('open');
//Inject a "Next" button into the pointer
jQuery( 'a.close' ).after('<a href="#" class="my-plugin-next button-primary">Next</a>');
};

generatePointer( pointerContentIndex );
//Move to the next pointer when 'Next' is clicked
//Event needs to be attached this way since the link was manually injected into the HTML
jQuery( 'body' ).on( 'click', 'a.my-plugin-next', function(e){
e.preventDefault();
//Manually hide the current pointer. We don't close it because if we do, the 'close' function,
//which also disables tour mode, would be called
jQuery(this).parents('.wp-pointer').hide();
if( pointerContentIndex < pointer.length  ){
++pointerContentIndex;
}
else{//End of the tour
//Dismiss the pointer in the WP db
//Disable tour mode
jQuery.post( my_plugin_admin.ajax_url, {
action: 'my_plugin_disable_tour_mode'
});
return;
}
//Open the next pointer
generatePointer( pointerContentIndex );

});
}

The CSS

We need to position the ‘Next’ button we manually injected into the pointer.


.wp-pointer-buttons a.my-plugin-next {
margin-right: 22px;
margin-top: -6px;
}

That should do it.

That’s it! Extending this to add a ‘Previous’ button is easy.

It’s pretty a mouthful but I hope you are up and running. To see the code in action, you could download Kanzu Support Desk and take the intro tour. I used ‘plugin’ throughout the explanation but a theme can use the same logic.

That Street Preacher isn’t for you

This side of my writing has been in the works for a loooong time; it’s been more and more second-guessing before letting it lie ‘a little longer’. Today though, I finally leave my comfort zone and try something new. I hope you find it useful.

A friend of mine and I were driving past a street preacher last week when he asked whether they are effective. Does anyone ever listen to them? Does that message get through to anyone? I’ve heard this sentiment before and it’s one I held for a while myself. I’d quicken my pace as I approached them, making every effort not to make eye contact lest they direct their potent message my way. I’d hurry away, feeling a bit bad for them.

Street Preacher

When Simon asked though, for that’s my friend’s name, I shared what I know now. We are naturally wired to count success based on numbers – to us, a street preacher like that is only successful if he reaches out to say 50 people during his day in the sweltering heat. We’d consider him effective if whenever we looked up to distract ourselves from the snail-paced traffic, we’d see him surrounded by tear-faced men and women, on their knees begging that he asks the God he serves to save their souls from eternal damnation. I’ve never seen this happen before but wouldn’t that be something! Right there on Jinja Road, near the traffic lights. That’d be a successful street preacher.

The God I see in the Bible though is the kind of guy who’ll go through all that trouble for one person. I see that He counts one soul a huge, huge success. That street preacher could be on the street all day for one person. That person may not be you.

Christ gave parables about the lost coin and the lost sheep.

Then Jesus told them this parable: 4 “Suppose one of you has a hundred sheep and loses one of them. Doesn’t he leave the ninety-nine in the open country and go after the lost sheep until he finds it? 5 And when he finds it, he joyfully puts it on his shoulders 6 and goes home. Then he calls his friends and neighbors together and says, ‘Rejoice with me; I have found my lost sheep.’ 7 I tell you that in the same way there will be more rejoicing in heaven over one sinner who repents than over ninety-nine righteous persons who do not need to repent.

8 “Or suppose a woman has ten silver coins[a] and loses one. Doesn’t she light a lamp, sweep the house and search carefully until she finds it? 9 And when she finds it, she calls her friends and neighbors together and says, ‘Rejoice with me; I have found my lost coin.’ 10 In the same way, I tell you, there is rejoicing in the presence of the angels of God over one sinner who repents.” Luke 15: 3-10 (NIV)

Every time I read this, whenever He asks rhetorically, “Doesn’t he leave the ninety-nine in the open country and go after the lost sheep until he finds it?”, in my head I go, “Um, No, Jesus, he doesn’t.”

Unfazed, Jesus asks of the lady who lost her coin, “Doesn’t she light a lamp, sweep the house and search carefully until she finds it? And when she finds it, she calls her friends and neighbors together and says, ‘Rejoice with me” I still go, “Ummm, that ‘rejoicing’ might cost more than the coin! Hehehe. Nope, Jesus, she doesn’t.”

But that’s me. Him, Christ, God, He’s committed (sweeping the house, going out to look for the sheep- there’s effort and being deliberate right there) to finding that one sheep. That one coin. You. Or that guy. Or that lady. You just might not be the reason that guy’s out there shouting…But someone is. That kind of calculation and focus has a definite goal, a soul He’s winning over.

From how fast we usually go past these guys, we usually only hear snippets of what they are saying. The temptation is to think that because of how little we hear, that message cannot be effective. That would be true if we were listening to a man’s words. God’s word though, from what I’ve seen, is the kind where even one verse can tell an entire story about the situation you are going through. You who drove past, windows up, Nicki jam pumping, may have missed it. That lady dealing with some things that are weighing her down, those words might be a huge boost. That other guy might be mulling over the few bits he heard. The word may only plant a seed – do a Dicaprio inception, and the rest is done somewhere else by something else.

That street preacher, by our standards, isn’t pulling his weight. I’d ask him to organize a flash mob and as the crowd gathers, bam! drop the word on them (and then find a way to fence them off so they can’t flee till they hear it all. Muhahahaha). Thankfully, he listens to someone else. Given the success indicators of the guy he serves, he is probably successful….but you aren’t the target. It’s not him, it’s you.

Create Google Charts using MySQL data

While trying to create my own Google charts using MySQL data, the closest solution I found was this in Google’s documentation on how to do something similar. The code used there is:

 function drawChart() {
      var jsonData = $.ajax({
          url: "getData.php",
          dataType:"json",
          async: false
          }).responseText;

      // Create our data table out of JSON data loaded from server.
      var data = new google.visualization.DataTable(jsonData);

      // Instantiate and draw our chart, passing in some options.
      var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
      chart.draw(data, {width: 400, height: 240});
    }

I disagree with the approach there because of one line in their code:

async: false

That bit goes against the whole idea of AJAX. AJAX loads a certain section of your page Asynchronously; the line of code above stops that from happening. Everything is loaded synchronously meaning that your browser will wait while your Google chart is being generated. The code though won’t work if you change it to async:true because the variable jsonData will still be null by the time var data = new google.visualization.DataTable(jsonData); runs.

Secondly, in the example, data is read from a file.

$string = file_get_contents("sampleData.json");
echo $string;

It is very unlikely you’ll load dynamic data from a file. How can we do this better?

Two things:

  1. Your Json data has to be formatted in a particular way
  2. The JavaScript shouldn’t use async: false

Here’s what I used:

1. RETRIEVING AND FORMATTING THE DATA

In my case, I was drawing a line chart. The data I’d retrieve from the database needed to be formatted to look like this.

{
cols: [{id: 'A', label: 'NEW A', type: 'string'},
{id: 'B', label: 'B-label', type: 'number'},
{id: 'C', label: 'C-label', type: 'date'}
],
rows: [{c:[{v: 'a'},
{v: 1.0, f: 'One'},
{v: new Date(2008, 1, 28, 0, 31, 26), f: '2/28/08 12:31 AM'}
]},
{c:[{v: 'b'},
{v: 2.0, f: 'Two'},
{v: new Date(2008, 2, 30, 0, 31, 26), f: '3/30/08 12:31 AM'}
]},
{c:[{v: 'c'},
{v: 3.0, f: 'Three'},
{v: new Date(2008, 3, 30, 0, 31, 26), f: '4/30/08 12:31 AM'}
]}
],
p: {foo: 'hello', bar: 'world!'}
}

That’s a JavaScript object describing a table with three columns and three rows. The data you retrieve has to be formatted into something similar. Using PHP:

$output_array = array();
			$output_array["cols"] = array (
                            array(
                                "label"=>"Your Y Axis Label",
                                "type"=>"number"),
                            array(
                                "label"=>"Your X Axis Label",
                                "type"=>"number")
                        );
                        $output_array["rows"] = array ();
//Add MySQL connect & all that other stuff that connects and retrieves Objects from your Db
                        foreach( $retrieved_values as $value) {
                             $output_array["rows"][] = array("c"=>array(array(
                            "v"=>(float)$value->y_axis_field_being_plotted,
                            "f"=>null
                            ),array(
                            "v"=>$value->x_axis_field,
                            "f"=>null
                            )));
                        }
echo json_encode( $output_array );
//NB: Without casting $value->y_axis_field_being_plotted to float (or int or whichever), 
//your output values will be escaped as Strings and graphing won't work. If you don't want to cast, 
//you could change echo json_encode( $output_array ) to echo json_encode( $output_array, JSON_NUMERIC_CHECK ) 
//but that only works for PHP >=5.3

UPDATE: I discovered that you could retrieve the array simply by using:

$output_array = array();
                        $output_array[] = array( $y_axis_label,$x_axis_label );
                        //Connect to database, retrieve Objects
			foreach ( $retrieved_values as $value) {
				$output_array[] = array ( date_format(date_create($value->x_axis_field),'d-m-Y') ,(float)$value->y_axis_field_being_plotted);
			}
                        echo json_encode( $output_array );

2. THE JAVASCRIPT

google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(DrawGraph);
                    function DrawGraph() {
                        jQuery.post( "yourPostURL.php", //If in WordPress, it'd be admin_url( 'admin-ajax.php')
                                {   dataValueOne : 'Any_info_to_send',
                                    dataValueTwo : 'More_info_to_send'
                                },
                                function( response ) {
                                    var respObj = JSON.parse(response);
                                    if ( 'undefined' !== typeof(respObj.error) ){
                                        jQuery('#IDofChart').html( respObj.error.message );//Display an error message if something went wrong. You can display a generic message instead of respObj.error.message
                                        return ;
                                    }
                                    var chartData =  google.visualization.arrayToDataTable( respObj );
                                    var chartOptions = {
                                        title: "Your Chart Title"
                                                };//You can add other chart options
                                    var YourGoogleChart = new google.visualization.LineChart(document.getElementById('IDofChart'));
                                    YourGoogleChart.draw( chartData, chartOptions );
                        });
                    }

This worked to create the line graph below:

Google Charts Line Graph

Why the President should own all the money

One day to the LC5 by-elections in Busia, our beloved leader visited the district to buy the elections (because what else can you do in by-elections?). That was a joke. Back to the point; a day before the elections, our leader shows up to drum-up some support for his party’s candidate. To sway the electorate, I believe he whipped out charm and exuded hardcore passion for seeing the district develop. He probably used the kind of eloquence that undoubtedly brought the eager listeners to tears. In all that, he slipped in this,

“I have the money you need for some of the social services but if you make a mistake and vote for the Opposition, you would be blocking the channel because they cannot approach me.”

Beloved leader with all the money

Beloved leader with all the money

It was a wrap. The electorate was fully convinced. All those that had been on the fence, unmoved by the eloquence, passion, charm, and all those other great things we’ve come to expect from our leader, were finally sold on the money. How would the district develop under someone who can’t approach the man with the money? The district needs social services, social services need money, the man with the money says no one but his party’s candidate can approach him (maybe because he has a force field around him that can only be penetrated by his party’s cardholders)-it was an easy decision for the electorate to make. They showed up the next day and 58% of all votes cast went to the man our leader backed. It is believed that all those who voted someone else had not had the opportunity to listen to our leader’s speech the previous day.

All the naysayers finding fault with our dear leader having the nation’s money haven’t thought it through. Think about it- you, or any other citizen, can stop his motorcade and he’d help you out right there and then. No need to take the long route of advocating through your MP-he might fall asleep in Parliament and not deliver your request.

Also, our leader has good security, among the best in the world. We are very certain that our money is safe at all times.

Another thing is that our beloved leader is a rich man so he won’t eat the money.

And then, if ever any money got lost (though this can’t happen), we’d know whom to ask. No need to setup entire committees (that need facilitation) to investigate misappropriation. In this setup, we’d just ask him and he’d tell us.