@@ -36,7 +36,8 @@ npm install @object-ui/plugin-charts
3636
3737<InteractiveDemo
3838 schema = { {
39- type: " line-chart" ,
39+ type: " chart" ,
40+ chartType: " line" ,
4041 data: [
4142 { month: " Jan" , revenue: 4000 , expenses: 2400 },
4243 { month: " Feb" , revenue: 3000 , expenses: 1398 },
@@ -45,31 +46,42 @@ npm install @object-ui/plugin-charts
4546 { month: " May" , revenue: 5000 , expenses: 4800 },
4647 { month: " Jun" , revenue: 7000 , expenses: 3800 }
4748 ],
48- lines: [
49- { dataKey: " revenue" , stroke: " #8884d8" , name: " Revenue" },
50- { dataKey: " expenses" , stroke: " #82ca9d" , name: " Expenses" }
51- ],
5249 xAxisKey: " month" ,
53- height: 300
50+ series: [
51+ { dataKey: " revenue" },
52+ { dataKey: " expenses" }
53+ ],
54+ config: {
55+ revenue: { label: " Revenue" , color: " #8884d8" },
56+ expenses: { label: " Expenses" , color: " #82ca9d" }
57+ }
5458 }}
5559 title = " Multi-Line Chart"
5660 description = " Compare multiple metrics over time"
5761/>
5862
5963<InteractiveDemo
6064 schema = { {
61- type: " pie-chart" ,
65+ type: " chart" ,
66+ chartType: " area" ,
6267 data: [
63- { name: " Desktop" , value: 45 , fill: " #8884d8" },
64- { name: " Mobile" , value: 35 , fill: " #82ca9d" },
65- { name: " Tablet" , value: 20 , fill: " #ffc658" }
68+ { month: " Jan" , users: 1200 },
69+ { month: " Feb" , users: 1450 },
70+ { month: " Mar" , users: 1680 },
71+ { month: " Apr" , users: 1920 },
72+ { month: " May" , users: 2100 },
73+ { month: " Jun" , users: 2350 }
6674 ],
67- dataKey: " value" ,
68- nameKey: " name" ,
69- height: 300
75+ xAxisKey: " month" ,
76+ series: [
77+ { dataKey: " users" }
78+ ],
79+ config: {
80+ users: { label: " Users" , color: " #8884d8" }
81+ }
7082 }}
71- title = " Pie Chart"
72- description = " Show proportional data distribution "
83+ title = " Area Chart"
84+ description = " Show data trends with filled areas "
7385/>
7486
7587## Usage
@@ -96,7 +108,7 @@ const schema = {
96108
97109## Features
98110
99- - ** Bar, line, area, and pie charts**
111+ - ** Bar, line, and area charts**
100112- ** Responsive design**
101113- ** Customizable colors and styles**
102114- ** Lazy-loaded** (~ 540 KB loads only when rendered)
@@ -149,46 +161,41 @@ const schema = {
149161
150162``` tsx
151163const schema = {
152- type: ' chart-line' ,
164+ type: ' chart' ,
165+ chartType: ' line' ,
153166 data: [
154167 { date: ' 2024-01' , users: 120 },
155168 { date: ' 2024-02' , users: 180 },
156169 { date: ' 2024-03' , users: 250 }
157170 ],
158- dataKey: ' users' ,
159171 xAxisKey: ' date' ,
160- height: 350
172+ series: [
173+ { dataKey: ' users' }
174+ ],
175+ config: {
176+ users: { label: ' Users' , color: ' #8884d8' }
177+ }
161178}
162179```
163180
164181### Area Chart
165182
166183``` tsx
167184const schema = {
168- type: ' chart-area' ,
185+ type: ' chart' ,
186+ chartType: ' area' ,
169187 data: [
170188 { time: ' 9:00' , value: 20 },
171189 { time: ' 10:00' , value: 35 },
172190 { time: ' 11:00' , value: 45 }
173191 ],
174- dataKey: ' value' ,
175192 xAxisKey: ' time' ,
176- color: ' #10b981'
177- }
178- ```
179-
180- ### Pie Chart
181-
182- ``` tsx
183- const schema = {
184- type: ' chart-pie' ,
185- data: [
186- { name: ' Desktop' , value: 400 },
187- { name: ' Mobile' , value: 300 },
188- { name: ' Tablet' , value: 200 }
193+ series: [
194+ { dataKey: ' value' }
189195 ],
190- dataKey: ' value' ,
191- nameKey: ' name'
196+ config: {
197+ value: { label: ' Value' , color: ' #10b981' }
198+ }
192199}
193200```
194201
@@ -217,16 +224,23 @@ const revenueChart = {
217224
218225``` tsx
219226const growthChart = {
220- type: ' chart-line' ,
227+ type: ' chart' ,
228+ chartType: ' line' ,
221229 data: [
222230 { month: ' Jan' , users: 1200 , active: 980 },
223231 { month: ' Feb' , users: 1450 , active: 1150 },
224232 { month: ' Mar' , users: 1680 , active: 1380 },
225233 { month: ' Apr' , users: 1920 , active: 1620 }
226234 ],
227- dataKey: ' users' ,
228235 xAxisKey: ' month' ,
229- height: 350
236+ series: [
237+ { dataKey: ' users' },
238+ { dataKey: ' active' }
239+ ],
240+ config: {
241+ users: { label: ' Total Users' , color: ' #8884d8' },
242+ active: { label: ' Active Users' , color: ' #82ca9d' }
243+ }
230244}
231245```
232246
@@ -257,9 +271,14 @@ const schema = {
257271
258272``` tsx
259273const schema = {
260- type: ' chart-line' ,
274+ type: ' chart' ,
275+ chartType: ' line' ,
261276 data: metricsData ,
262- height: 500 ,
277+ xAxisKey: ' date' ,
278+ series: [{ dataKey: ' value' }],
279+ config: {
280+ value: { label: ' Metrics' , color: ' #8884d8' }
281+ },
263282 className: ' h-64 sm:h-96 lg:h-[500px]'
264283}
265284```
0 commit comments