diff --git a/classes/Visualizer/Module/Chart.php b/classes/Visualizer/Module/Chart.php index aaee18cc..4c5038b6 100644 --- a/classes/Visualizer/Module/Chart.php +++ b/classes/Visualizer/Module/Chart.php @@ -876,12 +876,13 @@ private function _handleDataAndSettingsPage() { 'visualizer', array( 'l10n' => array( - 'invalid_source' => esc_html__( 'You have entered an invalid URL. Please provide a valid URL.', 'visualizer' ), - 'loading' => esc_html__( 'Loading...', 'visualizer' ), - 'json_error' => esc_html__( 'An error occured in fetching data.', 'visualizer' ), - 'select_columns' => esc_html__( 'Please select a few columns to include in the chart.', 'visualizer' ), - 'save_settings' => __( 'You have modified the chart\'s settings. To modify the source/data again, you must save this chart and reopen it for editing. If you continue without saving the chart, you may lose your changes.', 'visualizer' ), - 'copied' => __( 'The data has been copied to your clipboard. Hit Ctrl-V/Cmd-V in your spreadsheet editor to paste the data.', 'visualizer' ), + 'invalid_source' => esc_html__( 'You have entered an invalid URL. Please provide a valid URL.', 'visualizer' ), + 'loading' => esc_html__( 'Loading...', 'visualizer' ), + 'json_error' => esc_html__( 'An error occured in fetching data.', 'visualizer' ), + 'select_columns' => esc_html__( 'Please select a few columns to include in the chart.', 'visualizer' ), + 'save_settings' => __( 'You have modified the chart\'s settings. To modify the source/data again, you must save this chart and reopen it for editing. If you continue without saving the chart, you may lose your changes.', 'visualizer' ), + 'copied' => __( 'The data has been copied to your clipboard. Hit Ctrl-V/Cmd-V in your spreadsheet editor to paste the data.', 'visualizer' ), + 'invalid_format' => esc_html__( 'This format pattern is not supported in the series settings field. Use the Manual Configuration option instead.', 'visualizer' ), ), 'charts' => array( 'canvas' => $data, @@ -1405,7 +1406,8 @@ private function _handleDataPage() { array( 'l10n' => array( 'invalid_source' => esc_html__( 'You have entered an invalid URL. Please provide a valid URL.', 'visualizer' ), - 'loading' => esc_html__( 'Loading...', 'visualizer' ), + 'loading' => esc_html__( 'Loading...', 'visualizer' ), + 'invalid_format' => esc_html__( 'This format pattern is not supported in the series settings field. To display percentages, use the Manual Configuration option instead.', 'visualizer' ), ), 'charts' => array( 'canvas' => $data, diff --git a/js/render-google.js b/js/render-google.js index a8137741..18ac617b 100644 --- a/js/render-google.js +++ b/js/render-google.js @@ -449,19 +449,30 @@ var isResizeRequest = false; } var formatter = null; - switch (type) { - case 'number': - formatter = new gv.NumberFormat({pattern: format}); - break; - case 'date': - case 'datetime': - case 'timeofday': - formatter = new gv.DateFormat({pattern: format}); - break; - } + var $formatInput = $('input.control-text[name*="[format]"]').filter(function() { + return $(this).val() === format; + }); + try { + switch (type) { + case 'number': + formatter = new gv.NumberFormat({pattern: format}); + break; + case 'date': + case 'datetime': + case 'timeofday': + formatter = new gv.DateFormat({pattern: format}); + break; + } - if (formatter) { - formatter.format(table, index); + if (formatter) { + formatter.format(table, index); + $formatInput.nextAll('.visualizer-format-error').remove(); + } + } catch (e) { + if ($formatInput.length) { + $formatInput.nextAll('.visualizer-format-error').remove(); + $('

').text(visualizer.l10n.invalid_format).insertAfter($formatInput); + } } var arr = id.split('-');