Skip to main content
Glama
blitzstermayank

Teradata MCP Server

plot_radar_chart

Generate radar charts to visualize multidimensional data relationships from Teradata tables using specified labels and columns for comparative analysis.

Instructions

Function to generate a radar plot for labels and columns. Columns mentioned in labels are used as labels and column is used to plot.

PARAMETERS: table_name: Required Argument. Specifies the name of the table to generate the donut plot. Types: str

labels:
    Required Argument.
    Specifies the labels to be used for the line plot.
    Types: str

columns:
    Required Argument.
    Specifies the column to be used for generating the line plot.
    Types: str

RETURNS: dict

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
labelsYes
columnsYes

Implementation Reference

  • The handler function implementing the core logic for the 'plot_radar_chart' tool. It validates that 'labels' is a string and calls the helper function to generate radar chart data.
    def handle_plot_radar_chart(conn: TeradataConnection, table_name: str, labels: str, columns: str|List[str]):
        """
        Function to generate a radar plot for labels and columns.
        Columns mentioned in labels are used as labels and column is used to plot.
    
        PARAMETERS:
            table_name:
                Required Argument.
                Specifies the name of the table to generate the donut plot.
                Types: str
    
            labels:
                Required Argument.
                Specifies the labels to be used for the line plot.
                Types: str
    
            columns:
                Required Argument.
                Specifies the column to be used for generating the line plot.
                Types: str
    
        RETURNS:
            dict
        """
        if not isinstance(labels, str):
            raise ValueError("labels must be a string representing the column name for x-axis.")
    
        result = get_radar_plot_json_data(conn, table_name, labels, columns)
        return result
  • Helper utility that executes SQL query on the specified table, processes the data into Chart.js compatible radar chart JSON format with predefined colors, and returns a structured response.
    def get_radar_plot_json_data(conn, table_name, labels, columns):
        """
        Helper function to fetch data from a Teradata table and formats it for plotting.
        Right now, designed only to support line plots from chart.js .
        """
        logger.debug(f"Tool: get_json_data_for_plotting")
        # Define the colors first.
        border_colors = [
            'rgb(255, 99, 132)',
            'rgb(54, 162, 235)',
            '#d7d0c4',
            '#fac778',
            '#e46c59',
            '#F9CB99',
            '#280A3E',
            '#F2EDD1',
            '#689B8A'
        ]
        background_colors = [
            'rgba(255, 99, 132, 0.2)',
            'rgba(54, 162, 235, 0.2)',
            'rgb(222, 232, 206, 0.2)',
            'rgb(187, 102, 83, 0.2)',
            'rgb(240, 139, 81, 0.2)',
            'rgb(255, 248, 232, 0.2)'
        ]
        point_background_color = [
            'rgba(255, 99, 132)',
            'rgba(54, 162, 235)',
            'rgb(222, 232, 206)',
            'rgb(187, 102, 83)',
            'rgb(240, 139, 81)',
            'rgb(255, 248, 232)'
        ]
    
        columns = [columns] if isinstance(columns, str) else columns
        sql = "select {labels}, {columns} from {table_name} order by {labels}".format(
              labels=labels, columns=','.join(columns), table_name=table_name)
    
        # Execute the SQL query
    
        # Prepare the statement.
        with conn.cursor() as cur:
            recs = cur.execute(sql).fetchall()
    
        labels = []
        datasets = [[] for _ in range(len(columns))]
        for rec in recs:
            labels.append(rec[0])
            for i_, val in enumerate(rec[1:]):
                datasets[i_].append(val)
    
        # Prepare the datasets for chart.js
        datasets_ = []
        for i, dataset in enumerate(datasets):
            datasets_.append({
                'label': columns[i],
                'data': dataset,
                'fill': True,
                "backgroundColor": background_colors[i % len(background_colors)],
                'borderColor': border_colors[i % len(border_colors)],
                "pointBackgroundColor": point_background_color[i % len(point_background_color)],
                "pointBorderColor": '#fff',
                "pointHoverBackgroundColor": '#fff',
                "pointHoverBorderColor": point_background_color[i % len(point_background_color)]
            })
    
        chart_data = {"labels": [str(l) for l in labels],
                      "datasets": datasets_}
        logger.debug("Chart data: %s", json.dumps(chart_data, indent=2))
    
        return create_response(data=chart_data, metadata={
                "tool_description": "chart js radar plot data",
                "table_name": table_name,
                "labels": labels,
                "columns": columns
            })

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/blitzstermayank/MCP'

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