Skip to main content
Glama

generate_heatmap_chart

Generate a heatmap chart to visualize data density or intensity across two dimensions. Useful for patterns like user activity by time and day or correlation matrices. Customize axes, title, and output format (PNG, SVG, ECharts option).

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.
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.
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

Implementation Reference

  • Tool handler/run function for generate_heatmap_chart: transforms user data into ECharts heatmap configuration and calls generateChartImage to produce the output (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",
      );
    },
  • Input schema definition for generate_heatmap_chart, defines data array, axis titles, dimensions, theme, output type.
    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,
    }),
  • Internal data item schema for heatmap chart entries with x, y coordinates and heat value.
    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."),
    });
  • src/index.ts:28-35 (registration)
    Registration of all tools (including generate_heatmap_chart) with the MCP server by iterating the array from src/tools/index.ts.
      for (const tool of tools) {
        const { name, description, inputSchema, run } = tool;
        // biome-ignore lint/suspicious/noExplicitAny: <explanation>
        server.tool(name, description, inputSchema.shape as any, run as any);
      }
    
      return server;
    }
  • Registration of generateHeatmapChartTool in the tools array, which is then used by the server to register as an MCP tool.
    export const tools = [
      generateEChartsTool,
      generateAreaChartTool,
      generateLineChartTool,
      generateBarChartTool,
      generatePieChartTool,
      generateRadarChartTool,
      generateScatterChartTool,
      generateSankeyChartTool,
      generateFunnelChartTool,
      generateGaugeChartTool,
      generateTreemapChartTool,
      generateSunburstChartTool,
      generateHeatmapChartTool,
      generateCandlestickChartTool,
      generateBoxplotChartTool,
      generateGraphChartTool,
      generateParallelChartTool,
      generateTreeChartTool,
    ];
Behavior2/5

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

No annotations are provided, so the description bears full responsibility for behavioral transparency. It fails to mention any side effects, required permissions, or whether the tool is read-only. It merely describes the output, which is already detailed in the schema.

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 sentence, concise and front-loaded with the core purpose. It is efficient but could benefit from a structured breakdown of key considerations.

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

Completeness3/5

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

Given the complexity of the tool (8 parameters, many siblings), the description is minimal. It lacks context on when to choose a heatmap over other chart types and does not mention any constraints beyond what is in the schema.

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 coverage is 100%, so the schema already documents all parameters. The description adds no additional meaning or context beyond what is in the schema, achieving the baseline of 3.

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

Purpose5/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, with concrete examples (user activity patterns, correlation matrix). It effectively distinguishes from sibling chart tools by specifying the chart type.

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?

No guidance is provided on when to use this tool versus alternatives like scatter or line charts. The description only states what it does, without indicating use cases or exclusions.

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

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