DHIS2 API Visualizations/id/data Error

Hello everyone,

Could anyone help me with this question, here is the question, so lets say you have finished to create some different parts of charts in data visualizer app, you are going to create a standard report in HTML. at this point you have finished to design the template now you include your charts in the template(I know we are going to use APIs) and am trying to use this api “…/api/charts//data?width&height” unformunately nothing is being returned the error is “409 not found”.

Whats the cause , is this endpoint no longer available ? if so which endpoint should we use ?

I would like to also request if there is anyone with some resources were i can find dhis.objects for example objects like “dhis.report.date”,“dhis2.report.periods” can share with me. thank you

1 Like

Hi @mugisha_alain , try to use api/visualizations/id , /charts was is for old versions of DHIS2

1 Like

Thanks for the response, i have tried the above API but it responds with a blank page. for example take alook at this image

hello everyone,

Am trying to use an API to get a chart as an image i have use this API “/api/visualizations/{id}/data” but this API responds with a blank page, see in this image


so what could be the cause ?, is there a parameter am missing ?

a few questions :

  • which version of dhis2 are you using ?
  • does the visualiation works “in the browser” /dhis-web-data-visualizer/#/{id} (without extra params)
  • which kind of visualisation are you trying to get as an image (not sure every graph type is supported)

From the documentation you might need to pass extra params depending how the period are calculated or you want them to be overridden.

Note that previously the images rendered where really different, sometime not good compared to visualization library in the browser. So not I sure I would rely on the current api for a good looking graph. I think in newer dhis2, they will use a browser less chrome to render the image (not sure when).

see New Push Analytics in 41.1 (Automatically email dashboards)

https://play.im.dhis2.org/stable-2-41-1/api/visualizations/DeRrc1gTMjn/data

1 Like

am using version 2.41.1.0
the visualizations works in the browser and am trying to get a piechart
Another thing is that in the data visualizer app am able to download any chart as an image or pdf

I remember that you need

 -Djava.awt.headless=true

and some packages for the fonts to be present.

what looks strange is that you get the labels.

@Gassim might know someone who can help in the dev team ?

1 Like

Note the pie chart is not working on play too

https://play.im.dhis2.org/stable-2-41-1/api/visualizations/ZfQMIA4o2s3/data

1 Like

This is normal it’s done in javascript in the browser. it’s not calling that api to get the graph. That’s why I said I don’t recommend using the /api/vizualisations/…/data because they are not exactly rendered the same way.

Have you tried with a bar chart and that api ?

1 Like