Skip to main content
Glama

Generate chart code

generate_chart

Generate ready-to-render chart code for a dataset: the backend picks a suitable chart type (or honors chart_type) and returns code that has passed its eligibility gates and quality checks. Pass the table as data ({columns, rows}) or csv_text. This hosted server receives your table, profiles it in memory and sends only the profile to generation; rows aren't stored or logged. The code and the render-ready data come back inline in the reply; this server writes no files. JavaScript (D3) unless you pass language or renderer. The D3 code is a portable render(container, data, options) function meant to be MERGED into your own app; an integration contract describes exactly how to call it. A generation uses your account's credits. The arguments chart_style, level_of_detail and culture are the person's choices, and the guide's 'settings' topic lists every choice a person can make with its options.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "generate_chart"
  }
}

Input Schema

NameRequiredDescriptionDefault
dataNoA pre-typed {columns, rows} table — the shape a Fabric DAX query / dataframe already has. Alternative to csv_path/csv_text; when columns carry isMeasure/format/description the shape matches PBI fidelity with no guessing.
wrapNoCode form: 'none' (default) = the raw render() function to merge; 'esm' = same code plus `export { render };` so the file can be `import`ed. Both forms are accepted everywhere - @bicharts/chart-host strips the export clause before compiling - so this is a convenience, never a compatibility choice.
modelNoModel code; empty = backend default.
widthNo
heightNo
promptNoFreeform guidance for the generation — the same 'user commentary' lane the Power BI visual uses. Steer encoding/axes/emphasis in plain language, e.g. 'put Year on the x-axis, color by Division', 'render citations as a chord diagram', 'log scale on revenue', 'annotate the peak'. A RegiaBI plan reads up to 1000 characters of it (an account that brings its own model has no limit); text past that isn't read, and the result names it.
cultureNoThe caller's language and region as a BCP 47 tag such as 'de-DE', 'fr' or 'ja-JP'. Default 'en-US'. It is the language the chart's own text is written in (titles, axis labels, legends, notes), and it breaks the tie when a CSV's numbers or dates are ambiguous: 12.500 as twelve thousand five hundred or twelve and a half, 05.03.2024 as 5 March or 3 May. Set it from the end user's locale when you know it; it does not translate the data.
formatsNoPer-column number/date FORMAT STRING (e.g. {"Revenue":"$#,##0","Margin":"0.0%"}). PBI supplies these from its model; a CSV can't, so provide them to steer number formatting.
out_dirNoNot accepted by this hosted server: this hosted server returns the chart inline; it can't write to your machine.
overlayNoThe analytical layer the person asks for: 'moving_avg' = moving average, 'trend_line' = trend / regression line, 'anomaly' = anomaly highlights, 'confidence_band' = confidence band, 'forecast' = forecast / projection, 'yoy' = year-over-year comparison. It is strongly preferred where it applies to the chosen chart and data (the engine adds the derived measures it needs); where it can't apply, this data can't honor it. Unset: the engine decides.
csv_pathNoNot accepted by this hosted server: this hosted server can't read files on your machine, so pass the table as data or csv_text.
csv_textNoInline CSV text (alternative to csv_path).
group_byNoColumns that are the PRIMARY series/breakdown (the PBI 'Group by' well); the backend leads the visualization with these.
industryNoThe industry the person names for the data, one of the listed values. A recognized metric name is used only when the columns are that industry's inputs for it. Unset: no industry context is added.
languageNoProject source language: javascript/typescript generates D3 (the renderer @bicharts/chart-host draws), python lets the backend pick within Plotly/matplotlib. Omit for JavaScript (D3); `renderer`, when given, overrides it.
limit_toNoThe subset the person asks for, passed on as an authoritative instruction to limit to or focus on exactly it: 'latest', 'top' (top / greatest), 'bottom' (bottom / smallest), 'most_common' or 'outliers'. limit_count says how many are kept. Unset: the engine decides.
measuresNoColumns to treat as MEASURES (the PBI 'Values' well — fields the chart aggregates). Numeric non-identifier columns are measures by default.
rendererNoForce a specific renderer (overrides `language`). Omit to use `language`/auto-detection; 'VISUAL'/'' = let the backend choose.
chart_typeNoPreferred chart type by name (honored unless the data shape disqualifies it). A form the person described (a map, bars) counts as named: pass the listed type of that form.
date_grainNoThe time grain the person asks for on the time axis: day, week, month, quarter, year or decade. It is passed on as a strong request, and a different bucket the engine plans is rewritten to it when the dates give that grain 2 or more periods; data with no date column can't honor it. Unset: the engine chooses, from the number of periods the dates give at each grain.
dimensionsNoColumns to treat as DIMENSIONS (a PBI category/axis well — fields to group/break by). Use for numeric codes/years that should NOT be aggregated.
projectionNoThe grain to draw chart_type at, for a type that fits only once the rows are totalled: the projection key a what-fits list gave for that type on this same data, copied exactly (e.g. "AggregateOut|CountryCode|"). It selects one way of totalling the rows; unset, such a type is drawn at the first grain that admits it.
show_titleNoWhether the person wants a title inside the chart: true asks for a concise one, false asks for none. A yes or no, not the title's text. Unset: one narrower than 400 px or shorter than 300 px gets none; a larger one draws at random whether to have one, once per page.
chart_styleNoNarrows the charts considered to one family: 'traditional' = the familiar forms (bar, stacked and grouped bar, line, area, pie, donut, card, gauge), 'non_traditional' = every other chart type. A chart named in chart_type is still honored unless the data shape disqualifies it, and 'traditional' also turns chart_variety off. Unset considers both families.
compactnessNoHow roomy the person wants the chart: 'spacious' = roomier margins and more aggressive aggregation of a high-cardinality column, 'balanced' = standard margins and label density, 'compact' = tighter margins and denser axes, aggregating only when cardinality clearly exceeds what fits. Unset: a level is drawn at random for each generation.
data_labelsNoWhether the person wants the value printed on each mark: 'include' asks for the labels, 'exclude' for none. Per-mark labels are suppressed when more than 30 marks would carry one. Unset: the engine decides.
font_familyNoThe font family the person names for the chart's own text (titles, axis labels, tick labels, legends), or the one their house style says: a family such as 'Segoe UI' or a stack such as 'Segoe UI, Arial, sans-serif'. A font isn't a property of the data or the project. It applies to whichever renderer is chosen, and an unavailable family falls back to a web-safe stack rather than failing. Unset: the engine decides.
limit_countNoHow many groups or categories the person asks to keep, from 1 to 10000. The engine keeps exactly that many by the measure, and its own Top-N, 'Other'-cap and cardinality rules yield to it. Unset: no limit from the person (the engine's own Top-N rules still apply).
project_dirNoNot accepted by this hosted server: this hosted server can't see your project folder, so pass language or renderer instead.
rows_policyNo'auto' (default) = the engine decides how to summarize. 'all' = render EXACTLY one mark/row per source row, with no Top-N, no 'Other' rollup and no sampling. Use 'all' when your app depends on every row being present (a row-per-entity table, a point per location).
style_blockNoThe name of a style block saved on the account, as the person states it, or 'none' for no block. The chart follows that block's appearance notes and palette; a name the account doesn't have is reported back with the account's block names. Unset: the account's default block applies, if it has one.
descriptionsNoPer-column human DESCRIPTION — gives the model semantic context the bare column name lacks.
group_othersNoWhether the person allows the categories beyond a limit to be grouped into one 'Others' bucket. True is the same as unset: under a limit the rest is grouped and the total stays whole; with no limit the engine decides whether to group. False: the rest is dropped and nothing is grouped. Unset: grouping allowed. group_others true is not sent with rows_policy 'all', which draws every row.
include_codeNoInclude the full code in the response — governs BOTH the text block and structuredContent.code. Default: true, or FALSE when out_dir is given (the code is then already on disk, and a large chart's code can overflow a client's tool-output limit). Set it explicitly to override either default.
non_additiveNoMEASURE columns that must NOT be summed (a ratio/average/rate — use mean, never stack). Usually auto-detected; this is an authoritative override.
others_labelNoThe name the person gives the 'Others' bucket, at most 40 characters; quotes, backticks and control characters are removed and longer text is cut. Unset: 'Other'. Not sent when group_others is false.
palette_modeNoWhere the person wants the category colors from: 'host' = the app's options.palette, else the fallback palette; 'fallback' = one fixed palette in category-name order, the same in every chart; 'randomized' = a palette the engine proposes for this chart. The last two ignore options.palette. Unset: 'host'.
preview_htmlNoNot accepted by this hosted server: this hosted server returns the chart inline; it can't write to your machine.
chart_varietyNoHow much variety the person asks for: the probability, from 0 to 1, that the choice among the charts that fit this data is nudged toward a less conventional one, when the engine runs its planning pass. The nudge is among already-valid charts only: when only the obvious chart honestly fits, it is kept. It has no effect with an explicit chart_type, chart_style 'traditional' or reasoning_mode 1P or CP. Unset: the server's own default.
privacy_levelNoHow much detail to compute/share: 0 names only, 10 +counts, 20 +detailed stats (default), 30 +obfuscated sample rows.
reasoning_modeNoLLM pass structure; empty = backend heuristic.
level_of_detailNoThe user's own preference for how much of the data to see, as they've stated it; it isn't a property of the data. 'High' = every observation drawn as its own mark (scatter, beeswarm, strip). 'Medium' = every row used, but shown as a distribution (box, violin, histogram). 'Low' = one mark per category (bars, cards, pies). Unset when the user hasn't stated one; unset is a proven no-op and the engine decides. This is a strong nudge, not a filter: it reorders charts that already fit, and an explicit chart_type still wins.
derived_measuresNoWhether the person allows derived measures (ratios, z-scores, percent change, rank, index): 'discourage' keeps the chart to the raw columns (aggregations and sorts still apply); 'encourage' keeps them allowed and rules out the draw that would turn them off, without asking for more of them. Unset: a weighted draw for each generation. 'encourage' is not sent with forbid_derived_columns.
in_chart_captionNoWhether the person asks for a one-line subtitle under the chart title naming the chart type, any derived measure used and any non-default aggregation. Unset or false: none.
legend_placementNoWhere the person wants the legend: 'outside' = in the chart margin, 'inside' = within the plot area where it overlaps the data least, 'none' = no standalone legend (the chart's own labels carry the names). A single-series chart draws no legend whichever is chosen. Unset: outside on a chart at least 500 px wide, the renderer's default on a narrower one.
required_columnsNoFields that MUST be visible in the output, each as its own column/channel. AUTHORITATIVE and VERIFIED: if the generated code never references one, the server regenerates automatically rather than returning a chart that silently dropped it.
direction_of_goodNoWhich way is good for each measure the chart judges, by its column name as sent: { "Bookings": "higher", "Cost": "lower" }. The person's own answer; unset when they haven't given one, and the engine then infers a direction where it can and leaves the rest neutral.
forbid_derived_columnsNoTrue = show only fields present in the data (plus required_columns) — no per-capita, share-of-total, index, rank or z-score columns the engine would otherwise add. Use when your app owns the analytics and the chart is only the display.

Output Schema

NameRequiredDescriptionDefault
geoYesRegion/basemap wiring; null for non-geo charts.
codeNoThe render() source. Omitted when include_code is false.
dataNoThe render payload {columns, rows, …} to hand render() — INCLUDING any __geoIso__/__geoLat__/__geoLon__ columns the caller cannot reconstruct. Present only when out_dir was NOT given; otherwise read files.data.
buildYesMCP server build stamp — the bundle actually serving this call.
filesNoAbsolute paths written, when out_dir was given.
bindingNoHow `data` was built from your rows. Hand all three to @bicharts/chart-host - <BicChartGroup geo point destination> or createChartGroup(columns, rows, { geo, point, destination }) - and it builds the payload again from LIVE rows with the same columns; never rebuild __rowIdx__ or __geo* columns by hand.
versionYesServer-side version number of this generation.
geoPointYesPoint-geocoding outcome (a route's ORIGIN end when geoPointDest is present). `placed` counts only rows with a coordinate: neither an unplaced nor an ambiguous name is plotted. Null when the chart geocodes no points.
languageYesRenderer/language of the code (D3, PYTHON, …).
settingsNoWHICH SETTINGS APPLIED to this chart and where each value came from, so a person can be told what was assumed. Present on every generation.
chartNameYesThe chart type the backend produced.
dropLinesNoA 3D scatter's optional hover drop lines (a line from a hovered point to each back wall). requested: on, because the request asked; on/off: the user's answer, already applied to the generated component; ask: put askUser to the user ONCE before finishing, then pass hoverDropLines: true in the chart's options on a yes. Absent for every other chart.
creditCostYesCredits billed, when the server reported them.
outputHashNoThe server's identity for this exact code: the same code always carries the same hash, which names the delivered code in a support request or a later report. Absent when the server sent none.
codeSummaryNoThe backend's own one-line description of what it built.
optionsReadNoThe option names THIS chart's code reads (sorted). A chart honors nothing it does not read, so a live restyle - host.setOptions({...}), never a regeneration - can only move these. Some are the host's to supply (width, height, geo, geoPoint, uiState, setUiState, themeFg/themeBg); the integration contract says what each one does. Empty for a non-D3 language.
userTextCutNoPresent when the prompt was longer than a RegiaBI plan reads (1000 characters; an account that brings its own model has no limit), so its tail never reached the model. Absent otherwise.
capabilitiesNoWhat the server declares the host may do with this chart, beside chartName. Absent when the chart has no capability: a chart type that declares none, a language other than D3, or an older server.
geoPointDestNoA route's DESTINATION end (an origin-destination flow map), geocoded apart from geoPoint, which is then the origin. `placed` counts only rows with a destination coordinate: neither an unplaced nor an ambiguous name is plotted. Present only for a route.
hostContractYesHost contract version the code targets; a host on a different MAJOR may not interoperate.
chartMinWidthNoThe chart type's minimum width in pixels: below it the chart scrolls sideways rather than squash, and the component written with a D3 chart already does that. Never regenerate the type narrower to fit a phone. Absent when the type has none, or from an older server.
correlationIdYesTies this generation to the server-side log; it is what a support request quotes.
chartMinHeightNoThe chart type's minimum height in pixels: below it the chart scrolls rather than squash. Absent when the type has none, or from an older server.
warningMessageNoPresent when what was drawn differs from what was requested: a chart type that was overruled (it names the requested type, the reason and what was drawn instead), or an ask this data couldn't honor in full (it names the ask and why). Surface it to the user verbatim — never suppress it because the chart rendered fine.
recoveredAfterMsNoPresent when the response stream was cut after the server accepted the request and this chart was then fetched back by its correlation: milliseconds from the start of the call to delivery. creditCost is null then: the fetch that delivered it reports only its own cost (a recovery is free), not the generation's, which was charged once, as usual.
requiredD3PluginsYesD3 plugin PACKAGES this code calls (e.g. ["d3-sankey"]) — install them and pass the host ONE d3 that carries them, built with assembleD3(d3, { ...plugins }) from @bicharts/chart-host (assigning onto an ES-module d3 namespace throws), or the chart throws mid-render. Empty for core-only d3 and for non-D3 languages.
integrationContractNoHOW TO RUN THIS CHART IN YOUR APP - the same integration contract the text block carries, here because a host that shows the model only this structured result would otherwise never see it: the payload and option shapes, the reference host (@bicharts/chart-host) with its React bindings AND its framework-free group (createChartGroup + createChartHost + attach) for a plain page or a UI framework reached through interop, this chart's d3 plugins and geometry, and the host-page prerequisites. Read it before wiring the chart in.
improvementSuggestionNoPresent when the server has a note on how this chart was made: for example, that it is the standard version of the chart type because the tailored one didn't pass a quality check. It is meant for the person who asked for the chart.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / style_block
      Added value: +{
      +  "description": "The name of a style block saved on the account, as the person states it, or 'none' for no block. The chart follows that block's appearance notes and palette; a name the account doesn't have is reported back with the account's block names. Unset: the account's default block applies, if it has one.",
      +  "type": "string"
      +}
  2. Changed2 schema fields changed
    • addedInput schema / properties / palette_mode
      Added value: +{
      +  "description": "Where the person wants the category colors from: 'host' = the app's options.palette, else the fallback palette; 'fallback' = one fixed palette in category-name order, the same in every chart; 'randomized' = a palette the engine proposes for this chart. The last two ignore options.palette. Unset: 'host'.",
      +  "enum": [
      +    "",
      +    "host",
      +    "fallback",
      +    "randomized"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / projection
      Added value: +{
      +  "description": "The grain to draw chart_type at, for a type that fits only once the rows are totalled: the projection key a what-fits list gave for that type on this same data, copied exactly (e.g. \"AggregateOut|CountryCode|\"). It selects one way of totalling the rows; unset, such a type is drawn at the first grain that admits it.",
      +  "type": "string"
      +}
  3. First observed

TDQS

A4/5.0
Behavior5/5

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

Beyond the annotations, it discloses that the hosted server profiles the table in memory, sends only the profile, does not store/log rows, returns code and render-ready data inline, writes no files, uses account credits, and produces a portable render() function intended for merging. These are material operational and privacy details not captured by readOnlyHint/openWorldHint/destructiveHint/idempotentHint, and nothing contradicts the annotations.

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 front-loaded and compact for a 48-parameter tool, with no obvious filler. It is a dense single paragraph rather than structured bullet points, but each sentence carries useful information about output, privacy, storage, credits and code integration.

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

Completeness5/5

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

Given the 48-parameter schema, output schema and annotations, the description supplies the operational context an agent needs: what is generated, what is returned, what is not stored or written, how credits are used, and how the code integrates. The remaining parameter-level detail is adequately covered by the high-coverage 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?

The schema already documents 96% of 48 parameters, including most enums and nested objects, so the baseline is 3. The description adds only limited parameter context — data vs csv_text as input, and that chart_style, level_of_detail and culture are user choices listed in the guide — without explaining most parameter meanings beyond the schema.

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 opens with a specific verb and resource — 'Generate ready-to-render chart code for a dataset' — and explains the backend's chart-type selection plus returned code/data. It is clear what the tool does, but it never names or contrasts siblings such as preview_request or list_eligible_charts, so sibling differentiation is left to the tool name.

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?

It gives input guidance ('Pass the table as data ... or csv_text') and points to the guide's settings topic, but it does not state when to use this tool rather than check_request, assess_data_shape, list_eligible_charts or preview_request, nor any explicit when-not condition. Usage is implied by the generation task rather than routed.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources