Worldbank API Comparison Year More Indicators Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

Worldbank API Comparison Year More Indicators Tutorial

Worldbank API Comparison Year More Indicators Tutorial   ๐Ÿ”

Todayโ€™s progress onto yesterdayโ€™s Worldbank API Comparison Year Google Chart Mobile Tutorial is a callback to the original reason for the work, that being a graphical way to present what is the real marvel of proceedings, the amazing breadth and depth of public data presented at The World Bank โ€“ Indicators | Data, thanks. Sometimes we tend to ignore the primary source of information, but we need to acknowledge every now and again, such โ€œfounts of informationโ€, broken into indicators within the categories โ€ฆ

  • Agriculture & Rural Development
  • Aid Effectiveness
  • Climate Change
  • Economy & Growth
  • Education
  • Energy & Mining
  • Environment
  • External Debt
  • Financial Sector
  • Gender
  • Health
  • Infrastructure
  • Poverty
  • Private Sector
  • Public Sector
  • Science & Technology
  • Social Development
  • Social Protection & Labor
  • Trade
  • Urban Development

Pretty impressive! Weโ€™ve chosen a few new indicators to add to the pre-existant top two of โ€ฆ

  • Population
  • Gross Domestic Product
  • Access to electricity (% of population)
  • Forest Area (sq km)
  • Agricultural Land (sq km)
  • Fertility rate, total (births per woman)
  • Hospital Beds (per 1,000 people)
  • Rail Lines (total route-km)
  • Labor Force, Total
  • Population density (people per sq. km of land area)
  • Time required to start a business (days)

โ€ฆ โ€œAccess to electricity (% of population)โ€ noteworthy Pie Chart wise benefitting from option part pieSliceText: โ€œvalueโ€, โ€ฆ the general โ€œthemeโ€ being the more we all find out, the better we are to tackle the worldwide discussions we all need to have regarding Earthโ€™s big issues.

This needed changes to โ€ฆ



Previous relevant Worldbank API Comparison Year Google Chart Mobile Tutorial is shown below.

Worldbank API Comparison Year Google Chart Mobile Tutorial

Worldbank API Comparison Year Google Chart Mobile Tutorial   ๐Ÿ”

Yesterdayโ€™s Worldbank API Comparison Year Pie Chart Differences Tutorial involved Google Charts Pie Chart Difference graphics that โ€ฆ

As you may well be familiar with, here is a liveโœ‚run link to try this WorldBank data reporting yourself.


Previous relevant Worldbank API Comparison Year Pie Chart Differences Tutorial is shown below.

Worldbank API Comparison Year Pie Chart Differences Tutorial

Worldbank API Comparison Year Pie Chart Differences Tutorial   ๐Ÿ”

When you compare two year data sets with the web application of yesterdayโ€™s Worldbank API World Country Reporting Revisit Tutorial you are likely to be accessing the Google Charts Pie Chart Differences tool using Googleโ€smartsโ€ to compare two data sets via three graphical components.

Those โ€œgraphical componentsโ€ are each โ€œentitiesโ€ in terms of servicing any Google Charts โ€œselectโ€ event logic. In order to still have some โ€œselectโ€ (onclick) event logic we needed to compromise in two ways โ€ฆ

  • onmouseover tooltips could not be supported
  • the smaller Pie Chart slices two small to display a percentage value have not be zeroed into

