Skip to content

Chart extension - register plugin #2960

Answered by stsrki
kachna96 asked this question in Q&A
Discussion options

You must be logged in to vote

I have quickly tested to see how it could work. You need to execute the JS script directly after you include chart.js in the index.html to register custom plugins.

<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>

<script>
        Chart.pluginService.register({
            beforeDraw: function (chart) {
                var width = chart.chart.width,
                    height = chart.chart.height,
                    ctx = chart.chart.ctx;
                ctx.restore();
                var fontSize = (height / 114).toFixed(2);
                ctx.font = fontSize + "em sans-serif";
                ctx.textBaseline = "middle";
                var text = chart.config.options.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kachna96
Comment options

Answer selected by kachna96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants