Skip to content Skip to sidebar Skip to footer

Chart Js Multiple Datasets Different Labels Bar Chart

Bar Chart

What is Chart Js?

Chart Js is a JavaScript library that allows you to create different types of charts, including line, bar, pie, radar, and more. It is an open-source library that is free to use, and it is easy to integrate into your web application or website.

What is a Multiple Datasets Different Labels Bar Chart?

A Multiple Datasets Different Labels Bar Chart is a type of bar chart that displays multiple sets of data with different labels on the X-axis. This type of chart is useful when you want to compare multiple data sets that are related to each other.

Multiple Datasets Different Labels Bar Chart

How to Create a Multiple Datasets Different Labels Bar Chart using Chart Js?

Creating a Multiple Datasets Different Labels Bar Chart using Chart Js is easy. You need to include the Chart Js library in your HTML file and create a canvas element where the chart will be displayed. Then, you need to create a JavaScript file where you will define the data sets and the labels for the chart.

The following is an example of how to create a Multiple Datasets Different Labels Bar Chart using Chart Js:

<!-- Include the Chart Js library --><script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script><!-- Create a canvas element --><canvas id="myChart"></canvas><!-- Create a JavaScript file --><script src="myChart.js"></script>

In the JavaScript file, you need to define the data sets and the labels for the chart. The following is an example of how to do this:

var ctx = document.getElementById('myChart').getContext('2d');var myChart = new Chart(ctx, {type: 'bar',data: {labels: ['January', 'February', 'March', 'April', 'May', 'June'],datasets: [{label: 'Dataset 1',data: [12, 19, 3, 5, 2, 3],backgroundColor: 'rgba(255, 99, 132, 0.2)',borderColor: 'rgba(255, 99, 132, 1)',borderWidth: 1}, {label: 'Dataset 2',data: [2, 3, 20, 5, 1, 4],backgroundColor: 'rgba(54, 162, 235, 0.2)',borderColor: 'rgba(54, 162, 235, 1)',borderWidth: 1}]},options: {scales: {yAxes: [{ticks: {beginAtZero: true}}]}}});

In this example, we have defined two data sets with different labels. The chart will display the data sets side by side, with the labels on the X-axis.

Conclusion

A Multiple Datasets Different Labels Bar Chart is a useful tool for comparing multiple sets of data that are related to each other. With Chart Js, you can easily create this type of chart and customize it to fit your needs.

Conclusion

Related video of Chart Js Multiple Datasets Different Labels Bar Chart