@optifye/dashboard-core 4.3.4 → 4.3.6

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.
Files changed (3) hide show
  1. package/dist/index.js +562 -212
  2. package/dist/index.mjs +562 -212
  3. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -24427,6 +24427,7 @@ var AIAgentView = () => {
24427
24427
  const entityConfig = useEntityConfig();
24428
24428
  const dateTimeConfig = useDateTimeConfig();
24429
24429
  const shiftConfig = useShiftConfig();
24430
+ const { formatNumber } = useFormatNumber();
24430
24431
  const [inputValue, setInputValue] = useState("");
24431
24432
  const [loadingThreads, setLoadingThreads] = useState(/* @__PURE__ */ new Set());
24432
24433
  const [lastError, setLastError] = useState(null);
@@ -25057,17 +25058,49 @@ var AIAgentView = () => {
25057
25058
  chartElements.push(chartElement);
25058
25059
  } else {
25059
25060
  console.warn(`[DEBUG] Chart element was null for type: ${chartType}`);
25061
+ console.warn(`[DEBUG] Args were:`, args);
25062
+ chartElements.push(
25063
+ /* @__PURE__ */ jsxs(
25064
+ "div",
25065
+ {
25066
+ className: "text-red-500 text-sm border border-red-300 bg-red-50 p-3 rounded",
25067
+ children: [
25068
+ /* @__PURE__ */ jsx("strong", { children: "Chart Rendering Error:" }),
25069
+ " Failed to render ",
25070
+ chartType,
25071
+ /* @__PURE__ */ jsx("br", {}),
25072
+ /* @__PURE__ */ jsxs("small", { children: [
25073
+ "Check console for details. Args: ",
25074
+ JSON.stringify(args, null, 2)
25075
+ ] })
25076
+ ]
25077
+ },
25078
+ `error-${startIndex}`
25079
+ )
25080
+ );
25060
25081
  }
25061
25082
  } catch (error) {
25062
25083
  console.error(`Failed to parse chart ${chartType}:`, error);
25084
+ console.error(`Args string was:`, argsString);
25063
25085
  chartElements.push(
25064
25086
  /* @__PURE__ */ jsxs(
25065
25087
  "div",
25066
25088
  {
25067
- className: "text-red-500 text-sm",
25089
+ className: "text-red-500 text-sm border border-red-300 bg-red-50 p-3 rounded",
25068
25090
  children: [
25069
- "Error rendering chart: ",
25070
- match[0]
25091
+ /* @__PURE__ */ jsx("strong", { children: "Chart Parsing Error:" }),
25092
+ " Failed to parse ",
25093
+ chartType,
25094
+ /* @__PURE__ */ jsx("br", {}),
25095
+ /* @__PURE__ */ jsxs("small", { children: [
25096
+ "Error: ",
25097
+ error instanceof Error ? error.message : String(error)
25098
+ ] }),
25099
+ /* @__PURE__ */ jsx("br", {}),
25100
+ /* @__PURE__ */ jsxs("small", { children: [
25101
+ "Original: ",
25102
+ match[0]
25103
+ ] })
25071
25104
  ]
25072
25105
  },
25073
25106
  `error-${startIndex}`
@@ -25098,111 +25131,265 @@ var AIAgentView = () => {
25098
25131
  return chartElements;
25099
25132
  };
25100
25133
  const parseChartArguments = (argsString) => {
25101
- const args = {};
25102
25134
  console.log("[DEBUG] Parsing chart arguments:", argsString);
25103
- const jsonParamRegex = /(\w+)\s*=\s*(\[[\s\S]*?\](?=\s*(?:,|\s*\)|\s*$))|\{[\s\S]*?\}(?=\s*(?:,|\s*\)|\s*$)))/g;
25104
- let jsonMatch;
25105
- while ((jsonMatch = jsonParamRegex.exec(argsString)) !== null) {
25106
- const paramName = jsonMatch[1];
25107
- const jsonValue = jsonMatch[2];
25108
- console.log(`[DEBUG] Found JSON parameter: ${paramName} = ${jsonValue}`);
25109
- try {
25110
- args[paramName] = JSON.parse(jsonValue);
25111
- console.log(`[DEBUG] Successfully parsed ${paramName}:`, args[paramName]);
25112
- argsString = argsString.replace(jsonMatch[0], "");
25113
- } catch (e) {
25114
- console.error(`Failed to parse ${paramName} JSON:`, e);
25115
- console.error(`JSON value that failed:`, jsonValue);
25116
- }
25117
- }
25118
- const argRegex = /(\w+)\s*=\s*("([^"]*)"|'([^']*)'|([^,\s\)]+))/g;
25119
- let argMatch;
25120
- while ((argMatch = argRegex.exec(argsString)) !== null) {
25121
- const key = argMatch[1];
25122
- const value = argMatch[3] || argMatch[4] || argMatch[5];
25123
- if (key === "data") continue;
25124
- if (value === "true" || value === "True") {
25125
- args[key] = true;
25126
- } else if (value === "false" || value === "False") {
25127
- args[key] = false;
25128
- } else if (value === "null" || value === "None") {
25129
- args[key] = null;
25130
- } else if (!isNaN(Number(value)) && value !== "") {
25131
- args[key] = Number(value);
25132
- } else {
25133
- args[key] = value;
25135
+ const extractParameters = (str) => {
25136
+ const params = {};
25137
+ let currentPos = 0;
25138
+ while (currentPos < str.length) {
25139
+ while (currentPos < str.length && /\s|,/.test(str[currentPos])) {
25140
+ currentPos++;
25141
+ }
25142
+ if (currentPos >= str.length) break;
25143
+ const paramMatch = str.substring(currentPos).match(/^(\w+)\s*=/);
25144
+ if (!paramMatch) {
25145
+ console.warn("[DEBUG] No parameter name found at position", currentPos);
25146
+ break;
25147
+ }
25148
+ const paramName = paramMatch[1];
25149
+ currentPos += paramMatch[0].length;
25150
+ while (currentPos < str.length && /\s/.test(str[currentPos])) {
25151
+ currentPos++;
25152
+ }
25153
+ if (currentPos >= str.length) break;
25154
+ let value;
25155
+ let valueEnd;
25156
+ if (str[currentPos] === "[") {
25157
+ let bracketCount = 0;
25158
+ let arrayStart = currentPos;
25159
+ valueEnd = str.length;
25160
+ for (let i = currentPos; i < str.length; i++) {
25161
+ if (str[i] === "[") bracketCount++;
25162
+ else if (str[i] === "]") bracketCount--;
25163
+ if (bracketCount === 0) {
25164
+ valueEnd = i + 1;
25165
+ break;
25166
+ }
25167
+ }
25168
+ if (bracketCount !== 0) {
25169
+ console.error("[DEBUG] Unmatched brackets in array value");
25170
+ break;
25171
+ }
25172
+ const arrayStr = str.substring(arrayStart, valueEnd);
25173
+ console.log(`[DEBUG] Found array parameter: ${paramName} = ${arrayStr}`);
25174
+ try {
25175
+ value = JSON.parse(arrayStr);
25176
+ console.log(`[DEBUG] Successfully parsed array ${paramName}:`, value);
25177
+ } catch (e) {
25178
+ console.error(`[DEBUG] Failed to parse array ${paramName}:`, e);
25179
+ console.error(`Array value that failed:`, arrayStr);
25180
+ value = arrayStr;
25181
+ }
25182
+ } else if (str[currentPos] === "{") {
25183
+ let braceCount = 0;
25184
+ let objectStart = currentPos;
25185
+ valueEnd = str.length;
25186
+ for (let i = currentPos; i < str.length; i++) {
25187
+ if (str[i] === "{") braceCount++;
25188
+ else if (str[i] === "}") braceCount--;
25189
+ if (braceCount === 0) {
25190
+ valueEnd = i + 1;
25191
+ break;
25192
+ }
25193
+ }
25194
+ if (braceCount !== 0) {
25195
+ console.error("[DEBUG] Unmatched braces in object value");
25196
+ break;
25197
+ }
25198
+ const objectStr = str.substring(objectStart, valueEnd);
25199
+ console.log(`[DEBUG] Found object parameter: ${paramName} = ${objectStr}`);
25200
+ try {
25201
+ value = JSON.parse(objectStr);
25202
+ console.log(`[DEBUG] Successfully parsed object ${paramName}:`, value);
25203
+ } catch (e) {
25204
+ console.error(`[DEBUG] Failed to parse object ${paramName}:`, e);
25205
+ console.error(`Object value that failed:`, objectStr);
25206
+ value = objectStr;
25207
+ }
25208
+ } else if (str[currentPos] === '"') {
25209
+ let stringStart = currentPos + 1;
25210
+ let stringEnd = stringStart;
25211
+ while (stringEnd < str.length) {
25212
+ if (str[stringEnd] === '"' && str[stringEnd - 1] !== "\\") {
25213
+ break;
25214
+ }
25215
+ stringEnd++;
25216
+ }
25217
+ if (stringEnd >= str.length) {
25218
+ console.error("[DEBUG] Unterminated string value");
25219
+ valueEnd = str.length;
25220
+ break;
25221
+ }
25222
+ value = str.substring(stringStart, stringEnd);
25223
+ valueEnd = stringEnd + 1;
25224
+ console.log(`[DEBUG] Found string parameter: ${paramName} = "${value}"`);
25225
+ } else {
25226
+ let valueStart = currentPos;
25227
+ let valueEndPos = valueStart;
25228
+ while (valueEndPos < str.length && str[valueEndPos] !== ",") {
25229
+ valueEndPos++;
25230
+ }
25231
+ const rawValue = str.substring(valueStart, valueEndPos).trim();
25232
+ valueEnd = valueEndPos;
25233
+ if (rawValue === "true" || rawValue === "True") {
25234
+ value = true;
25235
+ } else if (rawValue === "false" || rawValue === "False") {
25236
+ value = false;
25237
+ } else if (rawValue === "null" || rawValue === "None") {
25238
+ value = null;
25239
+ } else if (!isNaN(Number(rawValue)) && rawValue !== "") {
25240
+ value = Number(rawValue);
25241
+ } else {
25242
+ value = rawValue;
25243
+ }
25244
+ console.log(`[DEBUG] Found unquoted parameter: ${paramName} = ${rawValue} (parsed as ${typeof value})`);
25245
+ }
25246
+ params[paramName] = value;
25247
+ currentPos = valueEnd;
25134
25248
  }
25135
- }
25136
- console.log("[DEBUG] Final parsed arguments:", args);
25137
- return args;
25249
+ return params;
25250
+ };
25251
+ const result = extractParameters(argsString);
25252
+ console.log("[DEBUG] Final parsed arguments:", result);
25253
+ return result;
25138
25254
  };
25139
25255
  const renderChart = (chartType, args, key) => {
25140
25256
  console.log(`[DEBUG] Attempting to render chart type: ${chartType}`, args);
25257
+ const CHART_COLORS = {
25258
+ primary: "#3b82f6",
25259
+ // blue-500
25260
+ secondary: "#10b981",
25261
+ // green-500
25262
+ accent: "#f59e0b",
25263
+ // amber-500
25264
+ danger: "#ef4444",
25265
+ // red-500
25266
+ violet: "#8b5cf6",
25267
+ // violet-500
25268
+ cyan: "#06b6d4",
25269
+ // cyan-500
25270
+ orange: "#f97316",
25271
+ // orange-500
25272
+ indigo: "#6366f1"
25273
+ // indigo-500
25274
+ };
25275
+ const CHART_COLOR_PALETTE = Object.values(CHART_COLORS);
25276
+ const CHART_STYLES = {
25277
+ grid: {
25278
+ strokeDasharray: "3 3",
25279
+ stroke: "#e5e7eb"
25280
+ // gray-300
25281
+ },
25282
+ axis: {
25283
+ tick: { fontSize: 12, fill: "#4b5563" },
25284
+ // gray-600
25285
+ stroke: "#9ca3af"
25286
+ // gray-400
25287
+ },
25288
+ margin: { top: 10, right: 30, left: 20, bottom: 40 },
25289
+ barRadius: [4, 4, 0, 0]
25290
+ // Top corners rounded
25291
+ };
25292
+ const CustomTooltip = ({ active, payload, label }) => {
25293
+ if (active && payload && payload.length) {
25294
+ return /* @__PURE__ */ jsxs("div", { className: "bg-white px-4 py-3 shadow-lg rounded-lg border border-gray-200", children: [
25295
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-900 mb-1", children: label }),
25296
+ payload.map((entry, index) => /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-600", style: { color: entry.color }, children: [
25297
+ entry.name,
25298
+ ": ",
25299
+ typeof entry.value === "number" ? formatNumber(entry.value) : entry.value,
25300
+ args.unit || ""
25301
+ ] }, index))
25302
+ ] });
25303
+ }
25304
+ return null;
25305
+ };
25306
+ const ChartWrapper = ({ children, title }) => /* @__PURE__ */ jsxs("div", { className: "my-6 bg-white rounded-xl shadow-sm border border-gray-200 p-6", children: [
25307
+ title && /* @__PURE__ */ jsx("h3", { className: "text-base font-semibold text-gray-900 mb-4", children: title }),
25308
+ children
25309
+ ] });
25141
25310
  switch (chartType) {
25142
25311
  case "create_gauge_chart":
25143
25312
  console.log("[DEBUG] Rendering gauge chart");
25144
- return /* @__PURE__ */ jsx("div", { className: "my-6 h-64 w-full flex justify-center", children: /* @__PURE__ */ jsx(
25313
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "h-64 w-full flex justify-center", children: /* @__PURE__ */ jsx(
25145
25314
  GaugeChart,
25146
25315
  {
25147
25316
  value: args.value || 0,
25148
25317
  min: args.min_value || 0,
25149
25318
  max: args.max_value || 100,
25150
25319
  target: args.target,
25151
- label: args.title || "",
25320
+ label: args.label || "",
25152
25321
  unit: args.unit || "",
25153
25322
  thresholds: args.thresholds,
25154
25323
  className: "w-full max-w-sm"
25155
25324
  }
25156
- ) }, `gauge-${key}`);
25325
+ ) }) }, `gauge-${key}`);
25157
25326
  case "create_bar_chart":
