How to remove default error message in google chart

How to remove the default error shown in a google chart that looks like this:

enter image description here

+5
source share
1 answer

To remove Google errors, listen for the 'error' event on a chart or other object.
When the event is fired, use google.visualization.errors.removeError

Here I deliberately throw an error, delete it from google chart and display it in my own div

 google.load('visualization', '1', {packages:['corechart'], callback: drawChart}); function drawChart() { var data = google.visualization.arrayToDataTable([ ["Element", "Density", { role: "style" } ] ]); var view = new google.visualization.DataView(data); view.setColumns([0, 1, { calc: "stringify", sourceColumn: 1, type: "string", role: "annotation" }, 2]); var chart = new google.visualization.ColumnChart(document.getElementById("chart_div")); google.visualization.events.addListener(chart, 'error', function (googleError) { google.visualization.errors.removeError(googleError.id); document.getElementById("error_msg").innerHTML = "Message removed = '" + googleError.message + "'"; }); chart.draw(view, {height: 20}); } 
 <script src="https://www.google.com/jsapi"></script> <div id="chart_div"></div> <div id="error_msg"></div> 
+7
source

Source: https://habr.com/ru/post/1241012/


All Articles