Claude Code के साथ Chart Libraries का उपयोग
Claude Code का उपयोग करके chart libraries के बारे में जानें। Practical code examples शामिल हैं।
Claude Code से Chart Libraries का उपयोग
Dashboards और report screens में graph display essential है। Recharts, Chart.js, D3.js जैसी कई libraries हैं, लेकिन Claude Code का उपयोग करके हर library की strengths leverage करते हुए chart components quickly बनाए जा सकते हैं।
Library Selection
> React app में charts display करना है।
> Line chart, bar chart, pie chart, area chart implement करो।
> Recharts use करो, responsive और dark mode support के साथ।
- Recharts: React native, declarative और simple
- Chart.js: Lightweight, wide chart support
- D3.js: Maximum flexibility, high learning cost
Recharts से विभिन्न Charts
// src/components/charts/SalesLineChart.tsx
import {
LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip,
Legend, ResponsiveContainer
} from 'recharts';
interface DataPoint {
date: string;
revenue: number;
orders: number;
}
export function SalesLineChart({ data }: { data: DataPoint[] }) {
return (
<div className="bg-white dark:bg-gray-800 rounded-xl p-6 shadow-sm">
<h3 className="text-lg font-semibold mb-4 dark:text-white">Sales Trend</h3>
<ResponsiveContainer width="100%" height={300}>
<LineChart data={data}>
<CartesianGrid strokeDasharray="3 3" stroke="#374151" />
<XAxis dataKey="date" stroke="#9CA3AF" />
<YAxis yAxisId="revenue" stroke="#3B82F6" />
<YAxis yAxisId="orders" orientation="right" stroke="#10B981" />
<Tooltip
contentStyle={{
backgroundColor: '#1F2937',
border: 'none',
borderRadius: '8px',
color: '#fff',
}}
/>
<Legend />
<Line yAxisId="revenue" type="monotone" dataKey="revenue" stroke="#3B82F6" name="Revenue" strokeWidth={2} dot={false} />
<Line yAxisId="orders" type="monotone" dataKey="orders" stroke="#10B981" name="Orders" strokeWidth={2} dot={false} />
</LineChart>
</ResponsiveContainer>
</div>
);
}
Bar Chart
// src/components/charts/CategoryBarChart.tsx
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Cell } from 'recharts';
const COLORS = ['#3B82F6', '#10B981', '#F59E0B', '#EF4444', '#8B5CF6'];
interface CategoryData {
name: string;
value: number;
}
export function CategoryBarChart({ data }: { data: CategoryData[] }) {
return (
<div className="bg-white dark:bg-gray-800 rounded-xl p-6 shadow-sm">
<h3 className="text-lg font-semibold mb-4 dark:text-white">Category-wise Sales</h3>
<ResponsiveContainer width="100%" height={300}>
<BarChart data={data} layout="vertical">
<CartesianGrid strokeDasharray="3 3" horizontal={false} />
<XAxis type="number" />
<YAxis type="category" dataKey="name" width={100} />
<Tooltip />
<Bar dataKey="value" radius={[0, 4, 4, 0]}>
{data.map((_, index) => (
<Cell key={index} fill={COLORS[index % COLORS.length]} />
))}
</Bar>
</BarChart>
</ResponsiveContainer>
</div>
);
}
Pie Chart
// src/components/charts/DistributionPieChart.tsx
import { PieChart, Pie, Cell, Tooltip, ResponsiveContainer, Legend } from 'recharts';
const COLORS = ['#3B82F6', '#10B981', '#F59E0B', '#EF4444', '#8B5CF6', '#EC4899'];
interface SegmentData {
name: string;
value: number;
}
export function DistributionPieChart({ data, title }: { data: SegmentData[]; title: string }) {
const total = data.reduce((sum, d) => sum + d.value, 0);
return (
<div className="bg-white dark:bg-gray-800 rounded-xl p-6 shadow-sm">
<h3 className="text-lg font-semibold mb-4 dark:text-white">{title}</h3>
<ResponsiveContainer width="100%" height={300}>
<PieChart>
<Pie
data={data}
cx="50%"
cy="50%"
innerRadius={60}
outerRadius={100}
dataKey="value"
label={({ name, value }) => `${name} ${((value / total) * 100).toFixed(0)}%`}
>
{data.map((_, index) => (
<Cell key={index} fill={COLORS[index % COLORS.length]} />
))}
</Pie>
<Tooltip formatter={(v: number) => `${v.toLocaleString()} (${((v / total) * 100).toFixed(1)}%)`} />
<Legend />
</PieChart>
</ResponsiveContainer>
</div>
);
}
Chart Dashboard Assembly
// src/app/dashboard/analytics/page.tsx
import { SalesLineChart } from '@/components/charts/SalesLineChart';
import { CategoryBarChart } from '@/components/charts/CategoryBarChart';
import { DistributionPieChart } from '@/components/charts/DistributionPieChart';
export default async function AnalyticsPage() {
const [salesData, categoryData, channelData] = await Promise.all([
fetchSalesData(),
fetchCategoryData(),
fetchChannelData(),
]);
return (
<div className="space-y-6">
<h1 className="text-2xl font-bold dark:text-white">Analytics Dashboard</h1>
<SalesLineChart data={salesData} />
<div className="grid md:grid-cols-2 gap-6">
<CategoryBarChart data={categoryData} />
<DistributionPieChart data={channelData} title="Channel-wise Traffic" />
</div>
</div>
);
}
Related Articles
Data visualization overall के लिए Data Visualization Implementation देखें, dashboard construction के लिए Admin Dashboard Development देखें।
Recharts official documentation (recharts.org) पर API reference check कर सकते हैं।
मुफ़्त PDF: 5 मिनट में Claude Code चीटशीट
बस अपना ईमेल दर्ज करें और हम तुरंत A4 एक-पृष्ठ चीटशीट PDF भेज देंगे।
हम आपकी व्यक्तिगत जानकारी की सुरक्षा करते हैं और स्पैम नहीं भेजते।
लेखक के बारे में
Masa
Claude Code का गहराई से उपयोग करने वाले इंजीनियर। claudecode-lab.com चलाते हैं, जो 10 भाषाओं में 2,000 से अधिक पेजों वाला टेक मीडिया है।
संबंधित लेख
हर दिन बहुभाषी Claude Code लेख प्रकाशित करने से पहले 7 जांचें
एक व्यावहारिक चेकलिस्ट ताकि आप हर दिन बहुभाषी Claude Code लेख प्रकाशित करते समय कोई भाषा न छोड़ें, CTA न तोड़ें और पुराना पेज लाइव न रहने दें।
Codex Automations क्या है? AI से content ops, analysis और deploy करवाने का तरीका
Codex Automations से analytics, article planning, CTA सुधार, deploy और monetization workflow चलाने की practical guide.
Claude Code × GCP Cloud Functions संपूर्ण गाइड | सर्वरलेस फंक्शन तेज़ी से विकसित करें
Claude Code से GCP Cloud Functions को ऑप्टिमाइज़ करें। HTTP/Pub/Sub/Firestore ट्रिगर, लोकल टेस्टिंग और डिप्लॉयमेंट ऑटोमेशन — Masa के व्यावहारिक अनुभव से रियल कोड उदाहरणों के साथ।