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

Callback if no data is found in given chart #19

Closed tannerneuro closed 2 years ago

tannerneuro commented 4 years ago

I have a chart that can have filters applied that will result in no data being returned. (An empty chart) I'd like to have the flexibility to manage that empty state after the chart renders.

Upon rendering the chart, the promise should return if data is present or not. Alternatively, a getChartData method could be applicable after rendering the chart.

The alternative is probably just grabbing this existing data and aggregating/filtering to whatever the given chart data is supposed to look like. Its just overkill to have to grab that data when the chart should have it.

kristinamongo commented 4 years ago

Hello and thanks for logging this request. It's on our radar and we will have it in mind for our new features.

khanguslee commented 2 years ago

Hello @tannerneuro!

Sorry for the long wait but with our new v2.2.0 release, we have added a new getData() method which might be able to resolve your problem. Can you please confirm this so we can close this issue?

kristinamongo commented 2 years ago

I'm closing this issue as it's resolved by the getData method in v2.2.0 as Angus mentioned ⬆️ The output of the method for a chart with no data would be:

{
    documents: []
    fields: <the fields of the charts - axes, groups, etc - depending on the chart type>
}

You can also see the method's usage in this example here: Unauthenticated Charts Example