Do you mean you want to load the data generated by some PHP file and use it as a data provider for the chart?
In that case I suggest you use the Data Loader plugin.
Here’s more info about it:
http://www.amcharts.com/tutorials/using-data-loader-plugin/
No, I just want to load the PHP file and use some variables…
In my PHP file I’m calculating an average according to a ‘fixedValue’ and I return multiple arrays:
<?php
$connection = mysql_connect(*,*,*) or die(mysql_error());
$database = mysql_select_db(*) or die(mysql_error());
$query = "SELECT * FROM *";
$result = mysql_query($query);
$mean = array(0,0,0,0,0,0,0);
$mean2 = array(0,0,0,0,0);
$count = array(0,0,0,0,0,0,0);
$count2 = array(0,0,0,0,0);
while($row = mysql_fetch_array($result)){
for($i = 0; $i < count($mean); $i++){
if ($row[Col1]==$i && $row[Col2]=='fixedValue'){
$mean[$i]=($mean[$i]*$count[$i]+$row[Col3])/($count[$i]+1);
$count[$i]++;
}
}
for($i = 0; $i < count($mean2); $i++){
if ($row[Col4]==$i && $row[Col2]=='otherFixedValue'){
$mean2[$i]=($mean2[$i]*$count2[$i]+$row[Col3])/($count2[$i]+1);
$count2[$i]++;
}
}
}
?>
<script>
var mean1 = [<?php echo '"'.implode('","', $mean).'"' ?>];
var mean2 = [<?php echo '"'.implode('","', $mean2).'"' ?>];
</script>
So, I want to include same PHP file and use vars mean1 and mean2
Well, you can’t include PHP code into chart, if that’s what you need. Even if we could make it work, it would be awfully unsecure to allow PHP code to be added via admin interface directly.
I suppose you would need to add that functionality to your WP theme or create a standalone WP plugin for that.
But I turned PHP array into JavaScript array, is there a way to include the JavaScript code?
Sure. You can copy and paste the JavaScript output into the chart code.