Has anyone worked on a transformer function to take a visualizer (meta data) api call and convert it into the appropriate analytics API call?
I’ve noticed (now consistently) the “api/visualizations/{uid}/data” end point does not return data exactly as defined in a saved visualization output. I’m hoping someone has already solved this work-around. It’s notable that the Visualizer App itself does not use “…api/visualizations/{uid}/data” path for data returned to the app but a transformed analytics call…
Alternatively, it would be great if the visualizer metadata API could include a “runtime” version of the associated analytics api url. I would assume that will solve many future use cases…
I think I have attempted something similar; however,I noticed that the UI does pick out the values needed from the API calls.
Could you please provide examples of what you’re seeing and what you expect? Is it possible that it might just be easier to just reformat/recreate the API call?
We’re already reading visualization/data but some of the users are finding the underlying data is not updating after they save changes to filters. etc. I’ve added a unique url parameter to ensure a fresh result set.
Are you saying this {uid}/data end-point should be safe and stable? I’m happy to test further until our api query approach is stable for our reporting tool. I don’t expect to be able to write the transformer without some guidance and pointers… hoping someone in the community can either point me to the code in the visualizer app that completes this transformation or share some pointers…
Is this issue with the filter happening in a custom app or is it in the Data Visualizer app? I hope you could share an example from play.dhis2.org instance if possible to get a clearer picture about what’s going on.
This is for a custom app; busy engaging the TZ team who may have looked into this for their flexi portal app… but I’m not familiar with the source code that builds analytics API calls. Hopefully someone on the dev team can provide pointers…
First, I had no idea there was such an endpoint as `api/visualizations/{uid}/data`, so I have never actually used it.
To get the analytics call, we have our own custom transformer functions that are implemented depending on what we support. Here is an example hook that collects all data and metadata required for a visualization to be plotted.
You can also check out the DHIS2 analytics library here, which is used internally by DHIS2 core apps and exposes the Analytics Class that can be used to fetch data.
Yes, the `api/visualizations/{uid}/data` endpoint is very useful. The only drawback is you’re unable to access the underlying data for charts - it returns an image stream regardless of resource representation (xml,json,etc).
We should connect - I’ll drop you a DM; thank you for pointing out the hooks above!