I am getting the error "Error loading data for this chart " when embedding one of my charts. The chart data loads fine when viewing it through mongodb Atlas dashboards. Is it possible to get more details as to why the data cannot be retrieved when embedding?
The error i am receiving is considered an unknown error in the embedded charts error docs https://www.mongodb.com/docs/charts/embedded-chart-error-codes/
Hi @Paula_farrugia -
Sorry to hear you are having problems. Can you help me with a bit more info:
- What is the chart ID you are trying to embed?
- How are you embedding - IFRAME or SDK?
- What authentication mode are you using?
- Are you doing anything “interesting”, e.g. programmatic filtering?
Hi @tomhollander , Thanks for your reply!
I am using the charts-embed-dom SDK and i am running an aggregation to filter the data before showing it in the chart. The chart IDs are as follows:
The same aggregation is also being used in a similar chart (638e4505-6b6e-491c-8f53-43649d83c00f) but the data is loading, which is why i was curious to see the errors as the other charts were also loading fine up till a few days ago.
My guess was that the only difference between them is the one that’s loading has to filter a lot less records, but there’s no way for me to confirm this as when loading through the charts dashboard itself, everything loads fine.
It doesn’t look like these charts are enabled for embedding? Did you check this setting?
I am actually using authenticated access and it is enabled on both dashboard and the chart itself. The data was loading up till a few days ago and the settings have not changed
Oh right, sorry I forgot to check the dashboard settings. Is it possible to briefly enable unauthenticated embedding and see if that renders without the token? If so that would imply that issue is to do with the token verification (or if not it will give other clues).
Hi Tom, i enabled it on both dashboard and chart but still got the same error.
After doing some debugging it seems that after removing this part of the aggregation, it works:
Is there a reason you could think of why this works fine on atlas but not when embedding?
That’s really strange. The aggregation stage is valid, and I just tested it on one of my embedded charts and it works fine. Can you email me at tom.hollander @ mongodb.com so we can troubleshoot further?
Just to close off the loop here. As discussed offline, in this particular case, the authenticated embedding uses App Service as authentication provider with the “Fetch data using Atlas App Services” enabled. When rules configured in App Services, it will only support aggregation stages/expressions supported by MongoDB 4.4 for user functions. $dateSubtract is an aggregation expression that has been added with MongoDB 5.0, hence the App Service raised an error which causes the “Cannot retrieve data” error in Charts.
Until the 5.0 aggregation expression is supported, the workaround for this issue is to disable the “Fetch data using Atlas App Services” option from the authentication provider setting.