Plot Advanced Employment Gantt Chart with Career Metrics Summary
Source:R/vecshift_plots.R
plot_employment_gantt_advanced.RdCreates a sophisticated two-panel visualization combining employment Gantt charts with career metrics summary displays. This advanced function integrates employment timelines with comprehensive career performance indicators, providing deep insights into career trajectories and professional development patterns. The function ensures perfect color consistency with plot_employment_gantt() and uses identical person selection logic for reproducible research.
Usage
plot_employment_gantt_advanced(
data,
career_metrics_data = NULL,
person_ids = NULL,
metrics_to_show = c("career_success_index", "career_advancement_index",
"employment_security_index", "career_complexity_index"),
metrics_viz_type = "bar",
max_persons = 5,
palette = "Set2",
title = "Employment Timeline and Career Metrics",
show_legend = TRUE
)Arguments
- data
Data.table or data.frame containing employment segments with required columns: cf (person ID), inizio (start date), fine (end date), stato (employment status). Should be output from vecshift() or compatible format.
- career_metrics_data
Data.table or data.frame from calculate_comprehensive_career_metrics() containing career performance indicators. Must include 'cf' column for person matching. When NULL, shows only the Gantt chart (default: NULL)
- person_ids
Character or numeric vector. Specific person identifiers to visualize. For reproducible research, always specify person_ids explicitly. When provided, shows only these persons regardless of max_persons parameter. When NULL, uses max_persons to select first N individuals. Example: c(6, 8, 21) (default: NULL)
- metrics_to_show
Character vector. Career metrics to display in right panel. Must match column names in career_metrics_data. Common metrics include: "career_success_index", "career_advancement_index", "employment_security_index", "career_complexity_index", "mobility_rate", "employment_rate" (default: c("career_success_index", "career_advancement_index", "employment_security_index", "career_complexity_index"))
- metrics_viz_type
Character. Visualization type for career metrics panel: "bar" (side-by-side bars), "dot" (dot plot with faceting), "radar" (circular/polar plot) (default: "bar")
- max_persons
Integer. Maximum number of persons to show when person_ids is NULL. Used only for exploratory analysis; specify person_ids for reproducible research (default: 5)
- palette
Character. Color palette for career metrics: "Set2" uses RColorBrewer Set2 palette (recommended for accessibility), or fallback to vecshift colors (default: "Set2")
- title
Character. Main title for the combined visualization (default: "Employment Timeline and Career Metrics")
- show_legend
Logical. Whether to show legends for both panels (default: TRUE). Set to FALSE for cleaner multi-panel publications where legends appear elsewhere
Value
A list containing three elements:
- combined_plot
Combined plot object using patchwork if available, otherwise a list of plots or single plot
- gantt_plot
Individual Gantt chart (ggplot2 object) showing employment timeline
- metrics_plot
Individual career metrics visualization (ggplot2 object), NULL if no career_metrics_data provided
The combined_plot can be directly printed or saved. Individual plots allow for custom arrangements or separate analysis.
Details
Two-Panel Design: The visualization consists of two perfectly aligned panels:
Left Panel: Employment Gantt chart showing contract timelines, employment statuses, and transitions using standardized employment colors
Right Panel: Career metrics summary displayed as bar charts, dot plots, or radar charts showing comparative performance indicators across individuals
Perfect Alignment: Both panels use identical y-axis scaling and person ordering to ensure visual alignment. This is critical for comparing individual employment patterns with their corresponding career metrics.
Color Consistency:
Employment statuses use identical colors to plot_employment_gantt()
Career metrics use Set2 palette (RColorBrewer) for accessibility
All colors are colorblind-friendly and print-compatible
Publication Reproducibility: Like plot_employment_gantt(), this function supports explicit person_ids specification for identical results across analyses. The person selection logic is identical between both functions.
Accessibility Features:
Uses colorblind-friendly palettes (Set2, employment colors) with good contrast ratios
Clear legends and comprehensive annotations
Graceful handling of missing data and mismatched datasets
Optimized for both screen display and print reproduction
Supports black and white output for print publications
Supported Career Metrics Visualizations:
Bar Charts: Best for comparing metric values across individuals with clear visual distinction
Dot Plot: Effective for precise value comparison with minimal visual clutter and faceting support
Radar Chart: Ideal for showing multi-dimensional metric profiles per person in circular format
Color Standards and Consistency
This function maintains perfect color consistency with other longworkR functions:
Employment statuses use identical colors to plot_employment_gantt()
Career metrics use Set2 palette for clear distinction from employment colors
All palettes are colorblind-accessible and print-friendly
Black and white mode available for print publications
Perfect Panel Alignment
The function ensures perfect vertical alignment between panels:
Identical y-axis scaling and person ordering
Consistent person labeling across both panels
Synchronized data filtering and validation
See also
plot_employment_gantt for basic Gantt charts with identical color consistency,
calculate_comprehensive_career_metrics for computing career performance indicators,
theme_vecshift for the underlying plot theme used in both panels,
get_standardized_employment_colors for employment color standardization,
vecshift_colors for the broader color palette system
Examples
if (FALSE) { # \dontrun{
# Load sample employment data
employment_data <- readRDS("data/sample.rds")
# Basic Gantt chart only (no metrics) - exploratory analysis
gantt_only <- plot_employment_gantt_advanced(
data = employment_data,
max_persons = 3
)
print(gantt_only$combined_plot)
# Calculate comprehensive career metrics first
career_metrics <- calculate_comprehensive_career_metrics(employment_data)
# Publication-ready: Advanced Gantt with career metrics using specific persons
advanced_plot <- plot_employment_gantt_advanced(
data = employment_data,
career_metrics_data = career_metrics,
person_ids = c(6, 8, 21), # Explicit specification for reproducibility
title = "Employment and Career Development Analysis"
)
print(advanced_plot$combined_plot)
# Dot plot visualization with custom metrics selection
dot_analysis <- plot_employment_gantt_advanced(
data = employment_data,
career_metrics_data = career_metrics,
person_ids = c("Person_A", "Person_B", "Person_C"),
metrics_viz_type = "dot",
metrics_to_show = c("career_success_index", "employment_security_index"),
title = "Career Development Analysis: Selected Metrics"
)
# Radar chart for multi-dimensional profile comparison
radar_profiles <- plot_employment_gantt_advanced(
data = employment_data,
career_metrics_data = career_metrics,
person_ids = c(1, 5, 10, 15),
metrics_viz_type = "radar",
show_legend = FALSE,
title = "Career Profile Comparison"
)
# Access individual plots for custom arrangements
gantt_chart <- advanced_plot$gantt_plot
metrics_chart <- advanced_plot$metrics_plot
# Print individual components
print(gantt_chart)
print(metrics_chart)
# Save for publication
ggsave("employment_analysis.png", advanced_plot$combined_plot,
width = 12, height = 8, dpi = 300)
} # }