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

Integrating the SDK in a React application #16

Closed tomcanac closed 2 years ago

tomcanac commented 4 years ago

Integrating the SDK in a react app is undocumented and a bit obscure right now.

It would be nice to have an example of integration of a chart with the SDK in a react component.

I tried myself but didn't manage to get something really functionnal and I don't have much time in my project to do a lot of R&D. An official documentation example would be amazing.

tomhollander commented 4 years ago

Hi @tomcanac, great suggestion. We'll try to get to this soon.

tomhollander commented 4 years ago

Actually we already do have an example of the Charts Embedding SDK in a React app - see the Timeline example. This does show a bunch of other stuff on top of the minimalist React integration, so I still think a simpler sample is a good idea, but this should help you in the meantime.

tomcanac commented 4 years ago

Great thanks for pointing this out! It will definitely do the job for my need, feel free to close this issue if you want or keep it open for a simpler integration example.

Thanks!

cpotdevin commented 2 years ago

For anyone coming to this thread this is an updated blog of an example using React (2022-03).

Also, if you are using Authenticated Embedding remember to use the getUserToken in the EmbedChartOptions to define a function that returns a valid authorization token or you will receive a Error 3: Embedding not enabled on this chart.

khanguslee commented 2 years ago

Thanks for sharing @cpotdevin! Any feedback in terms of documentation is always helpful to the team!

I recently updated the main README.md file so that users can easily find a React usage example which links to the existing timeline example. This change can be found in https://github.com/mongodb-js/charts-embed-sdk/pull/61.

kristinamongo commented 2 years ago

Thank you all for participating in this discussion. I'm closing the issue as there are a few React examples mentioned above.