Here is the design: 1) on index.html - ajax call is made by client as the dataset selected 2) processor.php - creates the new csv file of the data generated by mysql query 3) index.html callback - causes d3.js to take the dataset from csv file and to produce a graph 4) Repeat step 1 to 3 - does not allow d3 to get the most recent csv file
I am able to retrieve CSV file through d3 the first time AJAX call is made, however, afterwards Ajax calls from client side does not allow d3 to retrieve the newest file., the code does not take the most recent file
So here is the index.html
$.post( 'processor.php',
$("#queryform :input").serializeArray(),
function(data) {
d3.csv('diagrams/chord.csv', function (error, data) {
var mpr = chordMpr(data);
mpr
.addValuesToMap('chimp')
.setFilter(function (row, a, b) {
return (row.chimp === a.name && row.performedon === b.name)
})
.setAccessor(function (recs, a, b) {
if (!recs[0]) return 0;
return +recs[0].count;
});
sliderbanimate()
drawChords(mpr.getMatrix(), mpr.getMap());
});
This is only partial code but what I am trying to achieve is during th Ajax call, I want d3 plugin to use most recent CSV file
here is the processor.php - creates a new CSV file created from MYSQL on AJAX call
$chordquery = mysqli_query($connection, 'SELECT a.CName as CName, a.Performed_on as performed_on,Count(*) as Count
FROM behavior a WHERE
BName IN ('.$behaviourarry.') GROUP BY CName, performed_on');
$num = 0;
while($resultchord = mysqli_fetch_array($chordquery)) {
$rel[$num]['chimp'] = $resultchord['CName'];
$rel[$num]['performedon'] = $resultchord['performed_on'];
$rel[$num]['count'] = $resultchord['Count'];
$num++;
//$data2[] = $row3['CName'];
//echo $row3['CName']."-".$row3['performed_on']."-".$row3['BName']."-".$row3['Year']."-".$row3['Count']."<br/>";
}
$output = fopen("diagrams/chord.csv",'w') or die("Can't open php://output");
//header("Content-Type:application/csv");
//header("Content-Disposition:attachment;filename=pressurecsv.csv");
fputcsv($output, array('chimp','performedon','count'));
foreach($rel as $relation) {
fputcsv($output, $relation);
}
fclose($output) or die("Can't close php://output");
Really hope if someone can help me out here...cheers!