Hi,
I am having an issue with my Google charts using an Ajax request to fetch the chart data.
Through debugging the code I can see the Javascript function which draws my chart is being called.
The issue is the chart appears for a few seconds then disappears.
From looking through the forum I am thinking it is some kind of issue with how the Google charts library is loaded.
I am loading the library and calling the Javascript function which draws the chart after the Dom has completely loaded.
Could you perhaps give me some tips on what is the best way to debug this situation?
Any assistance you could give me would be much appreciated.
Below is a quick example of my chart script
Many thanks.
Aine
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart","gauge"]});
function drawHitRatioChart(dataPoints) {
var data = google.visualization.arrayToDataTable([
['Label', 'Value'],
['Hit Ratio', {v: 50, f: ''}]
]);
var options = {
width: 450, height: 140,
redFrom: 0, redTo: dataPoints, redColor: "#C1DAD6",
yellowFrom: dataPoints, yellowTo: 100, yellowColor: "#ACD1E9",
minorTicks: 10,
max: 100
};
var chart = new google.visualization.Gauge(document.getElementById('hitRatioGraph'));
chart.draw(data, options);
}
}
--
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 google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.
It is a bit of a complicated one.
This is all part of a web application.
The application allows the user to select some parameters, they click submit and the charts are drawn.
I have two scenarios:
1. I am rendering the charts in a number of tabs using Richfaces <rich:tabPanel
There is an ontabenter event from which I call my javascript function to draw the chart
e.g. <rich:tab label="My Tab" ….. ontabenter="createHitRatioChartData();”>
<a4j:jsFunction name="createHitRatioChartData" oncomplete="drawHitRatioChart(#{behaviourAnalysisToolSession.behaviourChartData.hitRatioString});" immediate="true">
</a4j:jsFunction>
The <a4j:jsFunction calls the javascript as above.
This working fine and the charts are displayed and I am not using a callback here.
2. Unfortunately this will not work for the first tab - I want to load the charts here when the tab is loaded and ontabenter only fires when the tab is actually clicked on.
So I have been trying to call the same <a4j:jsFunction from my submit button.
<a4j:commandButton oncomplete="createHitRatioChartData();"
However when I do it this way the charts appear for a moment then disappear.
Any ideas you might have would be great.
Thanks again.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.
--
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 google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.
--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.
I have found a solution to my problem, it is somewhat specific to my scenario but may be of help to anyone in a similar situation.
I have an iFrame which contains a number of Richfaces tabs where my charts are displayed.
If I call the Javascript function to draw the charts (in the first post) from the ‘onload’ method on the iframe the charts will display in the first tab.