1.0.2 • Published 6 months ago

react-funnel-chart-pro v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

React Funnel Chart Pro

A beautiful and customizable funnel chart library for React applications, featuring both basic and advanced visualization options for sales funnels, conversion funnels, and other funnel-based analytics.

Features

Basic Funnel Chart

  • 📊 Smooth animations and transitions
  • 🎨 Fully customizable colors and styles
  • 📱 Responsive design
  • 🔧 Configurable display options
  • 💡 Interactive tooltips
  • 📝 TypeScript support
  • 🎯 Zero dependencies

Advanced Funnel Chart

  • 📈 Conversion rate analysis
  • 💰 Revenue and cost tracking
  • ⏱️ Time-in-stage metrics
  • 📉 Drop-off analysis
  • 🔄 Velocity tracking
  • 🖱️ Interactive stage selection
  • 📊 Detailed metrics panel

Installation

npm install react-funnel-chart-pro
# or
yarn add react-funnel-chart-pro

Basic Usage

import { FunnelChart } from 'react-funnel-chart-pro';

const data = [
  { label: 'Visitors', value: 5000, color: '#60A5FA' },
  { label: 'Interested', value: 2500, color: '#34D399' },
  { label: 'Prospects', value: 1200, color: '#A78BFA' },
  { label: 'Negotiations', value: 600, color: '#F472B6' },
  { label: 'Deals', value: 200, color: '#FBBF24' },
];

function App() {
  return (
    <FunnelChart
      data={data}
      height={500}
      width={800}
      showPercentages={true}
      showValues={true}
      showLabels={true}
      showLegend={true}
    />
  );
}

Advanced Usage

import { AdvancedFunnelChart } from 'react-funnel-chart-pro';

const advancedData = [
  {
    label: 'Website Visits',
    value: 10000,
    color: '#3B82F6',
    subLabel: 'Total unique visitors',
    timeInStage: 1,
    revenue: 0,
    cost: 1000
  },
  {
    label: 'Sign Ups',
    value: 7500,
    color: '#10B981',
    subLabel: 'Created an account',
    timeInStage: 2,
    revenue: 25000,
    cost: 2000
  },
  // ... more stages
];

function App() {
  return (
    <AdvancedFunnelChart
      data={advancedData}
      showMetrics={true}
      showRevenue={true}
      showVelocity={true}
      onStageClick={(stage) => console.log('Stage clicked:', stage)}
    />
  );
}

API Reference

FunnelChart Props

PropTypeDefaultDescription
dataFunnelData[]requiredArray of data points for the funnel chart
heightnumber400Height of the chart in pixels
widthnumber600Width of the chart in pixels
showPercentagesbooleantrueShow percentage values
showValuesbooleantrueShow raw values
showLabelsbooleantrueShow labels
showLegendbooleantrueShow legend
showTooltipsbooleantrueShow tooltips on hover
formatValue(value: number) => stringvalue.toLocaleString()Custom value formatter
formatPercentage(percentage: number) => string`${percentage.toFixed(1)}%`Custom percentage formatter
customTooltip(item: FunnelData) => stringundefinedCustom tooltip content
animationDurationnumber300Animation duration in milliseconds
classNamestring''Additional CSS classes
styleobject{}Additional inline styles

AdvancedFunnelChart Props

PropTypeDefaultDescription
dataAdvancedFunnelData[]requiredArray of advanced data points
heightnumber600Height of the chart
widthnumber1000Width of the chart
showMetricsbooleantrueShow conversion metrics
showRevenuebooleantrueShow revenue data
showVelocitybooleantrueShow velocity metrics
onStageClick(stage: AdvancedFunnelData) => voidundefinedStage click handler
classNamestring''Additional CSS classes
styleobject{}Additional inline styles

Data Types

interface FunnelData {
  label: string;      // Label for the funnel level
  value: number;      // Numeric value
  color: string;      // Color for the funnel level
  subLabel?: string;  // Optional additional information
}

interface AdvancedFunnelData extends FunnelData {
  timeInStage?: number;  // Average time in days
  revenue?: number;      // Revenue at this stage
  cost?: number;         // Cost at this stage
}

Features in Detail

Basic Funnel Chart

  • Percentage calculations between stages
  • Customizable colors and styles
  • Interactive tooltips
  • Responsive design
  • Value and label formatting
  • Legend support

Advanced Funnel Chart

  • Conversion rate analysis between stages
  • Revenue and cost tracking per stage
  • Time-in-stage metrics
  • Drop-off analysis
  • Velocity tracking
  • Interactive stage selection
  • Detailed metrics panel
  • Custom formatting for numbers and currencies

License

MIT © sabiraie

Buy Me a Coffee