โ€ฆ and so we become keen to help out here in two ways โ€ฆ

  1. try to make the legend not need clicking (and so size it to be a full list, at least for single letter executions) โ€ฆ thanks to this useful link, thanks, for lead to โ€ฆ


    <form onsubmit='return preiframeviaurl();' target='myiframe' id='myform' style='display:none;' method='POST' action='" . $preudiff . $udiff . ".php'>

    <input type='hidden' name='title' id='title' value='" . $reportmode2 . " by World Country " . $startswith . " for Year " . $tbit . "'></input>

    " . $onclick . "

    <input type='hidden' name='task' id='task' value='" . $reportmode . "'></input>

    <input type='hidden' name='desc' id='desc' value='" . $reportmode . "'></input>

    <input type='hidden' name='label' id='label' value='Year'></input>

    <input type='hidden' name='value' id='value' value='" . str_replace('%2c','',str_replace('%2C','',$valuelist)) . "'></input>

    <input type='hidden' name='onclick' value='y'></input>

    <input type='hidden' name='moreopt' value=' width: 620, height: 1200, chartArea: { width: \"50%\", height: \"70%\" }, '></input>

    <input type='hidden' name='data' id='data' value='" . explode("&data=",$url)[1] . "'></input>" . "\n" . $idata2 . "\n" . "

    <input id='mysubmit' type='submit' value='Draw Pie Chart'></input>

    </form>
  2. make sure a full data list appears (along with emoji flags and population numbers) in the Javascript prompt window value part

This involved the โ€œsupervisory childโ€ โ€ฆ


Previous relevant Worldbank API World Country Reporting Revisit Tutorial is shown below.

Worldbank API World Country Reporting Revisit Tutorial

Worldbank API World Country Reporting Revisit Tutorial   ๐Ÿ”

Weโ€™re revisiting the PHP web application of Worldbank API World Country Reporting Regex Tutorial for a few days to โ€ฆ

  • add some emoji flags
  • fix some event logic weaknesses, starting today with the single year Worldbank Data incarnations (thanks to World Bank API), but not finished as far as comparison years Worldbank Data incarnations
  • fix Mixed Content issues to allow for seamless SSL https: or http: URL usage

So, today, both โ€œparentโ€ HTML and โ€œchildโ€ PHP changed today so that โ€ฆ

โ€ฆ overseeing Google Chart Pie Chart interfacing that changed as per pie_chartโšซphp changed thisway and pie_chart_diffphp changed thisway.

Try a liveโœ‚run link for yourself to see where we are going with this.


Previous relevant Worldbank API World Country Reporting Regex Tutorial is shown below.

Worldbank API World Country Reporting Regex Tutorial

Worldbank API World Country Reporting Regex Tutorial   ๐Ÿ”

Donโ€™t know why, but have often equated regex work in Javascript or PHP with โ€œRegEx Rangersโ€, or some such other โ€œsuperheroโ€ categorization. That is because to wield RegEx principles is a bit like swinging a sword through the โ€œbutterโ€ of coding problems. Its use can feel arcane, but using it can solve so many issues and simplify projects, it is unbelievable. Trouble Iโ€™ve always found is that I like to be presented with a RegEx โ€œaskโ€ as a user, but donโ€™t think a lot of people like it. An upcoming tutorial, though, will show the wonders of a โ€œRegExโ€ scenario for a text editing job we did recently โ€ฆ weโ€™ll keep you posted on that.

But back to todayโ€™s โ€œRegExโ€ thinking, building on top of yesterdayโ€™s Worldbank API World Country Reporting Range Tutorial. We ended up asking the user for optional โ€œRegExโ€ matching criteria for name matches between the Worldbank API dataโ€™s โ€ฆ

  • key (or name)
  • value (numerical)

โ€ฆ properties, to add to the pre-existing, and still available, the โ€œstarting withโ€ name filtering functionality weโ€™ve had working ever since Worldbank API World Country Population Report Tutorial as shown way below.

RegEx โ€œthinkingโ€ exists for both server and client parts of web applications, for us, consecutively with โ€ฆ

โ€ฆ and we use it with serverside PHP today, under the auspices of the preg_match function, though we most often use RegEx thinking with the Javascript replace function, as the way to make substitutions for more than one occurrence, (the one occurrence design being) a default โ€œcuriosityโ€ (but can be useful too) about Javascriptโ€™s version of substitution. You may know this RegEx usage of the Javascript replace function as โ€œglobal substitutionโ€.

