10๐
I was able to figure this out, I needed to add a callback under my ticks object like so
ticks: {
beginAtZero:true,
callback: function(value, index, values) {
return value + 'ยฐ';
}
},
I hope this helps anyone who has a similar problem.
1๐
I tried this in Angular 7 and This works for me:
options: {
tooltips: {
callbacks: {
label: (tooltipItems, data) => {
return data.datasets[tooltipItems.datasetIndex].data[tooltipItems.index] + ' GB';
}
},
}
0๐
var data = {
labels: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"],
datasets: [
{
lineTension: 0.1,
backgroundColor: grd,
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: "rgba(75,192,192,1)",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "rgba(75,192,192,1)",
pointHoverBorderColor: "rgba(220,220,220,1)",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
data: [100, 250, 250, 400, 400, 400, 500, 700, 900, 1000, 1000, 1300, 1300, 1100, 900, 700, 500, 300, 100, 0],
spanGaps: false
}
]
};
var options = {
animation: false,
scaleLabel:
function(label){return label.value.toString() +' ยฐC';}
};
//Get the context of the canvas element we want to select
var ctx = document.getElementById("myChart").getContext("2d");
/*************************************************************************/
var myLineChart = new Chart(ctx).Line(data, options);
var grd = ctx.createLinearGradient(170.000, 600.000, 150.000, 0.000);
grd.addColorStop(0.000, 'rgba(0, 255, 0, 1.000)');
grd.addColorStop(0.200, 'rgba(191, 255, 0, 1.000)');
grd.addColorStop(0.400, 'rgba(221, 255, 0, 1.000)');
grd.addColorStop(0.600, 'rgba(255, 229, 0, 1.000)');
grd.addColorStop(0.800, 'rgba(255, 144, 0, 1.000)');
grd.addColorStop(1.000, 'rgba(255, 50, 0, 1.000)');
<script src="http://www.chartjs.org/assets/Chart.js"></script>
<canvas id="myChart" width="400" height="400"></canvas>
- [Chartjs]-Chart.js bar thickness
- [Chartjs]-What is the correct way to destructure a nested json object with fetch?
Source:stackexchange.com