chart.js
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@kurkle/color | 0.3.2 | 20.09 kB | MIT | prod |
Chart.js is a JavaScript library that enables designers and developers to create simple yet flexible charts using the HTML5 canvas element. This powerful tool supports a variety of chart types, including line, bar, pie, and radar charts, among others. Built for simplicity and flexibility, Chart.js provides an optimal solution for data visualization in web projects.
Using Chart.js is quite straightforward. First, you need to add the Chart.js script to your project by including it in your HTML file like so:
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
Then, you can create a canvas element in your HTML where the chart will be drawn:
<canvas id="myChart"></canvas>
Next, in your JavaScript file or script tag, you can create a new chart by creating a Chart object:
var ctx = document.getElementById('myChart').getContext('2d');
var myChart = new Chart(ctx, {
type: 'line', // type of chart: line, bar, radar, doughnut, etc.
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'],
datasets: [{
label: 'Sales',
data: [12, 19, 3, 5, 2, 3, 9, 10, 12, 17, 19, 22]
}]
},
options: {
scales: {
y: {
beginAtZero: true
}
}
}
});
The complete and thorough documentation for Chart.js can be found on their official website, Chart.js Documentation. Here, you can explore detailed guides on getting started with Chart.js, along with in-depth explanations about the general usage, different chart configurations, and diverse features that the library offers. The documentation also provides links to popular extensions and sample charts built with Chart.js. If you're looking for documentation of an older version of the library, you can find it by specifying the version in the URL, for example, Chart.js 2.9.4 Documentation.