Chart.js/docs/getting-started
Marc Silverman b834517378 Proposed fix for issue #6830 (#6884)
* proposed fix for issue #6830 https://github.com/chartjs/Chart.js/issues/6830

* Updated to pass the full options object instead of a shadow borderwidth. Updated migration guide regarding the API signature change.

* Moved to use options.radius instead of caching radius; updated related migration docs.
2020-01-15 17:13:36 -05:00
..
installation.md Remove bundled builds (#6680) 2019-11-02 15:48:49 -04:00
integration.md Remove moment from dependencies (#6745) 2019-11-15 13:13:33 -05:00
README.md Make decimalPlaces private and update CDN links (#6131) 2019-03-13 10:36:10 +01:00
usage.md Typos fix (#6924) 2020-01-06 18:07:08 -05:00
v3-migration.md Proposed fix for issue #6830 (#6884) 2020-01-15 17:13:36 -05:00

Getting Started

Let's get started using Chart.js!

First, we need to have a canvas in our page.

<canvas id="myChart"></canvas>

Now that we have a canvas we can use, we need to include Chart.js in our page.

<script src="https://cdn.jsdelivr.net/npm/chart.js@2.8.0"></script>

Now, we can create a chart. We add a script to our page:

var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
    // The type of chart we want to create
    type: 'line',

    // The data for our dataset
    data: {
        labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
        datasets: [{
            label: 'My First dataset',
            backgroundColor: 'rgb(255, 99, 132)',
            borderColor: 'rgb(255, 99, 132)',
            data: [0, 10, 5, 2, 20, 30, 45]
        }]
    },

    // Configuration options go here
    options: {}
});

It's that easy to get started using Chart.js! From here you can explore the many options that can help you customise your charts with scales, tooltips, labels, colors, custom actions, and much more.

All our examples are available online but you can also download the Chart.js.zip archive attached to every release to experiment with our samples locally from the /samples folder.