Write my own query for Mongo Charts

Mongo Chart is awesome.

However, sometimes the data query we would like to visualize is very complex, and we are unable to get it done through the charts UI.

I do notice the ability to “View aggregation pipeline”, so I am wondering whether there’s a way for us to actually write my own aggregation pipeline query, and then use Mongo Chart to display that?

Thank you!

Thanks @williamwjs - you most certainly can do this! Simply enter your aggregation pipeline (make sure it’s in square brackets) into the query bar in the chart builder. You can then drag and drop the fields returned from your query onto your chart channels.


Hi @tomhollander , thank you for the suggestion!

I do notice that when putting my query in it, it says:
Screenshot 2023-11-29 at 13.56.34

May I ask if there’s any workaround for it? The lookup button on the UI does not allow me to do filtering on the lookup results.

Thank you!

Yes, there are two workarounds:

  1. Use the “Lookup Field” option in the field panel
  2. Put the $lookup stage in a pipeline attached to a “Charts View” (on the Data Sources page).


1 Like

Thank you! This helps a lot!!!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.