Smart Mode is a new API-less demo option for ChartSpec that enables users to create visualizations using natural language commands without requiring an LLM API key. It combines:
- AVA (AntV) Integration - Intelligent chart type recommendations based on data characteristics
- Local Language Parser - In-browser command parsing with discrete vocabulary
- Interactive Guidance - Tooltips, suggestions, and vocabulary help
Smart Mode integrates AVA (Automated Visual Analytics) from AntV to provide data-driven chart recommendations:
- Analyzes data structure (numeric vs categorical columns, row count, date columns)
- Recommends optimal chart types based on visualization best practices
- Provides reasoning for recommendations
- Falls back to heuristic-based recommendations if AVA is unavailable
A built-in natural language parser understands commands without external APIs:
Supported Vocabulary:
bar/column- Bar chartsline/trend- Line chartsscatter/plot- Scatter plotspie/donut- Pie chartshistogram- Histogramsbox/boxplot- Box plotsheatmap/matrix- Heatmapstable/grid- Data tables
show/display/visualize- Show datafilter/where- Filter datagroup by- Group and aggregatesort/order- Sort resultstop N/first N- Limit results
sum/total- Sum valuesaverage/mean- Average valuescount- Count rowsmin/minimum- Minimum valuemax/maximum- Maximum value
Command Suggestions:
- Real-time suggestions appear as you type
- Click suggestions to auto-complete commands
- Contextual to your selected dataset
Vocabulary Help Modal:
- Complete reference of all supported commands
- Examples for common use cases
- Accessible via "View Commands" link
- Select a dataset from the Dataset panel
- Check the "Smart Mode (AVA-Powered)" checkbox in LLM Settings
- The chat interface will show command suggestions
show bar chart of Revenue by Region
display line chart of Temperature
show pie chart grouped by Product
show top 10 by Revenue descending
filter where Region equals North
Smart Mode understands flexible command patterns:
-
Basic visualization:
show [chart type] of [column] -
With grouping:
show [chart type] of [column] by [group column] -
With aggregation:
show [aggregation] of [column] by [group column] -
With sorting and limiting:
show top [N] [chart type] by [column] [ascending/descending]
Each parsed command receives a confidence score (0-100%):
- Higher scores indicate better command understanding
- Scores are displayed in the chat response
- AVA recommendations boost confidence by +25%
User Input
↓
Language Parser (languageParser.js)
↓
AVA Enhancement (avaIntegration.js)
↓
ChartSpec Generation (commandToSpec)
↓
Data Engine (applySpecToRows)
↓
Renderer (PlotlyRenderer/D3Renderer)
↓
Visualization
- chartspec/languageParser.js - Natural language command parsing
- chartspec/avaIntegration.js - AVA integration and fallback heuristics
- chartspec/main.js - Smart Mode integration and UI handling
| Feature | Smart Mode | LLM Mode | Local Mode |
|---|---|---|---|
| API Key Required | No | Yes | No |
| Natural Language | Limited vocabulary | Full NL | No |
| Chart Recommendations | AVA-powered | LLM-based | Manual |
| Offline Capable | Yes | No | Yes |
| Flexibility | Medium | High | Low |
- No API Costs - Completely free to use, no API keys needed
- Privacy - All processing happens in browser, no data sent to external services
- Speed - Instant responses, no network latency
- Learning - Vocabulary help teaches users the command structure
- Intelligent - AVA provides data-driven chart recommendations
- Limited Vocabulary - Only supports predefined command patterns
- Simpler Queries - Cannot handle complex multi-step transformations
- AVA Dependency - Requires AVA CDN to be accessible for full functionality
- Column Name Matching - Works best with simple, descriptive column names
- Expand vocabulary with more command patterns
- Add support for multiple filters and complex conditions
- Implement query builder UI for visual command construction
- Add command history and favorites
- Support for saved command templates
- Multi-language support for international users
The system checks if AVA is loaded:
function isAvaAvailable() {
return typeof window !== 'undefined' && window.AVA && window.AVA.Advisor;
}If AVA is unavailable, the system falls back to heuristic-based recommendations based on data characteristics.
- Normalize input (lowercase, trim)
- Tokenize into words
- Match chart types against vocabulary
- Detect operations and aggregations
- Extract column names from input
- Apply contextual rules (e.g., "by" indicates grouping)
- Calculate confidence score based on matches
- Enhance with AVA if available
When AVA is unavailable:
- Date column + numeric → Line chart
- 1 categorical + 1 numeric → Bar chart
- 2+ numeric columns → Scatter plot
- Few categories (≤10) → Pie chart
- Many rows + 1 numeric → Histogram
- Default → Bar chart
Smart Mode requires:
- ES6 Module support
- Modern JavaScript (arrow functions, template literals, etc.)
- LocalStorage API
- Recommended: Chrome 90+, Firefox 88+, Safari 14+, Edge 90+
- All processing happens client-side
- No data sent to external servers (when AVA loads from CDN)
- No API keys or credentials required
- Safe for sensitive data
show bar chart of Revenue by Region
show top 5 products by Revenue descending
show line chart of Revenue grouped by Date
show line chart of Temperature
show scatter plot of Temperature vs Humidity
show box plot of Temperature by City
show table
show histogram of Age
show pie chart grouped by Category
Note: Smart Mode is designed as a demo/educational tool and API-less alternative. For production use cases with complex requirements, LLM Mode provides more flexibility and power.