If youโ€™re new to RegEx thinking let me outline just a few tips โ€ฆ

  • ^ can mean โ€œstart ofโ€
  • $ can mean โ€œend ofโ€
  • . can sometimes mean โ€œone existant character wildcardโ€ โ€ฆ or sometimes it is % or ? for this in other โ€œsystemsโ€
  • * can often mean โ€œzero or more of preceding character wildcardโ€
  • [] and () bracketing rules are pretty crucial for the more esoteric usages โ€ฆ also study | usage

In our tutorial picture we are showing โ€œland$โ€ countries that would feature, if Greenland goes independent one day โ€ฆ

  • Greenland โ€ฆ โ€œfull of iceโ€ โ€ฆ and โ€ฆ
  • Iceland โ€ฆ โ€œfull of greenโ€

Again, both โ€œparentโ€ HTML and โ€œchildโ€ PHP changed today so that โ€ฆ

โ€ฆ to facilitate better (optional) Country name filtering for users of the web application.


Previous relevant Worldbank API World Country Reporting Range Tutorial is shown below.

Worldbank API World Country Reporting Range Tutorial

Worldbank API World Country Reporting Range Tutorial   ๐Ÿ”

If youโ€™ve been keeping up to date with the latest thread of blog postings regarding our โ€œWorldbank API World Country Reporting Projectโ€ web application, youโ€™ll notice that there is no mention of a Worldbank API indicators in the blog title. That is because we still have โ€œgenericโ€ matters to consider, but that is not an imposition to the web application design today. Today, as well as โ€ฆ

  • the original alphabetic starting with country filter (to key below) โ€ฆ weโ€™ve added, today, a โ€ฆ
  • value โ€œrangeโ€ filter (to value below) applied to the reporting themeโ€™s numerical value

โ€ฆ and because everything reported on has a โ€ฆ

  • key (or name)
  • value (numerical)

โ€ฆ basis, we can apply todayโ€™s value โ€œrangeโ€ filter generically โ€œacross the boardโ€ (for any of the indicators โ€œPopulationโ€ and โ€œGross Domestic Productโ€, so far).

Why do we use the word โ€œfilterโ€ here? Well, a filter limits something, and weโ€™re limiting the maximum amount of output data reported on, by, optionally, taking what a user says about the minimum and maximum (numerical) value ranges for data reporting.

In the case of Google Charts, when there is lots of data too close together to view it definitively, it does some clever data reduction, and we have a means today, to get in under that data reduction to more esoteric reporting possibilities, as a result of our new filter, used well by the user.

Letโ€™s show you how a cluttered //www.rjmprogramming.com.au/PHP/worldbank_population_data.php?startswith=C&year=2015&yearvs=-2011&justletters=y โ€ฆ

โ€ฆ can become uncluttered //www.rjmprogramming.com.au/PHP/worldbank_population_data.php?startswith=C&year=2015&yearvs=-2011&max=40000000&justletters=y for those smaller values, by using this value โ€œrangeโ€ filter below โ€ฆ

So yet again, both โ€œparentโ€ HTML and โ€œchildโ€ PHP changed today so that โ€ฆ

And so yet again, we would welcome you trying this webโœ‚application for yourself to try out the new value range filtering functionality that we also talk about at WordPress 4.1.1โ€™s Worldbank API World Country Reporting Range Tutorial.


Previous relevant Worldbank API World Country Gross Domestic Product Tutorial is shown below.

Worldbank API World Country Gross Domestic Product Tutorial

Worldbank API World Country Gross Domestic Product Tutorial   ๐Ÿ”

Weโ€™ve changed onion types today in our quest for the ultimate โ€œonion of the 4th dimensionโ€ concept this project, that being our โ€ฆ oops, the goalposts have shifted โ€ฆ web application project โ€œWorldbank API World Country Population Report Projectโ€ where we extend the โ€œscopeโ€ of the โ€œindicatorsโ€ we can report on to those we presented yesterday with Worldbank API World Country Population Period Tutorial, those being the original โ€ฆ

  • Population โ€ฆ and today we add to that, the World Bank โ€œindicatorโ€ โ€ฆ
  • Gross Domestic Product

โ€ฆ and here you may have sneaked a peek below to see that โ€ฆ

  • nothing codewise has been added to in terms of โ€œpieces of codeโ€ โ€ฆ we thank the excellence of (the organization of the) Worldbank API for this, as the form of the GDP data is not enough different to that of the Population data to warrant us thinking that we needed to change anything other than versions โ€ฆ and โ€ฆ
  • nothing codewise has been renamed in terms of โ€œpieces of codeโ€ โ€ฆ and that is us โ€ฆ weโ€™re not embarrassed that a โ€œguinea pigโ€ for an idea gets extended into a bigger picture โ€ฆ so long as โ€œWorldbankโ€ is there in the name somewhere

This โ€œguinea pigโ€ method of extending a project has its advantages and disadvantages as most methods of doing things (inherently) have (their own) advantages and disadvantages. The โ€œguinea pigโ€ approach may suffer if things become complex later when you try to fit in another โ€œextendedโ€ concept that is a bit of a โ€œsquare holeโ€ being forced into our โ€œround socketโ€ โ€ฆ (๐Ÿ˜„๐Ÿ’–๐Ÿ”ด). Conversely, if things stay simple enough, why not use methods like โ€ฆ

  • plugging in a programmatic โ€œvariableโ€ where once there was a โ€œhardcodingโ€ โ€ฆ and โ€ฆ
  • plugging in (the equivalent of) an HTML select element โ€œdropdownโ€ where once there was a titular piece of text

โ€ฆ to keep on pushing out the โ€œonionโ€ types โ€ฆ we know youโ€™re out there โ€ฆ come anโ€™ show us the cut of your jib!

Yet again, both โ€œparentโ€ HTML and โ€œchildโ€ PHP changed today for the new extended โ€œindicatorโ€ reporting (adding GDP to pre-existing Population indicator(s)), so that โ€ฆ

And yet again, we would welcome you trying this webโœ‚application for yourself to try out this new โ€œlayerโ€ of functionality โ€œpositioningโ€.


Previous relevant Worldbank API World Country Population Period Tutorial is shown below.

Worldbank API World Country Population Period Tutorial

Worldbank API World Country Population Period Tutorial   ๐Ÿ”

Yesterdayโ€™s Worldbank API World Country Population Trend Tutorial started us on the topic of โ€œtrendsโ€ with data and our Google Chart Pie Chart Differences representation of Worldbank API derived data took the form of the first of โ€ฆ

  • snapshot (of two different snapshotted times) โ€ฆ but today we turn our attention to โ€ฆ
  • period of time (of several regular snapshotted times)

โ€ฆ and for the purposes of this latter โ€œchartโ€ reporting we like, around here, still talking in terms of Google Charts, in order of our opinion โ€œregarding quality of reporting purposeโ€ with regard to this Worldbank API Population data reporting โ€ฆ

  • Line Chart
  • Column Chart
  • Bar Chart
  • Area Chart

โ€ฆ all Google Chart โ€œtypesโ€ looking for the same basic form of data, the hint, in the first place, why we associate these all together with that new period of time reporting options weโ€™ve integrated into the web application at the โ€œparentโ€ HTML supervisor level by, for every new option from yesterday of the form [year] compared to in that top lefthand HTML select element โ€œdropdownโ€, we also add in an associated [year] through to โ€œdropdownโ€ option which, if selected, will present the user with the opportunity to select the type of Google Chart theyโ€™d like to see from the list of four chart types as described above.

Again, both โ€œparentโ€ HTML and โ€œchildโ€ PHP changed today for that period of time concept of reporting, so that โ€ฆ

And again, we would welcome you trying this webโœ‚application for yourself, to get this into perspective regarding perhaps, your own opinions about the pros and cons, strengths and weaknesses of the various very useful Google Chart ideas we appreciate for those reporting tasks, helping support the adage โ€œevery picture is worth a thousand wordsโ€.


