L2 Hub
Pontus
analysis
Chart Analyzer

L2 Construct: chart_analyzer

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: chart_analyzer

Example Step

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

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"
    }
  ]
}
 

Schema

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://pontus.bpa/pkgs/l2/pontus/analysis/chart-analyzer-input",
  "$ref": "#/$defs/ChartAnalyzerInput",
  "$defs": {
    "ChartAnalysis": {
      "properties": {
        "type": {
          "type": "string"
        },
        "instruction": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["type", "instruction"]
    },
    "ChartAnalyzerInput": {
      "properties": {
        "table": {
          "$ref": "#/$defs/Table"
        },
        "analysis": {
          "items": {
            "$ref": "#/$defs/ChartAnalysis"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["table", "analysis"]
    },
    "Table": {
      "properties": {
        "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": [
    {
      "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."
    },
    {
      "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/chart-analyzer-output",
  "$ref": "#/$defs/ChartAnalyzerOutput",
  "$defs": {
    "ChartAnalyzerOutput": {
      "properties": {
        "chart_recommendations": {
          "items": {
            "$ref": "#/$defs/SimpleChartRecommendation"
          },
          "type": "array"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["chart_recommendations"]
    },
    "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"]
    },
    "SimpleChartRecommendation": {
      "properties": {
        "title": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "headers": {
          "$ref": "#/$defs/Series"
        },
        "values": {
          "$ref": "#/$defs/Series"
        },
        "explanation": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": ["title", "type", "headers", "values"]
    }
  }
}