Skip to main content
Glama

Slope Chart

render_slope_chart
Read-onlyIdempotent

Show how rankings change between two time periods: slope charts with lines connecting start and end positions to reveal shifts.

Instructions

Render a slope chart - 'How did rankings change?' SVG lines connecting two time periods showing relative position changes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesChart title
periodStartYesLabel for start period (e.g. '2024')
periodEndYesLabel for end period (e.g. '2025')
dataYesArray of {label, start, end} 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 renderSlopeChart function that implements the 'render_slope_chart' tool. It renders a slope chart (inline SVG with lines connecting start/end values per data item) into the provided container element.
    export function renderSlopeChart(container: HTMLElement, payload: SlopeData): 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 allVals = payload.data.flatMap((d) => [d.start, d.end]);
      const minVal = Math.min(...allVals);
      const maxVal = Math.max(...allVals);
      const range = maxVal - minVal || 1;
    
      const svgW = 460;
      const svgH = Math.max(120, payload.data.length * 28 + 20);
      const padX = 90;
      const padY = 10;
      const lineX1 = padX;
      const lineX2 = svgW - padX;
    
      function yPos(val: number): number {
        return padY + ((maxVal - val) / range) * (svgH - 2 * padY);
      }
    
      const groups = payload.data.map((item, i) => {
        const color = item.color || colors[i % colors.length];
        const y1 = yPos(item.start);
        const y2 = yPos(item.end);
        return `
          <g class="slope__group" data-idx="${i}" style="cursor:pointer">
            <line class="slope__line" x1="${lineX1}" y1="${y1}" x2="${lineX2}" y2="${y2}" stroke="${color}" />
            <circle class="slope__dot" cx="${lineX1}" cy="${y1}" fill="${color}" />
            <circle class="slope__dot" cx="${lineX2}" cy="${y2}" fill="${color}" />
            <text class="slope__label-left" x="${lineX1 - 6}" y="${y1 + 4}">${escapeHtml(item.label)} ${item.start}</text>
            <text class="slope__label-right" x="${lineX2 + 6}" y="${y2 + 4}">${item.end} ${escapeHtml(item.label)}</text>
          </g>
        `;
      }).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="slope">
              <div class="slope__labels">
                <span>${escapeHtml(payload.periodStart)}</span>
                <span>${escapeHtml(payload.periodEnd)}</span>
              </div>
              <svg class="slope__svg" viewBox="0 0 ${svgW} ${svgH}" preserveAspectRatio="xMidYMid meet">
                ${groups}
              </svg>
            </div>
          </div>
        </div>
      `;
    
      container.querySelectorAll<SVGGElement>(".slope__group").forEach((el) => {
        el.addEventListener("click", () => {
          const idx = parseInt(el.dataset.idx ?? "0", 10);
          const item = payload.data[idx];
          sendClickMessage(`[Slope] "${payload.title}" - ${item.label}: ${item.start} -> ${item.end}`);
        });
      });
    
      const card = container.querySelector<HTMLElement>(".chart-card")!;
      addHtmlExportButton(card, payload.title);
      addRefreshButton(card, () => (window as any).__mcpRefresh?.());
    }
  • Type definitions (SlopeItem and SlopeData) that define the input schema for the slope chart tool.
    interface SlopeItem {
      label: string;
      start: number;
      end: number;
      color?: string;
    }
    
    interface SlopeData {
      type: "slope";
      title: string;
      periodStart: string;
      periodEnd: string;
      data: SlopeItem[];
      theme?: string;
      palette?: string;
      typography?: string;
      effects?: string;
    }
  • Registers the slope chart type 'slope' with tool name 'render_slope_chart' pointing to the renderSlopeChart handler via registerChart().
    registerChart("slope", "render_slope_chart", renderSlopeChart);
  • The registerChart function definition in shared.ts which stores chart type → (toolName, render) mappings in the CHART_REGISTRY.
    export function registerChart(
      type: string,
      toolName: string,
      render: (root: HTMLElement, data: any) => void,
    ): void {
      CHART_REGISTRY[type] = { toolName, render };
    }
    
    export function getChartEntry(type: string): ChartEntry | undefined {
      return CHART_REGISTRY[type];
    }
    
    export function getTypeToToolMap(): Record<string, string> {
      const map: Record<string, string> = {};
      for (const [type, entry] of Object.entries(CHART_REGISTRY)) {
        map[type] = entry.toolName;
      }
      return map;
    }
  • The resolveTheme helper used by renderSlopeChart to resolve palette, typography, and effects from a theme name or overrides.
    export function resolveTheme(
      name?: string,
      overrides?: { palette?: string; typography?: string; effects?: string },
    ): ThemePreset | null {
      if (!name && !overrides?.palette && !overrides?.typography && !overrides?.effects) {
        return null;
      }
    
      const base = name ? THEME_PRESETS[name] : null;
    
      const palette = overrides?.palette
        ? PALETTES[overrides.palette]
        : base?.palette ?? null;
      const typography = overrides?.typography
        ? TYPOGRAPHY_SETS[overrides.typography]
        : base?.typography ?? null;
      const effects = overrides?.effects
        ? EFFECT_PRESETS[overrides.effects]
        : base?.effects ?? null;
    
      if (!palette) return null;
    
      return {
        name: name ?? "custom",
        palette,
        typography: typography ?? TYPOGRAPHY_SETS.system,
        effects: effects ?? EFFECT_PRESETS.none,
      };
    }
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, and idempotentHint=true. The description adds that it produces SVG lines, which is mildly informative but does not disclose any additional behavioral traits beyond what annotations cover.

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 a single sentence that immediately states the tool's action and purpose. No wasted words; direct and front-loaded.

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?

For a 8-parameter chart tool with no output schema, the description covers the core behavior and output format (SVG lines). It omits details about optional style parameters, but those are fully documented in the schema. The main functional context is sufficient.

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 8 parameters have descriptions in the input schema (100% coverage). The description does not add any extra meaning or usage hints for the parameters, so it stays at baseline.

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 specifies the verb 'Render', the resource 'slope chart', and explains it visualizes ranking changes across two time periods with SVG lines. This distinguishes it from other chart tools in the sibling list.

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 on when to use this tool versus alternatives like render_line_chart or render_variance_chart. The description only states what it does, not when it's appropriate.

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