Charts Integration
Configure visual analytics with the Charts module and Chart.js library.
Overview
The Visitors module integrates with the Drupal Charts module to provide interactive visualizations of your analytics data.
Installation
Charts Module
composer require drupal/charts
drush pm:install charts charts_chartjs
Configuration
- Navigate to
/admin/config/content/charts
- Select Chart.js as the default library
- Configure default chart settings
Available Charts
Visitor Trends
- Line charts showing visitor activity over time
- Daily, weekly, and monthly trend analysis
- Comparative period analysis
Geographic Distribution
- Country and region distribution pie charts
- World map visualizations (with mapping libraries)
- Geographic heat maps
Technical Analytics
- Browser usage pie charts
- Device type distribution
- Operating system statistics
Performance Charts
- Page load time trends
- Server response time analysis
- Performance metric comparisons
Custom Chart Creation
Using Views
- Create Views with Visitors data
- Add Charts display
- Configure chart type and styling
- Embed in pages or blocks
Programmatic Charts
// Example chart creation
$chart = [
'#type' => 'chart',
'#chart_type' => 'line',
'#title' => 'Daily Visitors',
'#data' => $visitor_data,
];