How to change colours for Angular-Chart.js

Your should declare colours object as an array “colours”: [{ fillColor: ‘rgba(47, 132, 71, 0.8)’, strokeColor: ‘rgba(47, 132, 71, 0.8)’, highlightFill: ‘rgba(47, 132, 71, 0.8)’, highlightStroke: ‘rgba(47, 132, 71, 0.8)’ }]; Working Plunkr For more info refer this post / this too. For newer versions, see eli0tt’s answer, as the parameter names have changed.

Custom Legend with ChartJS v2.0

If you guys run through this post and tried the posted answer and didn’t work, try this one: legendCallback: function(chart) { var text = []; text.push(‘<ul>’); for (var i=0; i<chart.data.datasets.length; i++) { console.log(chart.data.datasets[i]); // see what’s inside the obj. text.push(‘<li>’); text.push(‘<span style=”background-color:’ + chart.data.datasets[i].borderColor + ‘”>’ + chart.data.datasets[i].label + ‘</span>’); text.push(‘</li>’); } text.push(‘</ul>’); return text.join(“”); … Read more

Error: “category” is not a registered scale

Like the error says you are using the category scale so you will need to import and register it like so: import {CategoryScale} from ‘chart.js’; Chart.register(CategoryScale); Or you can choose to not use treeshaking and import everything like so: import Chart from ‘chart.js/auto’; For all available things you might need to import and register please … Read more

chart.js load totally new data

I had huge problems with this First I tried .clear() then I tried .destroy() and I tried setting my chart reference to null What finally fixed the issue for me: deleting the <canvas> element and then reappending a new <canvas> to the parent container There’s a million ways to do this: var resetCanvas = function … Read more

Chart.js canvas resize

I had a lot of problems with that, because after all of that my line graphic looked terrible when mouse hovering and I found a simpler way to do it, hope it will help 🙂 Use these Chart.js options: // Boolean – whether or not the chart should be responsive and resize when the browser … Read more

Chart.js v2: How to make tooltips always appear on pie chart?

Solution for ChartJs Version > 2.1.5: Chart.pluginService.register({ beforeRender: function (chart) { if (chart.config.options.showAllTooltips) { // create an array of tooltips // we can’t use the chart tooltip because there is only one tooltip per chart chart.pluginTooltips = []; chart.config.data.datasets.forEach(function (dataset, i) { chart.getDatasetMeta(i).data.forEach(function (sector, j) { chart.pluginTooltips.push(new Chart.Tooltip({ _chart: chart.chart, _chartInstance: chart, _data: chart.data, _options: … Read more