Skip to main content
Glama

generate_line_chart

Create a line chart to visualize trends over time, such as sales vs. profits. Customize axes, themes, and formats (PNG, SVG). Supports multiple series, stacking, and smooth curves for detailed data analysis.

Instructions

Generate a line chart to show trends over time, such as, the ratio of Apple computer sales to Apple's profits changed from 2000 to 2016.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
axisXTitleNoSet the x-axis title of chart.
axisYTitleNoSet the y-axis title of chart.
dataYesData for line chart, such as, [{ time: '2015', value: 23 }, { time: '2016', value: 32 }]. For multiple series: [{ group: 'Series A', time: '2015', value: 23 }, { group: 'Series B', time: '2015', value: 18 }].
heightNoSet the height of the chart, default is 600px.
outputTypeNoThe output type of the diagram. Can be 'png', 'svg' or 'option'. Default is 'png', 'png' will return the rendered PNG image, 'svg' will return the rendered SVG string, and 'option' will return the valid ECharts option.png
showAreaNoWhether to fill the area under the line. Default is false.
showSymbolNoWhether to show symbols on data points. Default is true.
smoothNoWhether to use a smooth curve. Default is false.
stackNoWhether stacking is enabled. When enabled, line charts require a 'group' field in the data.
themeNoSet the theme for the chart, optional, default is 'default'.default
titleNoSet the title of the chart.
widthNoSet the width of the chart, default is 800px.

