import React from 'react' import * as z from "zod"; import { IconSchema } from '@/presentation-layouts/defaultSchemes'; import { ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent } from "@/components/ui/chart"; import { BarChart, Bar, LineChart, Line, PieChart, Pie, AreaChart, Area, ScatterChart, Scatter, XAxis, YAxis, CartesianGrid, Cell, ResponsiveContainer } from "recharts"; export const layoutId = 'chart-with-bullets-slide' export const layoutName = 'Chart with Bullet Boxes' export const layoutDescription = 'A slide layout with title, description, chart on the left and colored bullet boxes with icons on the right. Only choose this if data is available.' const barPieLineAreaChartDataSchema = z.object({ type: z.union([z.literal('bar'), z.literal('pie'), z.literal('line'), z.literal('area')]), data: z.array(z.object({ name: z.string().meta({ description: "Data point name" }), value: z.number().meta({ description: "Data point value" }), })).min(2).max(5) }) const scatterChartDataSchema = z.object({ type: z.literal('scatter'), data: z.array(z.object({ x: z.number().meta({ description: "X coordinate" }), y: z.number().meta({ description: "Y coordinate" }), })).min(2).max(100) }) const chartWithBulletsSlideSchema = z.object({ title: z.string().min(3).max(40).default('Market Size').meta({ description: "Main title of the slide", }), description: z.string().min(10).max(150).default('Businesses face challenges with outdated technology and rising costs, limiting efficiency and growth in competitive markets.').meta({ description: "Description text below the title", }), chartData: z.union([barPieLineAreaChartDataSchema, scatterChartDataSchema]).default({ type: 'scatter', data: [ { x: 5, y: 5 }, { x: 10, y: 12 }, { x: 15, y: 18 }, { x: 20, y: 23 }, { x: 25, y: 26 }, ] } ), color: z.string().default('#3b82f6').meta({ description: "Primary color for chart elements", }), showLegend: z.boolean().default(false).meta({ description: "Whether to show chart legend", }), showTooltip: z.boolean().default(true).meta({ description: "Whether to show chart tooltip", }), bulletPoints: z.array(z.object({ title: z.string().min(2).max(80).meta({ description: "Bullet point title", }), description: z.string().min(10).max(150).meta({ description: "Bullet point description", }), icon: IconSchema, })).min(1).max(3).default([ { title: 'Total Addressable Market', description: 'Companies can use TAM to plan future expansion and investment.', icon: { __icon_url__: 'https://cdn.jsdelivr.net/npm/lucide@latest/dist/esm/icons/target.js', __icon_query__: 'target market scope' } }, { title: 'Serviceable Available Market', description: 'Indicates more measurable market segments for sales efforts.', icon: { __icon_url__: 'https://cdn.jsdelivr.net/npm/lucide@latest/dist/esm/icons/pie-chart.js', __icon_query__: 'pie chart analysis' } }, { title: 'Serviceable Obtainable Market', description: 'Help companies plan development strategies according to the market.', icon: { __icon_url__: 'https://cdn.jsdelivr.net/npm/lucide@latest/dist/esm/icons/trending-up.js', __icon_query__: 'trending up growth' } } ]).meta({ description: "List of bullet points with colored boxes and icons", }) }) export const Schema = chartWithBulletsSlideSchema console.log(z.toJSONSchema(chartWithBulletsSlideSchema)) export type ChartWithBulletsSlideData = z.infer interface ChartWithBulletsSlideLayoutProps { data?: Partial } const chartConfig = { value: { label: "Value", }, name: { label: "Name", }, }; const CHART_COLORS = [ '#3b82f6', '#ef4444', '#10b981', '#f59e0b', '#8b5cf6', '#06b6d4', '#84cc16', '#f97316', '#ec4899', '#6366f1' ]; const BULLET_COLORS = [ '#7F31E9', '#2C78DA', '#F58AAB', '#10b981', '#f59e0b', '#06b6d4', '#84cc16', '#f97316', '#ec4899', '#6366f1' ]; const ChartWithBulletsSlideLayout: React.FC = ({ data: slideData }) => { const chartData = slideData?.chartData?.data || []; const chartType = slideData?.chartData?.type; const color = slideData?.color || '#3b82f6'; const xAxis = chartType === 'scatter' ? 'x' : 'name'; const yAxis = chartType === 'scatter' ? 'y' : 'value'; const showLegend = slideData?.showLegend || false; const showTooltip = slideData?.showTooltip || true; const bulletPoints = slideData?.bulletPoints || [] const renderChart = () => { const commonProps = { data: chartData, margin: { top: 20, right: 30, left: 40, bottom: 60 }, }; switch (chartType) { case 'bar': return ( {showTooltip && } />} {showLegend && } />} ); case 'line': return ( {showTooltip && } />} {showLegend && } />} ); case 'area': return ( {showTooltip && } />} {showLegend && } />} ); case 'pie': return ( {showTooltip && } />} {showLegend && } />} `${name} ${(percent * 100).toFixed(0)}%`} > {chartData.map((entry, index) => ( ))} ); case 'scatter': return ( {showTooltip && } />} {showLegend && } />} ); default: return
Unsupported chart type
; } }; return ( <> {/* Import Google Fonts */}
{/* Main Content */}
{/* Left Section - Title, Description, Chart */}
{/* Title */}

{slideData?.title || 'Market Size'}

{/* Description */}

{slideData?.description || 'Businesses face challenges with outdated technology and rising costs, limiting efficiency and growth in competitive markets.'}

{/* Chart Container */}
{renderChart()}
{/* Right Section - Bullet Point Boxes */}
{bulletPoints.map((bullet, index) => (
{/* Icon and Title */}
{bullet.icon.__icon_query__}

{bullet.title}

{/* Description */}

{bullet.description}

))}
) } export default ChartWithBulletsSlideLayout