<?php

include 'include_config.php';
//OUPUT HEADERS
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"database_sizes\";");
header("Content-Transfer-Encoding: binary");
echo 'database,size' . "\n";
if (!isset($_GET['dbh'])) {
    echo 'ERROR,1' . "\n";
} else {
    $arrDBSizes = getDatabaseSizes($_GET['dbh']);
    #  print_r($arrDBSizes);
    foreach ($arrDBSizes as $key => $value) {
        echo $key . ',' . $value . "\n";
    }
}
          .attr("d", arc)
          .style("fill", function(d) { return color(d.data.database); });

      g.append("text")
          .attr("transform", function(d) { return "translate(" + arc.centroid(d) + ")"; })
          .attr("dy", ".35em")
          .style("text-anchor", "middle")
          .text(function(d) { return d.data.database; });

    });

    </script>
    <script type="text/javascript" src="js/d3.ay-pie-chart.js"></script>
    <script type="text/javascript">
    <?php 
$arrDBSizes = getDatabaseSizes($strNode);
$arrJSON = array();
$intX = 1;
foreach ($arrDBSizes as $key => $value) {
    $arrJSON[] = array('index' => $intX, 'name' => $key, 'value' => $value);
    $intX++;
}
$arrJSON = json_encode($arrJSON);
?>

    $(function(){
      var mydata = <?php 
echo $arrJSON;
?>
;
      ay.pie_chart('DatabaseSpaceChart', mydata, {radius_inner: 40, percentage: true, group_data: 1});