1a2,6 > $data0 = ""; > if (isset($_GET['data0'])) { > $data0 = "&data0=" . $_GET['data0']; > } > 9,12c14,15 < < < < Pie Chart - RJM Programming - http://www.rjmprogramming.com.au (Copyright © 2013 rjmprogramming.com.au all rights reserved.) --- > > Pie Chart (Differences) - RJM Programming - http://www.rjmprogramming.com.au (Copyright © 2013 rjmprogramming.com.au all rights reserved.) 14c17 < --- > 18,20d20 < $gd = ""; < $ntt=false; < $nondefs=", is3D: true "; 25,55c25,29 < if (isset($_POST['data'])) { < if (isset($_GET['title'])) { < $ourtitles=explode(";", $_GET['title']); < if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "2d") !== false) { < $nondefs=""; < } < if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "donut") !== false) { < $nondefs=", pieHole: 0.4 "; < } < $GETtitle = str_replace("\\'", "'", $ourtitles[sizeof($ourtitles) - 1]); < } else { < $ourtitles=explode(";", $_POST['title']); < if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "2d") !== false) { < $nondefs=""; < } < if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "donut") !== false) { < $nondefs=", pieHole: 0.4 "; < } < $GETtitle = str_replace("\\'", "'", $ourtitles[sizeof($ourtitles) - 1]); < } < if (isset($_GET['task'])) { < $GETtask = str_replace("\\'", "'", $_GET['task']); < } else { < $GETtask = str_replace("\\'", "'", $_POST['task']); < } < if (isset($_GET['desc'])) { < $GETdesc = str_replace("\\'", "'", $_GET['desc']); < } else { < $GETdesc = str_replace("\\'", "'", $_POST['desc']); < } < $GETdata = str_replace("\\'", "'", $_POST['data']); --- > if (isset($_GET['desc'])) { > $GETtitle = $_GET['title']; > $GETtask = $_GET['task']; > $GETdesc = $_GET['desc']; > $GETdata = $_GET['data']; 57,70d30 < if (isset($_GET['data'])) { < $ourtitles=explode(";", $_GET['title']); < if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "2d") !== false) { < $nondefs=""; < } < if (sizeof($ourtitles) > 1 && strpos(strtolower($ourtitles[0]), "donut") !== false) { < $nondefs=", pieHole: 0.4 "; < } < $GETtitle = str_replace("\\'", "'", $ourtitles[sizeof($ourtitles) - 1]); < $GETtask = str_replace("\\'", "'", $_GET['task']); < $GETdesc = str_replace("\\'", "'", $_GET['desc']); < $GETdata = str_replace("\\'", "'", $_GET['data']); < } < $newextras=$nondefs; 72c32,33 < echo ' google.load("visualization", "1", {packages:["corechart"]}); ' . "\n"; --- > if (isset($_GET['data0'])) { > echo " google.load('visualization', '1.1', {packages:['corechart']}); " . "\n"; 74a36,44 > echo ' var data = google.visualization.arrayToDataTable([ ' . "\n"; > echo " ['" . $GETtask . "','" . $GETdesc . "'] \n"; > echo str_replace("~,", "',", str_replace("[~", "['", str_replace(",]", ",0]", str_replace(",]", ",0]", str_replace(",]", ",0]", $GETdata))))); > echo " ]);\n"; > echo ' var data0 = google.visualization.arrayToDataTable([ ' . "\n"; > echo " ['" . $GETtask . "','" . $GETdesc . "'] \n"; > echo str_replace("~,", "',", str_replace("[~", "['", str_replace(",]", ",0]", str_replace(",]", ",0]", str_replace(",]", ",0]", $_GET['data0']))))); > echo " ]);\n"; > 75a46,56 > echo " var pieChartBefore = new google.visualization.PieChart(document.getElementById('piechart_before')); \n"; > echo " var pieChartAfter = new google.visualization.PieChart(document.getElementById('piechart_after')); \n"; > echo " var pieChartDiff = new google.visualization.PieChart(document.getElementById('piechart_diff')); \n"; > > echo " var options = { pieSliceText: 'none' }; \n"; > > echo " pieChartBefore.draw(data0, options); \n"; > echo " pieChartAfter.draw(data, options); \n"; > > echo " var diffData = pieChartDiff.computeDiff(data0, data); \n"; > echo " pieChartDiff.draw(diffData, options); \n } \n"; 77,105c58,71 < // A column for custom tooltip content < if ((isset($_GET['data']) || isset($_POST['data'])) && (isset($_GET['tooltip']) || isset($_POST['tooltip']) || strpos($GETdata, "'") !== false || strpos($GETdata, '"') !== false)) { < $ntt=true; < //$newextras=$nondefs . ", focusTarget: 'category', tooltip: {isHtml: true} "; < $newextras=$nondefs . ",legend:'none', pieSliceText: 'label', tooltip: { isHtml: true } "; < echo " var tooltip = [ \n"; < $bits=explode("~,", substr($GETdata,1)); < $delts=""; < for ($iy=1; $iy", $postbits[0])); < $delts=","; < } < echo "]; \n"; < $gd=$GETdata; < for ($iy=1; $iy > echo " \n"; > echo " \n"; > echo " \n"; > echo "

" . $GETtitle . " Pie Chart