25158
25327
  console.log("[DEBUG] Rendering bar chart");
25159
25328
  if (!args.data || !args.x_field || !args.y_field) {
25160
25329
  console.error("Bar chart missing required parameters:", { data: !!args.data, x_field: !!args.x_field, y_field: !!args.y_field });
25161
25330
  return null;
25162
25331
  }
25163
- return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", style: { maxWidth: args.max_width || "100%" }, children: [
25332
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-64", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(BarChart$1, { data: args.data, margin: CHART_STYLES.margin, children: [
25333
+ /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
25164
25334
  /* @__PURE__ */ jsx(
25165
- BarChart,
25335
+ XAxis,
25166
25336
  {
25167
- data: args.data,
25168
- bars: [{
25169
- dataKey: args.y_field,
25170
- fill: args.color || "#3b82f6",
25171
- labelList: args.show_values
25172
- }],
25173
- xAxisDataKey: args.x_field,
25174
- className: "h-64",
25175
- showLegend: false
25337
+ dataKey: args.x_field,
25338
+ ...CHART_STYLES.axis
25176
25339
  }
25177
25340
  ),
25178
- args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25179
- ] }, `bar-${key}`);
25341
+ /* @__PURE__ */ jsx(
25342
+ YAxis,
25343
+ {
25344
+ ...CHART_STYLES.axis,
25345
+ tickFormatter: (value) => formatNumber(value)
25346
+ }
25347
+ ),
25348
+ /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CustomTooltip, {}), cursor: { fill: "rgba(0, 0, 0, 0.05)" } }),
25349
+ /* @__PURE__ */ jsx(
25350
+ Bar,
25351
+ {
25352
+ dataKey: args.y_field,
25353
+ fill: args.color || CHART_COLORS.primary,
25354
+ radius: CHART_STYLES.barRadius
25355
+ }
25356
+ )
25357
+ ] }) }) }) }, `bar-${key}`);
25180
25358
  case "create_line_chart":
