encode_point_icon
Set custom icons for graph nodes based on column values to visually distinguish categories or continuous data ranges in Graphistry visualizations.
Instructions
Set node icon encoding for a graph using Graphistry's encode_point_icon API.
Args:
graph_id (str): The ID of the graph to modify.
column (str): The node column to use for icon encoding (e.g., 'type', 'origin').
categorical_mapping (dict, optional): Map of category values to icon names or URLs. Example: {'macbook': 'laptop', 'Canada': 'flag-icon-ca'}. See FontAwesome 4 or ISO country codes for built-ins.
default_mapping (str, optional): Icon to use for values not in categorical_mapping. Example: 'question'.
as_text (bool, optional): If True, use text as the icon (for continuous binning or direct text display).
continuous_binning (list, optional): List of [threshold, icon] pairs for binning continuous values. Example: [[33, 'low'], [66, 'mid'], [None, 'high']].
Returns:
dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL.
Example:
encode_point_icon(graph_id, column='type', categorical_mapping={'macbook': 'laptop', 'Canada': 'flag-icon-ca'}, default_mapping='question')
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| graph_id | Yes | ||
| column | Yes | ||
| categorical_mapping | No | ||
| default_mapping | No | ||
| as_text | No | ||
| continuous_binning | No |
Implementation Reference
- MCP tool handler for 'encode_point_icon'. Decorated with @mcp.tool() for registration. Implements node icon encoding using Graphistry's encode_point_icon method on cached graph object. The docstring provides input schema details.@mcp.tool() async def encode_point_icon( graph_id: str, column: str, categorical_mapping: Optional[dict] = None, default_mapping: Optional[str] = None, as_text: Optional[bool] = False, continuous_binning: Optional[list] = None ) -> Dict[str, Any]: """ Set node icon encoding for a graph using Graphistry's encode_point_icon API. Args: graph_id (str): The ID of the graph to modify. column (str): The node column to use for icon encoding (e.g., 'type', 'origin'). categorical_mapping (dict, optional): Map of category values to icon names or URLs. Example: {'macbook': 'laptop', 'Canada': 'flag-icon-ca'}. See FontAwesome 4 or ISO country codes for built-ins. default_mapping (str, optional): Icon to use for values not in categorical_mapping. Example: 'question'. as_text (bool, optional): If True, use text as the icon (for continuous binning or direct text display). continuous_binning (list, optional): List of [threshold, icon] pairs for binning continuous values. Example: [[33, 'low'], [66, 'mid'], [None, 'high']]. Returns: dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL. Example: encode_point_icon(graph_id, column='type', categorical_mapping={'macbook': 'laptop', 'Canada': 'flag-icon-ca'}, default_mapping='question') """ if graph_id not in graph_cache: raise ValueError(f"Graph not found: {graph_id}") g = graph_cache[graph_id]["graph"] kwargs = {"column": column} if categorical_mapping: kwargs["categorical_mapping"] = categorical_mapping if default_mapping: kwargs["default_mapping"] = default_mapping if as_text: kwargs["as_text"] = as_text if continuous_binning: kwargs["continuous_binning"] = continuous_binning g = g.encode_point_icon(**kwargs) graph_cache[graph_id]["graph"] = g return {"graph_id": graph_id, "url": g.plot(render=False)}
- src/graphistry_mcp_server/server.py:406-406 (registration)The @mcp.tool() decorator registers the encode_point_icon function as an MCP tool.@mcp.tool()