Previous relevant Worldbank API World Country Population Trend Tutorial is shown below.

Worldbank API World Country Population Trend Tutorial

Worldbank API World Country Population Trend Tutorial   ๐Ÿ”

The โ€œonion of the 4th dimensionโ€ way to go (after yesterdayโ€™s Worldbank API World Country Population Report Tutorial as shown below) for our latest web application project โ€œWorldbank API World Country Populationโ€ we like is to now start thinking of a means to show โ€œtrendsโ€ in population. With this in mind there is a ready made Google Chart Pie Chart Differences to help here. With the Google Chart Pie Chart Differences weโ€™ll supply two different years worth of data, and the cleverness of this Google Chart product is called into play to show three Pie Charts, namely โ€ฆ

  • original yearโ€™s Pie Chart Worldbank API data
  • โ€œcompared toโ€ yearโ€˜s Pie Chart data
  • a Google Chart Pie Chart Differences โ€œtrendโ€ Pie Chart showing an โ€œinner ringโ€ Pie Chart within an โ€œouter ringโ€ Pie Chart where you can get a sense of โ€œtrendsโ€ that are taking place

โ€ฆ that is manifested in the โ€œparentโ€ HTML code by changing the previous hardcoded โ€œYearโ€ word with an HTML select element โ€œdropdownโ€ element to define that optional second โ€œcompared toโ€ year of interest.

The other new functionality today is a โ€œshareโ€ via Email emoji (HTML a link โ€œbuttonโ€) that latches on to the userโ€™s Email client program via Middle Word Share Tutorialโ€˜s approach, namely โ€ฆ

mailto:[emailAddress]?subject=[Subject]&body=[URLtoLinkTo] type of href property (on that link). As you can imagine, it is possible to piece together a Javascript encodeURIComponent() version of [URLtoLinkTo] value via the current webpageโ€™s document.URL

โ€ฆ the curious variation being that we donโ€™t think of the โ€œparentโ€ HTMLโ€™s document.URL here (in blurb above), but, rather, it is more useful to consider the โ€œchildโ€ HTML iframe element PHPโ€™s document.URL both as an easier to code concept, and the simplifier of โ€œlength of dataโ€ GET vs POST HTML form element originated data issues. You see, if your data getting to the Pie Chart is over a certain length, it will be POSTed and you would lose the opportunity to Email this (in that mailto: email client program way), because you rely on real GET method URLs for this approach. At the โ€œviewโ€ of the middle โ€œchildโ€ PHP, though, it gets its calls, always, in a GET URL way, so it is, counterintuitively, the best (and simplest) place to intervene and code for this Email โ€œshareโ€ functionality.

Both โ€œparentโ€ HTML and โ€œchildโ€ PHP changed today, so that โ€ฆ

We would welcome you trying this webโœ‚application for yourself, to get this into perspective.


Previous relevant Worldbank API World Country Population Report Tutorial is shown below.

Worldbank API World Country Population Report Tutorial

Worldbank API World Country Population Report Tutorial   ๐Ÿ”

In yesterdayโ€™s Worldbank API World Country Population Primer Tutorial, as shown below, we noted โ€ฆ

the data is presented in some way shape or form with the Pie Chart, but for all the advantages of lots of information in the one place, it does suffer a bit with clutter

โ€ฆ and today we show some practical strategies to be more clear (less cluttered) with the data, should the user, optionally, be interested, here.

In practical terms, we built a supervisory HTML โ€œparentโ€ you could call worldbank_population_dataโšซhtml (with this new liveโœ‚run link) on top of yesterdayโ€™s โ€œduck with the legs moving fastโ€ hard working โ€œchildโ€ HTML iframe element housed PHP worldbank_population_dataโšซphp (changed thisway to accomodate this move).