25181
25359
  console.log("[DEBUG] Rendering line chart");
25182
25360
  if (!args.data || !args.x_field || !args.y_field) {
25183
25361
  console.error("Line chart missing required parameters:", { data: !!args.data, x_field: !!args.x_field, y_field: !!args.y_field });
25184
25362
  return null;
25185
25363
  }
25186
- return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", style: {
25187
- height: args.height || 256,
25188
- width: args.width || "100%"
25189
- }, children: [
25364
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-64", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(LineChart$1, { data: args.data, margin: CHART_STYLES.margin, children: [
25365
+ /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
25190
25366
  /* @__PURE__ */ jsx(
25191
- LineChart,
25367
+ XAxis,
25368
+ {
25369
+ dataKey: args.x_field,
25370
+ ...CHART_STYLES.axis
25371
+ }
25372
+ ),
25373
+ /* @__PURE__ */ jsx(
25374
+ YAxis,
25192
25375
  {
25193
- data: args.data,
25194
- lines: [{
25195
- dataKey: args.y_field,
25196
- stroke: "#3b82f6",
25197
- strokeWidth: 2
25198
- }],
25199
- xAxisDataKey: args.x_field,
25200
- className: "h-full",
25201
- showLegend: false
25376
+ ...CHART_STYLES.axis,
25377
+ tickFormatter: (value) => formatNumber(value)
25202
25378
  }
25203
25379
  ),
25204
- args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25205
- ] }, `line-${key}`);
25380
+ /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CustomTooltip, {}), cursor: { strokeDasharray: "3 3" } }),
25381
+ /* @__PURE__ */ jsx(
25382
+ Line,
25383
+ {
25384
+ type: "monotone",
25385
+ dataKey: args.y_field,
25386
+ stroke: CHART_COLORS.primary,
25387
+ strokeWidth: 2,
25388
+ dot: { r: 4, fill: CHART_COLORS.primary },
25389
+ activeDot: { r: 6 }
25390
+ }
25391
+ )
25392
+ ] }) }) }) }, `line-${key}`);
25206
25393
  case "create_pie_chart":
