Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I implement plugins using laravel-chartjs? #71

Open
john-oldfield opened this issue Apr 16, 2018 · 1 comment
Open

How can I implement plugins using laravel-chartjs? #71

john-oldfield opened this issue Apr 16, 2018 · 1 comment

Comments

@john-oldfield
Copy link

I am wanting to do things such as adding center text to doughnuts as well as many other tasks which involve using plugins but I am unable to find anything relating to how to do that in php?

Any help would be appreciated.

Thanks,

John

@ranakrisna
Copy link

ranakrisna commented Dec 3, 2018

i implement data label from https://github.com/chartjs/chartjs-plugin-datalabels
i just insert the code in bottom of my script, like this
<script type="text/javascript"> Chart.plugins.register({ afterDatasetsDraw: function(chart) { var ctx = chart.ctx; chart.data.datasets.forEach(function(dataset, i) { var meta = chart.getDatasetMeta(i); if (!meta.hidden) { meta.data.forEach(function(element, index) { ctx.fillStyle = 'rgb(0, 0, 0)'; var fontSize = 12; var fontStyle = 'normal'; var fontFamily = 'Helvetica Neue'; ctx.font = Chart.helpers.fontString(fontSize, fontStyle, fontFamily); var dataString = dataset.data[index].toString(); if(dataString > 0){ ctx.textAlign = 'center'; ctx.textBaseline = 'middle'; var padding = 0; var position = element.tooltipPosition(); ctx.fillText(dataString, position.x, position.y - (fontSize / 2) - padding); } }); } }); } }); </script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants