Chart.js – Styling Legend

No need to use legendCallback function. You can set usePointStyle = true to turn that rectangle into a circle. Chart.defaults.global.legend.labels.usePointStyle = true; var ctx = document.getElementById(“myChart”).getContext(“2d”); var myChart = new Chart(ctx, { type: ‘line’, data: { labels: [“Red”, “Blue”, “Yellow”, “Green”, “Purple”, “Orange”], datasets: [{ label: ‘Link One’, data: [1, 2, 3, 2, 1, 1.5, … Read more

Chartjs random colors for each part of pie chart with data dynamically from database

You should create a separate array for colors ( just like the ict_unit and efficiency ), instead of assigning a random color value each time to the coloR variable. Here is the revised version of your code : $(document).ready(function() { $.ajax({ url: “https://jsonblob.com/api/jsonBlob/a7176bce-84e0-11e7-8b99-016f34757045”, method: “GET”, success: function(data) { console.log(data); var ict_unit = []; var efficiency … Read more

Set minimum step size in chart js

If you don’t want to show point value (e.g. 0.5) labels you could write a callback function to filter the point value labels instead of using stepSize. Like this: ticks: { min: 0, // it is for ignoring negative step. beginAtZero: true, callback: function(value, index, values) { if (Math.floor(value) === value) { return value; } … Read more

ChartJS – Different color per data point

In updating to version 2.2.2 of ChartJS, I found that the accepted answer no longer works. The datasets will take an array holding styling information for the properties. In this case: var pointBackgroundColors = []; var myChart = new Chart($(‘#myChart’).get(0).getContext(‘2d’), { type: ‘line’, data: { datasets: [ { data: dataPoints, pointBackgroundColor: pointBackgroundColors } ] } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)