Vizro Documentation
repository·main·Indexed 26 days ago
https://github.com/mckinsey/vizroA low-code Python toolkit for building production-ready data visualization applications using simple configurations via Pydantic models, JSON, YAML, or Python dictionaries. The ecosystem includes vizro-core for the main framework, vizro-ai for natural language visualization generation, vizro-mcp for AI-assisted dashboard creation, and vizro-dash-components for specialized UI elements like vdc.Cascader and vdc.Markdown. It leverages Plotly as the underlying engine and provides tools for AI agent integration and end-to-end dashboard development flows.
What's inside Vizro
- Vizro is an open-source Python-based toolkit designed for building data visualization applications quickly. It is intended for users who want to create dashboards without requiring advanced engineering or design expertise. The framework provides high-level abstractions for components, controls, actions, data handling, and visual formatting.
Overview of Vizro-MCP
mainVizro-MCP is a Model Context Protocol (MCP) server designed to work with Large Language Models (LLMs) to assist in the creation of Vizro dashboards and charts. It provides a structured workflow for AI agents to design and implement visualizations using a consistent design language and validated configuration outputs.
Key capabilities include:
- Validated Config Output: Generates readable and maintainable configuration files.
- Live Preview: Enables iterative design through dashboard previews.
- Data Connectivity: Supports local or remote datasets via paths or URLs.
- Agent Skills: Integrates with tools supporting Agent skills to follow a 2-phase workflow: design (requirements, layout, visualization) and build (implementation, testing).
Overview of Vizro-AI
mainVizro-AI is an extension for the Vizro framework designed to generate data visualizations using natural language. It allows users to create interactive charts by leveraging LLM capabilities, making visual data exploration accessible to both novices and experienced data practitioners. It uses Vizro's themes to ensure charts are visually optimized and uses Plotly as the underlying engine for interactivity.Overview of Vizro core concepts
mainVizro apps are defined by a simple configuration using high-level categories. You can write these configurations using Pydantic models, JSON, YAML, or Python dictionaries.
Key configuration categories include:
- Components: charts, tables, cards, KPI indicators, forms, etc.
- Controls: filters and parameters (e.g., drop-down menus, sliders).
- Actions: component interactions, drill-throughs, and export functionality.
- Layouts: grid layouts or flexible containers with pre-set styles.
- Navigation: app layout and navigation settings, including nested page hierarchies.
Use Vizro-AI for chart generation
mainVizro-AI allows you to use natural language instructions (e.g., English) to create interactive Plotly charts. It is built on Pydantic AI and provides an agent-based architecture that supports asynchronous runs, streaming, and dependency injection.
Important Migration Note: Dashboard generation functionality in Vizro-AI is no longer actively developed and has been superseded by Vizro-MCP. As of version
0.4.0, Vizro-AI supports only chart generation.Understand the Vizro conceptual model of Actions
mainVizro separates app configuration into two aspects:
- Layout: Controls what the app looks like (components and placement). This is powered by Dash layout.
- Interactivity: Controls how the app behaves in response to user input (e.g., clicking a button). This is powered by Actions.
Many Vizro models (such as
vm.Graph,vm.Filter,vm.Button, andvm.Page) configure both layout and interactivity. For instance, avm.Filteruses aselectorargument to define the UI component and anactionsargument to define the behavior when the selector changes. By default, many models include a filtering action that updates dependent components on the page.Key principles of Vizro actions
mainUnderstanding how custom actions function in Vizro is essential for building interactive dashboards.
- Definition: An action is a Python function triggered by user interaction with a component.
- Inputs/Outputs: An action can have any number of inputs and outputs, but it is associated with exactly one trigger.
- Chaining: Actions can be linked in two ways:
- Explicitly: Using the
actions=[action_1, action_2, ...]parameter. In this mode,action_2only begins afteraction_1has successfully completed. - Implicitly: When an action's output automatically satisfies the input requirements of another action, triggering it.
- Explicitly: Using the
- Execution: When multiple actions are triggered at the same time, they typically execute in parallel.
- Error Handling: You can stop the execution of an action and prevent any subsequent chained actions from running by raising an exception.
- Security: Always treat action inputs as untrusted data, as they are generated by the user.
Explore Vizro packages
mainVizro is a monorepo containing several specialized packages:
- vizro-core: The main Vizro framework. Documentation
- vizro-ai: Specialized tools for AI integration. Documentation
- vizro-mcp: Model Context Protocol implementation. Documentation
Compare Vizro with Python packages and BI tools
mainVizro occupies a niche between low-level Python visualization libraries (like Plotly/Dash or Streamlit) and proprietary Business Intelligence (BI) tools (like Tableau or PowerBI).
Key differentiators include:
- Assembly System: Uses a configuration-driven approach to build high-level dashboard concepts (e.g., filters) from low-level components, reducing the need for manual "glue code."
- Inbuilt Design & Architecture: Provides automatic UX/visual design decisions (spacing, colors, placement) and application architecture (navigation, drill-throughs) to ensure consistency.
- Declarative Configuration: Supports multiple formats including Python, YAML, JSON, and TOML, allowing for programmatic dashboard generation (e.g., via Kedro pipelines).
- Grammar of Dashboards: Uses a mostly tech-agnostic configuration language rather than being strictly tied to a specific Python package syntax.
- Inbuilt Validation: Leverages Pydantic models to provide early, meaningful feedback on configuration choices.
- Modularity & Scaling: Enables reuse of entire dashboard screens and configurations across projects. It is designed for Git-based collaboration and programmatic updates from a central location.
- Flexibility: Combines a low-code configuration approach for simple tasks with a high-code approach (custom Python functions) for infinite extensibility.
Understand the Vizro Visual Vocabulary
mainThe Vizro Visual Vocabulary dashboard is a guide designed to help users select and create appropriate chart types for their data. It provides guidance on data visualization best practices, sample Python code using Plotly, and instructions for embedding these charts into a Vizro dashboard. It is intended to help users decide when to use specific chart types to ensure effective communication of data messages.Understand Vizro Dashboard and Page basics
mainVizro applications are structured around a hierarchy of Dashboards and Pages:
Dashboard Level
A
Dashboardis the top-level container. At this level, you configure:- Pages: The individual building blocks of your dashboard.
- Navigation: How users move between different pages.
- Title/Logo: The branding and identity of the dashboard.
Page Level
Each
Pagecontains the specific content and interactivity. At this level, you configure:- Components: Visual elements like charts, tables, and input/output interfaces.
- Controls: Interactivity elements like filters and parameters.
- Layouts: The arrangement and placement of components on the page.
- Actions: Logic that creates interactions between different components.
Understand the Vizro JSON schema and grammar
mainVizro uses a JSON schema to define a "grammar of dashboards," providing a unified, implementation-independent language to configure dashboards. This schema allows you to define dashboards using Python, JSON, or YAML.
A valid dashboard configuration generally requires:
- A
title(string) pages(an array of Page objects)- A
theme(eithervizro_darkorvizro_light)
Each
Pagemust contain:- A
title(string) components(an array of component objects, e.g.,Graph,Table,AgGrid,Card,Button,Container)- Optional
controls(an array ofFilterorParameterobjects)
Note: The schema is evolving. Some features, like
CapturedCallableobjects used infigurearguments, may not be explicitly defined in the schema yet but can still be configured via JSON.{ "pages": [ { "components": [ { "figure": { "_target": "scatter", "color": "species", "data_frame": "iris", "x": "sepal_length", "y": "petal_width" }, "type": "graph" } ], "controls": [ { "column": "species", "type": "filter" } ], "title": "My first dashboard" } ] }- A