added query results chart when results have only one column.
This commit is contained in:
@@ -36,7 +36,7 @@ function PMA_chart_status($data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$chart = new PMA_pChart_Pie(
|
$chart = new PMA_pChart_Pie(
|
||||||
array_slice($chartData, 0, 18, true),
|
$chartData,
|
||||||
array('titleText' => __('Query statistics'))
|
array('titleText' => __('Query statistics'))
|
||||||
);
|
);
|
||||||
$chartCode = $chart->toString();
|
$chartCode = $chart->toString();
|
||||||
@@ -57,7 +57,7 @@ function PMA_chart_profiling($data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$chart = new PMA_pChart_Pie(
|
$chart = new PMA_pChart_Pie(
|
||||||
array_slice($chartData, 0, 18, true),
|
$chartData,
|
||||||
array('titleText' => __('Query execution time comparison (in microseconds)'))
|
array('titleText' => __('Query execution time comparison (in microseconds)'))
|
||||||
);
|
);
|
||||||
$chartCode = $chart->toString();
|
$chartCode = $chart->toString();
|
||||||
@@ -99,27 +99,40 @@ function PMA_chart_results($data, &$chartSettings, &$chartErrors = array())
|
|||||||
return __('No data found for the chart.');
|
return __('No data found for the chart.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($data[0]) == 2) {
|
if (count($data[0]) == 1 || count($data[0] == 2)) {
|
||||||
// Two columns in every row.
|
// Two columns in every row.
|
||||||
// This data is suitable for a simple bar chart.
|
// This data is suitable for a simple bar chart.
|
||||||
|
|
||||||
if ($chartSettings['type'] == 'pie') {
|
if ($chartSettings['type'] == 'pie') {
|
||||||
// loop through the rows, data for pie chart has to be formated
|
// loop through the rows, data for pie chart has to be formated
|
||||||
// in a different way then in other charts.
|
// in a different way then in other charts.
|
||||||
foreach ($data as $row) {
|
foreach ($data as $rowKey => $row) {
|
||||||
$values = array_values($row);
|
$values = array_values($row);
|
||||||
|
|
||||||
|
if (count($row) == 1) {
|
||||||
|
$chartData[$rowKey] = $values[0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
$chartData[$values[0]] = $values[1];
|
$chartData[$values[0]] = $values[1];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$chartSettings['legend'] = true;
|
$chartSettings['legend'] = true;
|
||||||
$chart = new PMA_pChart_pie($chartData, $chartSettings);
|
$chart = new PMA_pChart_pie($chartData, $chartSettings);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// loop through the rows
|
// loop through the rows
|
||||||
foreach ($data as $row) {
|
foreach ($data as $rowKey => $row) {
|
||||||
|
|
||||||
|
// if only one column, we need to add
|
||||||
|
// placeholder data for x axis
|
||||||
|
if (count($row) == 1) {
|
||||||
|
$chartData[''][] = $rowKey;
|
||||||
|
}
|
||||||
|
|
||||||
// loop through the columns in the row
|
// loop through the columns in the row
|
||||||
foreach ($row as $key => $value) {
|
foreach ($row as $valueKey => $value) {
|
||||||
$chartData[$key][] = $value;
|
$chartData[$valueKey][] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@ class PMA_pChart_Pie extends PMA_pChart_multi
|
|||||||
{
|
{
|
||||||
public function __construct($data, $options = null)
|
public function __construct($data, $options = null)
|
||||||
{
|
{
|
||||||
|
$data = array_slice($data, 0, 18, true);
|
||||||
parent::__construct($data, $options);
|
parent::__construct($data, $options);
|
||||||
|
|
||||||
$this->setAreaMargins(array(20, 10, 20, 20));
|
$this->setAreaMargins(array(20, 10, 20, 20));
|
||||||
|
Reference in New Issue
Block a user