Chartjs-How to keep the styles of a graph when refreshing the page?

1👍

After some research I managed to find the solution to my problem. As @LeeLenalee said, the chart is independent of what styles you maintain in your template and where you call your chart from.

The problem was that it was not registering the Datalabels plugin correctly. When I found the library it guided me a lot of examples so I was doing something like "require(‘chart.js’)"

 chartCallback: (ChartJS) => {
                ChartJS.register(require('chartjs-plugin-datalabels'))
            }

I found a github thread that talked about this, but in diferent context so I turned to the documentation that specifies:

"Let ChartJSNodeCanvas manage the lifecycle of the plugin itself, each
instance will have a separate instance of the plugin"

 requireLegacy: ['chartjs-plugin-datalabels']

Thank you all very much for your immense help.

0👍

In CSS, did you use percent for the position of the texts? If your browser is in a different size, your old code will make the text look funky.

Leave a comment