Data Visualization
Flow-Like includes powerful visualization capabilities through Nivo and Plotly chart libraries. Create interactive charts directly in your A2UI interfaces—no frontend coding required.
Chart Libraries
Section titled “Chart Libraries”Flow-Like supports two chart libraries:
| Library | Best For | Chart Types |
|---|---|---|
| Nivo | Beautiful, declarative charts | 17 types |
| Plotly | Scientific, interactive charts | 9 types |
Available Chart Types
Section titled “Available Chart Types”Nivo Charts
Section titled “Nivo Charts”| Chart Type | Use Case |
|---|---|
| Bar | Compare categories |
| Line | Trends over time |
| Pie | Parts of a whole |
| Scatter | Correlations |
| Radar | Multi-dimensional comparison |
| Heatmap | Intensity matrices |
| Funnel | Conversion flows |
| Treemap | Hierarchical proportions |
| Sunburst | Hierarchical rings |
| Calendar | Daily patterns |
| Bump | Ranking changes |
| Area Bump | Area-based rankings |
| Sankey | Flow diagrams |
| Stream | Stacked time series |
| Waffle | Part-of-whole grids |
| Radial Bar | Circular bar charts |
| Chord | Relationship flows |
Plotly Charts
Section titled “Plotly Charts”| Chart Type | Use Case |
|---|---|
| Bar | Category comparison |
| Line | Time series |
| Scatter | Correlations, clusters |
| Pie | Proportions |
| Area | Cumulative trends |
| Histogram | Distribution |
| Heatmap | Matrix visualization |
| Box | Statistical distribution |
| Violin | Distribution shape |
Creating Charts in A2UI
Section titled “Creating Charts in A2UI”Charts are rendered using special markdown code blocks in A2UI content.
Basic Syntax
Section titled “Basic Syntax”```nivotype: bartitle: Sales by Region---region,salesNorth,150South,230East,180West,290Or for Plotly:
```markdown```plotlytype: bartitle: Sales by Region---region,salesNorth,150South,230East,180West,290### Chart Configuration
The header section (before `---`) configures the chart:
| Option | Description | Default ||--------|-------------|---------|| `type` | Chart type | Auto-detected || `title` | Chart title | None || `xLabel` | X-axis label | None || `yLabel` | Y-axis label | None || `colors` | Color scheme or array | `nivo` || `height` | Chart height (pixels) | 400 || `showLegend` | Show legend | true || `legendPosition` | top, bottom, left, right | bottom || `stacked` | Stack bars/areas | false || `layout` | vertical, horizontal | vertical || `animate` | Enable animation | true |
### Color Schemes
Use predefined schemes or custom colors:
**Named schemes:**- `nivo` – Default Nivo palette- `paired` – Contrasting pairs- `category10` – D3 category colors- `accent` – Bold accent colors- `dark2` – Dark palette- `set1`, `set2`, `set3` – D3 sets- `pastel1`, `pastel2` – Soft colors- `spectral` – Rainbow spectrum
**Custom colors:**colors: [“#ff6b6b”, “#4ecdc4”, “#45b7d1”, “#96ceb4”]
## Chart Examples
### Bar Chart
```markdown```nivotype: bartitle: Quarterly Revenuecolors: pairedlayout: vertical---quarter,revenue,profitQ1,150000,45000Q2,230000,67000Q3,180000,52000Q4,290000,84000### Line Chart
```markdown```nivotype: linetitle: User GrowthxLabel: MonthyLabel: Active Userscolors: set2---month,users,premiumJan,1200,150Feb,1450,180Mar,1800,220Apr,2100,290May,2600,350Jun,3200,420### Pie Chart
```markdown```nivotype: pietitle: Market Sharecolors: category10showLegend: truelegendPosition: right---company,shareAcme Corp,35TechCo,28StartupX,22Others,15### Heatmap
```markdown```nivotype: heatmaptitle: Weekly Activitycolors: spectral---day,Morning,Afternoon,EveningMon,45,82,65Tue,52,88,58Wed,48,75,70Thu,55,90,62Fri,42,85,78Sat,30,65,85Sun,28,55,72### Scatter Plot
```markdown```plotlytype: scattertitle: Price vs QualityxLabel: Price ($)yLabel: Rating---price,rating,product29,4.2,Widget A45,4.5,Widget B35,3.8,Widget C52,4.8,Widget D28,3.5,Widget E### Histogram
```markdown```plotlytype: histogramtitle: Age DistributionxLabel: AgeyLabel: Count---age252832352941384533273642313944### Box Plot
```markdown```plotlytype: boxtitle: Salary by DepartmentyLabel: Salary ($K)---department,salaryEngineering,85Engineering,92Engineering,78Engineering,105Engineering,88Sales,65Sales,72Sales,68Sales,58Sales,75Marketing,70Marketing,62Marketing,68Marketing,75Marketing,71## Auto-Detection
When you don't specify `type`, the system auto-detects:
| Data Pattern | Detected Type ||--------------|---------------|| 2 columns, ≤6 rows, numeric second | `pie` || 2 columns, >6 rows | `bar` || Time-like first column | `line` || 3+ columns | `bar` |
## JSON Mode (Full Control)
For complete customization, use JSON format:
### Nivo JSON
```markdown```nivo{ "type": "bar", "data": [ {"region": "North", "sales": 150, "profit": 45}, {"region": "South", "sales": 230, "profit": 67} ], "keys": ["sales", "profit"], "indexBy": "region", "colors": {"scheme": "paired"}, "margin": {"top": 50, "right": 130, "bottom": 50, "left": 60}}### Plotly JSON
```markdown```plotly{ "data": [ { "x": ["Jan", "Feb", "Mar", "Apr"], "y": [10, 15, 13, 17], "type": "scatter", "mode": "lines+markers", "name": "2024" }, { "x": ["Jan", "Feb", "Mar", "Apr"], "y": [8, 12, 11, 15], "type": "scatter", "mode": "lines+markers", "name": "2023" } ], "layout": { "title": "Year over Year Comparison", "xaxis": {"title": "Month"}, "yaxis": {"title": "Sales"} }}## Dynamic Charts from Data
In your flows, generate chart markdown dynamically:
### From SQL QuerySQL Query ──▶ Format as CSV ──▶ Build Chart Markdown ──▶ A2UI Output │ │ │ │ │ └── “```nivo\ntype: bar\n---\n{csv}” │ └── “region,sales\nNorth,150\n…” └── CSVTable results
### Example Flow┌─────────────────────────────────────────────────────────────┐
│ │
│ SQL Query: “SELECT region, SUM(revenue) FROM sales │
│ GROUP BY region” │
│ │ │
│ ▼ │
│ CSV Table ──▶ Convert to CSV String │
│ │ │ │
│ │ ▼ │
│ │ “region,revenue │
│ │ North,150000 │
│ │ South,230000…” │
│ │ │ │
│ │ ▼ │
│ │ Concat Strings: │
│ │ “nivo │ │ │ type: bar │ │ │ title: Revenue by Region │ │ │ --- │ │ │ {csv_data} │ │ │ ” │
│ │ │ │
│ │ ▼ │
│ │ Push to A2UI │
│ │
└─────────────────────────────────────────────────────────────┘
## Building Dashboards
Combine multiple charts in A2UI for dashboards:
```markdown# Sales Dashboard
## Revenue Overview
```nivotype: linetitle: Monthly Revenue---month,revenueJan,150000Feb,175000...Regional Breakdown
Section titled “Regional Breakdown”type: pietitle: Revenue by Region---region,revenueNorth,450000South,380000...Performance Metrics
Section titled “Performance Metrics”| Metric | Value | Change |
|---|---|---|
| Total Revenue | $2.1M | +15% |
| Orders | 12,500 | +8% |
| Avg Order Value | $168 | +6% |
## Chart Selection Guide
| Data Type | Recommended Chart ||-----------|-------------------|| Compare categories | Bar || Show trend over time | Line || Parts of a whole | Pie, Waffle || Correlation | Scatter || Distribution | Histogram, Box, Violin || Hierarchical data | Treemap, Sunburst || Flow/conversion | Funnel, Sankey || Multi-dimensional comparison | Radar || Time patterns | Calendar, Stream || Ranking changes | Bump || Intensity/matrix | Heatmap |
## Best Practices
### 1. Choose the Right Chart- Don't use pie charts for more than 5-6 categories- Use line charts only for continuous data- Use bar charts for discrete categories
### 2. Keep It Simple- Remove unnecessary decorations- Use clear, descriptive titles- Label axes meaningfully
### 3. Use Consistent Colors- Stick to one color scheme per dashboard- Use color meaningfully (e.g., green=good, red=bad)- Consider colorblind-friendly palettes
### 4. Consider Data Density- Don't overcrowd charts with too many data points- Aggregate data if needed- Use interactive features (Plotly) for exploration
### 5. Provide Context- Add titles that explain the insight- Include comparison periods when relevant- Show targets/benchmarks when useful
## Troubleshooting
### "Chart not rendering"- Check markdown code block syntax (triple backticks)- Verify CSV format (comma-separated, newline rows)- Check for special characters in data
### "Wrong chart type"- Explicitly set `type` in configuration- Check data format matches chart requirements
### "Colors look wrong"- Verify color scheme name spelling- For custom colors, use valid hex codes- Check theme compatibility (light/dark mode)
### "Data not showing correctly"- Ensure numeric columns contain only numbers- Check for header row in CSV data- Verify column names match between config and data
## Next Steps
With visualization skills:
- **[DataFusion & SQL](/topics/datascience/datafusion/)** – Query data for charts- **[AI-Powered Analysis](/topics/datascience/ai-analysis/)** – Generate insights with AI- **[Machine Learning](/topics/datascience/ml/)** – Visualize ML results