CanvasJS React Charts - Official
npm install @canvasjs/react-charts
`
See npm documentation to know more about npm usage.
##### Import React Chart Component
Import the React Chart module into your React application.
`
import CanvasJSReact from '@canvasjs/react-charts';
//var CanvasJSReact = require('@canvasjs/react-charts');
var CanvasJSChart = CanvasJSReact.CanvasJSChart;
`
##### Set the chart-options & create chart
Set the chart-options & use ‘CanvasJSChart’ selector to create the chart.
`
class App extends Component {
render() {
const options = {
title: {
text: "Basic Column Chart in React"
},
data: [{
type: "column",
dataPoints: [
{ label: "Apple", y: 10 },
{ label: "Orange", y: 15 },
{ label: "Banana", y: 25 },
{ label: "Mango", y: 30 },
{ label: "Grape", y: 28 }
]
}]
}
return (
/ onRef = {ref => this.chart = ref} /
/>
);
}
}
``