mongodb-js / charts-embed-sdk

The easiest way to embed MongoDB Charts visualisations into your web app
https://docs.mongodb.com/charts/master/embedding-charts-sdk/
Apache License 2.0
43 stars 31 forks source link

Export chart data to csv/json #28

Closed tannerneuro closed 10 months ago

tannerneuro commented 3 years ago

This feature is offered in the mongo charts console, I would love to see it applied for embedded charts as well.

Pretty straight forward from a description standpoint, I'll leave it at that.

tomhollander commented 3 years ago

Thanks @tannerneuro, this is on our radar.

haep1 commented 3 years ago

Hi, we would really need this feature too, @tomhollander could you tell me if it is already on your roadmap? Is there any workaround to embed a button in our frontend and get the exported data from MongoDB-Atlas via an API call?

tomhollander commented 3 years ago

Hi @haep1 - We hope to get to this later in the year. If you really need this in the meantime, a workaround would be to call the HTTP endpoint that the chart users to get its data. You can see this in your browser dev tools; an example is https://us-east-1.aws.webhooks.mongodb-realm.com/api/client/v2.0/app/charts-tomh-yfpqi/service/http/incoming_webhook/embedding?tolerance=3600&id=ed1cc666-850e-4f42-8b58-b6c85424ac36. This will return a JSON payload of the data which you can then process (e.g. convert to CSV).

Note this method of integration isn't supported and it's possible the HTTP endpoints will change. Our ultimate goal is to have an SDK method that returns this in a supported manner.

khanguslee commented 2 years ago

@tannerneuro @haep1 We recently released a chart.getData() method in v2.2.0 of the SDK which may be of use to you. The data may not be in your desired JSON or CSV format, but you may transform the results to your liking after you've called this method!

You can have a look at the Unauthenticated Charts Example to quickly view the output of this method.

Let us know if this resolves your problem so that we can close this issue 😄

khanguslee commented 10 months ago

Closing this issue due to inactivity, feel free to reopen if my suggested comment does not suffice.