Instantiate the Chart class. To do this, we need to pass in the node, id, or 2d context of the canvas of where we want to draw the chart.
// Any of the following formats may be used, just choose one!
const chart = new F2.Chart({
id: 'myChart', // pass node's id
width: 375,
height: 260,
pixelRatio: window.devicePixelRatio
});
const chart = new F2.Chart({
el: document.getElementById('myChart'), // or pass node
width: 375,
height: 260,
pixelRatio: window.devicePixelRatio
});
const chart = new F2.Chart({
context: document.getElementById('myChart').getContext('2d'), // or pass 2d context of the canvas
width: 375,
height: 260,
pixelRatio: window.devicePixelRatio
});
then relate with data. The data below shows the different types of game's sales.
It's that easy to get started using F2! From here you can explore more options that can help you customize your charts with scales, tooltip, axis, guides, legends and much more.
There are many examples of F2 that are available in the AntV demos. You also can scan the QR code below to experience our demos on you phone.