@iflow-mcp/kamranbiglari-mcp-server-chart 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +264 -0
- package/biome.json +49 -0
- package/dist/charts/bar.js +43 -0
- package/dist/charts/bubble.js +71 -0
- package/dist/charts/doughnut.js +104 -0
- package/dist/charts/gauge.js +84 -0
- package/dist/charts/index.js +15 -0
- package/dist/charts/line.js +74 -0
- package/dist/charts/ohlc.js +455 -0
- package/dist/charts/pie.js +50 -0
- package/dist/charts/polarArea.js +50 -0
- package/dist/charts/progressBar.js +50 -0
- package/dist/charts/radar.js +59 -0
- package/dist/charts/radialGauge.js +43 -0
- package/dist/charts/sankey.js +64 -0
- package/dist/charts/scatter.js +70 -0
- package/dist/charts/sparkline.js +43 -0
- package/dist/charts/violin.js +67 -0
- package/dist/index.js +236 -0
- package/dist/stdio-server.js +58 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/schema.js +9 -0
- package/image.png +0 -0
- package/language.json +1 -0
- package/package.json +1 -0
- package/package_name +1 -0
- package/push_info.json +5 -0
- package/screenshot/image.png +0 -0
- package/src/charts/bar.ts +48 -0
- package/src/charts/bubble.ts +78 -0
- package/src/charts/doughnut.ts +117 -0
- package/src/charts/gauge.ts +92 -0
- package/src/charts/index.ts +15 -0
- package/src/charts/line.ts +80 -0
- package/src/charts/ohlc.ts +474 -0
- package/src/charts/pie.ts +56 -0
- package/src/charts/polarArea.ts +56 -0
- package/src/charts/progressBar.ts +56 -0
- package/src/charts/radar.ts +65 -0
- package/src/charts/radialGauge.ts +49 -0
- package/src/charts/sankey.ts +71 -0
- package/src/charts/scatter.ts +77 -0
- package/src/charts/sparkline.ts +49 -0
- package/src/charts/violin.ts +73 -0
- package/src/index.ts +279 -0
- package/src/stdio-server.ts +77 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/schema.ts +10 -0
- package/tsconfig.json +1 -0
- package/worker-configuration.d.ts +5709 -0
- package/wrangler.jsonc +28 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { zodToJsonSchema } from "../utils/index.js";
|
|
3
|
+
// Define the schema for the line chart
|
|
4
|
+
// {
|
|
5
|
+
// type: 'line',
|
|
6
|
+
// data: {
|
|
7
|
+
// labels: ['January', 'February', 'March', 'April', 'May'],
|
|
8
|
+
// datasets: [
|
|
9
|
+
// {
|
|
10
|
+
// label: 'Dogs',
|
|
11
|
+
// data: [50, 60, 70, 180, 190],
|
|
12
|
+
// fill: false,
|
|
13
|
+
// borderColor: 'blue',
|
|
14
|
+
// },
|
|
15
|
+
// {
|
|
16
|
+
// label: 'Cats',
|
|
17
|
+
// data: [100, 200, 300, 400, 500],
|
|
18
|
+
// fill: false,
|
|
19
|
+
// borderColor: 'green',
|
|
20
|
+
// },
|
|
21
|
+
// ],
|
|
22
|
+
// },
|
|
23
|
+
// }
|
|
24
|
+
const schema = {
|
|
25
|
+
type: z.literal("line").default("line"),
|
|
26
|
+
data: z.object({
|
|
27
|
+
labels: z.array(z.string()).describe("Labels for the x-axis"),
|
|
28
|
+
datasets: z.array(z.object({
|
|
29
|
+
label: z.string().describe("Label for the dataset"),
|
|
30
|
+
data: z.array(z.number()).describe("Data points for the dataset"),
|
|
31
|
+
fill: z.boolean().optional().describe("Whether to fill the area under the line"),
|
|
32
|
+
borderColor: z.string().optional().describe("Color of the line border"),
|
|
33
|
+
backgroundColor: z.string().optional().describe("Background color of the line"),
|
|
34
|
+
borderWidth: z.number().optional().describe("Width of the line border"),
|
|
35
|
+
pointRadius: z.number().optional().describe("Radius of the data points"),
|
|
36
|
+
pointBackgroundColor: z.string().optional().describe("Background color of the data points"),
|
|
37
|
+
pointBorderColor: z.string().optional().describe("Border color of the data points"),
|
|
38
|
+
tension: z.number().optional().describe("Bezier curve tension of the line"),
|
|
39
|
+
})),
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
const tool = {
|
|
43
|
+
name: "line",
|
|
44
|
+
description: `Generates a line chart with the provided data.
|
|
45
|
+
example input:
|
|
46
|
+
\`\`\`json
|
|
47
|
+
{
|
|
48
|
+
"type": "line",
|
|
49
|
+
"data": {
|
|
50
|
+
"labels": ["January", "February", "March", "April", "May"],
|
|
51
|
+
"datasets": [
|
|
52
|
+
{
|
|
53
|
+
"label": "Dogs",
|
|
54
|
+
"data": [50, 60, 70, 180, 190],
|
|
55
|
+
"fill": false,
|
|
56
|
+
"borderColor": "blue"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"label": "Cats",
|
|
60
|
+
"data": [100, 200, 300, 400, 500],
|
|
61
|
+
"fill": false,
|
|
62
|
+
"borderColor": "green"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
\`\`\`
|
|
68
|
+
`,
|
|
69
|
+
inputSchema: zodToJsonSchema(schema),
|
|
70
|
+
};
|
|
71
|
+
export const line = {
|
|
72
|
+
schema,
|
|
73
|
+
tool,
|
|
74
|
+
};
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { zodToJsonSchema } from "../utils/index.js";
|
|
3
|
+
// Define the schema for the bar chart
|
|
4
|
+
// {
|
|
5
|
+
// type: 'ohlc',
|
|
6
|
+
// data: {
|
|
7
|
+
// datasets: [
|
|
8
|
+
// {
|
|
9
|
+
// label: 'MSFT',
|
|
10
|
+
// yAxisID: 'y1',
|
|
11
|
+
// data: [
|
|
12
|
+
// ['2016-04-01', 18.23, 19.36, 18.18, 19.31],
|
|
13
|
+
// ['2016-04-02', 19.50, 19.89, 19.00, 19.29],
|
|
14
|
+
// ['2016-04-03', 19.13, 19.15, 18.43, 18.75],
|
|
15
|
+
// ['2016-04-06', 18.54, 18.76, 18.27, 18.76],
|
|
16
|
+
// ['2016-04-07', 18.76, 19.14, 18.63, 18.76],
|
|
17
|
+
// ['2016-04-08', 18.97, 19.62, 18.96, 19.19],
|
|
18
|
+
// ['2016-04-09', 19.45, 19.70, 19.22, 19.67],
|
|
19
|
+
// ['2016-04-13', 19.69, 19.85, 19.37, 19.59],
|
|
20
|
+
// ['2016-04-14', 19.44, 19.55, 19.00, 19.35],
|
|
21
|
+
// ['2016-04-15', 19.21, 19.25, 18.51, 18.83],
|
|
22
|
+
// ['2016-04-16', 19.16, 19.78, 18.99, 19.76],
|
|
23
|
+
// ['2016-04-17', 19.69, 19.69, 19.00, 19.20],
|
|
24
|
+
// ['2016-04-20', 18.89, 18.95, 18.57, 18.61],
|
|
25
|
+
// ['2016-04-21', 18.59, 19.08, 18.57, 18.97],
|
|
26
|
+
// ['2016-04-22', 18.76, 19.19, 18.70, 18.78],
|
|
27
|
+
// ['2016-04-23', 18.92, 18.94, 18.47, 18.92],
|
|
28
|
+
// ['2016-04-24', 19.82, 21.20, 19.50, 20.91],
|
|
29
|
+
// ['2016-04-27', 20.55, 20.82, 20.28, 20.40],
|
|
30
|
+
// ['2016-04-28', 20.25, 20.27, 19.79, 19.93],
|
|
31
|
+
// ['2016-04-29', 20.11, 20.89, 20.06, 20.25],
|
|
32
|
+
// ['2016-04-30', 20.60, 21.10, 20.01, 20.26],
|
|
33
|
+
// ['2016-05-01', 20.19, 20.35, 19.86, 20.24],
|
|
34
|
+
// ['2016-05-04', 20.37, 20.40, 19.98, 20.19],
|
|
35
|
+
// ['2016-05-05', 20.14, 20.24, 19.64, 19.79],
|
|
36
|
+
// ['2016-05-06', 20.06, 20.07, 19.61, 19.79],
|
|
37
|
+
// ['2016-05-07', 19.96, 19.99, 19.14, 19.32],
|
|
38
|
+
// ['2016-05-08', 19.46, 19.64, 19.14, 19.42],
|
|
39
|
+
// ['2016-05-11', 19.20, 19.73, 19.01, 19.32],
|
|
40
|
+
// ['2016-05-12', 19.51, 20.06, 19.47, 19.89],
|
|
41
|
+
// ['2016-05-13', 19.92, 20.00, 19.67, 19.75],
|
|
42
|
+
// ['2016-05-14', 19.83, 20.23, 19.80, 20.06],
|
|
43
|
+
// ['2016-05-15', 20.13, 20.50, 19.98, 20.22],
|
|
44
|
+
// ['2016-05-18', 20.36, 20.60, 20.24, 20.60],
|
|
45
|
+
// ['2016-05-19', 20.51, 20.74, 20.25, 20.31],
|
|
46
|
+
// ['2016-05-20', 20.41, 20.69, 20.22, 20.38],
|
|
47
|
+
// ['2016-05-21', 20.14, 20.23, 19.51, 19.82],
|
|
48
|
+
// ['2016-05-22', 19.93, 20.17, 19.47, 19.75],
|
|
49
|
+
// ['2016-05-26', 19.54, 20.45, 19.45, 20.34],
|
|
50
|
+
// ['2016-05-27', 20.25, 20.60, 20.07, 20.13],
|
|
51
|
+
// ['2016-05-28', 20.32, 20.63, 20.05, 20.45],
|
|
52
|
+
// ['2016-05-29', 20.56, 20.94, 20.30, 20.89],
|
|
53
|
+
// ['2016-06-01', 21.00, 21.50, 20.86, 21.40],
|
|
54
|
+
// ['2016-06-02', 21.36, 21.98, 21.20, 21.40],
|
|
55
|
+
// ['2016-06-03', 21.31, 21.76, 21.29, 21.73],
|
|
56
|
+
// ['2016-06-04', 21.77, 21.90, 21.58, 21.83],
|
|
57
|
+
// ['2016-06-05', 21.96, 22.31, 21.81, 22.14],
|
|
58
|
+
// ['2016-06-08', 21.98, 22.32, 21.63, 22.05],
|
|
59
|
+
// ['2016-06-09', 22.06, 22.32, 21.88, 22.08],
|
|
60
|
+
// ['2016-06-10', 22.17, 22.62, 22.12, 22.55],
|
|
61
|
+
// ['2016-06-11', 22.59, 23.26, 22.57, 22.83],
|
|
62
|
+
// ['2016-06-12', 22.90, 23.38, 22.74, 23.33],
|
|
63
|
+
// ['2016-06-15', 23.23, 23.54, 23.02, 23.42],
|
|
64
|
+
// ['2016-06-16', 23.47, 24.11, 23.44, 23.45],
|
|
65
|
+
// ['2016-06-17', 23.50, 23.82, 23.17, 23.68],
|
|
66
|
+
// ['2016-06-18', 23.62, 23.69, 23.30, 23.50],
|
|
67
|
+
// ['2016-06-19', 24.04, 24.34, 23.75, 24.07],
|
|
68
|
+
// ['2016-06-22', 23.95, 23.95, 23.25, 23.28],
|
|
69
|
+
// ['2016-06-23', 23.38, 23.66, 23.21, 23.34],
|
|
70
|
+
// ['2016-06-24', 23.45, 23.75, 23.36, 23.47],
|
|
71
|
+
// ['2016-06-25', 23.43, 23.92, 23.20, 23.79],
|
|
72
|
+
// ['2016-06-26', 23.57, 23.69, 23.32, 23.35],
|
|
73
|
+
// ].map(([d,o,h,l,c]) => ({x:new Date(d).getTime(),o,h,l,c})),
|
|
74
|
+
// color: {
|
|
75
|
+
// up: '#aaa',
|
|
76
|
+
// down: '#000',
|
|
77
|
+
// unchanged: '#ccc',
|
|
78
|
+
// },
|
|
79
|
+
// },
|
|
80
|
+
// {
|
|
81
|
+
// type: 'bar',
|
|
82
|
+
// yAxisID: 'y2',
|
|
83
|
+
// backgroundColor: '#bbb',
|
|
84
|
+
// label: 'Volume',
|
|
85
|
+
// data: [
|
|
86
|
+
// ['2016-04-01', 18],
|
|
87
|
+
// ['2016-04-02', 18],
|
|
88
|
+
// ['2016-04-03', 18],
|
|
89
|
+
// ['2016-04-06', 20],
|
|
90
|
+
// ['2016-04-07', 22],
|
|
91
|
+
// ['2016-04-08', 24],
|
|
92
|
+
// ['2016-04-09', 22],
|
|
93
|
+
// ['2016-04-13', 20],
|
|
94
|
+
// ['2016-04-14', 21],
|
|
95
|
+
// ['2016-04-15', 19],
|
|
96
|
+
// ['2016-04-16', 21],
|
|
97
|
+
// ['2016-04-17', 18],
|
|
98
|
+
// ['2016-04-20', 16],
|
|
99
|
+
// ['2016-04-21', 19],
|
|
100
|
+
// ['2016-04-22', 16],
|
|
101
|
+
// ['2016-04-23', 19],
|
|
102
|
+
// ['2016-04-24', 23],
|
|
103
|
+
// ['2016-04-27', 25],
|
|
104
|
+
// ['2016-04-28', 27],
|
|
105
|
+
// ['2016-04-29', 22],
|
|
106
|
+
// ['2016-04-30', 21],
|
|
107
|
+
// ['2016-05-01', 21],
|
|
108
|
+
// ['2016-05-04', 21],
|
|
109
|
+
// ['2016-05-05', 17],
|
|
110
|
+
// ['2016-05-06', 21],
|
|
111
|
+
// ['2016-05-07', 15],
|
|
112
|
+
// ['2016-05-08', 22],
|
|
113
|
+
// ['2016-05-11', 17],
|
|
114
|
+
// ['2016-05-12', 19],
|
|
115
|
+
// ['2016-05-13', 24],
|
|
116
|
+
// ['2016-05-14', 22],
|
|
117
|
+
// ['2016-05-15', 22],
|
|
118
|
+
// ['2016-05-18', 25],
|
|
119
|
+
// ['2016-05-19', 16],
|
|
120
|
+
// ['2016-05-20', 20],
|
|
121
|
+
// ['2016-05-21', 18],
|
|
122
|
+
// ['2016-05-22', 22],
|
|
123
|
+
// ['2016-05-26', 18],
|
|
124
|
+
// ['2016-05-27', 25],
|
|
125
|
+
// ['2016-05-28', 23],
|
|
126
|
+
// ['2016-05-29', 24],
|
|
127
|
+
// ['2016-06-01', 24],
|
|
128
|
+
// ['2016-06-02', 22],
|
|
129
|
+
// ['2016-06-03', 22],
|
|
130
|
+
// ['2016-06-04', 22],
|
|
131
|
+
// ['2016-06-05', 20],
|
|
132
|
+
// ['2016-06-08', 20],
|
|
133
|
+
// ['2016-06-09', 20],
|
|
134
|
+
// ['2016-06-10', 19],
|
|
135
|
+
// ['2016-06-11', 22],
|
|
136
|
+
// ['2016-06-12', 23],
|
|
137
|
+
// ['2016-06-15', 24],
|
|
138
|
+
// ['2016-06-16', 25],
|
|
139
|
+
// ['2016-06-17', 24],
|
|
140
|
+
// ['2016-06-18', 24],
|
|
141
|
+
// ['2016-06-19', 21],
|
|
142
|
+
// ['2016-06-22', 22],
|
|
143
|
+
// ['2016-06-23', 23],
|
|
144
|
+
// ['2016-06-24', 22],
|
|
145
|
+
// ['2016-06-25', 21],
|
|
146
|
+
// ['2016-06-26', 22],
|
|
147
|
+
// ].map(([d,y]) => ({x:new Date(d).getTime(),y})),
|
|
148
|
+
// },
|
|
149
|
+
// {
|
|
150
|
+
// type: 'line',
|
|
151
|
+
// yAxisID: 'y1',
|
|
152
|
+
// borderColor: '#f00',
|
|
153
|
+
// backgroundColor: '#f00',
|
|
154
|
+
// borderWidth: 2,
|
|
155
|
+
// pointRadius: 0,
|
|
156
|
+
// label: 'SMA',
|
|
157
|
+
// data: [
|
|
158
|
+
// ['2016-04-01', 18.832],
|
|
159
|
+
// ['2016-04-02', 18.98],
|
|
160
|
+
// ['2016-04-03', 18.97],
|
|
161
|
+
// ['2016-04-06', 19.082],
|
|
162
|
+
// ['2016-04-07', 19.262],
|
|
163
|
+
// ['2016-04-08', 19.352],
|
|
164
|
+
// ['2016-04-09', 19.39],
|
|
165
|
+
// ['2016-04-13', 19.438],
|
|
166
|
+
// ['2016-04-14', 19.278],
|
|
167
|
+
// ['2016-04-15', 19.108],
|
|
168
|
+
// ['2016-04-16', 19.018],
|
|
169
|
+
// ['2016-04-17', 18.97],
|
|
170
|
+
// ['2016-04-20', 18.996],
|
|
171
|
+
// ['2016-04-21', 19.328],
|
|
172
|
+
// ['2016-04-22', 19.66],
|
|
173
|
+
// ['2016-04-23', 19.93],
|
|
174
|
+
// ['2016-04-24', 20.266],
|
|
175
|
+
// ['2016-04-27', 20.34],
|
|
176
|
+
// ['2016-04-28', 20.304],
|
|
177
|
+
// ['2016-04-29', 20.282],
|
|
178
|
+
// ['2016-04-30', 20.272],
|
|
179
|
+
// ['2016-05-01', 20.144],
|
|
180
|
+
// ['2016-05-04', 19.998],
|
|
181
|
+
// ['2016-05-05', 19.764],
|
|
182
|
+
// ['2016-05-06', 19.638],
|
|
183
|
+
// ['2016-05-07', 19.61],
|
|
184
|
+
// ['2016-05-08', 19.584],
|
|
185
|
+
// ['2016-05-11', 19.718],
|
|
186
|
+
// ['2016-05-12', 19.95],
|
|
187
|
+
// ['2016-05-13', 20.15],
|
|
188
|
+
// ['2016-05-14', 20.248],
|
|
189
|
+
// ['2016-05-15', 20.31],
|
|
190
|
+
// ['2016-05-18', 20.27],
|
|
191
|
+
// ['2016-05-19', 20.106],
|
|
192
|
+
// ['2016-05-20', 20.054],
|
|
193
|
+
// ['2016-05-21', 20.036],
|
|
194
|
+
// ['2016-05-22', 20.12],
|
|
195
|
+
// ['2016-05-26', 20.334],
|
|
196
|
+
// ['2016-05-27', 20.698],
|
|
197
|
+
// ['2016-05-28', 20.91],
|
|
198
|
+
// ['2016-05-29', 21.2],
|
|
199
|
+
// ['2016-06-01', 21.48],
|
|
200
|
+
// ['2016-06-02', 21.676],
|
|
201
|
+
// ['2016-06-03', 21.816],
|
|
202
|
+
// ['2016-06-04', 21.988],
|
|
203
|
+
// ['2016-06-05', 22.152],
|
|
204
|
+
// ['2016-06-08', 22.34],
|
|
205
|
+
// ['2016-06-09', 22.59],
|
|
206
|
+
// ['2016-06-10', 22.872],
|
|
207
|
+
// ['2016-06-11', 23.138],
|
|
208
|
+
// ['2016-06-12', 23.344],
|
|
209
|
+
// ['2016-06-15', 23.572],
|
|
210
|
+
// ['2016-06-16', 23.716],
|
|
211
|
+
// ['2016-06-17', 23.698],
|
|
212
|
+
// ['2016-06-18', 23.688],
|
|
213
|
+
// ['2016-06-19', 23.65],
|
|
214
|
+
// ['2016-06-22', 23.556],
|
|
215
|
+
// ['2016-06-23', 23.486],
|
|
216
|
+
// ['2016-06-24', 23.604],
|
|
217
|
+
// ['2016-06-25', 23.724],
|
|
218
|
+
// ['2016-06-26', 23.79],
|
|
219
|
+
// ].map(([d,y]) => ({x:new Date(d).getTime(),y})),
|
|
220
|
+
// },
|
|
221
|
+
// ],
|
|
222
|
+
// },
|
|
223
|
+
// options: {
|
|
224
|
+
// scales:{
|
|
225
|
+
// x:{
|
|
226
|
+
// adapters: {
|
|
227
|
+
// date: {
|
|
228
|
+
// zone: 'UTC-4'
|
|
229
|
+
// }
|
|
230
|
+
// },
|
|
231
|
+
// time: {
|
|
232
|
+
// unit: 'day',
|
|
233
|
+
// stepSize: 1,
|
|
234
|
+
// displayFormats: {
|
|
235
|
+
// day: 'MMM d',
|
|
236
|
+
// month: 'MMM d',
|
|
237
|
+
// }
|
|
238
|
+
// },
|
|
239
|
+
// },
|
|
240
|
+
// y1: {
|
|
241
|
+
// stack: 'stockChart',
|
|
242
|
+
// stackWeight: 10,
|
|
243
|
+
// weight: 2,
|
|
244
|
+
// },
|
|
245
|
+
// y2: {
|
|
246
|
+
// display: false,
|
|
247
|
+
// stack: 'stockChart',
|
|
248
|
+
// stackWeight: 1,
|
|
249
|
+
// weight: 1,
|
|
250
|
+
// },
|
|
251
|
+
// },
|
|
252
|
+
// plugins: {
|
|
253
|
+
// legend: {
|
|
254
|
+
// display: false,
|
|
255
|
+
// },
|
|
256
|
+
// title: {
|
|
257
|
+
// display: true,
|
|
258
|
+
// text: 'MSFT',
|
|
259
|
+
// font: {
|
|
260
|
+
// size: 20,
|
|
261
|
+
// },
|
|
262
|
+
// },
|
|
263
|
+
// },
|
|
264
|
+
// },
|
|
265
|
+
// }
|
|
266
|
+
const ohlcDataPointSchema = z.object({
|
|
267
|
+
x: z.number(), // timestamp
|
|
268
|
+
o: z.number(), // open
|
|
269
|
+
h: z.number(), // high
|
|
270
|
+
l: z.number(), // low
|
|
271
|
+
c: z.number(), // close
|
|
272
|
+
});
|
|
273
|
+
const barDataPointSchema = z.object({
|
|
274
|
+
x: z.number(), // timestamp
|
|
275
|
+
y: z.number(), // value
|
|
276
|
+
});
|
|
277
|
+
const lineDataPointSchema = z.object({
|
|
278
|
+
x: z.number(), // timestamp
|
|
279
|
+
y: z.number(), // value
|
|
280
|
+
});
|
|
281
|
+
const colorSchema = z.object({
|
|
282
|
+
up: z.string().optional(),
|
|
283
|
+
down: z.string().optional(),
|
|
284
|
+
unchanged: z.string().optional(),
|
|
285
|
+
});
|
|
286
|
+
const ohlcDatasetSchema = z.object({
|
|
287
|
+
label: z.string(),
|
|
288
|
+
yAxisID: z.string().optional(),
|
|
289
|
+
data: z.array(ohlcDataPointSchema),
|
|
290
|
+
color: colorSchema.optional(),
|
|
291
|
+
});
|
|
292
|
+
const barDatasetSchema = z.object({
|
|
293
|
+
type: z.literal("bar"),
|
|
294
|
+
yAxisID: z.string().optional(),
|
|
295
|
+
backgroundColor: z.string().optional(),
|
|
296
|
+
label: z.string(),
|
|
297
|
+
data: z.array(barDataPointSchema),
|
|
298
|
+
});
|
|
299
|
+
const lineDatasetSchema = z.object({
|
|
300
|
+
type: z.literal("line"),
|
|
301
|
+
yAxisID: z.string().optional(),
|
|
302
|
+
borderColor: z.string().optional(),
|
|
303
|
+
backgroundColor: z.string().optional(),
|
|
304
|
+
borderWidth: z.number().optional(),
|
|
305
|
+
pointRadius: z.number().optional(),
|
|
306
|
+
label: z.string(),
|
|
307
|
+
data: z.array(lineDataPointSchema),
|
|
308
|
+
});
|
|
309
|
+
const datasetSchema = z.union([
|
|
310
|
+
ohlcDatasetSchema,
|
|
311
|
+
barDatasetSchema,
|
|
312
|
+
lineDatasetSchema,
|
|
313
|
+
]);
|
|
314
|
+
const dateAdapterSchema = z.object({
|
|
315
|
+
zone: z.string().optional(),
|
|
316
|
+
});
|
|
317
|
+
const timeConfigSchema = z.object({
|
|
318
|
+
unit: z.string().optional(),
|
|
319
|
+
stepSize: z.number().optional(),
|
|
320
|
+
displayFormats: z.record(z.string()).optional(),
|
|
321
|
+
});
|
|
322
|
+
const scaleSchema = z.object({
|
|
323
|
+
adapters: z.object({
|
|
324
|
+
date: dateAdapterSchema.optional(),
|
|
325
|
+
}).optional(),
|
|
326
|
+
time: timeConfigSchema.optional(),
|
|
327
|
+
stack: z.string().optional(),
|
|
328
|
+
stackWeight: z.number().optional(),
|
|
329
|
+
weight: z.number().optional(),
|
|
330
|
+
display: z.boolean().optional(),
|
|
331
|
+
});
|
|
332
|
+
const legendSchema = z.object({
|
|
333
|
+
display: z.boolean().optional(),
|
|
334
|
+
});
|
|
335
|
+
const titleSchema = z.object({
|
|
336
|
+
display: z.boolean().optional(),
|
|
337
|
+
text: z.string().optional(),
|
|
338
|
+
font: z.object({
|
|
339
|
+
size: z.number().optional(),
|
|
340
|
+
}).optional(),
|
|
341
|
+
});
|
|
342
|
+
const pluginsSchema = z.object({
|
|
343
|
+
legend: legendSchema.optional(),
|
|
344
|
+
title: titleSchema.optional(),
|
|
345
|
+
});
|
|
346
|
+
const scalesSchema = z.record(scaleSchema);
|
|
347
|
+
const optionsSchema = z.object({
|
|
348
|
+
scales: scalesSchema.optional(),
|
|
349
|
+
plugins: pluginsSchema.optional(),
|
|
350
|
+
});
|
|
351
|
+
const schema = {
|
|
352
|
+
type: z.literal("ohlc").default("ohlc"),
|
|
353
|
+
data: z.object({
|
|
354
|
+
datasets: z.array(datasetSchema),
|
|
355
|
+
}),
|
|
356
|
+
options: optionsSchema.optional(),
|
|
357
|
+
};
|
|
358
|
+
const tool = {
|
|
359
|
+
name: "ohlc",
|
|
360
|
+
description: `Generates an OHLC (Open, High, Low, Close) chart with the provided financial data.
|
|
361
|
+
example input:
|
|
362
|
+
\`\`\`json
|
|
363
|
+
{
|
|
364
|
+
"type": "ohlc",
|
|
365
|
+
"data": {
|
|
366
|
+
"datasets": [
|
|
367
|
+
{
|
|
368
|
+
"label": "MSFT",
|
|
369
|
+
"yAxisID": "y1",
|
|
370
|
+
"data": [
|
|
371
|
+
{"x": 1459468800000, "o": 18.23, "h": 19.36, "l": 18.18, "c": 19.31},
|
|
372
|
+
{"x": 1459555200000, "o": 19.50, "h": 19.89, "l": 19.00, "c": 19.29}
|
|
373
|
+
],
|
|
374
|
+
"color": {
|
|
375
|
+
"up": "#aaa",
|
|
376
|
+
"down": "#000",
|
|
377
|
+
"unchanged": "#ccc"
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"type": "bar",
|
|
382
|
+
"yAxisID": "y2",
|
|
383
|
+
"backgroundColor": "#bbb",
|
|
384
|
+
"label": "Volume",
|
|
385
|
+
"data": [
|
|
386
|
+
{"x": 1459468800000, "y": 18},
|
|
387
|
+
{"x": 1459555200000, "y": 18}
|
|
388
|
+
]
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
"type": "line",
|
|
392
|
+
"yAxisID": "y1",
|
|
393
|
+
"borderColor": "#f00",
|
|
394
|
+
"backgroundColor": "#f00",
|
|
395
|
+
"borderWidth": 2,
|
|
396
|
+
"pointRadius": 0,
|
|
397
|
+
"label": "SMA",
|
|
398
|
+
"data": [
|
|
399
|
+
{"x": 1459468800000, "y": 18.832},
|
|
400
|
+
{"x": 1459555200000, "y": 18.98}
|
|
401
|
+
]
|
|
402
|
+
}
|
|
403
|
+
]
|
|
404
|
+
},
|
|
405
|
+
"options": {
|
|
406
|
+
"scales": {
|
|
407
|
+
"x": {
|
|
408
|
+
"adapters": {
|
|
409
|
+
"date": {
|
|
410
|
+
"zone": "UTC-4"
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
"time": {
|
|
414
|
+
"unit": "day",
|
|
415
|
+
"stepSize": 1,
|
|
416
|
+
"displayFormats": {
|
|
417
|
+
"day": "MMM d",
|
|
418
|
+
"month": "MMM d"
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
"y1": {
|
|
423
|
+
"stack": "stockChart",
|
|
424
|
+
"stackWeight": 10,
|
|
425
|
+
"weight": 2
|
|
426
|
+
},
|
|
427
|
+
"y2": {
|
|
428
|
+
"display": false,
|
|
429
|
+
"stack": "stockChart",
|
|
430
|
+
"stackWeight": 1,
|
|
431
|
+
"weight": 1
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
"plugins": {
|
|
435
|
+
"legend": {
|
|
436
|
+
"display": false
|
|
437
|
+
},
|
|
438
|
+
"title": {
|
|
439
|
+
"display": true,
|
|
440
|
+
"text": "MSFT",
|
|
441
|
+
"font": {
|
|
442
|
+
"size": 20
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
\`\`\`
|
|
449
|
+
`,
|
|
450
|
+
inputSchema: zodToJsonSchema(schema),
|
|
451
|
+
};
|
|
452
|
+
export const ohlc = {
|
|
453
|
+
schema,
|
|
454
|
+
tool,
|
|
455
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { zodToJsonSchema } from "../utils/index.js";
|
|
3
|
+
// Define the schema for the pie chart
|
|
4
|
+
// {
|
|
5
|
+
// type: 'pie',
|
|
6
|
+
// data: {
|
|
7
|
+
// labels: ['January', 'February', 'March', 'April', 'May'],
|
|
8
|
+
// datasets: [{ data: [50, 60, 70, 180, 190] }],
|
|
9
|
+
// },
|
|
10
|
+
// }
|
|
11
|
+
const schema = {
|
|
12
|
+
type: z.literal("pie").default("pie"),
|
|
13
|
+
data: z.object({
|
|
14
|
+
labels: z.array(z.string()).describe("Labels for each pie slice"),
|
|
15
|
+
datasets: z.array(z.object({
|
|
16
|
+
data: z.array(z.number()).describe("Data values for each pie slice"),
|
|
17
|
+
label: z.string().optional().describe("Label for the dataset"),
|
|
18
|
+
backgroundColor: z.array(z.string()).optional().describe("Background colors for each slice"),
|
|
19
|
+
borderColor: z.array(z.string()).optional().describe("Border colors for each slice"),
|
|
20
|
+
borderWidth: z.number().optional().describe("Width of the slice borders"),
|
|
21
|
+
hoverBackgroundColor: z.array(z.string()).optional().describe("Background colors when hovering"),
|
|
22
|
+
hoverBorderColor: z.array(z.string()).optional().describe("Border colors when hovering"),
|
|
23
|
+
hoverBorderWidth: z.number().optional().describe("Border width when hovering"),
|
|
24
|
+
})),
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
const tool = {
|
|
28
|
+
name: "pie",
|
|
29
|
+
description: `Generates a pie chart with the provided data.
|
|
30
|
+
example input:
|
|
31
|
+
\`\`\`json
|
|
32
|
+
{
|
|
33
|
+
"type": "pie",
|
|
34
|
+
"data": {
|
|
35
|
+
"labels": ["January", "February", "March", "April", "May"],
|
|
36
|
+
"datasets": [
|
|
37
|
+
{
|
|
38
|
+
"data": [50, 60, 70, 180, 190]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
\`\`\`
|
|
44
|
+
`,
|
|
45
|
+
inputSchema: zodToJsonSchema(schema),
|
|
46
|
+
};
|
|
47
|
+
export const pie = {
|
|
48
|
+
schema,
|
|
49
|
+
tool,
|
|
50
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { zodToJsonSchema } from "../utils/index.js";
|
|
3
|
+
// Define the schema for the polar area chart
|
|
4
|
+
// {
|
|
5
|
+
// type: 'polarArea',
|
|
6
|
+
// data: {
|
|
7
|
+
// labels: ['January', 'February', 'March', 'April', 'May'],
|
|
8
|
+
// datasets: [{ data: [50, 60, 70, 180, 190] }],
|
|
9
|
+
// },
|
|
10
|
+
// }
|
|
11
|
+
const schema = {
|
|
12
|
+
type: z.literal("polarArea").default("polarArea"),
|
|
13
|
+
data: z.object({
|
|
14
|
+
labels: z.array(z.string()).describe("Labels for each polar area segment"),
|
|
15
|
+
datasets: z.array(z.object({
|
|
16
|
+
data: z.array(z.number()).describe("Data values for each segment"),
|
|
17
|
+
label: z.string().optional().describe("Label for the dataset"),
|
|
18
|
+
backgroundColor: z.array(z.string()).optional().describe("Background colors for each segment"),
|
|
19
|
+
borderColor: z.array(z.string()).optional().describe("Border colors for each segment"),
|
|
20
|
+
borderWidth: z.number().optional().describe("Width of the segment borders"),
|
|
21
|
+
hoverBackgroundColor: z.array(z.string()).optional().describe("Background colors when hovering"),
|
|
22
|
+
hoverBorderColor: z.array(z.string()).optional().describe("Border colors when hovering"),
|
|
23
|
+
hoverBorderWidth: z.number().optional().describe("Border width when hovering"),
|
|
24
|
+
})),
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
const tool = {
|
|
28
|
+
name: "polarArea",
|
|
29
|
+
description: `Generates a polar area chart with the provided data.
|
|
30
|
+
example input:
|
|
31
|
+
\`\`\`json
|
|
32
|
+
{
|
|
33
|
+
"type": "polarArea",
|
|
34
|
+
"data": {
|
|
35
|
+
"labels": ["January", "February", "March", "April", "May"],
|
|
36
|
+
"datasets": [
|
|
37
|
+
{
|
|
38
|
+
"data": [50, 60, 70, 180, 190]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
\`\`\`
|
|
44
|
+
`,
|
|
45
|
+
inputSchema: zodToJsonSchema(schema),
|
|
46
|
+
};
|
|
47
|
+
export const polarArea = {
|
|
48
|
+
schema,
|
|
49
|
+
tool,
|
|
50
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { zodToJsonSchema } from "../utils/index.js";
|
|
3
|
+
// Define the schema for the progress bar chart
|
|
4
|
+
// {
|
|
5
|
+
// type: 'progressBar',
|
|
6
|
+
// data: {
|
|
7
|
+
// datasets: [
|
|
8
|
+
// {
|
|
9
|
+
// data: [50],
|
|
10
|
+
// },
|
|
11
|
+
// ],
|
|
12
|
+
// },
|
|
13
|
+
// }
|
|
14
|
+
const schema = {
|
|
15
|
+
type: z.literal("progressBar").default("progressBar"),
|
|
16
|
+
data: z.object({
|
|
17
|
+
datasets: z.array(z.object({
|
|
18
|
+
data: z.array(z.number()).describe("Progress value (typically 0-100)"),
|
|
19
|
+
backgroundColor: z.string().optional().describe("Background color of the progress bar"),
|
|
20
|
+
borderColor: z.string().optional().describe("Border color of the progress bar"),
|
|
21
|
+
borderWidth: z.number().optional().describe("Width of the progress bar border"),
|
|
22
|
+
label: z.string().optional().describe("Label for the dataset"),
|
|
23
|
+
barColor: z.string().optional().describe("Color of the progress bar fill"),
|
|
24
|
+
barBackgroundColor: z.string().optional().describe("Background color of the empty progress bar"),
|
|
25
|
+
})),
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
const tool = {
|
|
29
|
+
name: "progressBar",
|
|
30
|
+
description: `Generates a progress bar chart with the provided value.
|
|
31
|
+
example input:
|
|
32
|
+
\`\`\`json
|
|
33
|
+
{
|
|
34
|
+
"type": "progressBar",
|
|
35
|
+
"data": {
|
|
36
|
+
"datasets": [
|
|
37
|
+
{
|
|
38
|
+
"data": [50]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
\`\`\`
|
|
44
|
+
`,
|
|
45
|
+
inputSchema: zodToJsonSchema(schema),
|
|
46
|
+
};
|
|
47
|
+
export const progressBar = {
|
|
48
|
+
schema,
|
|
49
|
+
tool,
|
|
50
|
+
};
|