DEV Community

Carlos Orelhas
Carlos Orelhas

Posted on

1

Build charts with nodejs + canvasJS + mongodb

Hey everyone !!

I'm working on my first real project and I have some trouble to show a chart with data from mongoDB..

This is what I have inside my handlebars with HTML

Alt text of image

And inside the same handlebar opened a script tag and inserted the following code
Alt Text

But on my routes folder, I have this ROUTER.GET and this way I can pass every expense from MongoDB inside Handlebars.
Alt Text

The way I have the preview code, it shows me a chart with the dataPoints I inserted in the script, but I don't know how can refactor and inside the router.get I can access the information and build the chart with the data from mongodb..

How can I use the router file to build the chart with mongodb data?

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay