I am using an ig.DataSource to retrieve data for an igDataChart. The code looks similar to the following. Sometimes the data retrieval fails. I can find no events for with ig.DataSource or igDataChart to capture any errors associated with the data retrievals.
Are there undocumented events that can be used?
ds = new $.ig.DataSource({ dataSource: dataUrl });
// Instantiate the chart $chart.igDataChart({dataSourceType: "remoteUrl", dataSource: ds,... });
Hello Ray,
Thank you for posting in our community.
What I can suggest is using callback function when data binding is complete. This function has two arguments - success and error so that you can determine when in the error scenario and apply your logic there. For example:
var
render =
function
(success, error) {
if
(success) {
alert(
"success"
);
}
else
{
alert(error);
$(window).load(
() {
url =
"">odata.netflix.com/.../Titles
;
ds =
new
$.ig.DataSource({
type:
"remoteUrl"
,
callback: render,
dataSource: url,
schema: oDataSchema,
responseDataKey :
"d.results"
responseDataType:
"jsonp"
});
ds.dataBind();
Please let me know if you need any further assistance with this matter.
I did the following but the callback function was never called. I assume the ds.DataBind() occurs automatically when the ig.DataSource is used by the chart because my chart is being populated as expected.
ds = new $.ig.DataSource({ dataSource: dataUrl,type: "remoteUrl", callback: function (success, error) { debugger; if (!success) { alert(error); } }
// Instantiate the chart$chart.igDataChart({dataSourceType: "remoteUrl",dataSource: ds,...});
In order to hit the callback a remote request should be performed.After looking further in your requirement I have another suggestion, which I believe will match your requirement - makin an ajax call for retrieving the data and handling its done and fail callbacks. If everything is successful in the done function you can retrieve the data and bind the chart. When the requests fails for some reason the fail function can be handled. For example:
$.ajax ({ url: url }) .done(function(data){ alert( "success" ); $("#chart").igDataChart({ dataSource: data, axes: [{ type: "categoryX", name: "xAxis", label: "DateString", }, { type: "numericY", name: "priceAxis", }], series: [{ type: "financial", name: "finSeries", title: "Price Movements", xAxis: "xAxis", yAxis: "priceAxis", openMemberPath: "Open", lowMemberPath: "Low", highMemberPath: "High", closeMemberPath: "Close", }] }); }) .fail(function(){ alert( "error" ); })
Please test this approach on your side and let me know if you need any further assistance.