Skip to content

Commit 987393d

Browse files
committed
feat(ReportBuilder): add chart configuration options for report sections
1 parent 0d9f655 commit 987393d

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

packages/plugin-report/src/ReportBuilder.tsx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,68 @@ export const ReportBuilder: React.FC<ReportBuilderProps> = ({ schema }) => {
520520
/>
521521
</div>
522522
)}
523+
{section.type === 'chart' && (
524+
<div className="col-span-2 grid grid-cols-2 gap-2 mt-2 p-2 bg-muted/20 rounded">
525+
<div className="col-span-2">
526+
<Label className="text-xs font-semibold">Chart Configuration</Label>
527+
</div>
528+
<div>
529+
<Label className="text-xs">Chart Type</Label>
530+
<select
531+
className="flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
532+
value={section.chart?.chartType || 'bar'}
533+
onChange={(e) => handleSectionChange(index, {
534+
...section,
535+
chart: { ...section.chart, type: 'chart', chartType: e.target.value } as any
536+
})}
537+
>
538+
<option value="bar">Bar</option>
539+
<option value="line">Line</option>
540+
<option value="area">Area</option>
541+
<option value="pie">Pie</option>
542+
</select>
543+
</div>
544+
<div>
545+
<Label className="text-xs">X-Axis Field</Label>
546+
<select
547+
className="flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
548+
value={section.chart?.xAxisField || ''}
549+
onChange={(e) => handleSectionChange(index, {
550+
...section,
551+
chart: { ...section.chart, type: 'chart', xAxisField: e.target.value } as any
552+
})}
553+
>
554+
<option value="">Select Field...</option>
555+
{availableFields.map(f => (
556+
<option key={f.name} value={f.name}>{f.label || f.name}</option>
557+
))}
558+
{/* Use mock fields if no available fields provided */}
559+
{availableFields.length === 0 && (
560+
<>
561+
<option value="name">Name</option>
562+
<option value="month">Month</option>
563+
</>
564+
)}
565+
</select>
566+
</div>
567+
<div className="col-span-2">
568+
<Label className="text-xs">Y-Axis Fields (comma separated)</Label>
569+
<Input
570+
className="h-8 text-sm"
571+
placeholder="e.g. value, count"
572+
value={section.chart?.yAxisFields?.join(', ') || ''}
573+
onChange={(e) => handleSectionChange(index, {
574+
...section,
575+
chart: {
576+
...section.chart,
577+
type: 'chart',
578+
yAxisFields: e.target.value.split(',').map(s => s.trim()).filter(Boolean)
579+
} as any
580+
})}
581+
/>
582+
</div>
583+
</div>
584+
)}
523585
</div>
524586
</div>
525587
))}

0 commit comments

Comments
 (0)