If you had to break up a huge chunk of Worldbank API data related to World Countries and their Population, what would you research as an idea to do this? No doubt a lot of people would agree with how we approach it, that being โ€ฆ



report via a "starting with" alphabetic criteria

Makes sense? We hope so, and weโ€™ll also ask for a Year of interest, with the caveat that we should offer the user the โ€œabsolute thinkingโ€ that would say if you are doing a report on โ€ฆ



Population by World Country A for year 2015

โ€ฆ for example, you should offer the user to show Pie Charts for the two scenarios below โ€ฆ

  • World Country A Populations compared to each other โ€ฆ or โ€ฆ
  • World Country A Populations compared to each other and a Non-A Population entry (which totals all non-A country populations)

We could present these functionality options in an HTML select element โ€œdropdownโ€, but we think today, weโ€™ll use a top menu of HTML a links to interface to the user of this โ€œparentโ€ supervisory webโœ‚application we welcome you to try out for yourself.


Previous relevant Worldbank API World Country Population Primer Tutorial is shown below.

Worldbank API World Country Population Primer Tutorial

Worldbank API World Country Population Primer Tutorial   ๐Ÿ”

Today weโ€™re revisiting the absolutely astonishing resource that the Worldbank API website provides. Such free public sources of data are very much appreciated in our books. Not so much in our pamphlets, but definitely in the books. Revisiting we thought, perhaps, we heard you ask โ€ฆ or were you passing wind? Glad you asked. Remember when we presented PHP Worldbank Growth of Merchandise Trade Tutorial, as shown below? Then, we used Google Chart Bubble Chart to present reams of information. Today, we again broach โ€œreamsโ€ of Wordbank Population data per country to present a Google Chart Pie Chart report.

On our โ€œfirst draftโ€ of this web application project we create just the one pie chart, but we do that, along the way showing you a couple of things โ€ฆ

  • the โ€œreamsโ€ of data is processed on the understanding it could be sent to an HTML iframe as a URL plonked into that iframe elementโ€™s src property (as if), or if that URL is too long then that data is plugged into the HTML form and then sent (POSTed) to that same HTML iframe (whose name is the same as the form elementโ€™s target=name) via an HTML form element whose action property is set to โ€ฆ


    //www.rjmprogramming.com.au/PHP/PieChart/pie_chart.php

  • the data is presented in some way shape or form with the Pie Chart, but for all the advantages of lots of information in the one place, it does suffer a bit with clutter

โ€ฆ and so we try some strategies to help with those clutter issues above in blog postings to come.

In the meantime, why not try a liveโœ‚run of the underlying PHP (serverside) web application you could call worldbank_population_dataโšซphp featuring โ€ฆ

  • use of PHP file_get_contents() to extract โ€ฆ
  • JSON data is extracted and parsed to help piece together that URL to the Google Chart Pie Chart, as mentioned way above

Previous relevant PHP Worldbank Growth of Merchandise Trade Tutorial is shown below.

PHP Worldbank Growth of Merchandise Trade Tutorial

PHP Worldbank Growth of Merchandise Trade Tutorial   ๐Ÿ”

Weโ€™ve said it before, and (no doubt) weโ€™ll say it again โ€ฆ there are great public data sources out there for you to explore.

As far as international data goes the Worldbank series of statistics is great, so, thanks.

Today we combine the Worldbank data for Growth of Merchandise Trade 2003-2013 with the wonderful Google Chart Bubble Chart to create (52 = (first letters of country name) 26 x 2 (concepts: Exports and Imports)) reporting charts of interest, we hope. Again, as with any reporting subject, it is a personal thing, whether the subject matter of a report is of interest, but you could say that about so many things in life.

So, we offer some PHP source code you could call growth_of_merchandise_tradeโšซphp and a liveโœ‚run link as well, the full loading of which requires patience.

Stop Press

Tomorrow we go over what was needed to change PHP code above to be more mobile friendly โ€ฆ

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Event-Driven Programming, Tutorials and tagged , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *