React Funnel Charts are used to represent linear process that has sequential connected stages. Funnel Charts are widely used in visualizing sales process, interview process etc. Given example shows Sales Process as Funnel Chart along with source code in react 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() { var dataPoint; var total; const options = { animationEnabled: true, title:{ text: "Sales Analysis" }, data: [{ type: "funnel", toolTipContent: "<b>{label}</b>: {y} <b>({percentage}%)</b>", indexLabelPlacement: "inside", indexLabel: "{label} ({percentage}%)", dataPoints: [ { y: 1400, label: "Prospects" }, { y: 1212, label: "Qualified Prospects" }, { y: 1080, label: "Proposals" }, { y: 665, label: "Negotiation" }, { y: 578, label: "Final Sales" } ] }] } //calculate percentage dataPoint = options.data[0].dataPoints; total = dataPoint[0].y; for(var i = 0; i < dataPoint.length; i++) { if(i == 0) { options.data[0].dataPoints[i].percentage = 100; } else { options.data[0].dataPoints[i].percentage = ((dataPoint[i].y / total) * 100).toFixed(2); } } 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;
The width and height of neck in Funnel Chart can be customized using neckWidth and neckHeight. valueRepresents, color, indexLabelPlacement, etc. are the other common customizations used.
Note For step by step instructions, follow our React Integration Tutorial