ChartjsNodeCanvas icon indicating copy to clipboard operation
ChartjsNodeCanvas copied to clipboard

chartjs-node-canvas showing squares

Open mjmaurya opened this issue 3 years ago • 2 comments

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 :

Chart Image

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"]

mjmaurya avatar Jul 17 '22 17:07 mjmaurya

hi, I have the same issue. Did you find a solution ? thanks.

kaboume avatar Nov 13 '22 20:11 kaboume

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

image

sinyo1015 avatar Feb 06 '23 17:02 sinyo1015