Skip to main content
Glama

generate_heatmap_chart

Create a heatmap chart to visualize data density or intensity distribution, such as user activity patterns by time and day or correlation matrices. Customize axis titles, dimensions, themes, and export formats like PNG, SVG, or ECharts options.

Instructions

Generate a heatmap chart to display data density or intensity distribution, such as, user activity patterns by time and day, or correlation matrix.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
axisXTitleNoSet the x-axis title of chart.
axisYTitleNoSet the y-axis title of chart.
dataYesData for heatmap chart, such as, [{ x: 'Mon', y: '12AM', value: 5 }, { x: 'Tue', y: '1AM', value: 3 }].
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
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 core handler function 'run' that processes the input data, transforms it into ECharts heatmap format, configures the chart options including visual map, axes, and series, and generates the final chart image using generateChartImage utility.
    run: async (params: {
      axisXTitle?: string;
      axisYTitle?: string;
      data: Array<{ x: string | number; y: string | number; value: number }>;
      height: number;
      theme?: "default" | "dark";
      title?: string;
      width: number;
      outputType?: "png" | "svg" | "option";
    }) => {
      const {
        axisXTitle,
        axisYTitle,
        data,
        height,
        theme,
        title,
        width,
        outputType,
      } = params;
    
      // Extract unique x and y values
      const xValues = Array.from(new Set(data.map((item) => item.x))).sort();
      const yValues = Array.from(new Set(data.map((item) => item.y))).sort();
    
      // Create data map for quick lookup
      const dataMap = new Map();
      for (const item of data) {
        dataMap.set(`${item.x}_${item.y}`, item.value);
      }
    
      // Transform data for ECharts heatmap
      const heatmapData = [];
      for (let i = 0; i < xValues.length; i++) {
        for (let j = 0; j < yValues.length; j++) {
          const value = dataMap.get(`${xValues[i]}_${yValues[j]}`) || 0;
          heatmapData.push([i, j, value]);
        }
      }
    
      // Calculate value range for visual map
      const values = data.map((item) => item.value);
      const minValue = Math.min(...values);
      const maxValue = Math.max(...values);
    
      const series: Array<SeriesOption> = [
        {
          type: "heatmap",
          data: heatmapData,
          label: {
            show: true,
            fontSize: 10,
          },
          emphasis: {
            itemStyle: {
              shadowBlur: 10,
              shadowColor: "rgba(0, 0, 0, 0.5)",
            },
          },
        },
      ];
    
      const echartsOption: EChartsOption = {
        grid: {
          height: "60%",
          top: "15%",
          right: "15%",
          bottom: "10%",
        },
        series,
        title: {
          left: "center",
          text: title,
          top: "3%",
        },
        tooltip: {
          position: "top",
        },
        visualMap: {
          min: minValue,
          max: maxValue,
          calculable: true,
          orient: "horizontal",
          left: "center",
          bottom: "15%",
          inRange: {
            color: [
              "#313695",
              "#4575b4",
              "#74add1",
              "#abd9e9",
              "#e0f3f8",
              "#ffffcc",
              "#fee090",
              "#fdae61",
              "#f46d43",
              "#d73027",
              "#a50026",
            ],
          },
        },
        xAxis: {
          type: "category",
          data: xValues,
          name: axisXTitle,
          splitArea: {
            show: true,
          },
        },
        yAxis: {
          type: "category",
          data: yValues,
          name: axisYTitle,
          splitArea: {
            show: true,
          },
        },
      };
    
      return await generateChartImage(
        echartsOption,
        width,
        height,
        theme,
        outputType,
        "generate_heatmap_chart",
      );
    },
  • Zod input schema defining parameters like axis titles, data array of {x, y, value}, dimensions, theme, title, and output type for the generate_heatmap_chart tool.
    inputSchema: z.object({
      axisXTitle: AxisXTitleSchema,
      axisYTitle: AxisYTitleSchema,
      data: z
        .array(data)
        .describe(
          "Data for heatmap chart, such as, [{ x: 'Mon', y: '12AM', value: 5 }, { x: 'Tue', y: '1AM', value: 3 }].",
        )
        .nonempty({ message: "Heatmap chart data cannot be empty." }),
      height: HeightSchema,
      theme: ThemeSchema,
      title: TitleSchema,
      width: WidthSchema,
      outputType: OutputTypeSchema,
    }),
  • Registration of all chart tools including generateHeatmapChartTool in the exported 'tools' array, likely used by the MCP server to register the tool.
    export const tools = [
      generateEChartsTool,
      generateLineChartTool,
      generateBarChartTool,
      generatePieChartTool,
      generateRadarChartTool,
      generateScatterChartTool,
      generateSankeyChartTool,
      generateFunnelChartTool,
      generateGaugeChartTool,
      generateTreemapChartTool,
      generateSunburstChartTool,
      generateHeatmapChartTool,
      generateCandlestickChartTool,
      generateBoxplotChartTool,
      generateGraphChartTool,
      generateParallelChartTool,
      generateTreeChartTool,
    ];
  • Re-export of generateHeatmapChartTool for convenient use.
    generateHeatmapChartTool,
  • Zod schema for individual heatmap data points used in the input schema.
    const data = z.object({
      x: z
        .union([z.string(), z.number()])
        .describe("X axis value, such as 'Mon' or 0."),
      y: z
        .union([z.string(), z.number()])
        .describe("Y axis value, such as 'AM' or 0."),
      value: z.number().describe("Heat value at this position, such as 5."),
    });
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. It states the tool generates a chart but doesn't cover critical aspects like whether it's a read-only operation, if it has side effects (e.g., saving files), performance considerations, or error handling. The examples hint at output types (e.g., PNG, SVG via schema), but the description itself lacks explicit behavioral details, leaving significant gaps.

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 concise and front-loaded, stating the core purpose in the first clause. The examples ('user activity patterns by time and day, or correlation matrix') are relevant and add clarity without unnecessary elaboration. It could be slightly more structured by explicitly separating purpose from examples, but overall, it's efficient with no wasted sentences.

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 complexity (8 parameters, no output schema, and no annotations), the description is insufficient. It doesn't explain what the tool returns (e.g., an image, data, or error messages), how to handle the output, or any prerequisites for use. With rich schema coverage but missing behavioral and output context, the description leaves the agent under-informed for proper tool invocation.

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?

The schema description coverage is 100%, meaning all parameters are well-documented in the schema itself. The description adds minimal value beyond the schema by mentioning 'data density or intensity distribution' and examples like 'user activity patterns,' which loosely relate to the data parameter but don't provide additional syntax or usage details. This meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Generate a heatmap chart to display data density or intensity distribution.' It provides specific examples like 'user activity patterns by time and day' and 'correlation matrix,' which help clarify the use case. However, it doesn't explicitly differentiate from sibling tools (e.g., other chart types), which prevents a perfect score.

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 offers no guidance on when to use this tool versus alternatives. With many sibling tools for different chart types (e.g., generate_bar_chart, generate_line_chart), there's no mention of when a heatmap is preferred (e.g., for matrix data or density visualization) or when other charts might be better. This lack of comparative context leaves the agent without usage direction.

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