React Spline Chart, also known as Smoothed / Curved Line Chart, is most widespread alternative to line chart except that the datapoints are connected using smooth curved line. Below example shows a React Spline chart along with source code that you can try running locally.
/* App.js */ import React, { Component } from 'react'; import CanvasJSReact from '@canvasjs/react-charts'; //var CanvasJSReact = require('@canvasjs/react-charts'); var CanvasJS = CanvasJSReact.CanvasJS; var CanvasJSChart = CanvasJSReact.CanvasJSChart; class App extends Component { render() { const options = { animationEnabled: true, title:{ text: "Monthly Sales - 2017" }, axisX: { valueFormatString: "MMM" }, axisY: { title: "Sales (in USD)", prefix: "$" }, data: [{ yValueFormatString: "$#,###", xValueFormatString: "MMMM", type: "spline", dataPoints: [ { x: new Date(2017, 0), y: 25060 }, { x: new Date(2017, 1), y: 27980 }, { x: new Date(2017, 2), y: 42800 }, { x: new Date(2017, 3), y: 32400 }, { x: new Date(2017, 4), y: 35260 }, { x: new Date(2017, 5), y: 33900 }, { x: new Date(2017, 6), y: 40000 }, { x: new Date(2017, 7), y: 52500 }, { x: new Date(2017, 8), y: 32300 }, { x: new Date(2017, 9), y: 42000 }, { x: new Date(2017, 10), y: 37160 }, { x: new Date(2017, 11), y: 38400 } ] }] } return ( <div> <CanvasJSChart options = {options} /* onRef={ref => this.chart = ref} */ /> {/*You can get reference to the chart instance as shown above using onRef. This allows you to access all chart properties and methods*/} </div> ); } } export default App;
In the above chart, valueFormatString helps you to set the string format for labels appearing on axes to increase readability. Other frequently used customization options include lineThickness, lineColor, lineDashType, etc
Note For step by step instructions, follow our React Integration Tutorial