Skip to content

Commit af267f4

Browse files
authored
Merge pull request #520 from objectstack-ai/copilot/fix-chart-visibility-issue
2 parents 97da6f9 + c573ad2 commit af267f4

5 files changed

Lines changed: 299 additions & 117 deletions

File tree

examples/crm/objectstack.config.ts

Lines changed: 55 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -281,40 +281,38 @@ export default defineStack({
281281
layout: { x: 0, y: 1, w: 3, h: 2 },
282282
options: {
283283
xField: 'month',
284-
yField: 'revenue'
284+
yField: 'revenue',
285+
data: {
286+
provider: 'value',
287+
items: [
288+
{ month: 'Jan', revenue: 155000 },
289+
{ month: 'Feb', revenue: 87000 },
290+
{ month: 'Mar', revenue: 48000 },
291+
{ month: 'Apr', revenue: 61000 },
292+
{ month: 'May', revenue: 55000 },
293+
{ month: 'Jun', revenue: 67000 },
294+
{ month: 'Jul', revenue: 72000 }
295+
]
296+
}
285297
},
286-
// @ts-ignore
287-
data: {
288-
provider: 'value',
289-
items: [
290-
{ month: 'Jan', revenue: 155000 },
291-
{ month: 'Feb', revenue: 87000 },
292-
{ month: 'Mar', revenue: 48000 },
293-
{ month: 'Apr', revenue: 61000 },
294-
{ month: 'May', revenue: 55000 },
295-
{ month: 'Jun', revenue: 67000 },
296-
{ month: 'Jul', revenue: 72000 }
297-
]
298-
}
299298
},
300299
{
301300
title: 'Lead Source',
302301
type: 'donut',
303302
layout: { x: 3, y: 1, w: 1, h: 2 },
304303
options: {
305304
xField: 'source',
306-
yField: 'value'
305+
yField: 'value',
306+
data: {
307+
provider: 'value',
308+
items: [
309+
{ source: 'Web', value: 2 },
310+
{ source: 'Referral', value: 1 },
311+
{ source: 'Partner', value: 1 },
312+
{ source: 'Existing Business', value: 3 }
313+
]
314+
}
307315
},
308-
// @ts-ignore
309-
data: {
310-
provider: 'value',
311-
items: [
312-
{ source: 'Web', value: 2 },
313-
{ source: 'Referral', value: 1 },
314-
{ source: 'Partner', value: 1 },
315-
{ source: 'Existing Business', value: 3 }
316-
]
317-
}
318316
},
319317

320318
// --- Row 3: More Charts ---
@@ -324,38 +322,36 @@ export default defineStack({
324322
layout: { x: 0, y: 3, w: 2, h: 2 },
325323
options: {
326324
xField: 'stage',
327-
yField: 'amount'
325+
yField: 'amount',
326+
data: {
327+
provider: 'value',
328+
items: [
329+
{ stage: 'Prospecting', amount: 250000 },
330+
{ stage: 'Qualification', amount: 35000 },
331+
{ stage: 'Proposal', amount: 85000 },
332+
{ stage: 'Negotiation', amount: 45000 },
333+
{ stage: 'Closed Won', amount: 225000 }
334+
]
335+
}
328336
},
329-
// @ts-ignore
330-
data: {
331-
provider: 'value',
332-
items: [
333-
{ stage: 'Prospecting', amount: 250000 },
334-
{ stage: 'Qualification', amount: 35000 },
335-
{ stage: 'Proposal', amount: 85000 },
336-
{ stage: 'Negotiation', amount: 45000 },
337-
{ stage: 'Closed Won', amount: 225000 }
338-
]
339-
}
340337
},
341338
{
342339
title: 'Top Products',
343340
type: 'bar',
344341
layout: { x: 2, y: 3, w: 2, h: 2 },
345342
options: {
346343
xField: 'name',
347-
yField: 'sales'
344+
yField: 'sales',
345+
data: {
346+
provider: 'value',
347+
items: [
348+
{ name: 'Workstation Pro Laptop', sales: 45000 },
349+
{ name: 'Implementation Service', sales: 32000 },
350+
{ name: 'Premium Support', sales: 21000 },
351+
{ name: 'Executive Mesh Chair', sales: 15000 }
352+
]
353+
}
348354
},
349-
// @ts-ignore
350-
data: {
351-
provider: 'value',
352-
items: [
353-
{ name: 'Workstation Pro Laptop', sales: 45000 },
354-
{ name: 'Implementation Service', sales: 32000 },
355-
{ name: 'Premimum Support', sales: 21000 },
356-
{ name: 'Executive Mesh Chair', sales: 15000 }
357-
]
358-
}
359355
},
360356

361357
// --- Row 4: Table ---
@@ -369,19 +365,18 @@ export default defineStack({
369365
{ header: 'Amount', accessorKey: 'amount' },
370366
{ header: 'Stage', accessorKey: 'stage' },
371367
{ header: 'Close Date', accessorKey: 'date' }
372-
]
368+
],
369+
data: {
370+
provider: 'value',
371+
items: [
372+
{ name: 'Berlin Automation Project', amount: '$250,000', stage: 'Prospecting', date: '2024-09-01' },
373+
{ name: 'ObjectStack Enterprise License', amount: '$150,000', stage: 'Closed Won', date: '2024-01-15' },
374+
{ name: 'London Annual Renewal', amount: '$85,000', stage: 'Proposal', date: '2024-05-15' },
375+
{ name: 'SF Tower Expansion', amount: '$75,000', stage: 'Closed Won', date: '2024-02-28' },
376+
{ name: 'Global Fin Q1 Upsell', amount: '$45,000', stage: 'Negotiation', date: '2024-03-30' }
377+
]
378+
}
373379
},
374-
// @ts-ignore
375-
data: {
376-
provider: 'value',
377-
items: [
378-
{ name: 'Berlin Automation Project', amount: '$250,000', stage: 'Prospecting', date: '2024-09-01' },
379-
{ name: 'ObjectStack Enterprise License', amount: '$150,000', stage: 'Closed Won', date: '2024-01-15' },
380-
{ name: 'London Annual Renewal', amount: '$85,000', stage: 'Proposal', date: '2024-05-15' },
381-
{ name: 'SF Tower Expansion', amount: '$75,000', stage: 'Closed Won', date: '2024-02-28' },
382-
{ name: 'Global Fin Q1 Upsell', amount: '$45,000', stage: 'Negotiation', date: '2024-03-30' }
383-
]
384-
}
385380
}
386381
]
387382
}

