Skip to main content
Glama

Waffle Chart

render_waffle_chart
Read-onlyIdempotent

Visualize proportional composition using a 10x10 grid of colored squares, where each value represents a percentage and all sum to 100.

Instructions

Render a waffle chart - 'What is the composition?' 10x10 grid of colored squares showing proportional composition. Values should sum to 100.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesChart title
dataYesArray of {label, value} composition items
themeNoTheme preset: boardroom, corporate, sales-floor, golden-treasury, clinical, startup, ops-control, tokyo-midnight, zen-garden, consultant, black-tron, black-elegance, black-matrix, forest-amber, forest-earth, sky-light, sky-ocean, sky-twilight, gray-hf, gray-copilot
paletteNoOverride palette only (mix-and-match)
typographyNoOverride typography: professional, luxury, cyberpunk, editorial, mono, bold, system, techno
effectsNoOverride effects: none, subtle, shimmer, neon, energetic

Implementation Reference

  • The main handler function renderWaffleChart that renders a 100-cell waffle chart. It resolves themes, calculates proportional counts per item, builds a grid of cells with colors, renders the HTML with legend, attaches a click handler to send selection messages, and adds export/refresh buttons.
    export function renderWaffleChart(container: HTMLElement, payload: WaffleData): void {
      const theme = resolveTheme(payload.theme, {
        palette: payload.palette,
        typography: payload.typography,
        effects: payload.effects,
      });
      if (theme) applyTheme(container, theme);
    
      const shimmer = theme?.effects.shimmerTitle ? " shimmer-text" : "";
      const colors = resolveColors(undefined, payload.data.length);
      const total = payload.data.reduce((s, d) => s + d.value, 0);
    
      // Build 100-cell grid
      const cells: { color: string; label: string }[] = [];
      let remaining = 100;
      payload.data.forEach((item, i) => {
        const count = Math.round((item.value / total) * 100);
        const actualCount = Math.min(count, remaining);
        const color = item.color || colors[i % colors.length];
        for (let j = 0; j < actualCount; j++) {
          cells.push({ color, label: item.label });
        }
        remaining -= actualCount;
      });
      // Fill any rounding gap with last color
      while (cells.length < 100 && payload.data.length > 0) {
        const last = payload.data[payload.data.length - 1];
        cells.push({ color: last.color || colors[(payload.data.length - 1) % colors.length], label: last.label });
      }
    
      const cellsHtml = cells.map((c, i) =>
        `<div class="waffle__cell" style="background:${c.color}" title="${escapeHtml(c.label)}" data-idx="${i}"></div>`
      ).join("");
    
      const legendHtml = payload.data.map((item, i) => {
        const color = item.color || colors[i % colors.length];
        const pct = total > 0 ? ((item.value / total) * 100).toFixed(0) : "0";
        return `
          <span class="waffle__legend-item">
            <span class="waffle__legend-dot" style="background:${color}"></span>
            ${escapeHtml(item.label)} (${pct}%)
          </span>
        `;
      }).join("");
    
      container.className = "chart-view";
      container.innerHTML = `
        <div class="card chart-card">
          <div class="chart-card__header">
            <div><div class="chart-card__title${shimmer}">${escapeHtml(payload.title)}</div></div>
          </div>
          <div class="chart-card__body chart-card__body--css">
            <div class="waffle">
              <div class="waffle__grid">${cellsHtml}</div>
              <div class="waffle__legend">${legendHtml}</div>
            </div>
          </div>
        </div>
      `;
    
      container.querySelector(".waffle__grid")?.addEventListener("click", (e) => {
        const cell = (e.target as HTMLElement).closest<HTMLElement>(".waffle__cell");
        if (!cell) return;
        sendClickMessage(`[Waffle] "${payload.title}" - ${cell.title}`);
      });
    
      const card = container.querySelector<HTMLElement>(".chart-card")!;
      addHtmlExportButton(card, payload.title);
      addRefreshButton(card, () => (window as any).__mcpRefresh?.());
    }
  • TypeScript interfaces WaffleItem (label, value, optional color) and WaffleData (type 'waffle', title, data array, optional theme/palette/typography/effects) defining the input schema for the waffle chart tool.
    interface WaffleItem {
      label: string;
      value: number;
      color?: string;
    }
    
    interface WaffleData {
      type: "waffle";
      title: string;
      data: WaffleItem[];
      theme?: string;
      palette?: string;
      typography?: string;
      effects?: string;
    }
  • Registration call: registerChart('waffle', 'render_waffle_chart', renderWaffleChart) which maps the chart type 'waffle' to tool name 'render_waffle_chart' and the render handler.
    registerChart("waffle", "render_waffle_chart", renderWaffleChart);
  • src/app.ts:27-27 (registration)
    Side-effect import of ./charts/waffle.js in app.ts which triggers the self-registration via registerChart() call.
    import "./charts/waffle.js";
  • The registerChart function in shared.ts which stores chart type -> {toolName, render} entries in the CHART_REGISTRY for later dispatch by app.ts.
    export function registerChart(
      type: string,
      toolName: string,
      render: (root: HTMLElement, data: any) => void,
    ): void {
      CHART_REGISTRY[type] = { toolName, render };
    }
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, so the description does not need to reiterate safety. The description adds the grid size (10x10) and value constraint (sum to 100), which are useful but not critical beyond annotations.

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

Conciseness5/5

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

The description is two sentences, front-loaded with the purpose, and every word adds value. No redundancy or filler.

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

Completeness4/5

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

The description covers the essential purpose and grid constraint. However, it does not mention the output format (likely an image) or that the chart is rendered in a specific environment. Given the schema richness, this is a minor gap.

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?

All parameters have descriptions in the schema (100% coverage), and the description repeats the value-sum constraint already in the schema. No additional semantic information is provided for parameters like theme, palette, etc.

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 renders a waffle chart, specifying it's a 10x10 grid of colored squares for proportional composition. This distinguishes it from other chart types like pie or funnel charts that also show composition.

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

Usage Guidelines3/5

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

The phrase 'What is the composition?' implies use for composition questions, but there is no explicit guidance on when to use this tool versus alternatives such as render_pie_chart or render_treemap_chart. No exclusion criteria or context is provided.

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/KyuRish/mcp-dashboards'

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