Visualization policies for chart customization in Snowflake Intelligence¶
Visualization policies let you define conditional chart rules that fire only when specific conditions are
met, for example, “apply brand colors only when the CATEGORY column is used for color.” This is
more precise than a vega_template, which always applies to every chart unconditionally.
For general chart customization information, see Customize charts in Snowflake Intelligence.
How it works¶
Each policy has:
Rules: Conditions that must all be true for the policy to fire. Omit rules to match every chart.
Actions: What to apply when the policy fires.
Policies are evaluated after the chart is generated and actions are applied directly to the chart spec.
Where to define policies¶
Add a viz_policies: marker inside a <chart_customization> block, followed by a JSON array.
Policies can be defined at the agent level or the semantic view level.
When an agent-level policy and a semantic view policy share the same name, the semantic view
policy wins.
Full semantic view example¶
Rules¶
Each rule can match on:
Field |
Description |
Example values |
|---|---|---|
|
Column name (case-insensitive). Omit to match any column. |
|
|
Where the column is used in the chart. Omit to match any role. |
|
|
Chart type. Omit to match any chart type. |
|
|
When |
|
Multiple rules in one policy are combined with AND. All rules must match for the policy to fire.
Role values¶
Value |
Vega-Lite channels matched |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
COLOR, FILL, and STROKE are separate roles. ensure_color checks all three channels
(color, fill, stroke) and applies to whichever one is present, but in rules they are
distinct: use COLOR for the color channel, FILL for fill, and so on.
Important
The column field must match the raw column name as it appears in the data (for example,
"REVENUE", "ORDER_STATUS"), not a display label or alias. Column matching is
case-insensitive.
Be aware that the LLM may rename or alias columns in the generated SQL (for example, selecting
SUM(REVENUE) AS TOTAL). In that case the column in the chart is TOTAL, not
REVENUE, and the rule doesn’t fire. To avoid this, use explicit column aliases in your
semantic view metrics definitions, or use the role field alone (without column) to match
by encoding position instead of by name.
Actions¶
All actions are applied directly to the chart spec. They’re deterministic and add no latency.
Action |
What it does |
|---|---|
|
Maps column values to specific hex colors |
|
Maps column values to point shapes (scatter plots only) |
|
Applies a D3 format string to an axis or legend |
|
Overrides the sort order on an encoding channel |
|
Pins the minimum or maximum of an axis scale |
ensure_color¶
Maps column values to specific hex colors. Unmapped values are auto-assigned colors from the chart’s existing palette.
Param |
Required |
Description |
|---|---|---|
|
Yes |
Column value to hex color |
ensure_shape¶
Maps column values to point shapes on scatter plots.
Supported shapes: circle, square, diamond, triangle-up, triangle-down,
triangle-right, triangle-left, cross, star.
Note
ensure_shape only applies to scatter plots (mark: point). It’s silently skipped for all
other chart types.
ensure_number_format¶
Formats an axis or legend using a D3 format string.
Param |
Required |
Description |
|---|---|---|
|
Yes |
D3 format string. Examples: |
|
No |
Axis channels: |
ensure_sort¶
Overrides the sort order on an encoding channel.
For a fixed sequence (for example, fiscal quarters or lifecycle stages):
Param |
Required |
Description |
|---|---|---|
|
No |
Encoding channel to sort. Default: |
|
No |
|
|
No |
Explicit value sequence. When set, |
ensure_axis_range¶
Pins the minimum or maximum of an axis scale.
Param |
Required |
Description |
|---|---|---|
|
No |
|
|
No |
Minimum scale value |
|
No |
Maximum scale value |
Examples¶
Brand colors when CATEGORY is on the color channel¶
Dollar formatting and descending sort for REVENUE¶
Apply descending sort only when QUARTER is not on the X axis¶
negate: true inverts a rule. The policy fires when the condition is not met. This is
useful for applying a default that should be skipped when a specific column is already present.
The policy fires and sorts descending on every chart except those where QUARTER is on the
X axis (where chronological order should be preserved instead).
Force Y-axis to start at zero for bar charts¶
Known limitations¶
Column aliasing can prevent rules from matching. The
columnfield in a rule matches the column name as it appears in the chart’s encoding, not the original table column. If the LLM aliases a column in the SQL (for example,SUM(REVENUE) AS TOTAL), a rule with"column": "REVENUE"doesn’t fire because the chart’s field isTOTAL. To avoid this, define explicit column aliases in your semantic view metrics, or userolealone (withoutcolumn) to match by encoding position.Multiple ensure_color actions silently overwrite each other. If two policies both fire
ensure_coloron the same chart, the second one replaces the first’s_colortransform. No warning is surfaced. The same applies toensure_shapewith_shape. To avoid this, write mutually exclusive rules (for example, eachensure_colorpolicy should include"role": "COLOR"with a distinct"column").Typos in parameter names are silently ignored. If a parameter key is misspelled (for example,
"chanell"instead of"channel"), the action still runs using default values for the missing parameter. A warning is logged server-side but no feedback is visible to the user. Double-check parameter names against the documented schemas.
Notes¶
Multiple actions in one policy all execute when the policy fires.
Multiple policies can fire on the same chart. They’re applied in order.
A semantic view policy with the same
nameas an agent-level policy replaces it.