Location: PHPKode > scripts > Circle Chart using SVG > circle-chart-using-svg/rand_circlechart.php

include ("circlechart.php");

function cmp($dataA,$dataB)
	return $dataA->m_nWidth > $dataB->m_nWidth;

class CData
	var $m_nWidth;
	var $m_nHeight;
	var $m_nWeight;
	var $m_nLight;
	var $m_nRand;
	var $m_strIndex;

// Path to write the svg file
$strPath ="c:\\temp\\rand.svg";
$strPathHtml ="<html><head></head><body><embed src=\"$strPath\" style=\"width: " . SIZEWIDTHCM ." cm; height: " . SIZEHEIGHTCM ."cm\"></p></body></html>\n";

// Create a new chart
$chart = new CCircleChart($strPath);

// Attributes used in the chart, begining for the most important
$chart->m_dataChart->m_arrAttributes[] ="m_nWidth";
$chart->m_dataChart->m_arrAttributes[] ="m_nHeight";
$chart->m_dataChart->m_arrAttributes[] ="m_nWeight";
$chart->m_dataChart->m_arrAttributes[] ="m_nLight";
$chart->m_dataChart->m_arrAttributes[] ="m_nRand";

// Load the data into the chart
$data = new CData();
for ($i=0;$i<40;$i++)
	$data->m_nWidth =rand();
	$data->m_nHeight =rand();
	$data->m_nWeight =rand();
	$data->m_nLight =rand();
	$data->m_nRand =rand();
	$data->m_strIndex =rand(1000,2000);
	$chart->m_dataChart->m_arrObjects[] =$data;

// Order the data used in the chart

// Position of the data circle
$chart->m_nCenterY =2200;

// Position of the attributes circle
$chart->m_nCenterXAttributes =1500;
$chart->m_nRadiusAttributes =400;


// Header of the chart
// Generate the scripts to change the info showed in the attributes circle

// Title of the chart
$chart->Text("RAND DATA, THE TWO CIRCLES ARE LINKED",1100,1600,"Verdana","40","black","middle");

// Draw the data circle
$chart->DrawCircle($chart->m_nCenterX,$chart->m_nCenterY,$chart->m_nRadius,":rgb(255,255,255)",":rgb(255,0,0)",5,"5 5");
// Draw the attributes circle
$chart->DrawCircle($chart->m_nCenterXAttributes,$chart->m_nCenterYAttributes,$chart->m_nRadiusAttributes,":rgb(255,255,255)",":rgb(255,0,0)",5,"5 5");

// Draw the text using the attribute m_strIndex, be carefully with the special characters
// Draw the lines before draw the data
// Draw the data

// Close the svg file
// write the page linking the svg file
echo $strPathHtml;
Return current item: Circle Chart using SVG