Show error messages when unable to display chart
This commit is contained in:
parent
fcc51cea40
commit
effd5a3cce
@ -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() {
|
||||
|
||||
@ -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="';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user