Chart.js/docs/getting-started
Wilson Lin c90cf2ebcd Make both README.md and installation.md clearer (#5274)
Address the ambiguity of "Selecting the Correct Build" section
2018-02-20 13:29:10 +01:00
..
installation.md Make both README.md and installation.md clearer (#5274) 2018-02-20 13:29:10 +01:00
integration.md Fix RequireJS doc to use UMD file instead (#4252) 2017-05-13 14:14:02 +02:00
README.md Fix typos and broken links in the docs (#5010) 2017-11-30 14:41:32 +01:00
usage.md Update the docs structure/content to use GitBook (#3751) 2017-03-20 20:36:54 -04: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://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></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.

There are many examples of Chart.js that are available in the /samples folder of Chart.js.zip that is attached to every release.