ChartjsNodeCanvas
ChartjsNodeCanvas copied to clipboard
chartjs-node-canvas showing squares
Describe the bug
I am using the npm module chartjs-node-canvas to create the chart and add it to my email. I am getting the wanted result without running the javascript script as a docker container. Here is the result got after running my javascript script with docker :

Versions
- NodeJS version: 16.19
- Chart.JS version: 3.8
Additional context
Dockerfile
FROM ubuntu:latest
RUN mkdir -p /usr/src/app/script
WORKDIR /usr/src/app
COPY . /usr/src/app/script
RUN apt-get update && apt-get upgrade -y && apt-get -y install curl && curl -sL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y nodejs
COPY package*.json ./
RUN npm install -g
RUN npm i chartjs-node-canvas chart.js
RUN apt-get update && apt-get -y install cron
RUN chmod +x script/src/DailyReports.js script/src/GenerateReport.js script/entrypoint.sh
ENTRYPOINT ["/usr/src/app/script/entrypoint.sh"]
hi, I have the same issue. Did you find a solution ? thanks.
You could add apt install fonts-freefont-ttf in your Dockerfile, although it will choose random font to display onto unless you specify it explicitly.
https://github.com/SeanSobey/ChartjsNodeCanvas/issues/105#issuecomment-1137985266
