React Spline Area Chart, also referred to as curved / smoothed area chart, is a type of Area Chart with envelop covered with smooth curve. CanvasJS react component supports Single / Multi Series Spline Area Charts. Given example shows a React Spline Area Chart along with source code that you can run 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: "Nuclear Electricity Generation in US" }, axisY: { title: "Net Generation (in Billion kWh)", suffix: " kWh" }, data: [{ type: "splineArea", xValueFormatString: "YYYY", yValueFormatString: "#,##0.## bn kW⋅h", showInLegend: true, legendText: "kWh = one kilowatt hour", dataPoints: [ { x: new Date(2008, 0), y: 70.735 }, { x: new Date(2009, 0), y: 74.102 }, { x: new Date(2010, 0), y: 72.569 }, { x: new Date(2011, 0), y: 72.743 }, { x: new Date(2012, 0), y: 72.381 }, { x: new Date(2013, 0), y: 71.406 }, { x: new Date(2014, 0), y: 73.163 }, { x: new Date(2015, 0), y: 74.270 }, { x: new Date(2016, 0), y: 72.525 }, { x: new Date(2017, 0), y: 73.121 } ] }] } 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, includeZero property is set to false to enhance the look and feel of chart when the difference among data points is very less compared to the values of y. Other commonly used customizations are markerColor, markerBorderColor, etc.
Note For step by step instructions, follow our React Integration Tutorial