@muriel.schmidt
To customize the horizontal bar in Chart.js, you can modify various options and settings. Here are the steps to customize the horizontal bar:
1
|
<canvas id="myChart"></canvas> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
// Create a chart context
var ctx = document.getElementById('myChart').getContext('2d');
// Define the chart data
var chartData = {
labels: ['Label 1', 'Label 2', 'Label 3'],
datasets: [{
label: 'Dataset 1',
data: [10, 20, 30],
backgroundColor: 'rgba(255, 99, 132, 0.5)', // Change color of bars
borderWidth: 1, // Change the border width around bars
}]
};
// Define the chart options
var chartOptions = {
responsive: true,
scales: {
x: {
beginAtZero: true, // Start y-axis at 0
max: 50 // Change the maximum value on y-axis
}
}
};
// Create the horizontal bar chart
var myChart = new Chart(ctx, {
type: 'horizontalBar',
data: chartData,
options: chartOptions
});
|
These are just a few examples, and there are many more customization options available. You can refer to the Chart.js documentation for a complete list of options and settings: https://www.chartjs.org/docs/latest/