Show error messages when unable to display chart

This commit is contained in:
Atul Pratap Singh 2013-01-27 20:48:07 +05:30
parent fcc51cea40
commit effd5a3cce
2 changed files with 18 additions and 1 deletions

View File

@ -203,7 +203,11 @@ function drawChart() {
$('select[name="chartXAxis"] option').each(function() {
columnNames.push($(this).text());
});
currentChart = PMA_queryChart(chart_data, columnNames, currentSettings);
try {
currentChart = PMA_queryChart(chart_data, columnNames, currentSettings);
} catch(err) {
PMA_ajaxShowMessage(err.message, false);
}
}
function getSelectedSeries() {

View File

@ -59,6 +59,12 @@ if (isset($_REQUEST['ajax_request'])
}
$response = PMA_Response::getInstance();
// Throw error if no sql query is set
if(! isset($sql_query) || $sql_query == '') {
$response->isSuccess(false);
$response->addHTML(PMA_Message::error(__('No SQL query was set to fetch data.')));
exit;
}
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('chart.js');
@ -159,6 +165,7 @@ $htmlString = '<script type="text/javascript">'
$keys = array_keys($data[0]);
$yaxis = -1;
$numeric_fields_present = false;
if (count($keys) > 1) {
$htmlString .= '<div style="float:left; padding-left:40px;">'
. '<label for="select_chartXAxis">' . __('X-Axis:') . '</label>'
@ -190,9 +197,15 @@ if (count($keys) > 1) {
. '" selected="selected">' . htmlspecialchars($key)
. '</option>';
}
$numeric_fields_present = true;
}
}
if(! $numeric_fields_present) {
$response->isSuccess(false);
$response->addJSON('message', __('No numeric fields present in the table to plot.'));
exit;
}
$htmlString .= '</select>'
. '<input type="hidden" name="dateTimeCols" value="';