Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Below is complete code with data filling separated.</p> <pre><code>&lt;?php function testing($chartId, $chartFunc, $chartTitle, $xAxisTitle, $chartData, $chartType) { $pageMeat =&lt;&lt;&lt;EOD &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="https://www.google.com/jsapi"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback($chartFunc); function $chartFunc() { var data = google.visualization.arrayToDataTable($chartData); var options = { title: '$chartTitle', hAxis: {title: '$xAxisTitle', titleTextStyle: {color: 'red'}} }; EOD; if($chartType == "line") { $pageMeat .=&lt;&lt;&lt;EOD var chart = new google.visualization.LineChart(document.getElementById('$chartId')); EOD; } else if($chartType == "pie") { $pageMeat .=&lt;&lt;&lt;EOD var chart = new google.visualization.PieChart(document.getElementById('$chartId')); EOD; } else { $pageMeat .=&lt;&lt;&lt;EOD var chart = new google.visualization.ColumnChart(document.getElementById('$chartId')); EOD; } $pageMeat .=&lt;&lt;&lt;EOD chart.draw(data, options); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="$chartId" style="width: 900px; height: 500px;"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; EOD; echo $pageMeat; } $gChartId = "vertColumns"; $gChartFn = "columnChart"; $gChartTitle = "Company Performance"; $gXAxisTitle = "Year"; $gChartData[] = array('Year', 'Sales', 'Expenses'); $gChartData[] = array('2004', 1000, 400); $gChartData[] = array('2005', 1170, 460); $gChartData[] = array('2006', 660, 1120); $gChartData[] = array('2007', 1030, 540); testing($gChartId, $gChartFn, $gChartTitle, $gXAxisTitle, json_encode($gChartData), "column"); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload