diff --git a/libraries/chart.lib.php b/libraries/chart.lib.php index cb48945a9..3a4b50315 100644 --- a/libraries/chart.lib.php +++ b/libraries/chart.lib.php @@ -1,7 +1,9 @@ toString(); } +/* + * Formats a chart for query results page. + */ +function PMA_chart_results($data) +{ + $chartData = array(); + + // loop through the rows + foreach ($data as $row) { + + // loop through the columns in the row + foreach ($row as $key => $value) { + $chartData[$key][] = $value; + } + } + + $chart = new PMA_pChart_bar( + __('Query results'), + $chartData); + echo $chart->toString(); +} + ?> diff --git a/libraries/chart/pma_pchart_bar.php b/libraries/chart/pma_pchart_bar.php new file mode 100644 index 000000000..9e4d88e17 --- /dev/null +++ b/libraries/chart/pma_pchart_bar.php @@ -0,0 +1,53 @@ +data); + $keys = array_keys($this->data); + + // Dataset definition + $this->dataSet = new pData; + $this->dataSet->AddPoint($values[1], "Values"); + $this->dataSet->AddPoint($values[0], "Keys"); + $this->dataSet->AddAllSeries(); + //$DataSet->RemoveSerie("Serie3"); + $this->dataSet->SetAbsciseLabelSerie("Keys"); + $this->dataSet->SetXAxisName($keys[0]); + $this->dataSet->SetYAxisName($keys[1]); + //$DataSet->SetYAxisUnit("°C"); + //$DataSet->SetXAxisUnit("h"); + } + + protected function prepareChart() + { + // Initialise the graph + $this->chart = new pChart($this->width, $this->height); + $this->chart->drawGraphAreaGradient(132,173,131,50,TARGET_BACKGROUND); + + $this->chart->setFontProperties($this->fontPath.'tahoma.ttf', 8); + $this->chart->setGraphArea($this->areaMargins[3],$this->labelHeight + $this->areaMargins[0],$this->width - $this->areaMargins[1],$this->height - $this->areaMargins[2]); + $this->chart->drawGraphArea(213,217,221,FALSE); + $this->chart->drawScale($this->dataSet->GetData(),$this->dataSet->GetDataDescription(),SCALE_ADDALL,213,217,221,TRUE,0,2,TRUE); + $this->chart->drawGraphAreaGradient(163,203,167,50); + $this->chart->drawGrid(4,TRUE,230,230,230,20); + + // Draw the bar chart + $this->chart->drawStackedBarGraph($this->dataSet->GetData(),$this->dataSet->GetDataDescription(),70); + + // Draw the title + $this->chart->drawTextBox(0,0,$this->width,$this->labelHeight,$titleText,0,255,255,255,ALIGN_CENTER,TRUE,0,0,0,30); + + $this->chart->addBorder(2); + } +} + +?> diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 2e54a8b19..11e7a0340 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -2228,7 +2228,7 @@ function PMA_displayResultsOperations($the_disp_mode, $analyzed_sql) { // show chart echo PMA_linkOrButton( 'tbl_chart.php' . PMA_generate_common_url($_url_params), - PMA_getIcon('b_chart.png', __('Show chart'), false, true), + PMA_getIcon('b_chart.png', __('Display chart'), false, true), '', true, true, '') . "\n"; } diff --git a/tbl_chart.php b/tbl_chart.php new file mode 100644 index 000000000..daafd36ff --- /dev/null +++ b/tbl_chart.php @@ -0,0 +1,82 @@ + $value) { + $chartData[$key][] = $value; + }*/ +} + +/** + * Displays top menu links + * We use db links because a chart is not necessarily on a single table + */ +$num_tables = 0; +require_once './libraries/db_links.inc.php'; + +$url_params['db'] = $GLOBALS['db']; +$url_params['reload'] = 1; + +/** + * Displays the page + */ +?> + +