Interactive Charts on Recharts for React Application

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:

Development stages

Latest works

  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1171
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1094
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    831
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    879
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    453

Building Interactive Charts with Recharts for React Applications

Recharts is a React-native charting library built on SVG and D3. Each chart component is a standard React component, simplifying customization and integration with application state.

Installation

npm install recharts

Area Chart with Custom Tooltip

import {
  AreaChart, Area, XAxis, YAxis, CartesianGrid,
  Tooltip, ResponsiveContainer, Legend
} from 'recharts';

function CustomTooltip({ active, payload, label }) {
  if (!active || !payload?.length) return null;

  return (
    <div className="bg-white border rounded-lg shadow-lg p-3">
      <p className="font-semibold text-gray-700 mb-2">{label}</p>
      {payload.map(entry => (
        <div key={entry.name} className="flex items-center gap-2">
          <div className="w-3 h-3 rounded-full" style={{ background: entry.color }} />
          <span className="text-sm">
            {entry.name}: <strong>{formatCurrency(entry.value)}</strong>
          </span>
        </div>
      ))}
    </div>
  );
}

function SalesAreaChart({ data }) {
  return (
    <ResponsiveContainer width="100%" height={300}>
      <AreaChart data={data} margin={{ top: 10, right: 30, left: 0, bottom: 0 }}>
        <defs>
          <linearGradient id="salesGradient" x1="0" y1="0" x2="0" y2="1">
            <stop offset="5%" stopColor="#3b82f6" stopOpacity={0.3} />
            <stop offset="95%" stopColor="#3b82f6" stopOpacity={0} />
          </linearGradient>
        </defs>
        <CartesianGrid strokeDasharray="3 3" stroke="#f0f0f0" />
        <XAxis dataKey="date" tickFormatter={d => format(parseISO(d), 'dd MMM')} />
        <YAxis tickFormatter={v => `${(v/1000).toFixed(0)}k`} />
        <Tooltip content={<CustomTooltip />} />
        <Area
          type="monotone"
          dataKey="revenue"
          name="Revenue"
          stroke="#3b82f6"
          fill="url(#salesGradient)"
          strokeWidth={2}
        />
      </AreaChart>
    </ResponsiveContainer>
  );
}

Composed Chart (Mixed Type)

import { ComposedChart, Bar, Line, Scatter } from 'recharts';

function ComposedAnalytics({ data }) {
  return (
    <ResponsiveContainer width="100%" height={350}>
      <ComposedChart data={data}>
        <CartesianGrid strokeDasharray="3 3" />
        <XAxis dataKey="month" />
        <YAxis yAxisId="revenue" orientation="left" />
        <YAxis yAxisId="count" orientation="right" />
        <Tooltip />
        <Legend />

        <Bar yAxisId="revenue" dataKey="revenue" name="Revenue" fill="#93c5fd" />
        <Line yAxisId="count" dataKey="orders" name="Orders"
          type="monotone" stroke="#f59e0b" strokeWidth={2} dot={false} />
        <Scatter yAxisId="revenue" dataKey="bigOrders" name="Large Orders"
          fill="#ef4444" />
      </ComposedChart>
    </ResponsiveContainer>
  );
}

Custom Shape for Bar

function RoundedBar(props) {
  const { x, y, width, height, fill } = props;
  const radius = 4;

  return (
    <path
      d={`M${x},${y + height}
         L${x},${y + radius}
         Q${x},${y} ${x + radius},${y}
         L${x + width - radius},${y}
         Q${x + width},${y} ${x + width},${y + radius}
         L${x + width},${y + height} Z`}
      fill={fill}
    />
  );
}

<Bar dataKey="value" shape={<RoundedBar />} />

Zoom via ReferenceArea

function ZoomableChart({ data }) {
  const [refArea, setRefArea] = useState({ left: '', right: '' });
  const [zoomedData, setZoomedData] = useState(data);

  const zoom = () => {
    if (refArea.left === refArea.right) return;
    const filtered = data.filter(d =>
      d.date >= refArea.left && d.date <= refArea.right
    );
    setZoomedData(filtered);
    setRefArea({ left: '', right: '' });
  };

  return (
    <LineChart data={zoomedData}
      onMouseDown={e => setRefArea({ left: e.activeLabel, right: '' })}
      onMouseMove={e => refArea.left && setRefArea(prev => ({ ...prev, right: e.activeLabel }))}
      onMouseUp={zoom}>
      {/* ... */}
      {refArea.left && refArea.right && (
        <ReferenceArea x1={refArea.left} x2={refArea.right} strokeOpacity={0.3} />
      )}
    </LineChart>
  );
}

Timeline

3–5 chart types with custom tooltips and interactivity — 3–4 days.