25207
25394
  console.log("[DEBUG] Rendering pie chart");
25208
25395
  if (!args.data || !args.label_field || !args.value_field) {
@@ -25215,16 +25402,14 @@ var AIAgentView = () => {
25215
25402
  value: item[args.value_field]
25216
25403
  }));
25217
25404
  console.log("[DEBUG] Pie chart data transformed:", pieData);
25218
- return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full flex flex-col items-center", children: [
25219
- args.title && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-700 mb-2", children: args.title }),
25220
- /* @__PURE__ */ jsx("div", { className: "h-64 w-full max-w-md", children: /* @__PURE__ */ jsx(
25221
- PieChart4,
25222
- {
25223
- data: pieData,
25224
- showPercentages: args.show_percentages || false
25225
- }
25226
- ) })
25227
- ] }, `pie-${key}`);
25405
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "h-64 w-full max-w-md mx-auto", children: /* @__PURE__ */ jsx(
25406
+ PieChart4,
25407
+ {
25408
+ data: pieData,
25409
+ showPercentages: args.show_percentages || false,
25410
+ colors: CHART_COLOR_PALETTE
25411
+ }
25412
+ ) }) }, `pie-${key}`);
25228
25413
  case "create_comparison_table":
25229
25414
  console.log("[DEBUG] Rendering comparison table");
25230
25415
  if (!args.data) {
@@ -25241,27 +25426,24 @@ var AIAgentView = () => {
25241
25426
  return args.sort_descending === false ? comparison : -comparison;
25242
25427
  });
25243
25428
  }
25244
- return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full overflow-x-auto", children: [
25245
- args.title && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-700 mb-2", children: args.title }),
25246
- /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-gray-200", children: [
25247
- /* @__PURE__ */ jsx("thead", { className: "bg-gray-50", children: /* @__PURE__ */ jsx("tr", { children: columns.map((col) => /* @__PURE__ */ jsx(
25248
- "th",
25249
- {
25250
- className: `px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider ${col === args.highlight_column ? "bg-blue-50" : ""}`,
25251
- children: col
25252
- },
25253
- col
25254
- )) }) }),
25255
- /* @__PURE__ */ jsx("tbody", { className: "bg-white divide-y divide-gray-200", children: sortedData.map((row, rowIdx) => /* @__PURE__ */ jsx("tr", { className: rowIdx % 2 === 0 ? "bg-white" : "bg-gray-50", children: columns.map((col) => /* @__PURE__ */ jsx(
25256
- "td",
25257
- {
25258
- className: `px-4 py-2 whitespace-nowrap text-sm ${col === args.highlight_column ? "font-medium text-blue-600 bg-blue-50" : "text-gray-900"}`,
25259
- children: row[col]
25260
- },
25261
- col
25262
- )) }, rowIdx)) })
25263
- ] })
25264
- ] }, `table-${key}`);
25429
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "overflow-x-auto rounded-lg border border-gray-200", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-gray-200", children: [
25430
+ /* @__PURE__ */ jsx("thead", { className: "bg-gray-50", children: /* @__PURE__ */ jsx("tr", { children: columns.map((col) => /* @__PURE__ */ jsx(
25431
+ "th",
25432
+ {
25433
+ className: `px-6 py-3 text-left text-xs font-medium text-gray-600 uppercase tracking-wider ${col === args.highlight_column ? "bg-blue-50" : ""}`,
25434
+ children: col
25435
+ },
25436
+ col
25437
+ )) }) }),
25438
+ /* @__PURE__ */ jsx("tbody", { className: "bg-white divide-y divide-gray-200", children: sortedData.map((row, rowIdx) => /* @__PURE__ */ jsx("tr", { className: rowIdx % 2 === 0 ? "bg-white" : "bg-gray-50", children: columns.map((col) => /* @__PURE__ */ jsx(
25439
+ "td",
25440
+ {
25441
+ className: `px-6 py-4 whitespace-nowrap text-sm ${col === args.highlight_column ? "font-medium text-blue-600 bg-blue-50" : "text-gray-900"}`,
25442
+ children: typeof row[col] === "number" ? formatNumber(row[col]) : row[col]
25443
+ },
25444
+ col
25445
+ )) }, rowIdx)) })
25446
+ ] }) }) }, `table-${key}`);
25265
25447
  case "create_multi_line_chart":
25266
25448
  console.log("[DEBUG] Rendering multi-line chart");
25267
25449
  if (!args.data || !args.x_field || !args.y_fields || !args.legend) {
@@ -25273,30 +25455,44 @@ var AIAgentView = () => {
25273
25455
  });
25274
25456
  return null;
25275
25457
  }
25276
- const colors = ["#3b82f6", "#ef4444", "#10b981", "#f59e0b", "#8b5cf6", "#06b6d4", "#84cc16", "#f97316"];
25277
- return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", children: [
25278
- /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxs(LineChart$1, { data: args.data, children: [
25279
- /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
25280
- /* @__PURE__ */ jsx(XAxis, { dataKey: args.x_field }),
25281
- /* @__PURE__ */ jsx(YAxis, {}),
25282
- /* @__PURE__ */ jsx(Tooltip, {}),
25283
- /* @__PURE__ */ jsx(Legend, {}),
25284
- args.y_fields.map((field, index) => /* @__PURE__ */ jsx(
25285
- Line,
25286
- {
25287
- type: "monotone",
25288
- dataKey: field,
25289
- stroke: colors[index % colors.length],
25290
- strokeWidth: 2,
25291
- name: args.legend[index] || field,
25292
- dot: { r: 4 },
25293
- activeDot: { r: 6 }
25294
- },
25295
- field
25296
- ))
25297
- ] }) }),
25298
- args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25299
- ] }, `multi-line-${key}`);
25458
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(LineChart$1, { data: args.data, margin: CHART_STYLES.margin, children: [
25459
+ /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
25460
+ /* @__PURE__ */ jsx(
25461
+ XAxis,
25462
+ {
25463
+ dataKey: args.x_field,
25464
+ ...CHART_STYLES.axis
25465
+ }
25466
+ ),
25467
+ /* @__PURE__ */ jsx(
25468
+ YAxis,
25469
+ {
25470
+ ...CHART_STYLES.axis,
25471
+ tickFormatter: (value) => formatNumber(value)
25472
+ }
25473
+ ),
25474
+ /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CustomTooltip, {}), cursor: { strokeDasharray: "3 3" } }),
25475
+ /* @__PURE__ */ jsx(
25476
+ Legend,
25477
+ {
25478
+ wrapperStyle: { paddingTop: "20px" },
25479
+ formatter: (value) => /* @__PURE__ */ jsx("span", { className: "text-sm", children: value })
25480
+ }
25481
+ ),
25482
+ args.y_fields.map((field, index) => /* @__PURE__ */ jsx(
25483
+ Line,
25484
+ {
25485
+ type: "monotone",
25486
+ dataKey: field,
25487
+ stroke: CHART_COLOR_PALETTE[index % CHART_COLOR_PALETTE.length],
25488
+ strokeWidth: 2,
25489
+ name: args.legend[index] || field,
25490
+ dot: { r: 4 },
25491
+ activeDot: { r: 6 }
25492
+ },
25493
+ field
25494
+ ))
25495
+ ] }) }) }) }, `multi-line-${key}`);
25300
25496
  case "create_stacked_bar_chart":
25301
25497
  console.log("[DEBUG] Rendering stacked bar chart");
25302
25498
  if (!args.data || !args.x_field || !args.stack_fields) {
@@ -25307,27 +25503,42 @@ var AIAgentView = () => {
25307
25503
  });
25308
25504
  return null;
25309
25505
  }
25310
- const stackColors = ["#3b82f6", "#ef4444", "#10b981", "#f59e0b", "#8b5cf6", "#06b6d4", "#84cc16", "#f97316"];
25311
- return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", children: [
25312
- /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxs(BarChart$1, { data: args.data, children: [
25313
- /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
25314
- /* @__PURE__ */ jsx(XAxis, { dataKey: args.x_field }),
25315
- /* @__PURE__ */ jsx(YAxis, {}),
25316
- /* @__PURE__ */ jsx(Tooltip, {}),
25317
- /* @__PURE__ */ jsx(Legend, {}),
25318
- args.stack_fields.map((field, index) => /* @__PURE__ */ jsx(
25319
- Bar,
25320
- {
25321
- dataKey: field,
25322
- stackId: "stack",
25323
- fill: stackColors[index % stackColors.length],
25324
- name: field
25325
- },
25326
- field
25327
- ))
25328
- ] }) }),
25329
- args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25330
- ] }, `stacked-bar-${key}`);
25506
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(BarChart$1, { data: args.data, margin: CHART_STYLES.margin, children: [
25507
+ /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
25508
+ /* @__PURE__ */ jsx(
25509
+ XAxis,
25510
+ {
25511
+ dataKey: args.x_field,
25512
+ ...CHART_STYLES.axis
25513
+ }
25514
+ ),
25515
+ /* @__PURE__ */ jsx(
25516
+ YAxis,
25517
+ {
25518
+ ...CHART_STYLES.axis,
25519
+ tickFormatter: (value) => formatNumber(value)
25520
+ }
25521
+ ),
25522
+ /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CustomTooltip, {}), cursor: { fill: "rgba(0, 0, 0, 0.05)" } }),
25523
+ /* @__PURE__ */ jsx(
25524
+ Legend,
25525
+ {
25526
+ wrapperStyle: { paddingTop: "20px" },
25527
+ formatter: (value) => /* @__PURE__ */ jsx("span", { className: "text-sm", children: value })
25528
+ }
25529
+ ),
25530
+ args.stack_fields.map((field, index) => /* @__PURE__ */ jsx(
25531
+ Bar,
25532
+ {
25533
+ dataKey: field,
25534
+ stackId: "stack",
25535
+ fill: CHART_COLOR_PALETTE[index % CHART_COLOR_PALETTE.length],
25536
+ name: field,
25537
+ radius: index === args.stack_fields.length - 1 ? CHART_STYLES.barRadius : void 0
25538
+ },
25539
+ field
25540
+ ))
25541
+ ] }) }) }) }, `stacked-bar-${key}`);
25331
25542
  case "create_dual_axis_chart":
25332
25543
  console.log("[DEBUG] Rendering dual-axis chart");
25333
25544
  if (!args.data || !args.x_field || !args.left_y_field || !args.right_y_field) {
@@ -25339,19 +25550,67 @@ var AIAgentView = () => {
25339
25550
  });
25340
25551
  return null;
25341
25552
  }
25342
- return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", children: [
25343
- /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, children: [
25344
- /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
25345
- /* @__PURE__ */ jsx(XAxis, { dataKey: args.x_field }),
25346
- /* @__PURE__ */ jsx(YAxis, { yAxisId: "left", orientation: "left", label: { value: args.left_label || "", angle: -90, position: "insideLeft" } }),
25347
- /* @__PURE__ */ jsx(YAxis, { yAxisId: "right", orientation: "right", label: { value: args.right_label || "", angle: 90, position: "insideRight" } }),
25348
- /* @__PURE__ */ jsx(Tooltip, {}),
25349
- /* @__PURE__ */ jsx(Legend, {}),
25350
- /* @__PURE__ */ jsx(Bar, { yAxisId: "left", dataKey: args.left_y_field, fill: "#3b82f6", name: args.left_label || args.left_y_field }),
25351
- /* @__PURE__ */ jsx(Line, { yAxisId: "right", type: "monotone", dataKey: args.right_y_field, stroke: "#ef4444", strokeWidth: 2, name: args.right_label || args.right_y_field })
25352
- ] }) }),
25353
- args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25354
- ] }, `dual-axis-${key}`);
25553
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, margin: CHART_STYLES.margin, children: [
25554
+ /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
25555
+ /* @__PURE__ */ jsx(
25556
+ XAxis,
25557
+ {
25558
+ dataKey: args.x_field,
25559
+ ...CHART_STYLES.axis
25560
+ }
25561
+ ),
25562
+ /* @__PURE__ */ jsx(
25563
+ YAxis,
25564
+ {
25565
+ yAxisId: "left",
25566
+ orientation: "left",
25567
+ label: { value: args.left_label || "", angle: -90, position: "insideLeft" },
25568
+ ...CHART_STYLES.axis,
25569
+ tickFormatter: (value) => formatNumber(value)
25570
+ }
25571
+ ),
25572
+ /* @__PURE__ */ jsx(
25573
+ YAxis,
25574
+ {
25575
+ yAxisId: "right",
25576
+ orientation: "right",
25577
+ label: { value: args.right_label || "", angle: 90, position: "insideRight" },
25578
+ ...CHART_STYLES.axis,
25579
+ tickFormatter: (value) => formatNumber(value)
25580
+ }
25581
+ ),
25582
+ /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CustomTooltip, {}), cursor: { fill: "rgba(0, 0, 0, 0.05)" } }),
25583
+ /* @__PURE__ */ jsx(
25584
+ Legend,
25585
+ {
25586
+ wrapperStyle: { paddingTop: "20px" },
25587
+ formatter: (value) => /* @__PURE__ */ jsx("span", { className: "text-sm", children: value })
25588
+ }
25589
+ ),
25590
+ /* @__PURE__ */ jsx(
25591
+ Bar,
25592
+ {
25593
+ yAxisId: "left",
25594
+ dataKey: args.left_y_field,
25595
+ fill: CHART_COLORS.primary,
25596
+ name: args.left_label || args.left_y_field,
25597
+ radius: CHART_STYLES.barRadius
25598
+ }
25599
+ ),
25600
+ /* @__PURE__ */ jsx(
25601
+ Line,
25602
+ {
25603
+ yAxisId: "right",
25604
+ type: "monotone",
25605
+ dataKey: args.right_y_field,
25606
+ stroke: CHART_COLORS.danger,
25607
+ strokeWidth: 2,
25608
+ name: args.right_label || args.right_y_field,
25609
+ dot: { r: 4 },
25610
+ activeDot: { r: 6 }
25611
+ }
25612
+ )
25613
+ ] }) }) }) }, `dual-axis-${key}`);
25355
25614
  case "create_scatter_plot":
25356
25615
  console.log("[DEBUG] Rendering scatter plot");
25357
25616
  if (!args.data || !args.x_field || !args.y_field || !args.group_field) {
@@ -25371,26 +25630,50 @@ var AIAgentView = () => {
25371
25630
  acc[group].push(item);
25372
25631
  return acc;
25373
25632
  }, {});
25374
- const scatterColors = ["#3b82f6", "#ef4444", "#10b981", "#f59e0b", "#8b5cf6", "#06b6d4", "#84cc16", "#f97316"];
25375
- return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", children: [
25376
- /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxs(ScatterChart, { children: [
25377
- /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
25378
- /* @__PURE__ */ jsx(XAxis, { dataKey: args.x_field, type: "number", name: args.x_field }),
25379
- /* @__PURE__ */ jsx(YAxis, { dataKey: args.y_field, type: "number", name: args.y_field }),
25380
- /* @__PURE__ */ jsx(Tooltip, { cursor: { strokeDasharray: "3 3" } }),
25381
- /* @__PURE__ */ jsx(Legend, {}),
25382
- Object.entries(groupedData).map(([group, data], index) => /* @__PURE__ */ jsx(
25383
- Scatter,
25384
- {
25385
- name: group,
25386
- data,
25387
- fill: scatterColors[index % scatterColors.length]
25388
- },
25389
- group
25390
- ))
25391
- ] }) }),
25392
- args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25393
- ] }, `scatter-${key}`);
25633
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ScatterChart, { margin: CHART_STYLES.margin, children: [
25634
+ /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
25635
+ /* @__PURE__ */ jsx(
25636
+ XAxis,
25637
+ {
25638
+ dataKey: args.x_field,
25639
+ type: "number",
25640
+ name: args.x_field,
25641
+ ...CHART_STYLES.axis
25642
+ }
25643
+ ),
25644
+ /* @__PURE__ */ jsx(
25645
+ YAxis,
25646
+ {
25647
+ dataKey: args.y_field,
25648
+ type: "number",
25649
+ name: args.y_field,
25650
+ ...CHART_STYLES.axis
25651
+ }
25652
+ ),
25653
+ /* @__PURE__ */ jsx(
25654
+ Tooltip,
25655
+ {
25656
+ cursor: { strokeDasharray: "3 3" },
25657
+ content: /* @__PURE__ */ jsx(CustomTooltip, {})
25658
+ }
25659
+ ),
25660
+ /* @__PURE__ */ jsx(
25661
+ Legend,
25662
+ {
25663
+ wrapperStyle: { paddingTop: "20px" },
25664
+ formatter: (value) => /* @__PURE__ */ jsx("span", { className: "text-sm", children: value })
25665
+ }
25666
+ ),
25667
+ Object.entries(groupedData).map(([group, data], index) => /* @__PURE__ */ jsx(
25668
+ Scatter,
25669
+ {
25670
+ name: group,
25671
+ data,
25672
+ fill: CHART_COLOR_PALETTE[index % CHART_COLOR_PALETTE.length]
25673
+ },
25674
+ group
25675
+ ))
25676
+ ] }) }) }) }, `scatter-${key}`);
25394
25677
  case "create_combo_chart":
25395
25678
  console.log("[DEBUG] Rendering combo chart");
25396
25679
  if (!args.data || !args.x_field || !args.bar_field || !args.line_field) {
@@ -25402,19 +25685,65 @@ var AIAgentView = () => {
25402
25685
  });
25403
25686
  return null;
25404
25687
  }
