L2 Hub
Pontus
analysis
Bivariate Chart Recommender

L2 Construct: bivariate_chart_recommender

chart analysis

Description

The chart analyzer L2 analyzes table data to provide multiple intelligent chart recommendations. It leverages an LLM to determine the most appropriate simple chart types, titles, and data structures based on the input table structure, content, and user-specified analysis goals.

L2 Data

  1. Provider: pontus
  2. Module: analysis
  3. Action: bivariate_chart_recommender

Example Step

{
  "name": "insert-your-step-name",
  "type": "l2",
  "l2_data": {
    "provider": "pontus",
    "module": "analysis",
    "action": "bivariate_chart_recommender",
    "metadata": {}
  }
}
 

Input

Example

{
  "table": {
    "headers": ["Month", "Sales", "Expenses"],
    "rows": [["Jan", 1000, 800], ["Feb", 1200, 900], ["Mar", 1500, 1100]]
  },
  "analysis": [
    {
      "type": "Trend Analysis",
      "instruction": "Analyze how sales and expenses change over time"
    },
    {
      "type": "Comparison",
      "instruction": "Compare sales to expenses for each month"
    }
  ],
  "num_recommendations": 2
}
 

Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://pontus.bpa/pkgs/l2/pontus/analysis/bivarate-chart-rec-input",
  "$ref": "#/$defs/BivarateChartRecInput",
  "$defs": {
    "BivarateChartRecInput": {
      "properties": {
        "table": {
          "$ref": "#/$defs/Table"
        },
        "analysis": {
          "items": {
            "$ref": "#/$defs/ChartAnalysis"
          },
          "type": "array"
        },
        "num_recommendations": {
          "type": "integer"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["table", "analysis", "num_recommendations"]
    },
    "ChartAnalysis": {
      "properties": {
        "type": {
          "type": "string"
        },
        "instruction": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["type", "instruction"]
    },
    "Table": {
      "properties": {
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "headers": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "rows": {
          "items": {
            "items": true,
            "type": "array"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["headers", "rows"]
    }
  }
}
 

Output

Example

{
  "chart_recommendations": [
    {
      "simple_chart": {
        "title": "Monthly Sales and Expenses Trend",
        "type": "LINE",
        "headers": {
          "orientation": "horizontal",
          "start_row_number": 1,
          "start_col_number": 1,
          "length": 3
        },
        "values": {
          "orientation": "vertical",
          "start_row_number": 2,
          "start_col_number": 2,
          "length": 3
        }
      },
      "explanation": "This line chart shows the trend of sales and expenses over time, allowing for easy comparison of their growth rates."
    },
    {
      "simple_chart": {
        "title": "Monthly Sales vs Expenses Comparison",
        "type": "BAR",
        "headers": {
          "orientation": "vertical",
          "start_row_number": 1,
          "start_col_number": 1,
          "length": 3
        },
        "values": {
          "orientation": "vertical",
          "start_row_number": 1,
          "start_col_number": 2,
          "length": 2
        }
      },
      "explanation": "This bar chart directly compares sales and expenses for each month, highlighting the difference between them."
    }
  ]
}
 

Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://pontus.bpa/pkgs/l2/pontus/analysis/bivarate-chart-output",
  "$ref": "#/$defs/BivarateChartOutput",
  "$defs": {
    "BivarateChartOutput": {
      "properties": {
        "chart_recommendations": {
          "items": {
            "$ref": "#/$defs/BivariateChartRecommendation"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["chart_recommendations"]
    },
    "BivariateChartRecommendation": {
      "properties": {
        "simple_chart": {
          "$ref": "#/$defs/SimpleChart"
        },
        "explanation": {
          "type": "string"
        },
        "score": {
          "type": "integer"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["simple_chart"]
    },
    "Series": {
      "properties": {
        "orientation": {
          "type": "string"
        },
        "start_row_number": {
          "type": "integer"
        },
        "start_col_number": {
          "type": "integer"
        },
        "length": {
          "type": "integer"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["orientation", "start_row_number", "start_col_number"]
    },
    "SimpleChart": {
      "properties": {
        "title": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "sheet_name": {
          "type": "string"
        },
        "headers": {
          "$ref": "#/$defs/Series"
        },
        "values": {
          "$ref": "#/$defs/Series"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["title", "type", "headers", "values"]
    }
  }
}