\n"; > > echo " \n"; > echo " \n"; > echo " \n"; > } else { > echo ' var data0 = "";' . "\n"; > echo ' google.load("visualization", "1", {packages:["corechart"]}); ' . "\n"; > echo ' google.setOnLoadCallback(drawChart); ' . "\n"; > echo ' function drawChart() { ' . "\n"; 108c74 < echo str_replace("~,", "',", str_replace("[~", "['", str_replace(",]", ",0]", str_replace(",]", ",0]", str_replace(",]", ",0]", substr($GETdata,0)))))); --- > echo str_replace("~,", "',", str_replace("[~", "['", str_replace(",]", ",0]", str_replace(",]", ",0]", str_replace(",]", ",0]", $GETdata))))); 110,111d75 < } < 113c77 < echo " title: '" . $GETtitle . "'" . $newextras . " \n"; --- > echo " title: '" . $GETtitle . "' \n"; 117,144c81,82 < < if ($ntt) { < < //echo " var selection; \n"; < echo " var sliceid = 0; \n"; < < echo " function eventHandler(e){ \n"; < echo " chart.setSelection([e]); \n"; < echo " try { \n"; < echo " selection = chart.getSelection(); \n"; < echo " sliceid = selection[0].row; \n"; < echo " } \n"; < echo " catch(err) { \n"; < echo " ; \n"; < echo " } \n"; < echo ' $(".google-visualization-tooltip-item-list li:eq(0)").css("font-weight", "bold"); ' . "\n"; < echo ' $(".google-visualization-tooltip-item-list li:eq(1)").html(tooltip[sliceid]).css("font-family", "Arial"); ' . "\n"; < echo " } \n"; < < if (strpos($gd, "<") !== false) { < echo " google.visualization.events.addListener(chart, 'onclick', eventHandler); \n"; < } else { < echo " google.visualization.events.addListener(chart, 'onmouseover', eventHandler); \n"; < } < } < echo " chart.draw(data, options); \n \n"; < echo " } \n"; < --- > echo " chart.draw(data, options); \n } \n"; > 147d84 < if (!isset($_GET['desc']) && !isset($_POST['desc'])) { 149,151d85 < } else { < echo " \n"; < } 152a87,88 > echo '
' . "\n"; > } 154,155c90 <
< Another pie chart? --- > Another pie chart to show differences for? 157c92,93 < if (!isset($_GET['desc']) && !isset($_POST['desc'])) { --- > if (!isset($_GET['desc']) || $data0 == "") { > if (isset($_GET['data'])) $data0 = "&data0=" . $_GET['data']; 160d95 < echo ' var exra = ""; ' . "\n"; 165c100,108 < echo ' var title = prompt("Enter Pie Chart Title (prefixes 2d or donut (followed by ;) before title are available options)", "My Daily Activities"); ' . "\n"; --- > if (isset($_GET['data'])) { > echo " var title = '" . $GETtitle . "'; " . "\n"; > } else { > if (strpos($_SERVER['HTTP_REFERER'], "pie_chart") === false && strpos($_SERVER['QUERY_STRING'], "WebView=justmenuWebView") !== false) { > echo ' var title = null; ' . "\n"; > } else { > echo ' var title = prompt("Enter Pie Chart Title", "My Daily Activities"); ' . "\n"; > } > } 167,168c110,114 < echo ' var titles = title.split(";"); ' . "\n"; < echo ' var task = prompt("Enter Activity Type", "Task"); ' . "\n"; --- > if (isset($_GET['data'])) { > echo " var task = '" . $GETtask . "'; " . "\n"; > echo " var desc = '" . $GETdesc . "'; " . "\n"; > } else { > echo ' var task = prompt("Enter Activity Type", "' . $GETtask . '"); ' . "\n"; 169a116 > } 172c119 < echo ' datalineprefix = prompt("Enter " + task + " Type " + thisline + " (optionally append with ,\"tooltip of some sort\" (that can have HTML included))", ""); ' . "\n"; --- > echo ' datalineprefix = prompt("Enter " + task + " Type " + thisline, ""); ' . "\n"; 197,199c144,145 < echo ' if (datalineprefix.indexOf(",") != -1 && (datalineprefix.indexOf(String.fromCharCode(39)) != -1 || datalineprefix.indexOf(String.fromCharCode(34)) != -1)) { exra=String.fromCharCode(39) + String.fromCharCode(39) + ","; datac = datac + ", [~" + datalineprefix.replace(",","~,").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E").replace("<","%3C").replace(">","%3E") + "," + datalinesuffix + "] "; ' . "\n"; < echo ' } else { datac = datac + ", [~" + datalineprefix + "~," + exra + datalinesuffix + "] "; ' . "\n"; < echo ' } ' . "\n" . ' thisline++; ' . "\n"; --- > echo ' datac = datac + ", [~" + datalineprefix + "~," + datalinesuffix + "] "; ' . "\n"; > echo ' thisline++; ' . "\n"; 202c148 < echo ' window.location = "./pie_chart.php?title=" + title + "&task=" + task + "&desc=" + desc.replace(" ercent ", "") + "&data=" + datac; ' . "\n"; --- > echo ' window.location = "./pie_chart_diff.php?title=" + title + "&task=" + task + "&desc=" + desc.replace(" ercent ", "") + "' . $data0 . '&data=" + datac; ' . "\n";