25405
- return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", children: [
25406
- /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, children: [
25407
- /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
25408
- /* @__PURE__ */ jsx(XAxis, { dataKey: args.x_field }),
25409
- /* @__PURE__ */ jsx(YAxis, { yAxisId: "left", orientation: "left" }),
25410
- /* @__PURE__ */ jsx(YAxis, { yAxisId: "right", orientation: "right" }),
25411
- /* @__PURE__ */ jsx(Tooltip, {}),
25412
- /* @__PURE__ */ jsx(Legend, {}),
25413
- /* @__PURE__ */ jsx(Bar, { yAxisId: "left", dataKey: args.bar_field, fill: "#3b82f6", name: args.bar_field }),
25414
- /* @__PURE__ */ jsx(Line, { yAxisId: "right", type: "monotone", dataKey: args.line_field, stroke: "#ef4444", strokeWidth: 2, name: args.line_field })
25415
- ] }) }),
25416
- args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25417
- ] }, `combo-${key}`);
25688
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, margin: CHART_STYLES.margin, children: [
25689
+ /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
25690
+ /* @__PURE__ */ jsx(
25691
+ XAxis,
25692
+ {
25693
+ dataKey: args.x_field,
25694
+ ...CHART_STYLES.axis
25695
+ }
25696
+ ),
25697
+ /* @__PURE__ */ jsx(
25698
+ YAxis,
25699
+ {
25700
+ yAxisId: "left",
25701
+ orientation: "left",
25702
+ ...CHART_STYLES.axis,
25703
+ tickFormatter: (value) => formatNumber(value)
25704
+ }
25705
+ ),
25706
+ /* @__PURE__ */ jsx(
25707
+ YAxis,
25708
+ {
25709
+ yAxisId: "right",
25710
+ orientation: "right",
25711
+ ...CHART_STYLES.axis,
25712
+ tickFormatter: (value) => formatNumber(value)
25713
+ }
25714
+ ),
25715
+ /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CustomTooltip, {}), cursor: { fill: "rgba(0, 0, 0, 0.05)" } }),
25716
+ /* @__PURE__ */ jsx(
25717
+ Legend,
25718
+ {
25719
+ wrapperStyle: { paddingTop: "20px" },
25720
+ formatter: (value) => /* @__PURE__ */ jsx("span", { className: "text-sm", children: value })
25721
+ }
25722
+ ),
25723
+ /* @__PURE__ */ jsx(
25724
+ Bar,
25725
+ {
25726
+ yAxisId: "left",
25727
+ dataKey: args.bar_field,
25728
+ fill: CHART_COLORS.primary,
25729
+ name: args.bar_field,
25730
+ radius: CHART_STYLES.barRadius
25731
+ }
25732
+ ),
25733
+ /* @__PURE__ */ jsx(
25734
+ Line,
25735
+ {
25736
+ yAxisId: "right",
25737
+ type: "monotone",
25738
+ dataKey: args.line_field,
25739
+ stroke: CHART_COLORS.danger,
25740
+ strokeWidth: 2,
25741
+ name: args.line_field,
25742
+ dot: { r: 4 },
25743
+ activeDot: { r: 6 }
25744
+ }
25745
+ )
25746
+ ] }) }) }) }, `combo-${key}`);
25418
25747
  case "create_area_chart":
25419
25748
  console.log("[DEBUG] Rendering area chart");
25420
25749
  if (!args.data || !args.x_field || !args.y_field) {
@@ -25425,27 +25754,48 @@ var AIAgentView = () => {
25425
25754
  });
25426
25755
  return null;
25427
25756
  }
25428
- return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", children: [
25429
- /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, children: [
25430
- /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
25431
- /* @__PURE__ */ jsx(XAxis, { dataKey: args.x_field }),
25432
- /* @__PURE__ */ jsx(YAxis, {}),
25433
- /* @__PURE__ */ jsx(Tooltip, {}),
25434
- /* @__PURE__ */ jsx(Legend, {}),
25435
- /* @__PURE__ */ jsx(
25436
- Area,
25437
- {
25438
- type: "monotone",
25439
- dataKey: args.y_field,
25440
- stroke: "#3b82f6",
25441
- fill: args.fill ? "#3b82f6" : "none",
25442
- fillOpacity: args.fill ? 0.6 : 0,
25443
- name: args.y_field
25444
- }
25445
- )
25757
+ return /* @__PURE__ */ jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, margin: CHART_STYLES.margin, children: [
25758
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: "colorGradient", x1: "0", y1: "0", x2: "0", y2: "1", children: [
25759
+ /* @__PURE__ */ jsx("stop", { offset: "5%", stopColor: CHART_COLORS.primary, stopOpacity: 0.8 }),
25760
+ /* @__PURE__ */ jsx("stop", { offset: "95%", stopColor: CHART_COLORS.primary, stopOpacity: 0.1 })
25446
25761
  ] }) }),
25447
- args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25448
- ] }, `area-${key}`);
25762
+ /* @__PURE__ */ jsx(CartesianGrid, { ...CHART_STYLES.grid }),
25763
+ /* @__PURE__ */ jsx(
25764
+ XAxis,
25765
+ {
25766
+ dataKey: args.x_field,
25767
+ ...CHART_STYLES.axis
25768
+ }
25769
+ ),
25770
+ /* @__PURE__ */ jsx(
25771
+ YAxis,
25772
+ {
25773
+ ...CHART_STYLES.axis,
25774
+ tickFormatter: (value) => formatNumber(value)
25775
+ }
25776
+ ),
25777
+ /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CustomTooltip, {}), cursor: { strokeDasharray: "3 3" } }),
25778
+ /* @__PURE__ */ jsx(
25779
+ Legend,
25780
+ {
25781
+ wrapperStyle: { paddingTop: "20px" },
25782
+ formatter: (value) => /* @__PURE__ */ jsx("span", { className: "text-sm", children: value })
25783
+ }
25784
+ ),
25785
+ /* @__PURE__ */ jsx(
25786
+ Area,
25787
+ {
25788
+ type: "monotone",
25789
+ dataKey: args.y_field,
25790
+ stroke: CHART_COLORS.primary,
25791
+ strokeWidth: 2,
25792
+ fill: args.fill !== false ? "url(#colorGradient)" : "none",
25793
+ name: args.y_field,
25794
+ dot: { r: 4, fill: CHART_COLORS.primary },
25795
+ activeDot: { r: 6 }
25796
+ }
25797
+ )
25798
+ ] }) }) }) }, `area-${key}`);
25449
25799
  default:
25450
25800
  console.warn(`Unknown chart type: ${chartType}`);
25451
25801
  return null;