fixed default sizes and colors. Fixed some var names.

This commit is contained in:
Martynas Mickevicius
2010-06-17 17:39:32 +03:00
parent c152e0dd3e
commit 13c2a8cd24
3 changed files with 33 additions and 34 deletions

View File

@@ -27,11 +27,7 @@ function PMA_chart_status($data)
//$chart = new PMA_OFC_Pie(__('Query type'), $chartData, $options);
$chart = new PMA_pChart_Pie(
__('Query statistics'),
$chartData,
array(
'width' => 500,
'height' => 325,
));
$chartData);
echo $chart->toString();
}
@@ -49,13 +45,7 @@ function PMA_chart_profiling($data)
$chart = new PMA_pChart_Pie(
__('Query execution time comparison (in microseconds)'),
$chartData,
array(
'bgColor' => '#e5e5e5',
'width' => 500,
'height' => 325,
)
);
$chartData);
echo $chart->toString();
}

View File

@@ -34,17 +34,17 @@ class PMA_Chart
/*
* Chart background color.
*/
protected $bgColor = '#f5f5f5';
protected $bgColor = '#E5E5E5';
/*
* The width of the chart.
*/
protected $width = 400;
protected $width = 500;
/*
* The height of the chart.
*/
protected $height = 250;
protected $height = 325;
function __construct($options = null)
{
@@ -70,6 +70,11 @@ class PMA_Chart
if (isset($options['height']))
$this->height = $options['height'];
}
function getBgColorComp($component)
{
return hexdec(substr($this->bgColor, ($component * 2) + 1, 2));
}
}
?>

View File

@@ -15,49 +15,53 @@ class PMA_pChart_Pie extends PMA_pChart_Chart
require_once './libraries/chart/pChart/pChart.class';
// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint(array_values($data),"Serie1");
$DataSet->AddPoint(array_keys($data),"Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2");
$dataSet = new pData;
$dataSet->AddPoint(array_values($data),"Values");
$dataSet->AddPoint(array_keys($data),"Keys");
$dataSet->AddAllSeries();
$dataSet->SetAbsciseLabelSerie("Keys");
// Initialise the graph
$Test = new pChart($this->width, $this->height);
$chart = new pChart($this->width, $this->height);
foreach ($this->colors as $key => $color) {
$Test->setColorPalette(
$chart->setColorPalette(
$key,
hexdec(substr($color, 1, 2)),
hexdec(substr($color, 3, 2)),
hexdec(substr($color, 5, 2))
);
}
$Test->setFontProperties($this->fontPath.'tahoma.ttf', 8);
$Test->drawFilledRoundedRectangle(
$chart->setFontProperties($this->fontPath.'tahoma.ttf', 8);
$chart->drawFilledRoundedRectangle(
$this->border1Width,
$this->border1Width,
$this->width - $this->border1Width,
$this->height - $this->border1Width,
5,240,240,240);
$Test->drawRoundedRectangle(
5,
$this->getBgColorComp(0),
$this->getBgColorComp(1),
$this->getBgColorComp(2)
);
$chart->drawRoundedRectangle(
$this->border1Width,
$this->border1Width,
$this->width - $this->border1Width,
$this->height - $this->border1Width,
5,230,230,230);
5,0,0,0);
// Draw the pie chart
$Test->AntialiasQuality = 0;
$Test->setShadowProperties(2,2,200,200,200);
$chart->AntialiasQuality = 0;
$chart->setShadowProperties(2,2,200,200,200);
//$Test->drawFlatPieGraphWithShadow($DataSet->GetData(),$DataSet->GetDataDescription(),180,160,120,PIE_PERCENTAGE,8);
//$Test->drawBasicPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),180,160,120,PIE_PERCENTAGE,255,255,218,2);
$Test->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),180,160,120,PIE_PERCENTAGE,FALSE,60,30,10,1);
$Test->clearShadow();
$chart->drawPieGraph($dataSet->GetData(),$dataSet->GetDataDescription(),180,160,120,PIE_PERCENTAGE,FALSE,60,30,10,1);
$chart->clearShadow();
$Test->drawTitle(10,20,$titleText,0,0,0);
$Test->drawPieLegend(340,15,$DataSet->GetData(),$DataSet->GetDataDescription(),250,250,250);
$chart->drawTitle(20,20,$titleText,0,0,0);
$chart->drawPieLegend(350,15,$dataSet->GetData(),$dataSet->GetDataDescription(),250,250,250);
ob_start();
imagepng($Test->Picture);
imagepng($chart->Picture);
$output = ob_get_contents();
ob_end_clean();