Member-only story

Angular | Web Workers | Chart.js

Rendering Charts With Web Workers in Angular

How to use OffscreenCanvas to create charts from within a web worker

Kagklis Vasileios
Better Programming
Published in
6 min readDec 6, 2022
Rendering charts with Web Workers in Angular
Angular logo by Angular PressKit / CC BY 4.0

In our previous article, we talked about web workers in Angular. We presented some of the benefits and drawbacks of using one. We also had the chance to see them in action in a demo application.

In this article, we will continue studying web workers. We will use the OffscreenCanvas API to create a chart with a web worker. In the process, we will highlight a few of their limitations and how we can work around them.

Let’s get started!

Disclaimer: As of today, the OffscreenCanvas API is not yet supported by all browsers.

Rendering Charts

We will use Chart.js for rendering our charts. So, we need to install the respective package by running the following command in the terminal:

npm install chart.js

We add a new page to our demo application. This page creates a chart based on the selected number picked via a range input element.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

No responses yet

Write a response