Documentation Index
Fetch the complete documentation index at: https://mintlify.com/manusapis/Agix/llms.txt
Use this file to discover all available pages before exploring further.
Agix’s chart service bridges AI reasoning and the Office.js Excel API to turn raw data into polished, interactive charts. You can either ask Agix to suggest the best visualisation for your data — complete with confidence scores and reasoning — or supply an explicit configuration and let chartService.generate() build the chart directly in your active worksheet.
Supported chart types
chartService.getSupportedTypes() returns the six chart types Agix can produce:
getSupportedTypes(): ChartType[]
// → ["bar", "line", "scatter", "pie", "area", "radar"]
| Type | Best for |
|---|
bar | Comparing values across discrete categories |
line | Showing trends over time or sequential data |
scatter | Exploring correlation between two numeric columns |
pie | Visualising proportional composition (few slices) |
area | Cumulative or stacked trends over time |
radar | Multi-variable comparison across a common scale |
Getting AI chart suggestions
Before creating a chart, pass your column headers and a sample of row values to suggestChartType(). Agix analyses the data shape and returns a sorted array of ChartSuggestion objects, each with a confidence score between 0 and 1 and a plain-English reasoning string.
suggestChartType(headers: string[], sampleValues: unknown[][]): ChartSuggestion[]
Example response:
[
{
chartType: "bar",
confidence: 0.8,
reasoning: "Categorical data detected in the first column."
},
{
chartType: "line",
confidence: 0.6,
reasoning: "Sequential data pattern identified."
}
]
The array is sorted by confidence descending, so suggestions[0] is always the highest-ranked recommendation. You can present all suggestions to the user or automatically use the first.
Types
The chart service is fully typed through src/types/chart.types.ts:
export type ChartType = "bar" | "line" | "scatter" | "pie" | "area" | "radar";
export interface ChartConfig {
type: ChartType;
title: string;
dataRange: string; // Excel range address, e.g. "A1:B12"
labelColumn: string; // Column letter for axis labels
valueColumns: string[]; // One or more value column letters
colorPalette?: string[];
showLegend: boolean;
stacked: boolean;
}
export interface ChartResult {
chartId: string; // UUID generated at creation time
config: ChartConfig;
imageBase64?: string;
excelChartName?: string; // The title set on the Excel chart object
}
export interface ChartSuggestion {
chartType: ChartType;
confidence: number; // 0–1
reasoning: string;
}
Generating a chart
Call chartService.generate(config) with a ChartConfig object. The service uses Excel.run() to add a native chart to the active worksheet via sheet.charts.add(), set the title, and configure legend visibility, then syncs with the Office runtime.
const result = await chartService.generate({
type: "bar",
dataRange: "A1:B12",
title: "Monthly Revenue",
labelColumn: "A",
valueColumns: ["B"],
showLegend: true,
stacked: false,
});
// result: { chartId: "uuid", config: { ... }, excelChartName: "Monthly Revenue" }
The returned ChartResult includes a UUID chartId you can store and reference later — for example, when embedding charts in a PDF or PowerPoint report via pdfService.appendChart() or powerpointService.generate().
End-to-end example
The following shows a typical flow: read the selection, get a suggestion, then generate the top-ranked chart.
import { excelService } from "@/services/excel/excel.service";
import { chartService } from "@/services/charts/chart.service";
// 1. Read the selected range
const selection = await excelService.getSelectedRange();
const headers = selection.values[0] as string[];
const sampleValues = selection.values.slice(1, 6); // first 5 data rows
// 2. Ask Agix for the best chart type
const suggestions = chartService.suggestChartType(headers, sampleValues);
const best = suggestions[0]; // highest confidence
// 3. Generate the chart
const result = await chartService.generate({
type: best.chartType,
dataRange: selection.address,
title: "AI-Suggested Chart",
labelColumn: "A",
valueColumns: ["B"],
showLegend: true,
stacked: false,
});
console.log(`Created "${result.excelChartName}" (${result.chartId})`);
Select your data range in the sheet before asking Agix to create a chart. With a range already highlighted, clicking Use selection in the Chat panel inserts the address (e.g. Sheet1!A1:C24) directly into the prompt. You can then type “Create a bar chart from this range titled Q1 Sales” and Agix will populate the ChartConfig from your request automatically.