Hi Daniel,
Thank you for getting back to me so quickly - yes, I had forgotten to
include the <script> tag in the code I posted above, sorry.
Good to be able to eliminate the throttling, and like you I didn't think
the of the javascript would execute until all the scripts were loaded (or
failed to load)...
My working theory is that either the 'loader.js' is failing to load at all,
or a corrupt version has been cached somewhere - but I want to try and
eliminate other possibilities.
The fly in the ointment is that it has been rock solid for the customer for
years, and suddenly started having problems since around 17th June, which
appear to have been steadily getting worse since then. There has been no
code deployment at our end, and we are not aware of any infrastructure
changes at the customer's end.
On the other hand, we so far haven't seen it happen from our network.
Getting the client to refresh the page sometimes (but not always) fixes the
issue.
It's not going to be so easy to point you at the web-page, as it's a
customer specific and commercially sensitive application. Is there anything
specific you'd be looking for? It might be possible to spin up a test
environment if that will shed any light.
The only two google 'namespaces' the app references are 'google.maps' and
'google.charts'.
The site has been built in TypeScript, and the compiled JS gets bundled by
ASP.Net.
The only bits of code which reference google charts/visualization are:
*packages.config*:
<package id="google.visualization.TypeScript.DefinitelyTyped"
version="0.5.7" targetFramework="net452" />
*chart.html:*
<div class="chartDiv">
</div>
*chart.ts*:
namespace XXXX {
export class Chart {
element;
constructor(ele: JQuery) {
this.element = ele;
var me = this;
this.element.load('Content/Chart.html', () => me.initialise());
}
private isChartsLoaded: boolean;
private chartData: google.visualization.DataTable;
private classicChart: google.visualization.ColumnChart;
private chartOptions: google.visualization.ColumnChartOptions;
private initialise() {
var me = this;
me.isChartsLoaded = false;
// Set a callback to run when the Google Visualization API is
loaded.
// --- This line sometimes throws the exception ---
google.charts.load('current', { 'packages': ['corechart'] });
google.charts.setOnLoadCallback(() => {
me.isChartsLoaded = true;
me.drawChart();
window.addEventListener('resize', function (e) {
if (me.classicChart && me.chartData && me.chartOptions)
me.classicChart.draw(me.chartData, me.chartOptions);
});
});
}
private drawChart() {
// .. removed code checking for data ..
if (!this.isChartsLoaded || (typeof google === 'undefined') ||
(typeof google.visualization === 'undefined')) {
// --- ... And after that we end up in here
whenever drawChart is called. ---
logger.warn('google.visualization hasn\'t loaded yet...');
return;
}
// .. removed code as it is never reached ..
}
}
}
*MainPage.html:*
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>XXXXX</title>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
* <!-- style sheets loaded here -->*
<script src="bundles/jquery"></script>
<script type="text/javascript"
src="https://www.gstatic.com/charts/loader.js"></script>
<script
src="https://maps.googleapis.com/maps/api/js?client=XXX&channel=XXX"></script>
<script src="bundles/app-javascript"></script>
</head>
<body>
<!-- Various other widgets been removed for clarity, but none of them
use google charts -->
<div id="chart" class="container">
<div class="initialising">Please Wait</div>
</div>
</div>
<script type="text/javascript">
// -- other widgets removed
var chart;
$(function () {
// -- other widgets removed
chart = new XXXX.Chart($('#chart'));
});
</script>
</body>
</html>
In the Chrome console, the only error reported is the TypeError, and I get
the same behaviour if I manually break the script reference(e.g. change it
to 'loader-broken.js')
With thanks,
James
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/0f8a3f50-3c5c-4e75-984e-64707591b7f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.