1👍
✅
I found the solution. In order for chartjs-node-canvas to understand the type treemap, some custom configurations are required to be added.
Source: https://www.chartjs.org/docs/latest/developers/charts.html#extending-existing-chart-types
2👍
chartjs-node-canvas will use Chart.js plugins that have been imported into the global namespace.
Just import it like this:
const chartTreeMap = require('chartjs-chart-treemap');
const { CanvasRenderService } = require('chartjs-node-canvas');
And use CanvasRenderService normally. You don’t have to do anything with the chartTreeMap
object as it automatically overrides chart on import (see source code).
Many of the treemap library examples reference a Color
object. You would have to replace that with Chart.helpers.color
and also provide a global CanvasGradient
object.
Source:stackexchange.com