{"id":15909,"date":"2015-07-11T05:01:26","date_gmt":"2015-07-10T19:01:26","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=15909"},"modified":"2016-02-08T18:29:55","modified_gmt":"2016-02-08T08:29:55","slug":"php-and-jquery-google-pie-chart-tooltips-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-and-jquery-google-pie-chart-tooltips-tutorial\/","title":{"rendered":"PHP and jQuery Google Pie Chart Tooltips Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart.php\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"PHP and jQuery Google Pie Chart Tooltips Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/PieChart_ToolTip.jpg\" title=\"PHP and jQuery Google Pie Chart Tooltips Tutorial\"  \/><\/a><p class=\"wp-caption-text\">PHP and jQuery Google Pie Chart Tooltips Tutorial<\/p><\/div>\n<p>We&#8217;re returning to Google Graphs API, or Google Chart Tools, and its Pie Chart functionality as last talked about, specifically, with previous <a target=_blank title='PHP\/Javascript\/HTML Google Chart Diff Pie Chart Tutorial' href='#pjhgcdpct'>PHP\/Javascript\/HTML Google Chart Diff Pie Chart Tutorial<\/a> (as shown below), to develop, further, here, some improved functionality.  Specifically we address &#8230;<\/p>\n<ol>\n<li>a way to show a 3D look (now the default) or a 2D look to the Pie Chart<\/li>\n<li>a way to show a donut look (2D only)<\/li>\n<li>a way to cater for a POST message from an HTML form (so that more data can be handled)<\/li>\n<li>a way to show a customised tooltip<\/li>\n<\/ol>\n<p>The last two tooltip functionality improvements above, you may remember also being applied to the Map Chart a few days back when we published <a target=_blank title='PHP\/Javascript\/HTML Google Chart Map Onclick Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/phpjavascripthtml-google-chart-map-onclick-tutorial\/'>PHP\/Javascript\/HTML Google Chart Map Onclick Tutorial<\/a>.  As the weeks go on, others will also be attended to.<\/p>\n<p>It is quite likely that now is a good time for you to consult the Pie Chart information page <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/gallery\/piechart' title='Google Pie Charts'>via Google<\/a>.<\/p>\n<p>The Pie Chart&#8217;s tooltip (content) is heavily weighted towards being the percentage of the pie, as you&#8217;d expect, so we looked up whether other ideas can come into play and we stumbled upon this excellent <a target=_blank href='https:\/\/gist.github.com\/alexrainman\/bb8d49357250df0859c0' title='Useful link'>webpage<\/a>, for which we give hearty thanks.<\/p>\n<p>If you&#8217;ve &#8220;digested&#8221; this information, you&#8217;ll see that it calls upon <a target=_blank href='http:\/\/jquery.org' title='jQuery Javascript library home page'>jQuery<\/a> functionality to help out our usual Javascript client code for the Pie Charts.  It is clever enough to allow an onmouseover (ie. hover event) tooltip to be able to handle HTML functionality, so you&#8217;ll see most of the changes to our PHP <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart.php---GETME\" title='pie_chart.php'>pie_chart.php<\/a> code revolving around &#8230;<\/p>\n<ul>\n<li>effectively informing the user when they can intervene to tailor a tooltip (if combined with HTML content it can tailor the actual look of the Pie Chart as well, because it will show labels rather than percentages), and what they have to do, in general terms (just to set the pattern, for tailoring this, specifically (my favourite word today), to your own requirements)<\/li>\n<li>validating this user entry data for what will suit the PHP program and its interface to the Google Chart API usage &#8230; lots of <a target=_blank href='http:\/\/www.w3schools.com\/jsref\/jsref_encodeURIComponent.asp' title='Javascript encodeURIComponent  method information from w3schools'>encodeURIComponent<\/a> here!<\/li>\n<\/ul>\n<p>Having tooltips off the data sectors of the Pie Chart enhances its functionality considerably, should you be looking for the Pie Chart to be an interactive reporting tool, perhaps for collaboration purposes, as you can email your Pie Chart, as well, as we talked about with <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/ITblog\/google-charts-emailing-primer-tutorial\/' title='Google Charts Emailing Primer Tutorial'>Google Charts Emailing Primer Tutorial<\/a>.<\/p>\n<p>So the PHP code changed from that emailing (<a target=_blank href='https:\/\/www.rjmprogramming.com.au\/ITblog\/google-charts-emailing-primer-tutorial\/' title='Google Charts Emailing Primer Tutorial'>Google Charts Emailing Primer Tutorial<\/a>) functionality as per <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart.php---GETME\" title-'pie_chart.php'>this link<\/a>.<\/p>\n<p>And so it behoves moi to show you a link to a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart.php\" title='Click picture'>live run<\/a> (as a GET method) versus<\/p>\n<div align='center'><iframe frameborder=0 id='topi' style=\"height:50px; width:100%;\"  src='http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/postit.php' title='Google Chart Pie Chart form post method'><\/iframe><\/div>\n<\/p>\n<hr>\n<p id='pjhgcdpct'>Previous relevant <a target=_blank title='PHP\/Javascript\/HTML Google Chart Diff Pie Chart Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/phpjavascripthtml-google-chart-diff-pie-chart-tutorial\/'>PHP\/Javascript\/HTML Google Chart Diff Pie Chart Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart_diff.php\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"PHP\/Javascript\/HTML Google Chart Diff Pie Chart Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/PieChart_Diff.jpg\" title=\"PHP\/Javascript\/HTML Google Chart Diff Pie Chart Tutorial\"  \/><\/a><p class=\"wp-caption-text\">PHP\/Javascript\/HTML Google Chart Diff Pie Chart Tutorial<\/p><\/div>\n<p>Here is a tutorial that introduces you to Google Graphs API, or Google Chart Tools, and its Pie Chart functionality as outlined in previous <a target=_blank title='PHP\/Javascript\/HTML Google Chart Pie Chart Tutorial' href='#pjhgcpct'>PHP\/Javascript\/HTML Google Chart Pie Chart Tutorial<\/a> (as shown below) is developed further here with the concept of differences between data sets.   So today we use Google Charts for two data sets of similar criteria and then present a presentation of the differences.  Pie charts, column charts, bar charts, and scatter charts can all be used as the data basis for your <i>&#8220;difference&#8221;<\/i> analysis.<\/p>\n<blockquote><p>Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.<\/p><\/blockquote>\n<p>Let&#8217;s see some  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart_diff.php'>PHP<\/a> code in live action for this tutorial where you define your pie chart characteristics and data, twice &#8230; and you&#8217;ll see that stereo has advantages over mono &#8230; but <a target=_blank title='monotonous rocks' href='http:\/\/www.ncbi.nlm.nih.gov\/pubmed\/11543491'>monotonous rock<\/a>s rock?!<\/p>\n<p>Link to Google Chart Tools &#8220;spiritual home&#8221; &#8230; <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/index' title='Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.\n'>via Google<\/a>.<br \/>\nLink to Google Chart Tools Pie Chart information &#8230; <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/gallery\/piechart' title='Google Pie Charts'>via Google<\/a>.<br \/>\nLink to Google Chart Diff Charts information &#8230; <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/gallery\/diffchart' title='Google Diff Charts'>via Google<\/a>.<\/p>\n<p>Link to some downloadable PHP programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart_diff.php_GETME' title='Download me'>pie_chart_diff.php<\/a><\/p>\n<p>Here is a new link to some downloadable PHP programming source code explaining changes made (from tutorial below)  <a target=_blank title='pie_chart_diff.php' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart.php-GETME\">here<\/a>.<\/p>\n<hr \/>\n<p id='pjhgcpct'>Previous <a target=_blank title='PHP\/Javascript\/HTML Google Chart Pie Chart Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=1538'>PHP\/Javascript\/HTML Google Chart Pie Chart Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart.php\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"PHP\/Javascript\/HTML Google Chart Pie Chart Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/PieChart.jpg\" title=\"PHP\/Javascript\/HTML Google Chart Pie Chart Tutorial\"  \/><\/a><p class=\"wp-caption-text\">PHP\/Javascript\/HTML Google Chart Pie Chart Tutorial<\/p><\/div>\n<p>Here is a tutorial that introduces you to Google Graphs API, or Google Chart Tools, and its Pie Chart functionality.<\/p>\n<blockquote><p>Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.<\/p><\/blockquote>\n<p>Let&#8217;s see some  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart.php'>PHP<\/a> code in live action for this tutorial where you define your pie chart characteristics and data.<\/p>\n<p>Link to Google Chart Tools &#8220;spiritual home&#8221; &#8230; <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/index' title='Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.\n'>via Google<\/a>.<br \/>\nLink to Google Chart Tools Pie Chart information &#8230; <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/gallery\/piechart' title='Google Pie Charts'>via Google<\/a>.<\/p>\n<p>Link to some downloadable PHP programming code &#8230; rename to <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart.php_GETME' title='Download me'>pie_chart.php<\/a>.<\/p>\n<p>Did you know? &#8230; <a target=_blank title='Very interesting' href='http:\/\/www.kdnuggets.com\/news\/2008\/n07\/22i.html'>Very interesting!<\/a><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d1538' onclick='var dv=document.getElementById(\"d1538\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=Google+Chart#content\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d1538' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d5601' onclick='var dv=document.getElementById(\"d5601\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=Google+Chart#content\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d5601' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d15909' onclick='var dv=document.getElementById(\"d15909\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/?tag=tooltip\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d15909' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;re returning to Google Graphs API, or Google Chart Tools, and its Pie Chart functionality as last talked about, specifically, with previous PHP\/Javascript\/HTML Google Chart Diff Pie Chart Tutorial (as shown below), to develop, further, here, some improved functionality. Specifically &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/php-and-jquery-google-pie-chart-tooltips-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[1605,513,518,1608,576,652,663,861,871,932,944,997,1226,1609,1319],"class_list":["post-15909","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-encodeuricomponent","tag-google","tag-google-chart","tag-hover","tag-html","tag-javascript","tag-jquery","tag-onclick","tag-onmouseover","tag-php","tag-pie-chart","tag-programming","tag-svg","tag-tooltips","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/15909"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=15909"}],"version-history":[{"count":17,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/15909\/revisions"}],"predecessor-version":[{"id":20058,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/15909\/revisions\/20058"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=15909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=15909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=15909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}