import React from 'react' import * as z from "zod"; import { IconSchema } from '../defaultSchemes'; import { RemoteSvgIcon } from '@/app/hooks/useRemoteSvgIcon'; import { BarChart, Bar, LineChart, Line, PieChart, Pie, AreaChart, Area, ScatterChart, Scatter, XAxis, YAxis, CartesianGrid, Cell, ResponsiveContainer, Tooltip, Legend } 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(20) }) 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: 'bar', data: [ { name: 'Q1', value: 5 }, { name: 'Q1', value: 5 }, { name: 'Q1', value: 5 }, ] } ), 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://presenton-public.s3.ap-southeast-1.amazonaws.com/static/icons/bold/chart-line-up-bold.svg', __icon_query__: 'target market scope' } }, { title: 'Serviceable Available Market', description: 'Indicates more measurable market segments for sales efforts.', icon: { __icon_url__: 'https://presenton-public.s3.ap-southeast-1.amazonaws.com/static/icons/bold/chart-line-up-bold.svg', __icon_query__: 'pie chart analysis' } }, { title: 'Serviceable Obtainable Market', description: 'Help companies plan development strategies according to the market.', icon: { __icon_url__: 'https://presenton-public.s3.ap-southeast-1.amazonaws.com/static/icons/bold/chart-line-up-bold.svg', __icon_query__: 'trending up growth' } } ]).meta({ description: "List of bullet points with colored boxes and icons", }) }) export const Schema = chartWithBulletsSlideSchema export type ChartWithBulletsSlideData = z.infer interface ChartWithBulletsSlideLayoutProps { data?: Partial } const CustomTooltip = ({ active, payload, label }: any) => { if (active && payload && payload.length) { return (

{label}

{payload.map((entry: any, index: number) => (

{entry.name}: {entry.value?.toLocaleString()}

))}
); } return null; }; const CHART_COLORS = [ '#3b82f6', '#ef4444', '#10b981', '#f59e0b', '#8b5cf6', '#06b6d4', '#84cc16', '#f97316', '#ec4899', '#6366f1' ]; const ChartWithBulletsSlideLayout: React.FC = ({ data: slideData }) => { const chartData = slideData?.chartData?.data || []; const chartType = slideData?.chartData?.type; const color = 'var(--background-text, #9333ea)'; 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 renderPieLabel = (props: any) => { const { name, percent, x, y, textAnchor } = props; return ( {`${name} ${(percent * 100).toFixed(0)}%`} ); }; const commonProps = { data: chartData, margin: { top: 20, right: 30, left: 0, bottom: 0 }, }; const axisProps = { tick: { fill: 'var(--background-text, #7f8491)', fontSize: 12, fontWeight: 600 }, axisLine: { stroke: 'var(--background-text, #7f8491)' }, tickLine: { stroke: 'var(--background-text, #7f8491)' }, }; switch (chartType) { case 'bar': return ( {showTooltip && } />} {showLegend && } {chartData.map((_, index) => ( ))} ); case 'line': return ( {showTooltip && } />} {showLegend && } {chartData.map((_, index) => ( ))} ); case 'area': return ( {showTooltip && } />} {showLegend && } {chartData.map((_, index) => ( ))} ); case 'pie': return ( {showTooltip && } />} {showLegend && } {chartData.map((_, index) => ( ))} ); case 'scatter': return ( {showTooltip && } />} {showLegend && } {chartData.map((_, index) => ( ))} ); default: return
Unsupported chart type
; } }; return ( <>
{((slideData as any)?.__companyName__ || (slideData as any)?._logo_url__) && (
{(slideData as any)?._logo_url__ && logo} {(slideData as any)?.__companyName__ && {(slideData as any)?.__companyName__ || 'Company Name'} }
)} {/* 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.title}

{/* Description */}

{bullet.description}

))}
) } export default ChartWithBulletsSlideLayout