{"id":48010,"date":"2020-02-16T03:01:25","date_gmt":"2020-02-15T17:01:25","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=48010"},"modified":"2020-02-27T18:45:08","modified_gmt":"2020-02-27T08:45:08","slug":"google-chart-pie-chart-macos-korn-shell-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/google-chart-pie-chart-macos-korn-shell-tutorial\/","title":{"rendered":"Google Chart Pie Chart macOS Korn Shell 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=\"border: 15px solid pink;\" alt=\"Google Chart Pie Chart macOS Korn Shell Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart_korn_shell.jpg\" title=\"Google Chart Pie Chart macOS Korn Shell Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Google Chart Pie Chart macOS Korn Shell Tutorial<\/p><\/div>\n<p>Around here at RJM Programming we encourage the adage &#8220;keeping busy&#8221; and &#8220;keep moving forward&#8221; <font size=1>(and sometimes sideways)<\/font> even if that movement is a very nuanced moving forward.   Today&#8217;s tutorial is a case in point, because even though a regular reader might say &#8220;what is new with this Google Chart Pie Chart macOS Korn Shell Tutorial to the recent <a target=_blank title='Google Chart Geo Chart macOS Korn Shell Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/google-chart-geo-chart-macos-sorn-shell-tutorial\/'>Google Chart Geo Chart macOS Korn Shell Tutorial<\/a>?&#8221; &#8230; we found the exercise of interest &#8230;<\/p>\n<ul>\n<li>partly because when you get in there and code, environmental differences can surprise &#8230; and &#8230;<\/li>\n<li>don&#8217;t underestimate how good it is to &#8220;retry a similar concept&#8221; and learn better ways (perhaps) of approaching coding problems, as it is very seldom we code a problem twice the same way (ask someone to quietly hive away some code you wrote, but ask you to rewrite it even a day later, compare, and I&#8217;d be surprised that the code is the same, if it involves any complexity)<\/li>\n<\/ul>\n<p>At the macOS command line Korn Shell <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart.ksh_GETME\" title=\"pie_chart.ksh\">pie_chart.ksh<\/a> end, different to Google Chart Geo Chart macOS Korn Shell Tutorial we involved &#8230;<\/p>\n<ul>\n<li>a new &#8220;__&#8221; forced delimitation regime between the &#8220;?&#8221; and &#8220;=&#8221; (ie. within the one web application&#8217;s argument&#8217;s name) to be certain of a one to one association of data items &#8230;<\/li>\n<li>we use (good &#8216;ol) <a target=_blank title='Linux sed command information from computerhope' href='http:\/\/www.computerhope.com\/unix\/used.htm'><i>sed<\/i><\/a> as that brilliant command line &#8220;stream editor&#8221; &#8230; and can imagine more involved applications might benefit from the use of <a target=_blank title='Linux awk command information from computerhope' href='http:\/\/www.computerhope.com\/unix\/uawk.htm'><i>awk<\/i><\/a><\/li>\n<li>with the prompting progression, we back reference (via the good &#8216;ol Unix <b>`[interpret me and clobber me with it]`<\/b> backtick methodologies) variables we&#8217;ve already gleaned the value of, more &#8230; hence the use of <i>echo &#8220;blah ${blah} blah&#8221;<\/i> rather than <i>echo &#8216;blah ${blah} blah&#8217;<\/i><\/li>\n<\/ul>\n<p>At the PHP <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.'>Google Chart<\/a> <a target=_blank href='https:\/\/developers.google.com\/chart\/interactive\/docs\/gallery\/piechart' title='Google Pie Charts'>Pie Chart<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart.php-------------------GETME\">pie_chart.php<\/a> (<a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart.php\" title=\"Click picture\">web application<\/a> changed &#8230;<\/p>\n<p>&lt;?php<br \/>\n<code><br \/>\n    \/\/ Command line Korn Shell interfacing code<br \/>\n    if (!isset($_GET['data']) && !isset($_POST['data'])) {<br \/>\n    if (strpos(strtolower(('' . $_SERVER['QUERY_STRING'])), 'listis=') !== false) {<br \/>\n    $urlbase=\"https:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart.php\";<br \/>\n    $proposedform=\"&lt;ht\" . \"ml&gt;&lt;bo\" . \"dy onload=\\\"document.getElementById('clickme').click();\\\"&gt;&lt;form id=myf style=display:none; target=_self action='\" . $urlbase . \"' method=POST&gt;&lt;input type=hidden name=onclick value=y&gt;&lt;\/input&gt;&lt;input id=clickme type=submit value=Submit&gt;&lt;\/input&gt;&lt;\/form&gt;&lt;\/body&gt;&lt;\/html&gt;\";<br \/>\n    $datavalis=explode(\"=\", ('' . $_SERVER['QUERY_STRING']))[1];<br \/>\n    $bitsbetween=[\"?title=\", \"&onclick=y&task=\", \"&desc=\", \"&data=\"];<br \/>\n    $bitsap=explode(\"__\", explode(\"=\", explode(\"?\", ('?' . $_SERVER['QUERY_STRING']))[1])[0]);<br \/>\n    for ($iuy=0; $iuy&lt;sizeof($bitsap); $iuy++) {<br \/>\n      if (strtolower(str_replace(\"_\", \"%20\", $bitsap[$iuy])) == \"listis\") {<br \/>\n      $proposedform=str_replace(\" method=POST&gt;\", \" method=POST&gt;&lt;input type=hidden name='\" . explode(\"=\", explode(\"&\", substr($bitsbetween[$iuy],1))[-1 + sizeof(explode(\"&\", substr($bitsbetween[$iuy],1)))])[0] . \"' value='\" . str_replace(\"+\",\" \",urldecode($datavalis)) . \"'&gt;&lt;\/input&gt;\", $proposedform);<br \/>\n      $urlbase.=$bitsbetween[$iuy] . '' .  str_replace(\" \", \"%20\", str_replace(\"+\",\" \",urldecode($datavalis)));<br \/>\n      } else {<br \/>\n      $proposedform=str_replace(\" method=POST&gt;\", \" method=POST&gt;&lt;input type=hidden name='\" . explode(\"=\", explode(\"&\", substr($bitsbetween[$iuy],1))[-1 + sizeof(explode(\"&\", substr($bitsbetween[$iuy],1)))])[0] . \"' value='\" . str_replace(\"_\", \" \", $bitsap[$iuy]) . \"'&gt;&lt;\/input&gt;\", $proposedform);<br \/>\n      $urlbase.=$bitsbetween[$iuy] . '' . urlencode(str_replace(\"_\", \"%20\", $bitsap[$iuy]));<br \/>\n      }<br \/>\n    }<br \/>\n<br \/> <br \/>\n    if (strlen($urlbase) &gt; 800) {<br \/>\n    echo $proposedform;<br \/>\n    } else {<br \/>\n    header('Location: ' . $urlbase);<br \/>\n    }<br \/>\n    exit;<br \/>\n    }<br \/>\n    }<br \/>\n<\/code><br \/>\n?&gt;<\/p>\n<p> &#8230; <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\">this way<\/a>) interfacing end to allow for this command line &#8220;front interface&#8221; &#8230;  different feeling to Google Chart Geo Chart macOS Korn Shell Tutorial &#8230;<\/p>\n<ul>\n<li>we do not resort to Javascript at all for short URL cases &#8230; and for the long ones &#8230;<\/li>\n<li>check for proposed URL length within PHP and navigate via an HTML form method=POST methodology<\/li>\n<\/ul>\n<p>We&#8217;ll leave you with some Korn Shell code for this &#8230;<\/p>\n<p><code><br \/>\n#!\/bin\/ksh<br \/>\necho 'Interface to Google Chart Pie Chart interfacer created by RJM Programming ...'<br \/>\necho ''<br \/>\nequl=\"=\"<br \/>\nprefd=\",%20[~\"<br \/>\nsuffd=\"]%20\"<br \/>\necho \"Verb for command line eg. open eg. curl \"<br \/>\nread verb<br \/>\nif [ -z \"$verb\" ]; then<br \/>\n verb=\"open\"<br \/>\nfi<br \/>\nif [ ! -z \"$verb\" ]; then<br \/>\necho ''<br \/>\necho \"Enter Pie Chart title [My Daily Activities] \"<br \/>\nread pie_chart_title<br \/>\nif [ -z \"$pie_chart_title\" ]; then<br \/>\n pie_chart_title=\"My Daily Activities\"<br \/>\nfi<br \/>\necho ''<br \/>\necho \"Enter ${pie_chart_title} Activity Type title [Task] \"<br \/>\npie_chart_title=\"`echo ${pie_chart_title} | sed '\/ \/s\/\/_\/g'`\"<br \/>\nread activity_type_title<br \/>\nif [ -z \"$activity_type_title\" ]; then<br \/>\n activity_type_title=\"Task\"<br \/>\nfi<br \/>\nif [ ! -z \"$activity_type_title\" ]; then<br \/>\nactivitytypetitle=\"`echo ${activity_type_title}`\"<br \/>\necho ''<br \/>\necho \"Enter ${activity_type_title} Measure title [Percentage] \"<br \/>\nactivity_type_title=\"`echo ${activity_type_title} | sed '\/ \/s\/\/_\/g'`\"<br \/>\nread measure_title<br \/>\nif [ -z \"$measure_title\" ]; then<br \/>\n measure_title=\"Percentage\"<br \/>\nfi<br \/>\nmeasuretitle=\"`echo ${measure_title}`\"<br \/>\nmeasure_title=\"`echo ${measure_title} | sed '\/ \/s\/\/_\/g'`\"<br \/>\necho ''<br \/>\necho \"Enter semicolon separated list of Pie Chart comma separated ${activitytypetitle},${measuretitle} data sets  eg. Sleep,30;Work,30;Eating,10;Entertainment,20;Daily Chores,10 \"<br \/>\nread commastring<br \/>\nif [ ! -z \"$commastring\" ]; then<br \/>\ncstring=\"`echo ${commastring} | sed '\/,\/s\/\/~,\/g' | sed '\/;\/s\/\/]%20,%20[~\/g'`\"<br \/>\ncommastring=\"`echo ${prefd}${cstring}${suffd}`\"<br \/>\necho ''<br \/>\necho 'Starting the call ...'<br \/>\nrhs=\"`echo https:\/\/www.rjmprogramming.com.au\/PHP\/PieChart\/pie_chart.php?${pie_chart_title}__${activity_type_title}__${measure_title}__listis${equl}${commastring} | sed '\/ \/s\/\/%20\/g'`\"<br \/>\necho \"$verb ${rhs}\"<br \/>\nksh -c \"$verb ${rhs}\"<br \/>\nexit<br \/>\nfi<br \/>\nfi<br \/>\nfi<br \/>\nexit<br \/>\n<\/code><\/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='#d48010' onclick='var dv=document.getElementById(\"d48010\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/sed\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d48010' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Around here at RJM Programming we encourage the adage &#8220;keeping busy&#8221; and &#8220;keep moving forward&#8221; (and sometimes sideways) even if that movement is a very nuanced moving forward. Today&#8217;s tutorial is a case in point, because even though a regular &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/google-chart-pie-chart-macos-korn-shell-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,29,37],"tags":[3221,199,234,2276,2147,518,576,1577,3222,623,652,677,725,2178,3220,3049,932,944,997,1115,1138,3224,3223,1626,1252,1319,1402],"class_list":["post-48010","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-tutorials","tag-backtick","tag-chart","tag-command-line","tag-delimitation","tag-delimiter","tag-google-chart","tag-html","tag-interface","tag-interpret","tag-interpretive","tag-javascript","tag-korn-shell","tag-mac-os-x","tag-macos","tag-navigate","tag-open","tag-php","tag-pie-chart","tag-programming","tag-sed","tag-shell","tag-stream","tag-stream-editor","tag-string","tag-terminal","tag-tutorial","tag-web-application"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/48010"}],"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=48010"}],"version-history":[{"count":15,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/48010\/revisions"}],"predecessor-version":[{"id":48139,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/48010\/revisions\/48139"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=48010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=48010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=48010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}