examples/kitchen-sink/objectstack.config.ts

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,14 @@ export default defineStack({
120120
options: {
121121
xField: 'category',
122122
yField: 'count',
123-
},
124-
// @ts-ignore
125-
data: {
126-
provider: 'value',
127-
items: [
128-
{ category: 'Option A', count: 2 },
129-
{ category: 'Option B', count: 2 },
130-
{ category: 'Option C', count: 1 },
131-
],
123+
data: {
124+
provider: 'value',
125+
items: [
126+
{ category: 'Option A', count: 2 },
127+
{ category: 'Option B', count: 2 },
128+
{ category: 'Option C', count: 1 },
129+
],
130+
},
132131
},
133132
},
134133
{
@@ -138,17 +137,16 @@ export default defineStack({
138137
options: {
139138
xField: 'name',
140139
yField: 'amount',
141-
},
142-
// @ts-ignore
143-
data: {
144-
provider: 'value',
145-
items: [
146-
{ name: 'Alpha', amount: 1500 },
147-
{ name: 'Beta', amount: 3200 },
148-
{ name: 'Gamma', amount: 800 },
149-
{ name: 'Delta', amount: 5000 },
150-
{ name: 'Epsilon', amount: 12000 },
151-
],
140+
data: {
141+
provider: 'value',
142+
items: [
143+
{ name: 'Alpha', amount: 1500 },
144+
{ name: 'Beta', amount: 3200 },
145+
{ name: 'Gamma', amount: 800 },
146+
{ name: 'Delta', amount: 5000 },
147+
{ name: 'Epsilon', amount: 12000 },
148+
],
149+
},
152150
},
153151
},
154152

@@ -160,18 +158,17 @@ export default defineStack({
160158
options: {
161159
xField: 'month',
162160
yField: 'value',
163-
},
164-
// @ts-ignore
165-
data: {
166-
provider: 'value',
167-
items: [
168-
{ month: 'Jan', value: 3200 },
169-
{ month: 'Feb', value: 4500 },
170-
{ month: 'Mar', value: 4100 },
171-
{ month: 'Apr', value: 5800 },
172-
{ month: 'May', value: 6200 },
173-
{ month: 'Jun', value: 7500 },
174-
],
161+
data: {
162+
provider: 'value',
163+
items: [
164+
{ month: 'Jan', value: 3200 },
165+
{ month: 'Feb', value: 4500 },
166+
{ month: 'Mar', value: 4100 },
167+
{ month: 'Apr', value: 5800 },
168+
{ month: 'May', value: 6200 },
169+
{ month: 'Jun', value: 7500 },
170+
],
171+
},
175172
},
176173
},
177174
],

examples/todo/objectstack.config.ts

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,16 @@ export default defineStack({
156156
options: {
157157
xField: 'status',
158158
yField: 'count',
159-
},
160-
// @ts-ignore
161-
data: {
162-
provider: 'value',
163-
items: [
164-
{ status: 'Backlog', count: 2 },
165-
{ status: 'Todo', count: 2 },
166-
{ status: 'In Progress', count: 4 },
167-
{ status: 'Review', count: 1 },
168-
{ status: 'Done', count: 3 },
169-
],
159+
data: {
160+
provider: 'value',
161+
items: [
162+
{ status: 'Backlog', count: 2 },
163+
{ status: 'Todo', count: 2 },
164+
{ status: 'In Progress', count: 4 },
165+
{ status: 'Review', count: 1 },
166+
{ status: 'Done', count: 3 },
167+
],
168+
},
170169
},
171170
},
172171
{
@@ -176,17 +175,16 @@ export default defineStack({
176175
options: {
177176
xField: 'category',
178177
yField: 'count',
179-
},
180-
// @ts-ignore
181-
data: {
182-
provider: 'value',
183-
items: [
184-
{ category: 'Feature', count: 4 },
185-
{ category: 'Bug', count: 3 },
186-
{ category: 'Documentation', count: 2 },
187-
{ category: 'Design', count: 1 },
188-
{ category: 'Chore', count: 2 },
189-
],
178+
data: {
179+
provider: 'value',
180+
items: [
181+
{ category: 'Feature', count: 4 },
182+
{ category: 'Bug', count: 3 },
183+
{ category: 'Documentation', count: 2 },
184+
{ category: 'Design', count: 1 },
185+
{ category: 'Chore', count: 2 },
186+
],
187+
},
190188
},
191189
},
192190
],

packages/plugin-dashboard/src/DashboardRenderer.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ export const DashboardRenderer = forwardRef<HTMLDivElement, DashboardRendererPro
6868
// Handle Shorthand Registry Mappings
6969
const widgetType = (widget as any).type;
7070
if (widgetType === 'bar' || widgetType === 'line' || widgetType === 'area' || widgetType === 'pie' || widgetType === 'donut') {
71-
const dataItems = Array.isArray((widget as any).data) ? (widget as any).data : (widget as any).data?.items || [];
7271
const options = (widget as any).options || {};
72+
// Support data at widget level or nested inside options
73+
const widgetData = (widget as any).data || options.data;
74+
const dataItems = Array.isArray(widgetData) ? widgetData : widgetData?.items || [];
7375
const xAxisKey = options.xField || 'name';
7476
const yField = options.yField || 'value';
7577

@@ -85,10 +87,13 @@ export const DashboardRenderer = forwardRef<HTMLDivElement, DashboardRendererPro
8587
}
8688

8789
if (widgetType === 'table') {
90+
const options = (widget as any).options || {};
91+
// Support data at widget level or nested inside options
92+
const widgetData = (widget as any).data || options.data;
8893
return {
8994
type: 'data-table',
90-
...(widget as any).options,
91-
data: (widget as any).data?.items || [],
95+
...options,
96+
data: widgetData?.items || [],
9297
searchable: false,
9398
pagination: false,
9499
className: "border-0"

0 commit comments

Comments
 (0)