SeanSobey / ChartjsNodeCanvas

A node renderer for Chart.js using canvas.
MIT License
228 stars 70 forks source link

chartjs-node-canvas showing squares #113

Open mjmaurya opened 1 year ago

mjmaurya commented 1 year ago

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

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"]
kaboume commented 1 year ago

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

sinyo1015 commented 1 year ago

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