Implementation Reference

  • The complete tool object defining the 'generate_line_chart' tool, including its name, description, input schema (Zod validation), and the 'run' handler function that processes input data to create an ECharts line chart configuration and generates the output image.
    export const generateLineChartTool = {
      name: "generate_line_chart",
      description:
        "Generate a line chart to show trends over time, such as, the ratio of Apple computer sales to Apple's profits changed from 2000 to 2016.",
      inputSchema: z.object({
        axisXTitle: AxisXTitleSchema,
        axisYTitle: AxisYTitleSchema,
        data: z
          .array(data)
          .describe(
            "Data for line chart, such as, [{ time: '2015', value: 23 }, { time: '2016', value: 32 }]. For multiple series: [{ group: 'Series A', time: '2015', value: 23 }, { group: 'Series B', time: '2015', value: 18 }].",
          )
          .nonempty({ message: "Line chart data cannot be empty." }),
        height: HeightSchema,
        showArea: z
          .boolean()
          .optional()
          .default(false)
          .describe("Whether to fill the area under the line. Default is false."),
        showSymbol: z
          .boolean()
          .optional()
          .default(true)
          .describe("Whether to show symbols on data points. Default is true."),
        smooth: z
          .boolean()
          .optional()
          .default(false)
          .describe("Whether to use a smooth curve. Default is false."),
        stack: z
          .boolean()
          .optional()
          .default(false)
          .describe(
            "Whether stacking is enabled. When enabled, line charts require a 'group' field in the data.",
          ),
        theme: ThemeSchema,
        title: TitleSchema,
        width: WidthSchema,
        outputType: OutputTypeSchema,
      }),
      run: (params: {
        axisXTitle?: string;
        axisYTitle?: string;
        data: Array<{ time: string; value: number; group?: string }>;
        height: number;
        showArea?: boolean;
        showSymbol?: boolean;
        smooth?: boolean;
        stack?: boolean;
        theme?: "default" | "dark";
        title?: string;
        width: number;
        outputType?: "png" | "svg" | "option";
      }) => {
        const {
          axisXTitle,
          axisYTitle,
          data,
          height,
          showArea,
          showSymbol,
          smooth,
          stack,
          theme,
          title,
          width,
          outputType,
        } = params;
    
        // Check if data has group field for multiple series
        const hasGroups = data.some((item) => item.group);
    
        let series: Array<SeriesOption> = [];
        let categories: string[] = [];
    
        if (hasGroups) {
          // Handle multiple series data
          const groupMap = new Map<
            string,
            Array<{ time: string; value: number }>
          >();
          const timeSet = new Set<string>();
    
          // Group data by group field and collect all time points
          for (const item of data) {
            const groupName = item.group || "Default";
            if (!groupMap.has(groupName)) {
              groupMap.set(groupName, []);
            }
            const groupData = groupMap.get(groupName);
            if (groupData) {
              groupData.push({ time: item.time, value: item.value });
            }
            timeSet.add(item.time);
          }
    
          // Sort time points
          categories = Array.from(timeSet).sort();
    
          // Create series for each group
          groupMap.forEach((groupData, groupName) => {
            // Create a map for quick lookup
            const dataMap = new Map(groupData.map((d) => [d.time, d.value]));
    
            // Fill values for all time points (null for missing data)
            const values = categories.map((time) => dataMap.get(time) ?? null);
    
            series.push({
              areaStyle: showArea ? {} : undefined,
              connectNulls: false,
              data: values,
              name: groupName,
              showSymbol,
              smooth,
              stack: stack ? "Total" : undefined,
              type: "line",
            });
          });
        } else {
          // Handle single series data
          categories = data.map((item) => item.time);
          const values = data.map((item) => item.value);
    
          series = [
            {
              areaStyle: showArea ? {} : undefined,
              data: values,
              showSymbol,
              smooth,
              stack: stack ? "Total" : undefined,
              type: "line",
            },
          ];
        }
    
        const echartsOption: EChartsOption = {
          legend: hasGroups
            ? {
                left: "center",
                orient: "horizontal",
                bottom: 10,
              }
            : undefined,
          series,
          title: {
            left: "center",
            text: title,
          },
          tooltip: {
            trigger: "axis",
          },
          xAxis: {
            boundaryGap: false,
            data: categories,
            name: axisXTitle,
            type: "category",
          },
          yAxis: {
            name: axisYTitle,
            type: "value",
          },
        };
    
        return generateChartImage(
          echartsOption,
          width,
          height,
          theme,
          outputType,
          "generate_line_chart",
        );
      },
    };
  • The generateLineChartTool is registered by being included in the central 'tools' array export, which aggregates all MCP tools for higher-level registration.
    export const tools = [
      generateEChartsTool,
      generateLineChartTool,
      generateBarChartTool,
      generatePieChartTool,
      generateRadarChartTool,
      generateScatterChartTool,
      generateSankeyChartTool,
      generateFunnelChartTool,
      generateGaugeChartTool,
      generateTreemapChartTool,
      generateSunburstChartTool,
      generateHeatmapChartTool,
      generateCandlestickChartTool,
      generateBoxplotChartTool,
      generateGraphChartTool,
      generateParallelChartTool,
      generateTreeChartTool,
    ];
  • Import of generateLineChartTool from './line.ts' and its inclusion in exports.
    import { generateLineChartTool } from "./line";
    import { generateParallelChartTool } from "./parallel";
    import { generatePieChartTool } from "./pie";
    import { generateRadarChartTool } from "./radar";
    import { generateSankeyChartTool } from "./sankey";
    import { generateScatterChartTool } from "./scatter";
    import { generateSunburstChartTool } from "./sunburst";
    import { generateTreeChartTool } from "./tree";
    import { generateTreemapChartTool } from "./treemap";
    
    export const tools = [
      generateEChartsTool,
      generateLineChartTool,
      generateBarChartTool,
      generatePieChartTool,
      generateRadarChartTool,
      generateScatterChartTool,
      generateSankeyChartTool,
      generateFunnelChartTool,
      generateGaugeChartTool,
      generateTreemapChartTool,
      generateSunburstChartTool,
      generateHeatmapChartTool,
      generateCandlestickChartTool,
      generateBoxplotChartTool,
      generateGraphChartTool,
      generateParallelChartTool,
      generateTreeChartTool,
    ];
    
    // Re-export individual tools for convenient use in tests and other places
    export {
      generateEChartsTool,
      generateLineChartTool,
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states what the tool does (generate a line chart) but does not disclose any behavioral traits such as output format (image vs. data), performance characteristics, error handling, or dependencies. For a complex tool with 12 parameters, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose with an example. It is appropriately sized and front-loaded, with no redundant information. However, it could be slightly more structured by explicitly mentioning key parameters like 'data' or 'outputType' to enhance clarity without adding waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (12 parameters, no output schema, no annotations), the description is incomplete. It does not explain what the tool returns (e.g., an image file, SVG string, or configuration object), how to handle errors, or any limitations (e.g., data size constraints). For a chart generation tool with multiple output types and configurations, the description should provide more context to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 12 parameters thoroughly. The description adds minimal value beyond the schema—it provides a concrete example of data format ('ratio of Apple computer sales to Apple's profits changed from 2000 to 2016') which hints at the 'data' parameter's structure, but does not explain parameter interactions or usage nuances. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'Generate a line chart to show trends over time' which clarifies the verb (generate) and resource (line chart). However, it only provides a generic example ('ratio of Apple computer sales to Apple's profits changed from 2000 to 2016') without distinguishing it from sibling tools like generate_scatter_chart or generate_bar_chart that might also show trends. The purpose is clear but lacks sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no explicit guidance on when to use this tool versus alternatives. It mentions 'trends over time' which implies usage for temporal data, but does not specify when to choose line charts over other chart types (e.g., bar charts for categorical comparisons or scatter plots for correlations). There are no exclusions or prerequisites mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hustcc/mcp-echarts'

If you have feedback or need assistance with the MCP directory API, please join our Discord server