VSeed, an elegant data composer, transforming complexity into simplicity.
!!!###!!!title=text2Chart——VisActor/VMind api documents!!!###!!!
text2Chart
Interface Description:
The text2Chart function is used to call the LLM to complete two tasks: data extraction and intelligent chart generation. It returns the generated chart spec, chart two-dimensional data table, chart type, and field mapping, etc. This function enables the intelligent process of generating charts from plain text in one step.
text (string): Required, the original text content
userPrompt (string): Optional, the user's visualization intent (what data you mainly want to extract from the text and how to display it with a chart)
options: Optional, option parameters, including:
fieldInfo (Array): Field information contained in the text type, including field names, types, etc.; in scenarios where fieldInfo is provided, VMind will only extract content related to the passed fieldInfo
chartTypeList (ChartType[], optional): Supported chart type list. If not undefined, a chart will be generated from the chart types specified in this list.
enableDataQuery (boolean, optional): Decides whether to enable data aggregation during chart generation
colorPalette (Array, optional): Used to set the color palette of the chart
animationDuration (number, optional): Used to set the playback duration of the chart animation
theme (ChartTheme | string, optional): Sets the theme style of the final spec. By default, VMind uses a theme style with gradient colors. You can set VChart's general light or dark theme ('light' | 'dark') or a theme style that suits your usage scenario
Return Value Type:
interface GenerateChartResult {
/** Chart spec */spec: Record<string, any>;
/** Extracted data */ dataTable: DataTable;
/** Field information */ fieldInfo: FieldInfo[];
/** Chart type */ chartType: ChartType;
/** Final visual channel mapping */ cell: Cell;
/** Token consumption */ usage: Usage;
/* Specific command to generate the current chart, consistent with user prompt if provided */ command: string;
/** Configuration time used for converting to gif/video */ time: {
totalTime : number;
frameArr: number[];
};
/** Rule-based chart recommendation results, generated when manually setting rules or when the large model generation is incorrect */ chartAdvistorRes: {
/** Chart spec */spec: Record<string, any>;
/** Chart type */ chartType: ChartType;
/** Recommendation score */ score: number }[]
}
spec (Object): The generated VChart chart spec. If the dataset is empty, it is a spec template without data
dataTable (Record<string, string | number>[]): The two-dimensional table data extracted from the text
fieldInfo (FieldInfo): Field information extracted from the text when the user has not provided fieldInfo, i.e., the header information of the two-dimensional table
chartType (ChartType): The generated chart type, see the "Chart Type List" section
cell (Record<string, string | string[]>): Field mapping in the chart, describing how fields in the dataset are mapped to various visual channels of the chart
usage (any): Total LLM token consumption
time (number): Duration information of the chart animation, can be used for exporting GIFs and videos
chartAdvistorRes(Array): This result is the chart recommendation result deduced based on the current data and field information through VMind's built-in rules, generated as a fallback when some wrong happens in LLM. See: Rule-Based Chart Generation